cc-workspace 5.2.5 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +16 -14
  3. package/global-skills/agents/e2e-validator.md +1 -1
  4. package/global-skills/agents/implementer.md +9 -14
  5. package/global-skills/agents/reviewer.md +2 -2
  6. package/global-skills/agents/security-auditor.md +3 -3
  7. package/global-skills/agents/team-lead.md +18 -17
  8. package/global-skills/agents/workspace-init.md +1 -1
  9. package/global-skills/bootstrap-repo/SKILL.md +1 -1
  10. package/global-skills/cleanup/SKILL.md +1 -1
  11. package/global-skills/cross-service-check/SKILL.md +1 -1
  12. package/global-skills/cycle-retrospective/SKILL.md +2 -2
  13. package/global-skills/dispatch-feature/SKILL.md +84 -111
  14. package/global-skills/dispatch-feature/references/anti-patterns.md +11 -8
  15. package/global-skills/dispatch-feature/references/rollback-protocol.md +21 -6
  16. package/global-skills/dispatch-feature/references/spawn-templates.md +22 -45
  17. package/global-skills/doctor/SKILL.md +1 -1
  18. package/global-skills/hooks/orphan-cleanup.sh +1 -1
  19. package/global-skills/hooks/permission-auto-approve.sh +2 -2
  20. package/global-skills/hooks/user-prompt-guard.sh +3 -3
  21. package/global-skills/incident-debug/SKILL.md +1 -1
  22. package/global-skills/merge-prep/SKILL.md +1 -1
  23. package/global-skills/metrics/SKILL.md +2 -2
  24. package/global-skills/plan-review/SKILL.md +1 -1
  25. package/global-skills/qa-ruthless/SKILL.md +1 -1
  26. package/global-skills/refresh-profiles/SKILL.md +1 -1
  27. package/global-skills/rules/model-routing.md +2 -4
  28. package/global-skills/session/SKILL.md +1 -1
  29. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.3.0] — 2026-03-11
4
+
5
+ ### Two-tier worktree model + patch extraction (no more micro-QA Haiku)
6
+
7
+ Major workflow change: teammates now work in **isolated temporary worktrees** instead of
8
+ directly in the session worktree. The team lead extracts a patch after each commit unit,
9
+ applies it to the session worktree, and the user reviews uncommitted changes in their IDE.
10
+
11
+ **Two worktree types:**
12
+ - **Session worktree** (`/tmp/{repo}-{session-name}`): created once per session, persists
13
+ until session close. This is the reference branch where commits accumulate.
14
+ - **Temporary worktree** (`/tmp/{repo}-commit-{N}`): created per commit unit from session
15
+ worktree HEAD. The teammate works here. Destroyed after patch extraction.
16
+
17
+ **New 10-step cycle per commit unit:**
18
+ 1. Team lead creates temp worktree from session worktree HEAD
19
+ 2. Team lead dispatches teammate with temp worktree path
20
+ 3. Teammate codes, runs tests, signals "ready" (never commits)
21
+ 4. Team lead extracts diff: `git add -A && git diff --cached --binary HEAD`
22
+ 5. Team lead applies patch to session worktree: `git apply`
23
+ 6. Team lead removes temp worktree
24
+ 7. Team lead informs user: "review in your IDE"
25
+ 8. User validates (or requests corrections)
26
+ 9. Team lead commits in session worktree
27
+ 10. Next commit unit
28
+
29
+ **Micro-QA Haiku removed:**
30
+ - No more Haiku diff review step — the user reviews directly in their IDE
31
+ - Haiku micro-QA subagent template deleted from spawn-templates.md
32
+ - Micro-QA row removed from model-routing.md routing table
33
+ - Phase 3 and 4 merged into a single Phase 3 (Dispatch + Patch + Review + Commit)
34
+ - Phase 5 (post-impl) renumbered to Phase 4
35
+
36
+ **Files changed:**
37
+ - `agents/team-lead.md` — rules 4, 5, 8 rewritten; workflow table updated; commit tracking without "qa" field; "What you CAN write" updated for patch commands
38
+ - `agents/implementer.md` — description updated for temp worktree; startup simplified (no more leftover changes check)
39
+ - `agents/reviewer.md` — Phase 5 → Phase 4 reference
40
+ - `agents/security-auditor.md` — Phase 5 → Phase 4 references
41
+ - `dispatch-feature/SKILL.md` — Phase 3 rewritten (10-step cycle); Phase 4 removed (merged into Phase 3); Phase 5 renumbered to Phase 4; session recovery adapted; mode descriptions updated
42
+ - `dispatch-feature/references/spawn-templates.md` — all templates use temp_worktree_path; Haiku micro-QA template deleted; failure handling updated
43
+ - `dispatch-feature/references/anti-patterns.md` — micro-QA references replaced; new anti-pattern 19 (never let teammate work in session worktree); new common mistakes rows
44
+ - `dispatch-feature/references/rollback-protocol.md` — split into "before patch apply" and "after patch apply" failure cases
45
+ - `rules/model-routing.md` — Haiku micro-QA row removed; Gather→Reason pattern updated
46
+ - `hooks/orphan-cleanup.sh` — added `/tmp/*-commit-*` pattern for temp worktree cleanup
47
+ - `hooks/user-prompt-guard.sh` — micro-QA → patch extraction in role reminder
48
+ - `hooks/permission-auto-approve.sh` — micro-QA comments updated
49
+ - `metrics/SKILL.md` — micro-QA first-pass rate → patch-apply first-pass rate
50
+ - `cycle-retrospective/SKILL.md` — Phase 5 → Phase 4
51
+
3
52
  ## [5.2.5] — 2026-03-11
4
53
 
5
54
  ### Fix: team-lead can now spawn teammates
package/README.md CHANGED
@@ -230,9 +230,9 @@ parallel in each repo via Agent Teams.
230
230
 
231
231
  | Role | Model | What it does |
232
232
  |------|-------|-------------|
233
- | **Orchestrator** | Opus 4.6 | Clarifies, plans, manages git, delegates, micro-QA between commits. Writes in orchestrator/ only. |
233
+ | **Orchestrator** | Opus 4.6 | Clarifies, plans, manages git, delegates, extracts patches. Writes in orchestrator/ only. |
234
234
  | **Init** | Sonnet 4.6 | Diagnostic + interactive workspace configuration. Run once. |
235
- | **Teammates** | Sonnet 4.6 | Implement in an isolated worktree. One per commit unit, writes code without committing, signals when ready for review. |
235
+ | **Teammates** | Sonnet 4.6 | Implement in an isolated temp worktree. One per commit unit, writes code without committing, signals when ready. Team lead extracts patch. |
236
236
  | **Data extractors** | Haiku | Read-only. Collect raw data (types, configs, logs). Never judge or conclude. |
237
237
  | **QA** | Opus 4.6 | Hostile mode. Spawns Sonnet investigators. Min 3 problems found per service. |
238
238
  | **Reviewer** | Opus 4.6 | Evidence-based code review. Scope check + architecture + constitution compliance. |
@@ -254,10 +254,12 @@ parallel in each repo via Agent Teams.
254
254
  CLARIFY -> ask max 5 questions if ambiguity
255
255
  PLAN -> write the plan in ./plans/, wait for approval
256
256
  SESSION -> create session branches + worktrees in impacted repos (Phase 2.5)
257
- SPAWN -> Wave 1: API/data (one teammate per commit unit, user reviews between)
258
- Wave 2: frontend with validated API contract
259
- Wave 3: infra/config if applicable
260
- MICRO-QA -> Bash tests + Haiku diff after EVERY commit unit, user review, team lead commits
257
+ DISPATCH -> For each commit unit:
258
+ 1. Create temp worktree from session worktree HEAD
259
+ 2. Teammate implements in temp worktree (never commits)
260
+ 3. Team lead extracts patch, applies to session worktree
261
+ 4. User reviews in IDE, team lead commits after approval
262
+ Waves: API/data → frontend → infra/config
261
263
  VERIFY -> cross-service-check + qa-ruthless + reviewer + (security-auditor)
262
264
  MERGE -> merge-prep (PRs, conflict detection)
263
265
  RETRO -> cycle-retrospective (mandatory)
@@ -280,7 +282,7 @@ Protection layers:
280
282
 
281
283
  | Skill | Role | Trigger |
282
284
  |-------|------|---------|
283
- | **dispatch-feature** | 4 modes: Clarify -> Plan -> Git -> Delegate -> Micro-QA -> Track | "Implement X", "new feature" |
285
+ | **dispatch-feature** | 4 modes: Clarify -> Plan -> Git -> Delegate -> Patch -> Review -> Track | "Implement X", "new feature" |
284
286
  | **qa-ruthless** | Hostile QA + UX audit (Opus) | "QA", "review", "test" |
285
287
  | **cross-service-check** | Inter-repo consistency | "cross-service", "pre-merge" |
286
288
  | **incident-debug** | Multi-layer diagnostic | "Bug", "500", "not working" |
@@ -564,7 +566,7 @@ With `--chrome`, the agent:
564
566
  |---|---------|--------|
565
567
  | 1 | **Agent tool for team-lead** | Fixed missing `Agent` tool in team-lead's tool list — the team-lead can now spawn implementer teammates via `Agent(subagent_type: "implementer", team_name: ...)`. |
566
568
  | 2 | **One teammate per commit unit** | Shift from one teammate per repo (handling all commits) to one implementer per commit unit. Eliminates the unreliable "signal and wait" pattern — each implementer handles exactly one unit then stops. |
567
- | 3 | **User reviews before commit** | Implementers write code without committing. After micro-QA, the team lead presents changes to the user for review. The team lead commits only after user approval. |
569
+ | 3 | **User reviews before commit** | Implementers write code in temp worktrees without committing. Team lead extracts patch, applies to session worktree. User reviews in IDE. Team lead commits after approval. _(v5.3.0: micro-QA Haiku removed, replaced by patch extraction + user IDE review)_ |
568
570
  | 4 | **PreToolUse hook blocks git add/commit** | Implementer frontmatter now includes a Bash hook that physically blocks `git add` and `git commit`. Even if the model ignores instructions, commits are prevented. |
569
571
  | 5 | **Team lead commits** | The team lead (not the implementer) runs `git add` + `git commit` in the worktree after user approval. Commit tracking includes `user_committed` and `files_modified` fields. |
570
572
  | 6 | **Sequential with user gate** | Intra-repo commit units are strictly sequential with a user review gate between each. Cross-repo parallelism is preserved. |
@@ -578,9 +580,9 @@ With `--chrome`, the agent:
578
580
  | 1 | **Skills & rules now LOCAL** | Installed in `orchestrator/.claude/skills/` and `rules/` instead of `~/.claude/`. Only agents remain global. Claude behaves normally outside orchestrator/. |
579
581
  | 2 | **Automatic legacy cleanup** | `update --force` removes old global skills/rules from `~/.claude/` (from versions < 5.2). |
580
582
  | 3 | **Reviewer agent (Opus)** | Evidence-based code review: scope check (plan vs implemented), architecture assessment, constitution compliance. Anchored on constitution + CLAUDE.md + plan, never on legacy code. |
581
- | 4 | **Security auditor agent (Opus)** | 7-phase audit: auth flow tracing, tenant isolation, secrets scan, dependency CVEs, input validation, headers/CORS, session-scoped delta analysis. Conditional in Phase 5. |
583
+ | 4 | **Security auditor agent (Opus)** | 7-phase audit: auth flow tracing, tenant isolation, secrets scan, dependency CVEs, input validation, headers/CORS, session-scoped delta analysis. Conditional in Phase 4 (post-impl). |
582
584
  | 5 | **qa-ruthless explicit Opus** | Added `model: opus` in frontmatter. Previously inherited from caller context. |
583
- | 6 | **Phase 5 expanded** | Now: cross-service → qa-ruthless → reviewer → (security-auditor) → merge-prep → cycle-retrospective. |
585
+ | 6 | **Post-impl phase expanded** | Now: cross-service → qa-ruthless → reviewer → (security-auditor) → merge-prep → cycle-retrospective. _(v5.3.0: renumbered from Phase 5 to Phase 4)_ |
584
586
 
585
587
  ---
586
588
 
@@ -592,7 +594,7 @@ With `--chrome`, the agent:
592
594
  | 2 | **Secure `permission-auto-approve.sh`** | Compound commands rejected before pattern matching. |
593
595
  | 3 | **Robust `detectProjectType`** | JSON.parse + dependency lookup instead of string.includes(). |
594
596
  | 4 | **Split orphan cleanup** | Extracted into separate `orphan-cleanup.sh` hook. |
595
- | 5 | **JSON format for micro-QA** | Haiku returns structured `{"status":"OK"}` instead of free text. |
597
+ | 5 | **JSON format for micro-QA** | Haiku returns structured `{"status":"OK"}` instead of free text. _(v5.3.0: micro-QA Haiku removed entirely)_ |
596
598
  | 6 | **Chrome MCP check in doctor** | Verifies Chrome DevTools MCP configuration. |
597
599
  | 7 | **Hook unit tests** | `test_hooks.sh` with ~30 assertions. CLI unit tests with ~50 assertions. |
598
600
 
@@ -602,9 +604,9 @@ With `--chrome`, the agent:
602
604
 
603
605
  | # | Feature | Detail |
604
606
  |---|---------|--------|
605
- | 1 | **Opus has Bash** | `disallowedTools: Bash` removed from team-lead. Opus manages git (branches, worktrees) and micro-QA directly. |
606
- | 2 | **One teammate per repo** | Shift from one subagent per commit unit to one teammate per repo. Sequential commits with signal+wait protocol. _(v5.2.3: changed to one teammate per commit unit with user review gate)_ |
607
- | 3 | **Micro-QA between every commit** | Bash tests + Haiku diff review after each commit. _(v5.2.3: user reviews before team lead commits)_ |
607
+ | 1 | **Opus has Bash** | `disallowedTools: Bash` removed from team-lead. Opus manages git (branches, worktrees) and patch extraction directly. |
608
+ | 2 | **One teammate per repo** | Shift from one subagent per commit unit to one teammate per repo. Sequential commits with signal+wait protocol. _(v5.2.3: one per commit unit; v5.3.0: temp worktrees + patch extraction)_ |
609
+ | 3 | **Micro-QA between every commit** | Bash tests + Haiku diff review after each commit. _(v5.3.0: removed entirely replaced by patch extraction + user IDE review)_ |
608
610
  | 4 | **Worktrees after plan validation** | Branches and worktrees created by Opus only after user approves the plan. |
609
611
  | 5 | **Worktrees persist** | `/tmp/` worktrees live until `session close`. No pruning during active sessions. |
610
612
  | 6 | **cycle-retrospective mandatory** | Required Phase 5 step, not optional. |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: e2e-validator
3
- prompt_version: 5.2.2
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  E2E validation agent for completed plans. On first boot, sets up the E2E
6
6
  environment (docker-compose, test config). On subsequent boots, validates
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: implementer
3
- prompt_version: 5.2.3
3
+ prompt_version: 5.3.0
4
4
  description: >
5
- Implementation teammate for a single commit unit. Receives a ready worktree
6
- from the orchestrator and ONE commit unit to implement. Writes code without
7
- committing, signals when code is ready for review. No git setup, no git
8
- add, no git commit. The team lead commits after user review.
5
+ Implementation teammate for a single commit unit. Receives a temporary
6
+ worktree from the orchestrator for a single commit unit. Writes code
7
+ without committing, signals when code is ready for review. No git setup,
8
+ no git add, no git commit. The team lead extracts the patch after signal.
9
9
  model: sonnet
10
10
  tools: Read, Write, Edit, MultiEdit, Bash, Glob, Grep, SendMessage
11
11
  memory: project
@@ -56,15 +56,15 @@ You are a focused implementer for one commit unit. You write code and run tests
56
56
  commit unit, then signal that the code is ready for review.
57
57
  The orchestrator and user will review your work and commit it.
58
58
 
59
- ## Startup — go directly to your worktree
59
+ ## Startup — go directly to your temporary worktree
60
60
 
61
61
  The orchestrator provides:
62
- - `worktree_path`: the /tmp/ path of your ready worktree
63
- - `session_branch`: the branch already checked out in that worktree
62
+ - `worktree_path`: the /tmp/ path of your isolated temporary worktree (created fresh for this commit unit)
63
+ - `session_branch`: the branch checked out (with all previous commits)
64
64
  - Your single commit unit to implement
65
65
 
66
66
  ```bash
67
- # 1. Go to your worktree — it's ready
67
+ # 1. Go to your worktree — it's ready and clean
68
68
  cd {worktree_path}
69
69
 
70
70
  # 2. Verify you're on the right branch
@@ -72,11 +72,6 @@ git branch --show-current # must show session/{name}
72
72
 
73
73
  # 3. Check what's already on the branch (from previous commits)
74
74
  git log --oneline -5
75
-
76
- # 4. Check for existing uncommitted changes
77
- git status --short
78
- # Uncommitted changes may exist from a previous unit — this is normal in this workflow.
79
- # Assess: if they look like work from a previous unit, leave them. If junk, ask orchestrator.
80
75
  ```
81
76
 
82
77
  **macOS note**: /tmp is a symlink to /private/tmp. Both paths are valid.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: reviewer
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Senior code reviewer agent. Reads the full diff of a session branch
6
6
  (or any branch/PR) and produces evidence-based review comments.
7
7
  Judges implementation choices against constitution + CLAUDE.md + plan,
8
8
  NOT against existing legacy code. Detects scope drift (plan vs implemented).
9
9
  Standalone: claude --agent reviewer
10
- Also recommended in dispatch-feature Phase 5 after qa-ruthless.
10
+ Also recommended in dispatch-feature Phase 4 (post-impl) after qa-ruthless.
11
11
  model: opus
12
12
  tools: Read, Bash, Glob, Grep, Task(Explore)
13
13
  memory: project
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: security-auditor
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Security audit agent for multi-service workspaces. Traces auth flows
6
6
  end-to-end, audits tenant isolation, scans for secrets and exposed
@@ -8,7 +8,7 @@ description: >
8
8
  and reviews input validation. Produces a structured security report
9
9
  with severity ratings.
10
10
  Standalone: claude --agent security-auditor
11
- Also invocable by team-lead in Phase 5 for security-sensitive plans,
11
+ Also invocable by team-lead in Phase 4 (post-impl) for security-sensitive plans,
12
12
  or on-demand when user says "security", "audit", "pentest", "vulns",
13
13
  "tenant leak", "auth check", "secrets scan", "OWASP".
14
14
  model: opus
@@ -324,7 +324,7 @@ Write to `./plans/{plan-name}.md` (append) if session-scoped, or `./plans/securi
324
324
 
325
325
  ## Invocation by team-lead
326
326
 
327
- The team-lead can invoke this agent in Phase 5 when the plan involves:
327
+ The team-lead can invoke this agent in Phase 4 (post-impl) when the plan involves:
328
328
  - Auth changes (new endpoints, middleware modifications, token handling)
329
329
  - New models with tenant data
330
330
  - File upload features
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: team-lead
3
- prompt_version: 5.2.5
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Main orchestrator for multi-service workspaces. Clarifies specs,
6
6
  plans in markdown, manages git (branches, worktrees) directly,
7
- delegates implementation to one teammate per commit unit, tracks progress
8
- via micro-QA, presents code for user review, commits after approval.
9
- Never codes in repos — can write in orchestrator/ and run git commands.
10
- Triggered via claude --agent team-lead.
7
+ delegates implementation to one teammate per commit unit in temp worktrees,
8
+ extracts patches, applies to session worktree, user reviews in IDE,
9
+ commits after approval. Never codes in repos — can write in orchestrator/
10
+ and run git commands. Triggered via claude --agent team-lead.
11
11
  model: opus
12
12
  tools: Read, Write, Edit, Bash, Glob, Grep, Task(Explore), Agent, TeamCreate, TeamDelete, SendMessage
13
13
  memory: project
@@ -40,12 +40,12 @@ hooks:
40
40
 
41
41
  1. **NEVER write code in repos** — delegate ALL repo code work to teammates
42
42
  2. **ONE teammate per COMMIT UNIT** — one implementer per commit unit, sequentially within each repo
43
- 3. **Opus manages ALL git** — branches, worktrees, verification. Teammates receive a ready worktree path
44
- 4. **Micro-QA after EVERY commit unit, then ask user to review** Bash tests + Haiku diff review, then present to user for approval before committing
45
- 5. **Worktrees live until session close** never prune active session worktrees
43
+ 3. **Opus manages ALL git** — branches, worktrees, verification. Teammates receive a temp worktree path
44
+ 4. **Patch workflow after EVERY commit unit** extract diff from temp worktree, apply to session worktree, destroy temp worktree, inform user to review in IDE, commit after approval
45
+ 5. **Two worktree types** — session worktree persists until session close, temp worktrees are created per commit unit and destroyed after patch extraction
46
46
  6. **Full constitution in EVERY spawn prompt** — teammates don't receive it automatically
47
47
  7. **UX standards for frontend teammates** — inject frontend-ux-standards.md content
48
- 8. **Sequential within a service** — commit N+1 only after commit N is micro-QA validated AND user has committed. Cross-service parallelism OK
48
+ 8. **Sequential within a service** — commit N+1 only after commit N patch is applied, user has reviewed in IDE, AND team lead has committed. Cross-service parallelism OK
49
49
  9. **git branch, NEVER git checkout -b** in repos — checkout disrupts parallel sessions
50
50
  10. **Teammates must run tests before signaling** — a "code ready" signal without test results is rejected. Re-spawn for retest
51
51
  11. **Max 2 re-dispatches** per commit unit — then escalate to user, never loop
@@ -116,11 +116,11 @@ Store the effective source branch in session.json under source_branch_override i
116
116
  ```
117
117
 
118
118
  ### Commit tracking
119
- Update after each micro-QA + user review:
119
+ Update after each patch apply + user review:
120
120
  ```json
121
121
  "commits": {
122
- "1": { "status": "✅", "hash": "abc123", "files_modified": ["src/foo.ts", "src/bar.ts"], "user_committed": true, "qa": "OK" },
123
- "2": { "status": "⏳", "hash": null, "files_modified": null, "user_committed": false, "qa": null }
122
+ "1": { "status": "✅", "hash": "abc123", "files_modified": ["src/foo.ts", "src/bar.ts"], "user_committed": true },
123
+ "2": { "status": "⏳", "hash": null, "files_modified": null, "user_committed": false }
124
124
  }
125
125
  ```
126
126
 
@@ -136,9 +136,8 @@ This table is your quick reference — **defer to the skill for specifics**.
136
136
  | 2 — Plan | Write ./plans/{name}.md from _TEMPLATE.md | Wait for user validation |
137
137
  | 2.5 — Git setup | `git branch` + `git worktree add` via Bash | Only after plan validation |
138
138
  | 2.9 — Pre-dispatch | Verify branches + worktrees exist and are clean | Auto-fix simple cases |
139
- | 3 — Dispatch | ONE teammate per COMMIT UNIT user reviews between units, team lead commits after approval | See @dispatch-feature/references/spawn-templates.md |
140
- | 4 — Micro-QA | Verify changes + tests + present to user for review. Team lead commits after user approval | See @dispatch-feature/SKILL.md Phase 4 |
141
- | 5 — Post-impl | cross-service → qa-ruthless → reviewer → (security-auditor if needed) → merge-prep → retro | All mandatory except security-auditor |
139
+ | 3 — Dispatch + Patch + Review + Commit | ONE teammate per commit unit in temp worktree, extract patch, apply to session worktree, user reviews in IDE, team lead commits | See @dispatch-feature/SKILL.md Phase 3 |
140
+ | 4 — Post-impl | cross-service qa-ruthless reviewer (security-auditor if needed) merge-prep retro | All mandatory except security-auditor |
142
141
 
143
142
  ## Rollback & failure handling
144
143
 
@@ -153,8 +152,10 @@ Quick reference:
153
152
  ## What you CAN write / execute
154
153
  - Plans, sessions, workspace.md, constitution.md — anything in orchestrator/
155
154
  - Git commands on sibling repos (branch, worktree, log — never checkout on main trees)
156
- - Test/typecheck commands in /tmp/ worktrees for micro-QA
157
- - `git add` + `git commit` in /tmp/ worktrees AFTER user has approved the changes
155
+ - `git worktree add` / `git worktree remove` for temp worktrees
156
+ - `git add -A` + `git diff --cached --binary HEAD` in temp worktrees for patch extraction
157
+ - `git apply` in session worktrees to apply patches
158
+ - `git add` + `git commit` in session worktrees AFTER user has approved the changes
158
159
 
159
160
  ## Memory hygiene
160
161
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: workspace-init
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Initialization and diagnostic agent for the orchestrator workspace.
6
6
  Checks structure, hooks, settings, sibling repos.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bootstrap-repo
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Generate a high-quality CLAUDE.md for a repository that doesn't have one.
6
6
  Scans the repo to detect stack, patterns, conventions, tests, architecture.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cleanup
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Clean orphan worktrees, stale sessions, and temporary files left by
6
6
  crashed implementers. Session-aware: never removes worktrees belonging
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cross-service-check
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Validate technical consistency BETWEEN services. Does not review code
6
6
  quality (that's qa-ruthless). Checks: API contracts match frontend types,
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: cycle-retrospective
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
- MANDATORY post-cycle learning and knowledge capture. Always runs as Phase 5
5
+ MANDATORY post-cycle learning and knowledge capture. Always runs as Phase 4 (post-impl)
6
6
  of dispatch-feature after qa-ruthless and merge-prep. Analyzes QA findings, teammate
7
7
  session logs, and implementation patterns to improve repo CLAUDE.md files,
8
8
  service profiles, and project constitution.
@@ -1,16 +1,17 @@
1
1
  ---
2
2
  name: dispatch-feature
3
- prompt_version: 5.2.3
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Orchestrate multi-service feature implementation. Clarifies ambiguities,
6
6
  explores repos directly (no upfront Haiku scan), writes a persistent
7
- markdown plan, sets up git branches and worktrees after plan validation,
8
- spawns one teammate per commit unit with full context, runs micro-QA on
9
- uncommitted changes, presents to user for review, then team lead commits
10
- after approval. Runs cross-service-check, qa-ruthless, reviewer,
11
- security-auditor (when needed), merge-prep, and cycle-retrospective.
12
- Use whenever the user describes a feature, says "implement", "new feature",
13
- "dispatch", "start dev", "launch teammates", or provides a spec.
7
+ markdown plan, sets up git branches and session worktrees after plan
8
+ validation, spawns one teammate per commit unit in a temp worktree,
9
+ extracts patches, applies to session worktree, user reviews in IDE,
10
+ team lead commits after approval. Runs cross-service-check, qa-ruthless,
11
+ reviewer, security-auditor (when needed), merge-prep, and
12
+ cycle-retrospective. Use whenever the user describes a feature, says
13
+ "implement", "new feature", "dispatch", "start dev", "launch teammates",
14
+ or provides a spec.
14
15
  argument-hint: "[feature description]"
15
16
  context: fork
16
17
  allowed-tools: Read, Write, Bash, Glob, Grep, Task, TeamCreate, TeamDelete, SendMessage
@@ -27,7 +28,7 @@ Before any phase, check which mode was selected:
27
28
 
28
29
  | Mode | Behavior |
29
30
  |------|----------|
30
- | **A — Full** | All phases 0-5 (default) |
31
+ | **A — Full** | All phases 0-4 (default) |
31
32
  | **B — Quick plan** | Skip Phase 0 (Clarify). Start at Phase 1 exploration with specs as-is. |
32
33
  | **C — Go direct** | Skip Phases 0-2. Dispatch immediately from user specs. |
33
34
  | **D — Single-service** | Phases 0-2, then spawn ONE teammate. No waves. |
@@ -40,16 +41,16 @@ User provides clear specs upfront (e.g. a Jira ticket, a detailed description).
40
41
  1. Skip Phase 0 entirely — do NOT ask clarification questions
41
42
  2. Run Phase 1 (targeted exploration) scoped to the user's specs
42
43
  3. Run Phase 2 (plan) — write the plan from specs + exploration
43
- 4. Phases 2.5–5 proceed normally (git setup, dispatch, micro-QA, post-impl)
44
+ 4. Phases 2.5–4 proceed normally (git setup, dispatch + patch + review, post-impl)
44
45
  5. If ambiguities emerge during exploration, ask then (max 3 focused questions)
45
46
 
46
47
  ### Mode C — Go direct details
47
48
 
48
49
  For hotfixes, quick patches, or when the user provides exact instructions.
49
50
  1. Skip Phases 0–2 — no clarification, no exploration, no written plan
50
- 2. Run Phase 2.5 (git setup) — still create session branch + worktree
51
+ 2. Run Phase 2.5 (git setup) — still create session branch + session worktree
51
52
  3. Spawn ONE teammate per impacted repo with the user's specs as-is
52
- 4. Micro-QA still runs after each commit (Phase 4 is NOT skipped)
53
+ 4. Patch extraction + user IDE review still runs after each commit unit
53
54
  5. Post-impl: skip cross-service-check, run qa-ruthless (scoped), merge-prep, retro
54
55
  6. Write a minimal plan retroactively after dispatch for traceability
55
56
 
@@ -154,13 +155,16 @@ Opus runs git directly via Bash. No subagents for git setup.
154
155
 
155
156
  For each impacted repo:
156
157
  1. `git -C ../{repo} branch session/{name} {source_branch}` — **git branch**, never checkout -b
157
- 2. `git worktree add /tmp/{repo}-{session-name} session/{name}` — persists until session close
158
+ 2. `git worktree add /tmp/{repo}-{session-name} session/{name}` — session worktree, persists until session close
158
159
  3. Verify worktree appears in `git worktree list`
159
160
 
160
161
  Write `.sessions/{name}.json` with session metadata (name, created, status, per-repo: path, worktree_path, source_branch, session_branch, commits map).
161
162
 
162
163
  PR target at session close = effective source branch.
163
164
 
165
+ Temp worktrees for each commit unit are created in Phase 3 (not here).
166
+ They use path `/tmp/{repo}-commit-{N}` and are destroyed after patch extraction.
167
+
164
168
 
165
169
  ## Phase 2.9: Pre-dispatch check (before spawning any teammate)
166
170
 
@@ -176,33 +180,54 @@ Verify via Bash for each repo. Abort and fix before proceeding:
176
180
 
177
181
  Only proceed to Phase 3 once all checks pass.
178
182
 
179
- ## Phase 3: Dispatch one teammate per COMMIT UNIT
183
+ ## Phase 3: Dispatch + Patch + Review + Commit
180
184
 
181
185
  **ONE teammate per commit unit.** Use `TeamCreate` to create a team for the session, then
182
186
  spawn one implementer per commit unit via `Agent(subagent_type: "implementer", team_name: ...)`.
183
- Each implementer receives ONLY its commit unit's tasks + a summary of previous units.
184
- The implementer writes code without committing, signals when ready, then STOPS.
185
-
186
- After the implementer signals "code ready":
187
- 1. Run micro-QA (Phase 4)
188
- 2. Present results to user for review (worktree path, diff, tests)
189
- 3. Wait for user approval
190
- 4. Team lead commits via Bash (git add + git commit in worktree)
191
- 5. Verify commit, update session.json, proceed to next unit
187
+ Each implementer works in an **isolated temp worktree**, writes code without committing,
188
+ signals when ready, then STOPS. The team lead extracts a patch, applies it to the session
189
+ worktree, and the user reviews the uncommitted changes in their IDE.
192
190
 
193
- ### Teammate spawn workflow
191
+ ### Cycle per commit unit (10 steps)
194
192
 
195
193
  ```
196
- 1. TeamCreate(team_name: "session-{name}")
194
+ 1. TeamCreate(team_name: "session-{name}") — once per session
197
195
  2. For each commit unit (sequentially within a repo):
198
- a. Agent(subagent_type: "implementer", team_name: "session-{name}", prompt with ONE commit unit)
199
- b. Wait for "code ready" signal
200
- c. Run micro-QA (Phase 4 Steps 1-2)
201
- d. Present to user for review (Phase 4 Step 3)
202
- e. Wait for user approval
203
- f. Team lead commits: git -C /tmp/{repo}-{session-name} add {files} && git commit -m "..."
204
- g. Verify commit, update session.json
205
- h. Proceed to next commit unit
196
+
197
+ a. Create temp worktree from session worktree HEAD:
198
+ git worktree add /tmp/{repo}-commit-{N} session/{name}
199
+
200
+ b. Dispatch teammate:
201
+ Agent(subagent_type: "implementer", team_name: "session-{name}",
202
+ prompt with worktree_path = /tmp/{repo}-commit-{N} and ONE commit unit)
203
+
204
+ c. Wait for "code ready" signal (must include test results)
205
+
206
+ d. Extract patch from temp worktree:
207
+ cd /tmp/{repo}-commit-{N}
208
+ git add -A
209
+ git diff --cached --binary HEAD > /tmp/patch-{N}.diff
210
+
211
+ e. Verify patch applies cleanly:
212
+ cd /tmp/{repo}-{session-name} && git apply --check /tmp/patch-{N}.diff
213
+ (if fails: try git apply --3way, else escalate to user)
214
+
215
+ f. Apply patch to session worktree:
216
+ cd /tmp/{repo}-{session-name} && git apply /tmp/patch-{N}.diff
217
+
218
+ g. Remove temp worktree:
219
+ git worktree remove --force /tmp/{repo}-commit-{N}
220
+ rm -f /tmp/patch-{N}.diff
221
+
222
+ h. Inform user:
223
+ "Commit {N} ready — review in your IDE: /tmp/{repo}-{session-name}"
224
+ WAIT for user approval.
225
+
226
+ i. After user approves, team lead commits:
227
+ cd /tmp/{repo}-{session-name} && git add {files} && git commit -m "type(scope): description"
228
+ Verify: git log --oneline -1
229
+
230
+ j. Update session.json, proceed to next commit unit
206
231
  ```
207
232
 
208
233
  ### Teammate spawn prompt — context tiering
@@ -210,7 +235,7 @@ After the implementer signals "code ready":
210
235
  See @references/spawn-templates.md for full templates.
211
236
 
212
237
  **Always inject (Tier 1):**
213
- 1. `worktree_path`: /tmp/{repo}-{session-name}/ — ready, no git setup needed
238
+ 1. `worktree_path`: /tmp/{repo}-commit-{N}/ — temp worktree, ready, no git setup needed
214
239
  2. `session_branch`: session/{name}
215
240
  3. This commit unit's tasks ONLY + summary of what previous units implemented
216
241
  4. Constitution rules (all from constitution.md, translated to English)
@@ -238,106 +263,51 @@ See @references/spawn-templates.md for full templates.
238
263
  ### Wave execution
239
264
 
240
265
  1. Spawn wave 1 commit units (parallel across repos, sequential within each repo)
241
- 2. For each commit unit: implementer writes → micro-QA → user review → team lead commits
266
+ 2. For each commit unit: implementer writes in temp worktree patch extraction apply to session worktree → user IDE review → team lead commits
242
267
  3. Wait for ALL wave 1 commit units to be user-committed
243
268
  4. Collect validated API contracts from wave 1 results
244
269
  5. Spawn wave 2 commit units with validated contracts
245
270
  6. Repeat for wave 3
246
271
 
247
- ## Phase 4: Micro-QA + User review + Team lead commits
248
-
249
- After each implementer signals "code ready":
250
-
251
- ### Step 1 — Bash verification (Opus direct)
252
-
253
- ```bash
254
- # 1. Verify uncommitted changes exist
255
- git -C /tmp/{repo}-{session-name} status --short
256
- git -C /tmp/{repo}-{session-name} diff --stat
257
-
258
- # 2. Run scoped tests — adapt command to repo stack:
259
- # PHP/Laravel:
260
- cd /tmp/{repo}-{session-name} && php artisan test --filter={CommitScope} 2>&1 | tail -30
261
- # Vue/Node:
262
- cd /tmp/{repo}-{session-name} && npm run typecheck 2>&1 | tail -20
263
- # Go:
264
- cd /tmp/{repo}-{session-name} && go test ./... 2>&1 | tail -20
265
- # Python:
266
- cd /tmp/{repo}-{session-name} && pytest {scope_path} -v 2>&1 | tail -30
267
-
268
- # 3. Check for debug artifacts in uncommitted changes
269
- git -C /tmp/{repo}-{session-name} diff \
270
- | grep -E "(console\.log|dd\(|var_dump|\.only\(|TODO|FIXME|debugger|dump\()" \
271
- | head -20
272
- ```
273
-
274
- ### Step 2 — Haiku diff review (Task subagent, read-only)
275
-
276
- Use the Haiku micro-QA template from @references/spawn-templates.md (section "Haiku micro-QA subagent template").
277
-
278
- Spawn Task(Explore, model: haiku) with that template, injecting `git diff` output (uncommitted changes).
272
+ ### User review presentation
279
273
 
280
- **Do NOT rephrase or shorten the template** copy it verbatim from the reference file.
281
- Haiku needs the exact structured prompt to return clean JSON.
282
-
283
- ### Step 3 — User review, then team lead commits
284
-
285
- If Step 1 and Step 2 pass, present to the user:
274
+ Present to the user after applying the patch:
286
275
 
287
276
  ```
288
277
  ## Commit unit {N}/{total} for {repo} — ready for review
289
278
 
290
- 📂 Worktree: /tmp/{repo}-{session-name}
291
- 📝 Files modified: {git diff --stat output}
292
- Tests: {pass/fail summary}
293
- 🔍 Micro-QA: {OK or issues}
279
+ Worktree: /tmp/{repo}-{session-name}
280
+ Files modified: {git diff --stat output}
281
+ Tests: {pass/fail summary from teammate signal}
294
282
 
295
- You can review the code at the worktree path above.
296
- Approve to commit, or request changes.
283
+ Changes are uncommitted in the session worktree above.
284
+ Open it in your IDE to review, then approve or request corrections.
297
285
  ```
298
286
 
299
287
  **WAIT for user approval.**
300
288
 
301
- After user approves, the **team lead commits via Bash**:
302
- ```bash
303
- git -C /tmp/{repo}-{session-name} add {files}
304
- git -C /tmp/{repo}-{session-name} commit -m "type(scope): description"
289
+ If the user requests modifications:
290
+ 1. Discard changes in session worktree: `git -C /tmp/{repo}-{session-name} checkout -- . && git -C /tmp/{repo}-{session-name} clean -fd`
291
+ 2. Create a NEW temp worktree: `git worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
292
+ 3. Re-spawn implementer with fix instructions in the new temp worktree
293
+ 4. Max 2 retries per commit unit, then escalate to user
305
294
 
306
- # Verify commit
307
- git -C /tmp/{repo}-{session-name} log --oneline -1
308
- ```
295
+ ### Update after each commit unit
309
296
 
310
297
  Update session.json with the commit hash:
311
298
  ```json
312
299
  "commits": {
313
- "N": { "status": "✅", "hash": "abc123", "files_modified": [...], "user_committed": true, "qa": "OK" }
300
+ "N": { "status": "✅", "hash": "abc123", "files_modified": [...], "user_committed": true }
314
301
  }
315
302
  ```
316
303
 
317
- If the user requests modifications → re-spawn implementer for the same commit unit with fix instructions.
318
-
319
- ### Decision (Steps 1-2)
320
-
321
- | Bash | Haiku | Action |
322
- |------|-------|--------|
323
- | OK | OK | Present to user for review (Step 3). Team lead commits after approval |
324
- | FAIL | any | Opus analyzes failure, re-spawns implementer with fix instructions OR escalates |
325
- | OK | BLOCKER | Opus evaluates blocker severity, re-spawns with fix instructions or escalates |
326
-
327
- Retry limit: max 2 per commit unit → escalate to user, stop the wave.
328
-
329
- ### Update after each commit unit
330
-
331
304
  ```bash
332
- # Update plan progress tracker
333
- # Mark commit N ✅ or ❌
334
-
335
- # Update session.json commits tracking
305
+ # Update plan progress tracker — mark commit N ✅ or ❌
336
306
  # Add session log entry:
337
307
  # [HH:MM] {repo}-commit-{N}: {status}, {hash}, {N} files, tests {pass/fail}, user_committed: true
338
308
  ```
339
309
 
340
- ## Phase 5: Post-implementation (all mandatory)
310
+ ## Phase 4: Post-implementation (all mandatory)
341
311
 
342
312
  1. **cross-service-check** — inter-repo consistency (API shapes, env vars, gateway routes)
343
313
  2. **qa-ruthless** — adversarial QA, min 3 findings per service
@@ -363,13 +333,16 @@ For targeted fixes or single-repo work:
363
333
 
364
334
  1. Read ./workspace.md for project context
365
335
  2. List ./plans/ for active plans
366
- 3. Check ./.sessions/ for active session JSON — worktrees should still exist in /tmp/
336
+ 3. Check ./.sessions/ for active session JSON — session worktrees should still exist in /tmp/
367
337
  4. Read active plan — statuses and session log tell you where you are
368
- 5. Verify worktrees still exist: git worktree list for each repo
369
- 6. Check `user_committed` field in session.json to determine where to resume:
338
+ 5. Verify session worktrees still exist: `git worktree list` for each repo
339
+ 6. Check for orphaned temp worktrees (`/tmp/{repo}-commit-*`):
340
+ - If temp worktree has uncommitted changes → extract patch, apply to session worktree, present to user
341
+ - If temp worktree is clean → remove it (work was lost, re-dispatch)
342
+ 7. Check `user_committed` field in session.json to determine where to resume:
370
343
  - If last unit has `user_committed: true` → spawn next unit's implementer
371
- - If last unit has `user_committed: false` or missing → check worktree for uncommitted changes, present to user for review
372
- 7. Resume from the appropriate step (implementer spawn, micro-QA, or user review)
344
+ - If last unit has `user_committed: false` or missing → check session worktree for uncommitted changes (from a patch already applied), present to user for review
345
+ 8. Resume from the appropriate step (temp worktree creation, patch extraction, or user review)
373
346
 
374
347
  ## Anti-patterns
375
348
 
@@ -36,8 +36,7 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
36
36
  13. **NEVER use git checkout -b in repos** — use git branch {name} {source} (no checkout).
37
37
  Checkout changes the working directory, which disrupts other sessions running in parallel.
38
38
 
39
- 14. **NEVER skip micro-QA between commit units** — Bash tests + Haiku diff after every commit unit, before user review.
40
- Waiting until the final QA is too late — issues compound across units.
39
+ 14. **NEVER skip patch extraction between commit units** — extract diff from temp worktree, apply to session worktree, user reviews in IDE before team lead commits. Skipping means user cannot review isolated changes.
41
40
 
42
41
  15. **NEVER prune worktrees during an active session** — worktrees persist until session close.
43
42
  The session-start-context.sh hook only cleans worktrees that are truly orphaned (no session JSON).
@@ -45,14 +44,15 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
45
44
  16. **NEVER over-split commit units** — 10+ commit units per service is excessive.
46
45
  Sweet spot: 2-5 per repo. Each spawn has context loading overhead.
47
46
 
48
- 17. **NEVER spawn the next commit unit before user has committed the previous** — micro-QA must pass,
49
- user must review and approve, team lead must commit — only then spawn the next unit's implementer.
47
+ 17. **NEVER spawn the next commit unit before user has committed the previous** — patch must be applied,
48
+ user must review in IDE and approve, team lead must commit — only then spawn the next unit's implementer.
50
49
 
51
50
  18. **NEVER let implementer run git add or git commit** — the implementer writes code and runs tests.
52
51
  The team lead commits after user review. The PreToolUse hook blocks git add/commit as a safety net.
53
52
 
54
- 19. **NEVER spawn the next commit unit before user has committed the previous** each commit unit
55
- requires: implementer writes code micro-QA user review team lead commits → next unit.
53
+ 19. **NEVER let a teammate work in the session worktree** teammates always work in isolated temp
54
+ worktrees (/tmp/{repo}-commit-{N}). The session worktree is the reference branch where commits
55
+ accumulate. Direct teammate access risks corruption of committed work.
56
56
 
57
57
  ## Common mistakes to watch for
58
58
 
@@ -64,9 +64,12 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
64
64
  | API contract has {} placeholder | Frontend can't build types | Complete the contract shapes before wave 2 |
65
65
  | Two teammates spawned on same repo | Git conflicts guaranteed | Kill one, let the remaining handle all commits |
66
66
  | Implementer runs git add/commit | Code committed without user review | PreToolUse hook should block it; if bypassed, reset with git reset HEAD~1 and re-present for review |
67
- | Next unit spawned before user committed previous | Uncommitted changes from unit N conflict with unit N+1 | Wait for user approval + team lead commit before spawning next unit |
67
+ | Next unit spawned before user committed previous | Patch from unit N+1 conflicts with uncommitted changes | Wait for user approval + team lead commit before spawning next unit |
68
+ | Temp worktree not cleaned up | git worktree list shows stale entries | git worktree remove /tmp/{repo}-commit-{N} --force |
69
+ | Patch apply fails | git apply --check returns error | Try --3way, or keep temp worktree for manual resolution |
70
+ | New files missing from patch | Untracked files not in git diff | Always git add -A in temp worktree before extracting diff --cached HEAD |
68
71
  | No signal from teammate after implementation | Silent failure | Check worktree git status/diff, ask teammate to signal or escalate |
69
72
  | Worktree missing after crash | git worktree list shows nothing | Recreate worktree from session branch: git worktree add /tmp/... session/{name} |
70
73
  | Giant commit (500+ lines) | Unreadable PR | Note in session log; teammate should split next time |
71
74
  | Commit unit not self-contained | Teammate can't understand scope | Rewrite: each unit must be understandable with only previous context |
72
- | cycle-retrospective skipped | Lessons not captured | Always run Phase 5 fully — retrospective is mandatory |
75
+ | cycle-retrospective skipped | Lessons not captured | Always run Phase 4 (post-impl) fully — retrospective is mandatory |
@@ -20,18 +20,33 @@ If the branch is unrecoverable:
20
20
  3. Re-dispatch ALL commit units for this service from scratch
21
21
  4. Warn the user — this resets all progress on this service
22
22
 
23
- ## Discarding uncommitted changes (failed commit unit)
23
+ ## Discarding changes (failed commit unit)
24
24
 
25
- If an implementer produces bad code that fails micro-QA and cannot be fixed:
25
+ Two cases depending on when the failure occurs:
26
26
 
27
- 1. Discard all uncommitted changes in the worktree:
27
+ ### Before patch apply (failure in temp worktree)
28
+
29
+ If the teammate fails tests or produces bad code in the temp worktree:
30
+
31
+ 1. Remove the temp worktree: `git worktree remove --force /tmp/{repo}-commit-{N}`
32
+ 2. Mark the commit unit ❌ in the plan with reason
33
+ 3. Create a new temp worktree: `git worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
34
+ 4. Re-spawn implementer with corrected instructions in the new temp worktree
35
+ 5. If 2 retries fail → escalate to user
36
+
37
+ ### After patch apply (user rejects changes in session worktree)
38
+
39
+ If the patch was applied to the session worktree but the user rejects it:
40
+
41
+ 1. Discard all uncommitted changes in the session worktree:
28
42
  ```bash
29
43
  git -C /tmp/{repo}-{session-name} checkout -- .
30
- git -C /tmp/{repo}-{session-name} clean -fd # remove untracked files if needed
44
+ git -C /tmp/{repo}-{session-name} clean -fd # remove untracked new files
31
45
  ```
32
46
  2. Mark the commit unit ❌ in the plan with reason
33
- 3. Re-spawn implementer with corrected instructions
34
- 4. If 2 retries fail escalate to user
47
+ 3. Create a new temp worktree: `git worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
48
+ 4. Re-spawn implementer with corrected instructions (include user feedback)
49
+ 5. If 2 retries fail → escalate to user
35
50
 
36
51
  ## Failed dispatch tracking
37
52
 
@@ -2,18 +2,19 @@
2
2
 
3
3
  Reference file for dispatch-feature and team-lead. Loaded on-demand.
4
4
 
5
- > v5.2.3 model: ONE teammate per COMMIT UNIT. The teammate writes code without
6
- > committing, then signals when code is ready for review. The team lead commits
7
- > after user approval. Teammates receive a ready worktree NO git setup in
8
- > spawn prompts. Implementers do NOT receive the constitution automatically.
9
- > Every spawn template below includes a "Constitution" section that you MUST
10
- > fill with all rules from your workspace's constitution.md.
5
+ > v5.3.0 model: ONE teammate per COMMIT UNIT in a temporary worktree. The teammate
6
+ > writes code without committing, then signals when code is ready. The team lead
7
+ > extracts a patch, applies it to the session worktree, and the user reviews in
8
+ > their IDE. Teammates receive a temp worktree NO git setup in spawn prompts.
9
+ > Implementers do NOT receive the constitution automatically. Every spawn template
10
+ > below includes a "Constitution" section that you MUST fill with all rules from
11
+ > your workspace's constitution.md.
11
12
 
12
13
  ## Context tiering — what to inject per repo type
13
14
 
14
15
  | Context | Backend repo | Frontend repo | Infra repo |
15
16
  |---------|:-:|:-:|:-:|
16
- | worktree_path + session_branch | ALWAYS | ALWAYS | ALWAYS |
17
+ | temp_worktree_path + session_branch | ALWAYS | ALWAYS | ALWAYS |
17
18
  | This commit unit's tasks ONLY + context summary | ALWAYS | ALWAYS | ALWAYS |
18
19
  | Constitution rules | ALWAYS | ALWAYS | ALWAYS |
19
20
  | Signal-when-ready instruction (no commit) | ALWAYS | ALWAYS | ALWAYS |
@@ -21,7 +22,7 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
21
22
  | UX standards | Never | If UI commits | Never |
22
23
 
23
24
  > **No git instructions in spawn prompts.** The implementer agent knows it has
24
- > a ready worktree. Only provide the specific values: worktree_path, session_branch.
25
+ > a ready worktree. Only provide: temp_worktree_path (the /tmp/{repo}-commit-{N} path), session_branch.
25
26
 
26
27
  ## Backend/API teammate spawn template
27
28
 
@@ -29,7 +30,7 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
29
30
  You are the implementer teammate for [{repo}].
30
31
 
31
32
  ## Your workspace
32
- - Worktree (ready, go directly here): {worktree_path}
33
+ - Temporary worktree (ready, isolated, go directly here): {temp_worktree_path}
33
34
  - Session branch: {session_branch}
34
35
  - Your worktree is already on the correct branch — no git setup needed.
35
36
 
@@ -58,9 +59,9 @@ Do NOT run git add or git commit. Leave all changes uncommitted.
58
59
  The team lead will commit after user review.
59
60
 
60
61
  ## Instructions
61
- 1. Go directly to your worktree: cd {worktree_path}
62
+ 1. Go directly to your worktree: cd {temp_worktree_path}
62
63
  2. Read the repo CLAUDE.md — follow its conventions throughout
63
- 3. Check git log to see what's already on the branch (if resuming)
64
+ 3. Check git log to see what previous commits already implemented
64
65
  4. Implement your commit unit — run tests and report results
65
66
  5. Do NOT run git add or git commit
66
67
  6. List dead code found
@@ -74,7 +75,7 @@ The team lead will commit after user review.
74
75
  You are the implementer teammate for [{repo}].
75
76
 
76
77
  ## Your workspace
77
- - Worktree (ready, go directly here): {worktree_path}
78
+ - Temporary worktree (ready, isolated, go directly here): {temp_worktree_path}
78
79
  - Session branch: {session_branch}
79
80
  - Your worktree is already on the correct branch — no git setup needed.
80
81
 
@@ -105,9 +106,9 @@ Do NOT run git add or git commit. Leave all changes uncommitted.
105
106
  The team lead will commit after user review.
106
107
 
107
108
  ## Instructions
108
- 1. Go directly to your worktree: cd {worktree_path}
109
+ 1. Go directly to your worktree: cd {temp_worktree_path}
109
110
  2. Read the repo CLAUDE.md — follow its conventions throughout
110
- 3. Check git log to see what's already on the branch (if resuming)
111
+ 3. Check git log to see what previous commits already implemented
111
112
  4. Implement your commit unit
112
113
  5. For every UI component: implement all 4 states (skeleton, empty+CTA, error+retry, success)
113
114
  6. Run tests — report pass/fail in your signal
@@ -122,7 +123,7 @@ The team lead will commit after user review.
122
123
  You are the implementer teammate for [{repo}] (infrastructure/configuration).
123
124
 
124
125
  ## Your workspace
125
- - Worktree (ready, go directly here): {worktree_path}
126
+ - Temporary worktree (ready, isolated, go directly here): {temp_worktree_path}
126
127
  - Session branch: {session_branch}
127
128
  - Your worktree is already on the correct branch — no git setup needed.
128
129
 
@@ -146,47 +147,23 @@ Do NOT run git add or git commit. Leave all changes uncommitted.
146
147
  The team lead will commit after user review.
147
148
 
148
149
  ## Instructions
149
- 1. Go directly to your worktree: cd {worktree_path}
150
+ 1. Go directly to your worktree: cd {temp_worktree_path}
150
151
  2. Implement ONLY configuration changes — no application code
151
152
  3. Verify consistency with other services (env vars, routes, schemas)
152
153
  4. Do NOT run git add or git commit
153
154
  5. Escalate if you hit configuration decisions not covered by the plan
154
155
  ```
155
156
 
156
- ## Haiku micro-QA subagent template
157
-
158
- Used by Opus in Phase 4 micro-QA on uncommitted changes (git diff, not git diff HEAD~1 HEAD).
159
-
160
- ```
161
- Read the following git diff (uncommitted changes) and return ONLY a JSON object — no markdown, no preamble:
162
-
163
- If no issues found:
164
- {"status":"OK"}
165
-
166
- If a blocking issue found:
167
- {"status":"BLOCKER","file":"path/to/file","line":42,"reason":"specific reason"}
168
-
169
- Check for:
170
- 1. API contract consistency — do returned/sent fields match the contract shapes provided?
171
- 2. Unjustified TypeScript 'any' — any usage that loses type safety without clear reason
172
- 3. Missing error handling — new public endpoints or functions without error handling
173
- 4. Obvious logic errors — visible in the diff without running the code
174
-
175
- Return ONLY the JSON object. No text before or after it.
176
-
177
- Diff (uncommitted):
178
- {git diff output}
179
- ```
180
-
181
157
  ## Failure handling
182
158
 
183
- When a teammate signals a failure or when Bash/Haiku micro-QA fails:
159
+ When a teammate signals a failure or when patch extraction/apply fails:
184
160
 
185
161
  | Situation | Action |
186
162
  |-----------|--------|
187
- | Tests fail on commit unit N | Re-spawn implementer with fix instructions for the same commit unit |
188
- | Haiku BLOCKER on commit unit N | Opus evaluates — if fixable: re-spawn with instructions; if architectural: escalate to user |
163
+ | Tests fail on commit unit N | Re-spawn implementer with fix instructions in a NEW temp worktree |
164
+ | Patch apply fails | Try `git apply --3way`; if still fails, keep temp worktree, escalate to user |
189
165
  | Architectural decision not in plan | STOP the wave, escalate to user, resume after direction |
190
- | Teammate silent / no signal | Check worktree git status/diff, re-spawn or escalate |
166
+ | Teammate silent / no signal | Check temp worktree git status/diff, re-spawn or escalate |
191
167
  | Max 2 retries on same commit | Mark ❌ ESCALATED, stop the wave, present to user |
168
+ | User rejects changes | Discard in session worktree, create new temp worktree, re-dispatch with fix instructions |
192
169
  | Corrupted branch | Use rollback protocol (see team-lead agent / rollback-protocol.md) |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: doctor
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Full diagnostic of the orchestrator workspace installation. Checks global
6
6
  components (skills, rules, agents), local structure (hooks, settings,
@@ -12,7 +12,7 @@ SESSIONS_DIR="$PROJECT_DIR/.sessions"
12
12
  ORPHAN_COUNT=0
13
13
 
14
14
  shopt -s nullglob
15
- for wt in /tmp/*-session-* /tmp/e2e-*; do
15
+ for wt in /tmp/*-session-* /tmp/*-commit-* /tmp/e2e-*; do
16
16
  [ -d "$wt" ] || continue
17
17
 
18
18
  # Check if this worktree belongs to an active session
@@ -26,7 +26,7 @@ if [ "$TOOL_NAME" = "Bash" ]; then
26
26
 
27
27
  # SECURITY: reject compound commands — never auto-approve chained operations
28
28
  # This prevents `git branch session/x && rm -rf /` style bypasses
29
- # Exception: `cd /tmp/... && <safe-test-command>` is a legitimate micro-QA pattern
29
+ # Exception: `cd /tmp/... && <safe-test-command>` is a legitimate verification pattern
30
30
  if echo "$COMMAND" | grep -qE '(&&|\|\||[;|]|`|\$\()'; then
31
31
  # Allow: cd /tmp/{worktree} && {test-command}
32
32
  if echo "$COMMAND" | grep -qE '^\s*cd\s+(/private)?/tmp/[a-zA-Z][a-zA-Z0-9_-]+\s+&&\s+(npm run (typecheck|test|lint)|php artisan test|go test|pytest|npx vitest|npx jest|yarn test|pnpm test)\b'; then
@@ -56,7 +56,7 @@ if [ "$TOOL_NAME" = "Bash" ]; then
56
56
  exit 0
57
57
  fi
58
58
 
59
- # Safe typecheck/test commands in /tmp/ worktrees (micro-QA)
59
+ # Safe typecheck/test commands in /tmp/ worktrees
60
60
  # Compound check above already rejected chained commands
61
61
  if echo "$COMMAND" | grep -qE '^\s*cd\s+(/private)?/tmp/[a-zA-Z]'; then
62
62
  echo "$ALLOW_JSON"
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # user-prompt-guard.sh
3
3
  # UserPromptSubmit hook: conditionally reminds the orchestrator of its role.
4
- # v5.0: Updated to reflect that Opus can run git/bash on repos for orchestration
5
- # purposes (branch creation, worktree management, micro-QA), but not code changes.
4
+ # v5.3: Updated to reflect that Opus can run git/bash on repos for orchestration
5
+ # purposes (branch creation, worktree management, patch extraction), but not code changes.
6
6
  # Non-blocking (exit 0 + stdout = context injection).
7
7
  set -euo pipefail
8
8
 
@@ -13,7 +13,7 @@ PROMPT=$(echo "$INPUT" | jq -r '.prompt // empty' 2>/dev/null) || true
13
13
 
14
14
  # Only inject reminder if user prompt matches direct code-writing patterns
15
15
  if echo "$PROMPT" | grep -qiE '(modifie.*fichier|édite.*(api|front|light|spring|scraper|krakend|dashboard)|patch.*service|écris.*dans.*repo|write.*in.*repo|code.*dans.*repo)' 2>/dev/null; then
16
- echo "Role reminder: Writing application code in sibling repos is for teammates. You can write in orchestrator/ (plans, workspace.md, constitution.md) and run git commands (branch, worktree, log) and test commands in /tmp/ worktrees for micro-QA. For repo application code changes: spawn a teammate."
16
+ echo "Role reminder: Writing application code in sibling repos is for teammates. You can write in orchestrator/ (plans, workspace.md, constitution.md) and run git commands (branch, worktree, log, diff, apply) in /tmp/ worktrees for patch extraction. For repo application code changes: spawn a teammate."
17
17
  fi
18
18
 
19
19
  exit 0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: incident-debug
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Debug incidents across a multi-service stack. Spawns parallel
6
6
  investigators per layer. Use when user reports a bug, says "erreur",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: merge-prep
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Prepare branches for merge after QA passes. Checks for conflicts between
6
6
  teammate branches, generates PR summaries, lists review points.
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: metrics
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Quantitative analysis of orchestrator performance. Parses session logs,
6
6
  completed plans, and QA reports to produce KPIs: re-dispatch rate,
7
- micro-QA first-pass rate, commits per session, QA findings distribution,
7
+ patch-apply first-pass rate, commits per session, QA findings distribution,
8
8
  escalation rate, and phase timing estimates.
9
9
  Use: /metrics, /metrics last-5, /metrics session-name.
10
10
  Helps justify model routing decisions and prompt improvements.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: plan-review
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Quick sanity check on a plan before the user validates it. Verifies
6
6
  structural completeness: all tasks have a service, waves respect
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qa-ruthless
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Adversarial QA review after feature implementation. MUST find problems —
6
6
  a clean report is a failed review. Executes tests, hunts dead code,
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: refresh-profiles
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Regenerate service-profiles.md by reading CLAUDE.md from all repos
6
6
  listed in workspace.md. Use when conventions changed, or user says
@@ -8,7 +8,7 @@ globs: ["workspace.md", "plans/**", "constitution.md", "templates/**"]
8
8
  ## Golden rule
9
9
  The orchestrator NEVER writes application code in repos. It describes what teammates must do.
10
10
  Writing plans, workspace.md, constitution.md in orchestrator/ is expected and normal.
11
- Running git commands (branch, worktree, log) and test/typecheck in /tmp/ worktrees is expected (micro-QA).
11
+ Running git commands (branch, worktree, log, diff, apply) and test/typecheck in /tmp/ worktrees is expected.
12
12
  If you write application code in a repo (not a markdown plan, not a git command, not a test run), you have failed — delegate.
13
13
 
14
14
  ## Security layers (3 layers in agent frontmatter)
@@ -26,7 +26,6 @@ If you write application code in a repo (not a markdown plan, not a git command,
26
26
  | Code reviewer | **Opus** | `claude --agent reviewer` (evidence-based review, architecture judgment) |
27
27
  | Security auditor | **Opus** | `claude --agent security-auditor` (auth flows, tenant isolation, secrets, CVEs) |
28
28
  | Plan review | **Sonnet** | `plan-review` skill (constitution compliance needs reasoning) |
29
- | Micro-QA diff review | **Haiku** | `Task(Explore, model: haiku)` — structured diff check only |
30
29
  | Data extractors (cross-check, debug, retro) | **Haiku** | `Task(Explore, model: haiku)` — raw data extraction only |
31
30
 
32
31
  ## Gather → Reason pattern
@@ -41,8 +40,7 @@ Skills that need both data collection and analysis use a two-phase approach:
41
40
  the raw data and performs all analysis: comparison, correlation, judgment, diagnosis,
42
41
  and report writing.
43
42
 
44
- This pattern applies to: `cross-service-check`, `incident-debug`, `cycle-retrospective`,
45
- and micro-QA diff review in dispatch-feature Phase 4.
43
+ This pattern applies to: `cross-service-check`, `incident-debug`, `cycle-retrospective`.
46
44
 
47
45
  It does NOT apply to: `qa-ruthless` (QA investigators are Sonnet — they need to run tests
48
46
  and reason about code quality), `plan-review` (Sonnet — constitution compliance requires reasoning).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: session
3
- prompt_version: 5.2.1
3
+ prompt_version: 5.3.0
4
4
  description: >
5
5
  Manage parallel feature sessions. List active sessions, show detailed status
6
6
  with commits per repo, or close a session (PRs + branch cleanup + worktree removal).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-workspace",
3
- "version": "5.2.5",
3
+ "version": "5.3.0",
4
4
  "description": "Claude Code multi-workspace orchestrator \u2014 skills, hooks, agents, and templates for multi-service projects",
5
5
  "bin": {
6
6
  "cc-workspace": "./bin/cli.js"