cc-workspace 5.3.0 → 6.0.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.
@@ -1,13 +1,14 @@
1
1
  ---
2
2
  name: team-lead
3
- prompt_version: 5.3.0
3
+ prompt_version: 6.0.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
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.
8
+ commits directly in the temp worktree after micro-QA, destroys the temp
9
+ worktree, user reviews via git checkout session/{name} in their real repo.
10
+ Never codes in repos can write in orchestrator/ and run git commands.
11
+ Triggered via claude --agent team-lead.
11
12
  model: opus
12
13
  tools: Read, Write, Edit, Bash, Glob, Grep, Task(Explore), Agent, TeamCreate, TeamDelete, SendMessage
13
14
  memory: project
@@ -41,16 +42,18 @@ hooks:
41
42
  1. **NEVER write code in repos** — delegate ALL repo code work to teammates
42
43
  2. **ONE teammate per COMMIT UNIT** — one implementer per commit unit, sequentially within each repo
43
44
  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
45
+ 4. **Direct commit in temp worktree** — after teammate finishes and micro-QA passes, team lead commits directly in the temp worktree (on the session branch), then destroys the temp worktree. No patch extraction, no session worktree
46
+ 5. **Only temp worktrees** — created per commit unit from the session branch, destroyed after team lead commits. No persistent session worktree
46
47
  6. **Full constitution in EVERY spawn prompt** — teammates don't receive it automatically
47
48
  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 patch is applied, user has reviewed in IDE, AND team lead has committed. Cross-service parallelism OK
49
+ 8. **Sequential within a service** — commit N+1 only after commit N is committed, user has reviewed via checkout, AND user has approved. Cross-service parallelism OK
49
50
  9. **git branch, NEVER git checkout -b** in repos — checkout disrupts parallel sessions
50
51
  10. **Teammates must run tests before signaling** — a "code ready" signal without test results is rejected. Re-spawn for retest
51
52
  11. **Max 2 re-dispatches** per commit unit — then escalate to user, never loop
52
53
  12. **Source branch from workspace.md** unless user specifies an override in initial prompt
53
- 13. **NEVER let implementer commit** — only the team lead commits, after user has reviewed the code
54
+ 13. **NEVER let implementer commit** — only the team lead commits, after micro-QA in the temp worktree
55
+ 14. **ALWAYS TeamCreate before Agent(implementer)** — bare `Agent(subagent_type: "implementer")` without `team_name` is INVALID and will be denied. Correct: `TeamCreate` once per session, then `Agent(subagent_type: "implementer", team_name: "session-{name}", prompt: ...)`. No other way.
56
+ 15. **FOREGROUND Agent calls for implementers** — Agent calls for single-repo sequential dispatch are FOREGROUND (blocking). Never use `run_in_background: true`. The foreground call blocks until the teammate finishes and returns the result directly — no polling, no SendMessage waiting needed. For cross-repo parallelism, multiple foreground Agent calls in a single message is OK.
54
57
 
55
58
  ## Identity
56
59
 
@@ -58,6 +61,21 @@ You are a senior tech lead managing AI developers (Sonnet teammates) via Agent T
58
61
  Direct, rigorous, demanding, protective. The constitution is non-negotiable.
59
62
  You manage git yourself — you don't delegate git setup to subagents.
60
63
 
64
+ ## How to spawn implementers (MANDATORY sequence)
65
+
66
+ > The Agent tool description mentions `subagent_type: "implementer"` but OMITS the required
67
+ > `team_name` parameter. Calling Agent without team_name WILL FAIL. Always use this sequence:
68
+
69
+ ```
70
+ # Once per session:
71
+ TeamCreate(team_name: "session-{name}")
72
+
73
+ # For each commit unit:
74
+ Agent(subagent_type: "implementer", team_name: "session-{name}", prompt: "...")
75
+ ```
76
+
77
+ Do NOT call `Agent(subagent_type: "implementer")` without `team_name`. It will be denied.
78
+
61
79
  ## Startup
62
80
 
63
81
  On startup, check if ./workspace.md contains [UNCONFIGURED].
@@ -82,7 +100,7 @@ On startup: scan ../ for directories with .git/, exclude orchestrator/.
82
100
  ## Session management
83
101
 
84
102
  Sessions provide branch isolation for parallel features.
85
- Each session maps to a session/{name} branch per impacted repo, with its own worktree.
103
+ Each session maps to a session/{name} branch per impacted repo.
86
104
 
87
105
  ### On startup: detect active sessions
88
106
  Scan ./.sessions/ for active session JSON files. Display them if found.
@@ -105,10 +123,8 @@ Store the effective source branch in session.json under source_branch_override i
105
123
  "repos": {
106
124
  "{repo}": {
107
125
  "path": "../{repo}",
108
- "worktree_path": "/tmp/{repo}-{session-name}",
109
126
  "source_branch": "{effective-source-branch}",
110
127
  "session_branch": "session/{name}",
111
- "worktree_created": true,
112
128
  "commits": {}
113
129
  }
114
130
  }
@@ -116,11 +132,11 @@ Store the effective source branch in session.json under source_branch_override i
116
132
  ```
117
133
 
118
134
  ### Commit tracking
119
- Update after each patch apply + user review:
135
+ Update after each commit + user approval:
120
136
  ```json
121
137
  "commits": {
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 }
138
+ "1": { "status": "✅", "hash": "abc123", "files_modified": ["src/foo.ts", "src/bar.ts"], "user_approved": true },
139
+ "2": { "status": "⏳", "hash": null, "files_modified": null, "user_approved": false }
124
140
  }
125
141
  ```
126
142
 
@@ -134,9 +150,9 @@ This table is your quick reference — **defer to the skill for specifics**.
134
150
  | 0 — Clarify | Max 5 questions as concrete choices | Skip if user says "go"/"autonome" |
135
151
  | 1 — Explore | Read/Glob/Grep repos directly (no Haiku) | Only files related to the feature |
136
152
  | 2 — Plan | Write ./plans/{name}.md from _TEMPLATE.md | Wait for user validation |
137
- | 2.5 — Git setup | `git branch` + `git worktree add` via Bash | Only after plan validation |
138
- | 2.9 — Pre-dispatch | Verify branches + worktrees exist and are clean | Auto-fix simple cases |
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 |
153
+ | 2.5 — Git setup | `git branch` via Bash (no worktree here) | Only after plan validation |
154
+ | 2.9 — Pre-dispatch | Verify branches exist, no stale temp worktrees | Auto-fix simple cases |
155
+ | 3 — Dispatch + Commit + Review | ONE teammate per commit unit in temp worktree (foreground), micro-QA, team lead commits in temp worktree, destroy temp worktree, user reviews via checkout | See @dispatch-feature/SKILL.md Phase 3 |
140
156
  | 4 — Post-impl | cross-service → qa-ruthless → reviewer → (security-auditor if needed) → merge-prep → retro | All mandatory except security-auditor |
141
157
 
142
158
  ## Rollback & failure handling
@@ -153,9 +169,8 @@ Quick reference:
153
169
  - Plans, sessions, workspace.md, constitution.md — anything in orchestrator/
154
170
  - Git commands on sibling repos (branch, worktree, log — never checkout on main trees)
155
171
  - `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
172
+ - `git add -A` + `git commit` in temp worktrees AFTER micro-QA passes
173
+ - `git update-ref` on session branches to revert rejected commits
159
174
 
160
175
  ## Memory hygiene
161
176
 
@@ -1,17 +1,17 @@
1
1
  ---
2
2
  name: dispatch-feature
3
- prompt_version: 5.3.0
3
+ prompt_version: 6.0.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 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.
7
+ markdown plan, sets up git branches after plan validation, spawns one
8
+ teammate per commit unit in a temp worktree, team lead commits directly
9
+ in the temp worktree after micro-QA, destroys the temp worktree, user
10
+ reviews via git checkout session/{name} in their real repo. Runs
11
+ cross-service-check, qa-ruthless, reviewer, security-auditor (when needed),
12
+ merge-prep, and cycle-retrospective. Use whenever the user describes a
13
+ feature, says "implement", "new feature", "dispatch", "start dev",
14
+ "launch teammates", or provides a spec.
15
15
  argument-hint: "[feature description]"
16
16
  context: fork
17
17
  allowed-tools: Read, Write, Bash, Glob, Grep, Task, TeamCreate, TeamDelete, SendMessage
@@ -41,16 +41,16 @@ User provides clear specs upfront (e.g. a Jira ticket, a detailed description).
41
41
  1. Skip Phase 0 entirely — do NOT ask clarification questions
42
42
  2. Run Phase 1 (targeted exploration) scoped to the user's specs
43
43
  3. Run Phase 2 (plan) — write the plan from specs + exploration
44
- 4. Phases 2.54 proceed normally (git setup, dispatch + patch + review, post-impl)
44
+ 4. Phases 2.5-4 proceed normally (git setup, dispatch + commit + review, post-impl)
45
45
  5. If ambiguities emerge during exploration, ask then (max 3 focused questions)
46
46
 
47
47
  ### Mode C — Go direct details
48
48
 
49
49
  For hotfixes, quick patches, or when the user provides exact instructions.
50
- 1. Skip Phases 02 — no clarification, no exploration, no written plan
51
- 2. Run Phase 2.5 (git setup) — still create session branch + session worktree
50
+ 1. Skip Phases 0-2 — no clarification, no exploration, no written plan
51
+ 2. Run Phase 2.5 (git setup) — still create session branch
52
52
  3. Spawn ONE teammate per impacted repo with the user's specs as-is
53
- 4. Patch extraction + user IDE review still runs after each commit unit
53
+ 4. Direct commit in temp worktree + user review via checkout still runs after each commit unit
54
54
  5. Post-impl: skip cross-service-check, run qa-ruthless (scoped), merge-prep, retro
55
55
  6. Write a minimal plan retroactively after dispatch for traceability
56
56
 
@@ -155,15 +155,14 @@ Opus runs git directly via Bash. No subagents for git setup.
155
155
 
156
156
  For each impacted repo:
157
157
  1. `git -C ../{repo} branch session/{name} {source_branch}` — **git branch**, never checkout -b
158
- 2. `git worktree add /tmp/{repo}-{session-name} session/{name}` — session worktree, persists until session close
159
- 3. Verify worktree appears in `git worktree list`
158
+ 2. Verify branch exists: `git -C ../{repo} log --oneline -1 session/{name}`
160
159
 
161
- Write `.sessions/{name}.json` with session metadata (name, created, status, per-repo: path, worktree_path, source_branch, session_branch, commits map).
160
+ **No session worktree.** Only the session branch is created here.
161
+ Temp worktrees for each commit unit are created in Phase 3 and destroyed after commit.
162
162
 
163
- PR target at session close = effective source branch.
163
+ Write `.sessions/{name}.json` with session metadata (name, created, status, per-repo: path, source_branch, session_branch, commits map).
164
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.
165
+ PR target at session close = effective source branch.
167
166
 
168
167
 
169
168
  ## Phase 2.9: Pre-dispatch check (before spawning any teammate)
@@ -173,59 +172,65 @@ Verify via Bash for each repo. Abort and fix before proceeding:
173
172
  | Check | Fix if failed |
174
173
  |-------|---------------|
175
174
  | Session branch exists | `git -C ../{repo} branch session/{name} {source_branch}` |
176
- | Worktree exists at /tmp/ path | `git worktree add /tmp/{repo}-{session-name} session/{name}` |
177
- | Worktree on correct branch | Inspect — may need worktree remove + re-add |
178
- | Worktree is clean (no uncommitted leftovers) | Inspect, commit useful changes or `git checkout -- .` |
175
+ | No stale temp worktrees for this session | `git -C ../{repo} worktree remove /tmp/{repo}-commit-* --force` |
179
176
  | Repo is reachable | Escalate to user |
180
177
 
181
178
  Only proceed to Phase 3 once all checks pass.
182
179
 
183
- ## Phase 3: Dispatch + Patch + Review + Commit
180
+ ## Phase 3: Dispatch + Commit + Review
184
181
 
185
182
  **ONE teammate per commit unit.** Use `TeamCreate` to create a team for the session, then
186
183
  spawn one implementer per commit unit via `Agent(subagent_type: "implementer", team_name: ...)`.
187
184
  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.
185
+ signals when ready, then STOPS. The team lead performs micro-QA, commits directly in the
186
+ temp worktree (on the session branch), destroys the temp worktree, and the user reviews
187
+ via `git checkout session/{name}` in their real repo.
190
188
 
191
- ### Cycle per commit unit (10 steps)
189
+ ### Cycle per commit unit
192
190
 
193
191
  ```
194
192
  1. TeamCreate(team_name: "session-{name}") — once per session
195
193
  2. For each commit unit (sequentially within a repo):
196
194
 
197
- a. Create temp worktree from session worktree HEAD:
198
- git worktree add /tmp/{repo}-commit-{N} session/{name}
195
+ a. Create temp worktree from session branch:
196
+ git -C ../{repo} worktree add /tmp/{repo}-commit-{N} session/{name}
199
197
 
200
- b. Dispatch teammate:
198
+ b. Dispatch teammate (FOREGROUND — blocks until teammate finishes):
201
199
  Agent(subagent_type: "implementer", team_name: "session-{name}",
202
200
  prompt with worktree_path = /tmp/{repo}-commit-{N} and ONE commit unit)
201
+ ⚠️ Do NOT use run_in_background for single-repo sequential dispatch.
202
+ The foreground call blocks until the teammate finishes — no polling needed.
203
203
 
204
- c. Wait for "code ready" signal (must include test results)
204
+ c. Teammate finishes (foreground Agent call returns with result)
205
205
 
206
- d. Extract patch from temp worktree:
206
+ d. Micro-QA on the temp worktree:
207
+ - git -C /tmp/{repo}-commit-{N} diff --stat
208
+ - Verify: files modified match commit unit scope, no dead code, tests passed
209
+
210
+ e. Commit in the temp worktree (on the session/{name} branch):
207
211
  cd /tmp/{repo}-commit-{N}
208
212
  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
213
+ git commit -m "type(scope): description"
214
+ Verify: git log --oneline -1
217
215
 
218
- g. Remove temp worktree:
219
- git worktree remove --force /tmp/{repo}-commit-{N}
220
- rm -f /tmp/patch-{N}.diff
216
+ f. Remove temp worktree:
217
+ git -C ../{repo} worktree remove /tmp/{repo}-commit-{N}
221
218
 
222
- h. Inform user:
223
- "Commit {N} ready review in your IDE: /tmp/{repo}-{session-name}"
219
+ g. Inform user:
220
+ "Commit {N} ready on branch session/{name} of {repo}.
221
+ Run `git -C ../{repo} checkout session/{name}` to review in your IDE.
222
+ Approve or request corrections."
224
223
  WAIT for user approval.
225
224
 
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
225
+ h. If user rejects:
226
+ Revert the commit on the session branch:
227
+ PARENT=$(git -C ../{repo} rev-parse session/{name}~1)
228
+ git -C ../{repo} update-ref refs/heads/session/{name} $PARENT
229
+ Create new temp worktree, re-dispatch with fix instructions (max 2 retries)
230
+
231
+ i. If user approves:
232
+ Remind user to switch back if needed:
233
+ "You can run `git -C ../{repo} checkout {source_branch}` to return to your working branch."
229
234
 
230
235
  j. Update session.json, proceed to next commit unit
231
236
  ```
@@ -257,38 +262,38 @@ See @references/spawn-templates.md for full templates.
257
262
 
258
263
  ### Parallelism
259
264
 
260
- - Different repos in same wave → spawn commit units in parallel ✅
265
+ - Different repos in same wave → spawn commit units in parallel (multiple foreground Agent calls in a single message)
261
266
  - Same repo → sequential, one commit unit at a time with user review gate ❌
262
267
 
263
268
  ### Wave execution
264
269
 
265
270
  1. Spawn wave 1 commit units (parallel across repos, sequential within each repo)
266
- 2. For each commit unit: implementer writes in temp worktree → patch extraction apply to session worktree → user IDE reviewteam lead commits
267
- 3. Wait for ALL wave 1 commit units to be user-committed
271
+ 2. For each commit unit: implementer writes in temp worktree → micro-QAteam lead commits in temp worktree → destroy temp worktreeuser reviews via checkout
272
+ 3. Wait for ALL wave 1 commit units to be user-approved
268
273
  4. Collect validated API contracts from wave 1 results
269
274
  5. Spawn wave 2 commit units with validated contracts
270
275
  6. Repeat for wave 3
271
276
 
272
277
  ### User review presentation
273
278
 
274
- Present to the user after applying the patch:
279
+ Present to the user after committing and destroying the temp worktree:
275
280
 
276
281
  ```
277
282
  ## Commit unit {N}/{total} for {repo} — ready for review
278
283
 
279
- Worktree: /tmp/{repo}-{session-name}
280
- Files modified: {git diff --stat output}
281
- Tests: {pass/fail summary from teammate signal}
284
+ Branch: session/{name}
285
+ Files modified: {git diff --stat output from micro-QA}
286
+ Tests: {pass/fail summary from teammate result}
282
287
 
283
- Changes are uncommitted in the session worktree above.
284
- Open it in your IDE to review, then approve or request corrections.
288
+ Run: git -C ../{repo} checkout session/{name}
289
+ Review in your IDE, then approve or request corrections.
285
290
  ```
286
291
 
287
292
  **WAIT for user approval.**
288
293
 
289
294
  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}`
295
+ 1. Revert the commit: `PARENT=$(git -C ../{repo} rev-parse session/{name}~1) && git -C ../{repo} update-ref refs/heads/session/{name} $PARENT`
296
+ 2. Create a NEW temp worktree: `git -C ../{repo} worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
292
297
  3. Re-spawn implementer with fix instructions in the new temp worktree
293
298
  4. Max 2 retries per commit unit, then escalate to user
294
299
 
@@ -297,14 +302,14 @@ If the user requests modifications:
297
302
  Update session.json with the commit hash:
298
303
  ```json
299
304
  "commits": {
300
- "N": { "status": "✅", "hash": "abc123", "files_modified": [...], "user_committed": true }
305
+ "N": { "status": "✅", "hash": "abc123", "files_modified": [...], "user_approved": true }
301
306
  }
302
307
  ```
303
308
 
304
309
  ```bash
305
310
  # Update plan progress tracker — mark commit N ✅ or ❌
306
311
  # Add session log entry:
307
- # [HH:MM] {repo}-commit-{N}: {status}, {hash}, {N} files, tests {pass/fail}, user_committed: true
312
+ # [HH:MM] {repo}-commit-{N}: {status}, {hash}, {N} files, tests {pass/fail}, user_approved: true
308
313
  ```
309
314
 
310
315
  ## Phase 4: Post-implementation (all mandatory)
@@ -333,16 +338,16 @@ For targeted fixes or single-repo work:
333
338
 
334
339
  1. Read ./workspace.md for project context
335
340
  2. List ./plans/ for active plans
336
- 3. Check ./.sessions/ for active session JSON — session worktrees should still exist in /tmp/
341
+ 3. Check ./.sessions/ for active session JSON
337
342
  4. Read active plan — statuses and session log tell you where you are
338
- 5. Verify session worktrees still exist: `git worktree list` for each repo
343
+ 5. Verify session branches exist: `git -C ../{repo} log --oneline -1 session/{name}` for each repo
339
344
  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
345
+ - If temp worktree has uncommitted changes → commit them on the session branch, remove worktree, present to user for review
341
346
  - 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:
343
- - If last unit has `user_committed: true` → spawn next unit's implementer
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)
347
+ 7. Check `user_approved` field in session.json to determine where to resume:
348
+ - If last unit has `user_approved: true` → spawn next unit's implementer
349
+ - If last unit has `user_approved: false` or missing → check session branch HEAD, present last commit to user for review
350
+ 8. Resume from the appropriate step (temp worktree creation, dispatch, or user review)
346
351
 
347
352
  ## Anti-patterns
348
353
 
@@ -36,23 +36,30 @@ 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 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.
39
+ 14. **NEVER skip micro-QA before committing** — after teammate finishes, verify diff --stat, check files match commit unit scope, confirm tests passed. Only then commit in the temp worktree. Skipping micro-QA means bad code gets committed to the session branch.
40
40
 
41
- 15. **NEVER prune worktrees during an active session** — worktrees persist until session close.
42
- The session-start-context.sh hook only cleans worktrees that are truly orphaned (no session JSON).
41
+ 15. **NEVER leave temp worktrees alive after committing** — destroy them immediately after commit.
42
+ Stale temp worktrees waste disk and can cause branch lock conflicts.
43
43
 
44
44
  16. **NEVER over-split commit units** — 10+ commit units per service is excessive.
45
45
  Sweet spot: 2-5 per repo. Each spawn has context loading overhead.
46
46
 
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.
47
+ 17. **NEVER spawn the next commit unit before user has approved the previous** — team lead must commit
48
+ in temp worktree, user must review via checkout and approve — only then spawn the next unit's implementer.
49
49
 
50
50
  18. **NEVER let implementer run git add or git commit** — the implementer writes code and runs tests.
51
- The team lead commits after user review. The PreToolUse hook blocks git add/commit as a safety net.
51
+ The team lead commits after micro-QA. The PreToolUse hook blocks git add/commit as a safety net.
52
52
 
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.
53
+ 19. **NEVER let a teammate work outside their temp worktree** — teammates always work in isolated temp
54
+ worktrees (/tmp/{repo}-commit-{N}). The session branch is the reference where commits accumulate.
55
+ Direct teammate access to the real repo risks corruption of committed work.
56
+
57
+ 20. **NEVER call Agent(subagent_type: "implementer") without team_name** — bare Agent calls
58
+ without team_name are invalid and will be denied. The Agent tool description omits this
59
+ requirement. If denied, do NOT debug — just follow the TeamCreate + Agent(team_name) pattern.
60
+
61
+ 21. **NEVER skip TeamCreate before spawning implementers** — `TeamCreate(team_name: "session-{name}")`
62
+ must be called once per session BEFORE any `Agent(subagent_type: "implementer", team_name: ...)`.
56
63
 
57
64
  ## Common mistakes to watch for
58
65
 
@@ -63,13 +70,13 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
63
70
  | Plan has vague tasks like "implement feature" | Each task should have a clear input→output | Rewrite plan with specific tasks before dispatch |
64
71
  | API contract has {} placeholder | Frontend can't build types | Complete the contract shapes before wave 2 |
65
72
  | Two teammates spawned on same repo | Git conflicts guaranteed | Kill one, let the remaining handle all commits |
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 | 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 |
73
+ | Implementer runs git add/commit | Code committed without micro-QA | PreToolUse hook should block it; if bypassed, revert with git update-ref |
74
+ | Next unit spawned before user approved previous | Commits pile up without review | Wait for user approval before spawning next unit |
75
+ | Temp worktree not cleaned up after commit | git worktree list shows stale entries | git -C ../{repo} worktree remove /tmp/{repo}-commit-{N} --force |
76
+ | Agent called with run_in_background for single-repo | Team lead sleeps, doesn't detect completion | Always use foreground (blocking) Agent calls for sequential dispatch |
71
77
  | No signal from teammate after implementation | Silent failure | Check worktree git status/diff, ask teammate to signal or escalate |
72
78
  | Worktree missing after crash | git worktree list shows nothing | Recreate worktree from session branch: git worktree add /tmp/... session/{name} |
79
+ | Agent called without team_name | Denied by system, wasted turns debugging | Use TeamCreate first, then Agent with team_name. See rule 20 above |
73
80
  | Giant commit (500+ lines) | Unreadable PR | Note in session log; teammate should split next time |
74
81
  | Commit unit not self-contained | Teammate can't understand scope | Rewrite: each unit must be understandable with only previous context |
75
82
  | cycle-retrospective skipped | Lessons not captured | Always run Phase 4 (post-impl) fully — retrospective is mandatory |
@@ -7,7 +7,7 @@ Reference file for team-lead and dispatch-feature. Loaded on-demand.
7
7
  If an implementer corrupts the session branch (bad merge, broken state):
8
8
 
9
9
  1. Identify the last known good commit hash (from plan's session log)
10
- 2. Spawn a Task subagent (Bash):
10
+ 2. Reset the session branch:
11
11
  ```
12
12
  git -C ../[repo] update-ref refs/heads/session/{name} [good-commit-hash]
13
13
  ```
@@ -24,27 +24,27 @@ If the branch is unrecoverable:
24
24
 
25
25
  Two cases depending on when the failure occurs:
26
26
 
27
- ### Before patch apply (failure in temp worktree)
27
+ ### Before commit (failure in temp worktree during implementation)
28
28
 
29
29
  If the teammate fails tests or produces bad code in the temp worktree:
30
30
 
31
- 1. Remove the temp worktree: `git worktree remove --force /tmp/{repo}-commit-{N}`
31
+ 1. Remove the temp worktree: `git -C ../{repo} worktree remove --force /tmp/{repo}-commit-{N}`
32
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}`
33
+ 3. Create a new temp worktree: `git -C ../{repo} worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
34
34
  4. Re-spawn implementer with corrected instructions in the new temp worktree
35
35
  5. If 2 retries fail → escalate to user
36
36
 
37
- ### After patch apply (user rejects changes in session worktree)
37
+ ### After commit (user rejects changes after reviewing via checkout)
38
38
 
39
- If the patch was applied to the session worktree but the user rejects it:
39
+ If the team lead committed in the temp worktree but the user rejects it after review:
40
40
 
41
- 1. Discard all uncommitted changes in the session worktree:
41
+ 1. Revert the commit on the session branch:
42
42
  ```bash
43
- git -C /tmp/{repo}-{session-name} checkout -- .
44
- git -C /tmp/{repo}-{session-name} clean -fd # remove untracked new files
43
+ PARENT=$(git -C ../{repo} rev-parse session/{name}~1)
44
+ git -C ../{repo} update-ref refs/heads/session/{name} $PARENT
45
45
  ```
46
46
  2. Mark the commit unit ❌ in the plan with reason
47
- 3. Create a new temp worktree: `git worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
47
+ 3. Create a new temp worktree: `git -C ../{repo} worktree add /tmp/{repo}-commit-{N}-retry session/{name}`
48
48
  4. Re-spawn implementer with corrected instructions (include user feedback)
49
49
  5. If 2 retries fail → escalate to user
50
50
 
@@ -10,6 +10,11 @@ Reference file for dispatch-feature and team-lead. Loaded on-demand.
10
10
  > below includes a "Constitution" section that you MUST fill with all rules from
11
11
  > your workspace's constitution.md.
12
12
 
13
+ > **PREREQUISITE**: Before using any template below, you MUST have already called
14
+ > `TeamCreate(team_name: "session-{name}")`. Every `Agent()` call that spawns an
15
+ > implementer MUST include `team_name: "session-{name}"`. Omitting `team_name`
16
+ > will cause a denial — do not attempt to debug, just add it.
17
+
13
18
  ## Context tiering — what to inject per repo type
14
19
 
15
20
  | Context | Backend repo | Frontend repo | Infra repo |
@@ -54,4 +54,7 @@ Constraint: Opus reads only files directly related to the feature scope.
54
54
 
55
55
  ## Implementer model
56
56
  Implementation teammates use **Sonnet** via Agent Teams (`TeamCreate` + `Agent(subagent_type: "implementer", team_name: ...)`).
57
+ **WARNING**: The Agent tool description does not mention `team_name`, but it is REQUIRED.
58
+ Bare `Agent(subagent_type: "implementer")` without `team_name` will be denied.
59
+ Always call `TeamCreate(team_name: "session-{name}")` first.
57
60
  One teammate per commit unit. Each implementer handles a single commit unit, writes code without committing, and signals when ready for review.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-workspace",
3
- "version": "5.3.0",
3
+ "version": "6.0.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"