@jaggerxtrm/specialists 3.4.4 → 3.5.1

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 (34) hide show
  1. package/README.md +1 -0
  2. package/config/hooks/specialists-session-start.mjs +13 -28
  3. package/config/presets.json +26 -0
  4. package/config/skills/specialists-creator/SKILL.md +323 -145
  5. package/config/skills/specialists-creator/scripts/scaffold-specialist.ts +228 -0
  6. package/config/skills/using-specialists/SKILL.md +641 -183
  7. package/config/specialists/debugger.specialist.json +74 -0
  8. package/config/specialists/executor.specialist.json +117 -0
  9. package/config/specialists/explorer.specialist.json +82 -0
  10. package/config/specialists/memory-processor.specialist.json +64 -0
  11. package/config/specialists/node-coordinator.specialist.json +315 -0
  12. package/config/specialists/overthinker.specialist.json +65 -0
  13. package/config/specialists/parallel-review.specialist.json +65 -0
  14. package/config/specialists/planner.specialist.json +93 -0
  15. package/config/specialists/researcher.specialist.json +64 -0
  16. package/config/specialists/reviewer.specialist.json +60 -0
  17. package/config/specialists/specialists-creator.specialist.json +68 -0
  18. package/config/specialists/sync-docs.specialist.json +80 -0
  19. package/config/specialists/test-runner.specialist.json +67 -0
  20. package/config/specialists/xt-merge.specialist.json +60 -0
  21. package/dist/index.js +9242 -2331
  22. package/package.json +5 -3
  23. package/config/specialists/debugger.specialist.yaml +0 -121
  24. package/config/specialists/executor.specialist.yaml +0 -257
  25. package/config/specialists/explorer.specialist.yaml +0 -85
  26. package/config/specialists/memory-processor.specialist.yaml +0 -154
  27. package/config/specialists/overthinker.specialist.yaml +0 -76
  28. package/config/specialists/parallel-review.specialist.yaml +0 -75
  29. package/config/specialists/planner.specialist.yaml +0 -94
  30. package/config/specialists/reviewer.specialist.yaml +0 -142
  31. package/config/specialists/specialists-creator.specialist.yaml +0 -90
  32. package/config/specialists/sync-docs.specialist.yaml +0 -68
  33. package/config/specialists/test-runner.specialist.yaml +0 -65
  34. package/config/specialists/xt-merge.specialist.yaml +0 -159
@@ -2,92 +2,449 @@
2
2
  name: using-specialists
3
3
  description: >
4
4
  Use this skill whenever you're about to start a substantial task — pause first and
5
- ask whether to delegate. Consult before any: code review, security audit, deep bug
6
- investigation, test generation, multi-file refactor, or architecture analysis. Also
7
- use for the mechanics of delegation: --bead workflow, --context-depth, background
8
- jobs, MCP tool (`use_specialist`), specialists init,
9
- or specialists doctor. Don't wait for the user to say "use a specialist" — proactively
10
- evaluate whether delegation makes sense.
11
- version: 3.6
5
+ route the work through specialists instead of doing discovery or implementation
6
+ yourself. Consult before any: code review, security audit, deep bug investigation,
7
+ test generation, multi-file refactor, architecture analysis, or multi-wave
8
+ specialist orchestration. Also use for the mechanics of delegation: --bead
9
+ workflow, --context-depth, background jobs, MCP tool (`use_specialist`),
10
+ or specialists doctor. Don't wait for the user to say
11
+ "use a specialist" — proactively evaluate whether delegation makes sense.
12
+ version: 4.2
12
13
  ---
13
14
 
14
15
  # Specialists Usage
15
16
 
16
- When this skill is loaded, you are a **coordinator first**: delegate substantial work to specialists, monitor progress, and synthesize outcomes for the user.
17
+ When this skill is loaded, you are an **orchestrator** think CEO or CTO. You set direction, route work, unblock specialists, and synthesize outcomes. You do not implement.
17
18
 
18
- Specialists are autonomous AI agents that run independently fresh context, different
19
- model, no prior bias. Delegate when a task would take you significant effort, spans
20
- multiple files, or benefits from a dedicated focused run.
19
+ Specialists handle **99% of tasks**. The only things you do yourself are things that are genuinely trivial (one-liner, quick config) or require a global overview only you can provide. Everything else goes to a specialist. When in doubt, delegate.
21
20
 
22
- The reason isn't just speedit's quality. A specialist has no competing context,
23
- leaves a tracked record via beads, and can run in the background while you stay unblocked.
21
+ Your job is routing, sequencing, monitoring, and synthesis not exploration or implementation. Do **ZERO implementation** yourself for substantial work: no file reads, no code writing, no docs, no self-investigation. If you catch yourself doing discovery, stop and dispatch explorer instead.
24
22
 
25
- ## The Delegation Decision
23
+ > **Sleep timers**: When you dispatch a specialist for a longer task, set a sleep timer and step back. Don't poll manually — set a timer appropriate to the expected run time, sleep, then check results. This lets you work independently and iterate without babysitting jobs.
26
24
 
27
- Before starting any substantial task, ask: is this worth delegating?
25
+ Specialists are autonomous AI agents that run independently — fresh context, different model, no prior bias. The reason isn't just speed — it's quality. A specialist has no competing context, leaves a tracked record via beads, and can run in the background while you stay unblocked.
28
26
 
29
- **Delegate when:**
30
- - It would take >5 minutes of focused work
31
- - It spans multiple files or modules
32
- - A fresh perspective adds value (code review, security audit)
33
- - It can run in the background while you do other things
34
- - You have multiple independent tasks — dispatch them as a wave
35
- - It's a review/analysis loop (audit → approve/deny → resume) that benefits from interactive keep-alive
27
+ > **Session start**: Run `sp --help` once to see the full command surface. `sp` is the short alias for `specialists` — `sp run`, `sp feed`, `sp resume` etc. all work. Also useful: `sp run --help`, `sp resume --help`, `sp feed --help` for flag details.
36
28
 
37
- **Do it yourself when:**
38
- - It's a single-file edit or quick config change
39
- - It needs interactive back-and-forth
40
- - It's obviously trivial (one-liner, formatting fix)
29
+ ---
30
+
31
+ ## Hard Rules
41
32
 
42
- When in doubt, delegate. Specialists run in parallel you don't have to wait.
33
+ 1. **Zero implementation by orchestrator.** When this skill is active for substantial work, you do not implement the solution yourself.
34
+ 2. **Never explore yourself.** All discovery, codebase mapping, and read-only investigation go through **explorer** (or **debugger** for root-cause analysis).
35
+ 3. **Run explorer before executor when context is lacking.** If the bead already has clear scope — files, symbols, approach — send executor directly. Only run explorer first when the issue lacks a clear track.
36
+ 4. **For tracked work, the bead is the prompt.** The bead description, notes, and parent context are the instruction surface.
37
+ 5. **`--bead` and `--prompt` are mutually exclusive.** If you need to refine instructions, update the bead notes; do not add `--prompt`.
38
+ 6. **Wave sequencing is strict.** Never start wave N+1 before wave N is complete AND merged. Within-wave parallelism is fine only for independent jobs.
39
+ 7. **Merge between waves is mandatory.** Executor worktree branches must be merged into master before the next wave starts. See "Merge Protocol" below.
40
+ 8. **No destructive operations by specialists.** No `rm -rf`, no force pushes, no database drops, no credential rotation, no mass deletes, no history rewrites. Surface destructive requirements to the user.
41
+ 9. **Executor does not run tests.** Executor runs lint + tsc only. Tests are the reviewer's and test-runner's responsibility in the chained pipeline.
43
42
 
44
43
  ---
45
44
 
46
- ## Canonical Workflow
45
+ ## When to Use This Skill
46
+
47
+ **Default: always delegate.** Specialists handle 99% of tasks. The orchestrator only acts directly for things that are genuinely trivial (one-liner, quick config tweak) or require a global overview that only you can provide.
48
+
49
+ **Do it yourself only when:**
50
+ - It's a one-liner or formatting fix
51
+ - It's a quick config change that needs no investigation
52
+ - It genuinely requires high-level synthesis only you can do (e.g. reading results across multiple jobs and forming a next-step decision)
47
53
 
48
- For tracked work, always use `--bead`. This gives the specialist your issue as context,
49
- links results back to the tracker, and creates an audit trail.
54
+ Everything else — investigation, implementation, review, testing, docs, planning, design goes to a specialist.
55
+
56
+ ---
57
+
58
+ ## Canonical Workflow
50
59
 
51
60
  ### CLI commands
52
61
 
53
62
  ```bash
54
- specialists init # first-time project setup
63
+ # Discovery
55
64
  specialists list # discover available specialists
65
+ specialists doctor # health check: hooks, MCP, zombie jobs
66
+
67
+ # Running
56
68
  specialists run <name> --bead <id> # foreground run (streams output)
69
+ specialists run <name> --bead <id> --background # background run
70
+ specialists run <name> --bead <id> --worktree # isolated worktree (edit-capable specialists)
71
+ specialists run <name> --bead <id> --job <job-id> # reuse another job's worktree
57
72
  specialists run <name> --prompt "..." # ad-hoc (no bead tracking)
58
- specialists feed -f # tail merged feed (all jobs)
73
+ specialists run <name> --bead <id> --keep-alive # keep session alive after first turn
74
+ specialists run <name> --bead <id> --context-depth 2 # inject parent bead context
75
+
76
+ # Monitoring
77
+ specialists ps # list all jobs (status, specialist, elapsed, bead)
78
+ specialists ps <job-id> # inspect single job (full detail + ctx% badge)
79
+ specialists feed -f # tail merged feed (all jobs) — shows [ctx%] context window usage
59
80
  specialists feed <job-id> # events for a specific job
60
81
  specialists result <job-id> # final output text
82
+ specialists status --job <job-id> # single-job detail view (legacy — prefer `sp ps <id>`)
83
+
84
+ # Interaction
61
85
  specialists steer <job-id> "new direction" # redirect ANY running job mid-run
62
86
  specialists resume <job-id> "next task" # resume a waiting keep-alive job
63
87
  specialists stop <job-id> # cancel a job
64
- specialists edit <name> # edit a specialist's YAML config
65
- specialists status --job <job-id> # single-job detail view
66
- specialists clean # purge old job directories
67
- specialists doctor # health check
88
+
89
+ # Management
90
+ specialists edit <name> # edit specialist config (dot-path, --preset)
91
+ specialists clean # purge old job dirs + worktree GC
92
+ specialists clean --processes # kill all running/starting specialist jobs
93
+ specialists init --sync-skills # re-sync skills only (no full init)
94
+ specialists init --no-xtrm-check # skip xtrm prerequisite check (CI/testing)
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Chained Bead Pipeline
100
+
101
+ This is the **standard for ALL tracked work**. Every specialist run gets its own child bead.
102
+ Each step's output accumulates on its bead. Downstream steps see upstream output automatically
103
+ via `--context-depth 2`. The bead chain IS the context chain — zero manual wiring needed.
104
+
68
105
  ```
106
+ task-abc: "Fix auth token refresh"
107
+ └── abc-exp: explorer (READ_ONLY — auto-appends output to abc-exp notes)
108
+ └── abc-impl: executor (self-appends output to abc-impl notes, closes bead)
109
+ └── abc-rev: reviewer (READ_ONLY — auto-appends verdict via --job <exec-job>)
110
+ └── abc-fix: executor (if reviewer PARTIAL — fix bead, same worktree via --job)
111
+ ```
112
+
113
+ **How context flows (`--context-depth 2` = own + parent + grandparent = 3 beads):**
114
+
115
+ | Step | Specialist sees | Via |
116
+ |------|----------------|-----|
117
+ | abc-exp | abc-exp (own) + task-abc (parent) | `--bead abc-exp --context-depth 2` |
118
+ | abc-impl | abc-impl (own) + abc-exp (explorer findings in notes) + task-abc | `--bead abc-impl --context-depth 2` |
119
+ | reviewer | abc-impl bead (with executor output + reviewer verdict in notes) | `--bead abc-impl --job <exec-job>` |
120
+ | abc-fix | abc-fix (own) + abc-impl (executor output + reviewer verdict) + abc-exp | `--bead abc-fix --job <exec-job> --context-depth 2` |
69
121
 
70
- ### Typical flow
122
+ - No copy-paste, no manual note injection between steps
123
+ - Every step has a full audit trail on its own bead
124
+ - The dep graph IS the context graph — self-documenting
125
+
126
+ ### Complete flow example
71
127
 
72
128
  ```bash
73
- # 1. Create a bead describing what you need
129
+ # 1. Create the task bead
74
130
  bd create --title "Fix auth token refresh bug" --type bug --priority 2
75
131
  # -> unitAI-abc
76
132
 
77
- # 2. Run the right specialist against the bead
78
- specialists run executor --bead unitAI-abc &
133
+ # 2. Create chained child beads (create all upfront for clarity)
134
+ bd create --title "Explore: map token refresh code paths" --type task --priority 2
135
+ # -> unitAI-abc-exp
136
+ bd dep add abc-exp abc
137
+
138
+ bd create --title "Implement: fix token refresh retry on 401" --type task --priority 2
139
+ # -> unitAI-abc-impl
140
+ bd dep add abc-impl abc-exp
141
+
142
+ # 3. Wave 1 — Explorer
143
+ specialists run explorer --bead abc-exp --context-depth 2 --background
144
+ # -> Job started: e1f2g3
145
+ # Explorer output auto-appends to abc-exp notes (READ_ONLY behavior)
146
+ specialists result e1f2g3
147
+
148
+ # 4. [MERGE] Merge any worktree branches from Wave 1 into master (see Merge Protocol)
149
+
150
+ # 5. Wave 2 — Executor
151
+ specialists run executor --worktree --bead abc-impl --context-depth 2 --background
79
152
  # -> Job started: a1b2c3
153
+ # Executor sees: abc-impl + abc-exp (with explorer notes) + abc via context-depth
154
+ # Executor self-appends output to abc-impl notes, closes abc-impl on completion
155
+
156
+ # 6. [MERGE] Merge abc-impl worktree branch into master
157
+
158
+ # 7. Wave 3 — Reviewer (no separate bead — uses --job + --prompt to enter executor's worktree)
159
+ specialists run reviewer --job a1b2c3 --keep-alive --background --prompt "Review the token refresh fix"
160
+ # -> Job started: r4v5w6
161
+ # Reviewer reads task bead from job a1b2c3's status.json automatically
162
+ # Reviewer auto-appends verdict to bead notes (READ_ONLY)
163
+ specialists result r4v5w6
164
+ # -> PASS: close task bead. PARTIAL/FAIL: go to step 8.
165
+
166
+ # 8. If PARTIAL — fix loop (same worktree, new child bead)
167
+ bd create --title "Fix: reviewer gaps on abc-impl" --type bug --priority 1
168
+ # -> unitAI-abc-fix
169
+ bd dep add abc-fix abc-impl
170
+
171
+ specialists run executor --bead abc-fix --job a1b2c3 --context-depth 2 --background
172
+ # Fixer runs in same worktree (via --job a1b2c3)
173
+ # Sees: abc-fix + abc-impl (executor output + reviewer verdict) + abc-exp via context-depth
174
+ # Repeat reviewer --job → fix loop until PASS
175
+
176
+ # 9. Close when reviewer says PASS
177
+ bd close abc --reason "Fixed: token refresh retries on 401. Reviewer PASS."
178
+ ```
179
+
180
+ **Why chaining matters:**
181
+ - Every step's output is preserved — full audit trail on each bead
182
+ - `--context-depth 2` gives each specialist the previous step's findings automatically
183
+ - No copy-pasting results between steps
184
+ - The orchestrator only creates beads and dispatches — zero context injection
185
+
186
+ ---
187
+
188
+ ## --job and --worktree Semantics
189
+
190
+ These flags control **workspace isolation**. Executors run in isolated git worktrees so
191
+ concurrent jobs don't corrupt shared files.
192
+
193
+ | Flag | Semantics | Creates worktree? |
194
+ |------|-----------|:-:|
195
+ | `--worktree` | Provision a new isolated workspace; requires `--bead` | Yes |
196
+ | `--job <id>` | Reuse the workspace of an existing job | No |
197
+
198
+ `--worktree` and `--job` are **mutually exclusive**. Specifying both exits with an error.
199
+
200
+ ### `--worktree`
201
+
202
+ Provisions a new git worktree + branch for the specialist run. Branch name is derived
203
+ deterministically from the bead id: `feature/<beadId>-<specialist-slug>`.
204
+
205
+ ```bash
206
+ specialists run executor --worktree --bead hgpu.3
207
+ # stderr: [worktree created: /repo/.worktrees/hgpu.3/hgpu.3-executor branch: feature/hgpu.3-executor]
208
+ ```
209
+
210
+ If the worktree already exists (interrupted run), it is **reused**, not recreated.
211
+
212
+ ### `--job <id>`
213
+
214
+ Reads `worktree_path` from the target job's `status.json` and uses that directory as `cwd`.
215
+ The caller's own `--bead` remains authoritative — `--job` only selects the workspace.
216
+
217
+ ```bash
218
+ # Reviewer enters executor's worktree to review exactly what was written
219
+ specialists run reviewer --job 49adda --keep-alive --background
220
+
221
+ # Fix executor re-enters same worktree (--bead provides new fix bead, --job provides workspace)
222
+ specialists run executor --bead hgpu.3-fix --job 49adda --context-depth 2 --background
223
+ ```
224
+
225
+ **Concurrency guard:**
226
+ - READ_ONLY specialists (explorer, reviewer): allowed while owning job is still running
227
+ - MEDIUM/HIGH permission specialists (executor): **blocked** until owning job reaches terminal state
228
+
229
+ ### When to use each flag
230
+
231
+ | Scenario | Flag to use |
232
+ |----------|------------|
233
+ | First executor run for a task | `--worktree --bead <impl-bead>` |
234
+ | Reviewer on executor's output | `--job <exec-job-id>` (no `--worktree`) |
235
+ | Fix executor after reviewer PARTIAL | `--bead <fix-bead> --job <exec-job-id>` |
236
+ | Explorer (READ_ONLY) | Neither — explorers don't need worktrees |
237
+ | Overthinker, planner, debugger | Neither — read-only and interactive specialists |
238
+
239
+ ---
240
+
241
+ ## Dependency Mapping
242
+
243
+ Map bead dependencies to match the execution pipeline. The dep graph IS the wave plan.
244
+
245
+ ### Simple bug fix
246
+ ```
247
+ task → explore → impl
248
+ └── reviewer via --job (no own bead needed)
249
+ └── fix (if PARTIAL) → child of impl
250
+ ```
251
+ ```bash
252
+ bd dep add explore task
253
+ bd dep add impl explore
254
+ # reviewer: specialists run reviewer --job <impl-job>
255
+ # fix: bd dep add fix impl
256
+ ```
257
+
258
+ ### Complex feature (overthinker)
259
+ ```
260
+ task → explore → design → impl → [reviewer via --job] → [fix if PARTIAL]
261
+ ```
262
+ ```bash
263
+ bd dep add explore task
264
+ bd dep add design explore
265
+ bd dep add impl design
266
+ # reviewer: specialists run reviewer --job <impl-job>
267
+ ```
268
+
269
+ ### Epic with N children
270
+ Each child gets its own explore → impl chain. Reviewer runs via `--job` per impl.
271
+ ```
272
+ epic
273
+ ├── child-1 → explore-1 → impl-1 (reviewer via --job impl-1-job)
274
+ ├── child-2 → explore-2 → impl-2 (reviewer via --job impl-2-job)
275
+ └── child-N → explore-N → impl-N (reviewer via --job impl-N-job)
276
+ ```
277
+ Children within the same wave can run **in parallel** if they own disjoint files.
278
+
279
+ ### Parallel beads (same wave)
280
+ Beads in the same wave share no intra-wave dependencies. They depend on the previous wave's
281
+ output (same parent), not on each other.
282
+ ```
283
+ # Wave 2 parallel executors (after shared Wave 1 explorer):
284
+ bd dep add impl-a explore # impl-a depends on explore, NOT on impl-b
285
+ bd dep add impl-b explore # impl-b depends on explore, NOT on impl-a
286
+ ```
287
+ Each runs in its own `--worktree`. Merge both branches before Wave 3.
288
+
289
+ ### Test beads (batched)
290
+ Tests are **batched** — one test bead covers all impls in a wave, not per-impl.
291
+ The test bead depends on **all** impl beads it covers.
292
+ ```
293
+ bd dep add tests impl-a
294
+ bd dep add tests impl-b
295
+ bd dep add tests impl-c
296
+ # specialists run test-runner --bead tests --context-depth 2
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Review and Fix Loop
80
302
 
81
- # 3. Monitor (pick one)
82
- specialists feed a1b2c3 # check events so far
83
- specialists feed -f # tail all active jobs
303
+ The review fix loop is the mechanism for iterative quality improvement within a single worktree.
304
+
305
+ ### Standard loop
306
+
307
+ ```
308
+ 1. Executor claims impl bead, provisions --worktree, implements, closes bead.
309
+ -> Job: exec-job
310
+
311
+ 2. Reviewer enters same worktree via --job exec-job.
312
+ -> Reads task bead from exec-job status.json automatically.
313
+ -> Auto-appends verdict (PASS/PARTIAL/FAIL) to bead notes.
314
+
315
+ 3a. PASS: orchestrator closes parent task bead.
316
+
317
+ 3b. PARTIAL/FAIL:
318
+ -> Create fix bead as child of impl bead.
319
+ -> Run executor --bead fix-bead --job exec-job --context-depth 2.
320
+ -> Fix executor sees: fix-bead + impl (with reviewer verdict) + explore.
321
+ -> Fix executor closes fix-bead on completion.
322
+ -> Return to step 2 (reviewer on same job).
323
+
324
+ 4. Repeat until PASS.
325
+ ```
326
+
327
+ ### Commands
328
+
329
+ ```bash
330
+ # Step 1 — Executor with worktree
331
+ specialists run executor --worktree --bead unitAI-impl --context-depth 2 --background
332
+ # -> Job started: exec-job (e.g. 49adda)
333
+
334
+ # Step 2 — Reviewer enters same worktree (--prompt required when no --bead)
335
+ specialists run reviewer --job 49adda --keep-alive --background --prompt "Review impl changes"
336
+ # -> Job started: rev-job
337
+ specialists result rev-job
338
+ # PARTIAL → go to step 3b
339
+
340
+ # Step 3b — Create fix bead + run fix executor in same worktree
341
+ bd create --title "Fix: address reviewer findings on impl" --type bug --priority 1
342
+ # -> unitAI-fix1
343
+ bd dep add fix1 impl
344
+ specialists run executor --bead fix1 --job 49adda --context-depth 2 --background
345
+
346
+ # Re-review
347
+ specialists run reviewer --job 49adda --keep-alive --background --prompt "Re-review after fix"
348
+ # PASS → close parent
349
+ bd close unitAI-task --reason "Reviewer PASS. All findings addressed."
350
+ ```
351
+
352
+ ### Key invariants
353
+ - Reviewer never re-opens the impl bead — it was closed by the executor. The reviewer's verdict lives on the bead notes as appended output.
354
+ - Each fix iteration creates a **new child bead** — never reopen or re-claim the completed impl bead.
355
+ - The fix executor inherits the full context chain: fix-bead + impl (executor output + reviewer findings) + explore, via `--context-depth 2`.
356
+ - Multiple reviewer → fix cycles are expected for complex changes. The worktree is stable across all cycles.
357
+
358
+ ---
359
+
360
+ ## Merge Protocol — Orchestrator Responsibility
361
+
362
+ The orchestrator owns merge timing. This is not optional — failing to merge at the right
363
+ time means downstream specialists branch from stale master and miss upstream code.
364
+
365
+ ### When to merge vs when NOT to merge
366
+
367
+ **Do NOT merge within a chain.** A chain is a sequence of specialists sharing one worktree:
368
+ executor → reviewer → fix → re-review. The worktree stays live throughout. No merge until
369
+ the reviewer says PASS.
84
370
 
85
- # 4. Read results and close
86
- specialists result a1b2c3
87
- bd close unitAI-abc --reason "Fixed: token refresh now retries on 401"
88
371
  ```
372
+ executor --worktree --bead impl ← creates worktree
373
+ reviewer --job <exec-job> ← enters same worktree (no merge)
374
+ executor --bead fix --job <exec-job> ← re-enters same worktree (no merge)
375
+ reviewer --job <exec-job> ← re-enters same worktree (no merge)
376
+ PASS → NOW merge the worktree branch into master
377
+ ```
378
+
379
+ **DO merge between waves.** When the next wave's beads depend on this wave's code existing
380
+ on master, you must merge first. The dep graph tells you: beads connected by `--job` are
381
+ one chain (same worktree, no merge). Beads connected by `bd dep add` across different
382
+ file scopes are separate waves (different worktrees, merge between them).
383
+
384
+ ### Planning context upfront
385
+
386
+ Before dispatching any wave, identify:
387
+ - **Chains** — beads that share a worktree via `--job` (executor → reviewer → fix → re-review)
388
+ - **Waves** — groups of independent chains that can run in parallel
389
+ - **Merge points** — between waves, after all chains in the wave reach PASS
390
+
391
+ The dep graph encodes this. If bead B depends on bead A and they touch different files,
392
+ they're separate waves with a merge point between them.
393
+
394
+ ### FIFO — dependency order
395
+
396
+ Merge in **dependency order** (first dep first), not completion order.
397
+ Parallel beads (disjoint files) can merge in any order within their wave.
398
+
399
+ ```bash
400
+ # After Wave N — all beads closed, all jobs terminal:
401
+
402
+ # 1. Move to main checkout
403
+ cd /path/to/main/repo
404
+
405
+ # 2. Merge in dependency order
406
+ git merge feature/bead-a-executor # first dep in chain
407
+ npm run lint && npx tsc --noEmit # verify after each merge
408
+ git merge feature/bead-b-executor # second dep (parallel, disjoint files)
409
+ npm run lint && npx tsc --noEmit
410
+
411
+ # 3. Resolve conflicts if any
412
+ # Expected conflict: parallel executors creating the same utility file
413
+ # (e.g. job-root.ts created by two parallel beads)
414
+ # → Keep the version from the earlier dep, discard the duplicate
415
+ # → Re-run lint + tsc after resolution
416
+
417
+ # 4. Rebuild dist if project uses a bundled output
418
+ npm run build
419
+
420
+ # 5. Start Wave N+1
421
+ ```
422
+
423
+ **Why FIFO matters:**
424
+ - Bead A blocks bead B → A's code must land in master before B's worktree branches from it
425
+ - Merging B before A: broken imports, missing symbols, silent type errors
426
+ - Parallel beads (disjoint files): order doesn't matter within the wave, but ALL must merge before the next wave
427
+
428
+ **Common conflict pattern:** Parallel executors in the same wave may both create the same
429
+ utility file (e.g. `job-root.ts`). This is expected — implementations should be identical.
430
+ Keep one, delete the duplicate during conflict resolution.
431
+
432
+ **File overlap conflict:** If two parallel executors modify the **same file** (e.g. both touch
433
+ `init.ts`), their worktree branches will conflict on merge. Either sequence them as separate
434
+ waves, or accept manual conflict resolution. When resolving: copy the incoming version from
435
+ the worktree (`cat /path/to/.worktrees/.../file > main/file`), then re-apply missing changes
436
+ from the other branch. **Always verify your cwd is the main repo** — shell state can drift
437
+ into a worktree directory after merge operations.
438
+
439
+ ---
440
+
441
+ ## Bead-First Workflow (`--bead` is the prompt)
89
442
 
90
- ### Giving specialists extra context via bead notes
443
+ For tracked work, the bead is not just bookkeeping — it is the specialist's prompt.
444
+ The specialist reads:
445
+ - the bead title + description
446
+ - bead notes (including output appended by previous specialists in the chain)
447
+ - parent/ancestor bead context (controlled by `--context-depth`)
91
448
 
92
449
  `--prompt` and `--bead` cannot be combined. When you need to give a specialist
93
450
  specific instructions beyond what's in the bead description, update the bead notes first:
@@ -96,13 +453,13 @@ specific instructions beyond what's in the bead description, update the bead not
96
453
  bd update unitAI-abc --notes "INSTRUCTION: Rewrite docs/cli-reference.md from current
97
454
  source. Read every command in src/cli/ and src/index.ts. Document all flags and examples."
98
455
 
99
- specialists run executor --bead unitAI-abc &
456
+ specialists run executor --bead unitAI-abc --context-depth 2 --background
100
457
  ```
101
458
 
102
- This pattern was used extensively in Wave 5 of a real session — 4 executors all received
103
- writing instructions via bead notes and successfully produced doc files.
104
-
105
459
  **`--context-depth N`** — how many levels of parent-bead context to inject (default: 1).
460
+ Use **`--context-depth 2`** for all chained bead workflows. This gives each specialist its
461
+ own bead + the immediate predecessor's output + one more level of context.
462
+
106
463
  **`--no-beads`** — skip creating an auto-tracking sub-bead, but still reads the `--bead` input.
107
464
 
108
465
  ---
@@ -113,37 +470,109 @@ Run `specialists list` to see what's available. Match by task type:
113
470
 
114
471
  | Task type | Best specialist | Why |
115
472
  |-----------|----------------|-----|
116
- | Bug fix / implementation | **executor** (gpt-5.3-codex) | HIGH perms, writes code + tests autonomously |
117
- | Bug investigation / "why is X broken" | **debugger** (claude-sonnet-4-6) | GitNexus-first triage, 5-phase investigation, hypothesis ranking, evidence-backed remediation. Use for ANY root cause analysis. |
118
- | Design decisions / tradeoffs | **overthinker** (gpt-5.4) | 4-phase reasoning: analysis, devil's advocate, synthesis, conclusion. Interactive by default (`execution.interactive: true`). |
119
- | Code review / compliance | **reviewer** (claude-sonnet-4-6) | Post-run compliance checks, verdict contract (PASS/PARTIAL/FAIL). Interactive by default (`execution.interactive: true`). |
120
- | Multi-backend review | **parallel-review** (claude-sonnet-4-6) | Concurrent review across multiple AI backends |
121
- | Architecture exploration | **explorer** (claude-haiku-4-5) | Fast codebase mapping, READ_ONLY |
122
- | Reference docs / dense schemas | **explorer** (claude-haiku-4-5) | Better than sync-docs for reference-heavy output |
123
- | Planning / scoping | **planner** (claude-sonnet-4-6) | Structured issue breakdown with deps |
124
- | Doc audit / drift detection | **sync-docs** (claude-sonnet-4-6) | Interactive by default (`execution.interactive: true`): audits first, then approve/deny via `resume` |
125
- | Doc drift / audit | **sync-docs** (claude-sonnet-4-6) | Detects stale docs, restructures content |
126
- | Doc writing / updates | **executor** (gpt-5.3-codex) | sync-docs defaults to audit mode; executor writes files |
127
- | Test generation | **test-runner** (claude-haiku-4-5) | Runs suites, interprets failures |
128
- | Specialist authoring | **specialists-creator** (claude-sonnet-4-6) | Guides YAML creation against schema |
129
-
130
- ### Specialist selection lessons (from real sessions)
131
-
132
- - **debugger** is the most powerful investigation specialist. Uses GitNexus call-chain tracing (when available) for 5-phase root cause analysis with ranked hypotheses. Use for ANY "why is X broken" question don't do the investigation yourself.
133
- - **sync-docs** is an interactive specialist it audits first, then waits for approval before executing. This is correct behavior, not a bug.
134
- - **overthinker** and **reviewer** are also interactive.
135
- - Canonical pattern: orchestration is CLI-first (`specialists run/feed/result/steer/resume/stop`); use MCP only for one-shot `use_specialist` runs.
136
- - Use `--no-keep-alive` only when you explicitly want a one-shot run.
137
- - **explorer** is fast and cheap (Haiku) but READ_ONLY output auto-appends to the input bead's notes. Use for investigation, not implementation.
138
- - **executor** is the workhorse HIGH permissions, writes code and docs, runs tests, closes beads. Best for any task that needs files written.
139
- - **use_specialist MCP** is best for quick foreground runs where you need the result immediately in your context.
140
-
141
- ### Pi extensions availability (known gap)
142
-
143
- GitNexus and Serena are **pi extensions** (not MCP servers) at `~/.pi/agent/extensions/`.
144
- Specialists run with `--no-extensions` and only selectively re-enable `quality-gates` and
145
- `service-skills`. GitNexus (call-chain tracing for debugger/planner) and Serena LSP
146
- (token-efficient reads for explorer/executor) are NOT currently wired. Tracked as `unitAI-4abv`.
473
+ | Architecture exploration / initial discovery | **explorer** (claude-haiku) | Fast codebase mapping, READ_ONLY. Output auto-appends to bead. |
474
+ | Live docs / library lookup / code discovery | **researcher** (claude-haiku) | Targeted (ctx7/deepwiki) or discovery (ghgrep deepwiki) modes. `--keep-alive`. |
475
+ | Bug fix / feature implementation | **executor** (gpt-codex) | HIGH perms, writes code, runs lint+tsc, closes beads. `interactive: true` by default — enters `waiting` after first turn, orchestrator must stop explicitly. |
476
+ | Bug investigation / "why is X broken" | **debugger** (claude-sonnet) | 4-phase debug-fix-verify cycle. HIGH perms, keep-alive. GitNexus-first. |
477
+ | Complex design / tradeoff analysis | **overthinker** (gpt-4) | 4-phase: analysis devil's advocate synthesis → conclusion. `--keep-alive`. |
478
+ | Code review / compliance | **reviewer** (claude-sonnet) | PASS/PARTIAL/FAIL verdict. Use via `--job <exec-job>`. `--keep-alive`. |
479
+ | Multi-backend review | **parallel-review** (claude-sonnet) | Concurrent review across multiple backends |
480
+ | Planning / scoping | **planner** (claude-sonnet) | Structured issue breakdown with deps |
481
+ | Doc audit / drift detection / targeted sync | **sync-docs** (qwen3.5-plus) | 3-mode: targeted (named docs), area (time-window), full audit. MEDIUM perms, `--keep-alive`. |
482
+ | Doc writing / updates | **executor** (gpt-codex) | For heavy doc rewrites; sync-docs handles targeted updates directly |
483
+ | Test generation / suite execution | **test-runner** (claude-haiku) | Runs suites, interprets failures |
484
+ | Specialist authoring | **specialists-creator** (claude-sonnet) | Guides JSON creation against schema |
485
+
486
+ ### Specialist selection notes
487
+
488
+ - **executor does not run tests** — it runs `lint + tsc` only. Tests belong to the reviewer or test-runner phase.
489
+ - **executor enters `waiting` after first turn** `interactive: true` is now default. If executor bails early (e.g. GitNexus CRITICAL risk warning), orchestrator can `resume` with "proceed, this is additive" instead of re-dispatching. Always `stop` executor explicitly when work is complete.
490
+ - **explorer** is READ_ONLYits output auto-appends to the input bead's notes. No implementation.
491
+ - **reviewer** is best dispatched via `--job <exec-job> --prompt "..."` — it enters the same worktree to see exactly what was written. `--job` alone is not enough; `--prompt` or `--bead` is always required.
492
+ - **debugger** over **explorer** when you need root cause analysis GitNexus call-chain tracing, ranked hypotheses, evidence-backed remediation.
493
+ - **overthinker** before **executor** for any non-trivial task surfaces edge cases, challenges assumptions, produces solution direction. Cheap relative to wrong implementation.
494
+ - **researcher** is the docs specialistnever look up library docs yourself, delegate to researcher.
495
+ - **sync-docs** is interactivealways `--keep-alive`, use `resume` to approve/deny after audit.
496
+
497
+ ### Example dispatches
498
+
499
+ ```bash
500
+ specialists run explorer --bead unitAI-exp --context-depth 2 --background
501
+ specialists run researcher --bead unitAI-research --context-depth 2 --keep-alive --background
502
+ specialists run debugger --bead unitAI-bug --context-depth 2 --background
503
+ specialists run planner --bead unitAI-scope --context-depth 2 --background
504
+ specialists run overthinker --bead unitAI-design --context-depth 2 --keep-alive --background
505
+ specialists run executor --worktree --bead unitAI-impl --context-depth 2 --background
506
+ specialists run reviewer --job <exec-job-id> --keep-alive --background --prompt "Review the <feature> implementation"
507
+ specialists run sync-docs --bead unitAI-docs --context-depth 2 --keep-alive --background
508
+ specialists run test-runner --bead unitAI-tests --context-depth 2 --background
509
+ specialists run specialists-creator --bead unitAI-skill --context-depth 2 --background
510
+ ```
511
+
512
+ ### Overthinker-first pattern for complex tasks
513
+
514
+ ```bash
515
+ # Full chain: task → explore → design → impl
516
+ bd create --title "Redesign auth middleware" --type feature --priority 2 # -> unitAI-task
517
+ bd create --title "Explore: map auth middleware" --type task --priority 2 # -> unitAI-exp
518
+ bd dep add exp task
519
+ bd create --title "Design: auth middleware approach" --type task --priority 2 # -> unitAI-design
520
+ bd dep add design exp
521
+ bd create --title "Implement: auth middleware redesign" --type task --priority 2 # -> unitAI-impl
522
+ bd dep add impl design
523
+
524
+ # Wave 1: Explorer
525
+ specialists run explorer --bead unitAI-exp --context-depth 2 --background
526
+ # (output auto-appends to exp notes)
527
+
528
+ # Wave 2: Overthinker (sees exp findings via context-depth)
529
+ specialists run overthinker --bead unitAI-design --context-depth 2 --keep-alive --background
530
+ # enters waiting after Phase 4
531
+
532
+ specialists resume <job-id> "What about the edge case where X?"
533
+ specialists resume <job-id> "Is option B safer than option A here?"
534
+ specialists stop <job-id> # when satisfied
535
+ # (overthinker output is on unitAI-design notes)
536
+
537
+ # Wave 3: Executor (sees design + exp + task via context-depth — no manual wiring)
538
+ specialists run executor --worktree --bead unitAI-impl --context-depth 2 --background
539
+ ```
540
+
541
+ ### Monitoring with `sp ps`
542
+
543
+ Use `specialists ps` (alias `sp ps`) for job monitoring instead of manual JSON polling:
544
+
545
+ ```bash
546
+ # Quick overview — all jobs
547
+ specialists ps
548
+ # Output: ID, status, specialist, elapsed, bead, [ctx%] badge
549
+
550
+ # Inspect specific job
551
+ specialists ps <job-id>
552
+ # Shows: full status, worktree path, chain, ctx% (context window utilization)
553
+
554
+ # The ctx% in `sp feed` and `sp ps` shows context window utilization:
555
+ # - 0-40% = OK (plenty of room)
556
+ # - 40-65% = MONITOR
557
+ # - 65-80% = WARN (▲ indicator shown)
558
+ # - >80% = CRITICAL (▲ indicator shown)
559
+ ```
560
+
561
+ ---
562
+
563
+ ### Pi extensions and packages
564
+
565
+ Pi extensions are global at `~/.pi/agent/extensions/`. Pi packages are global npm installs.
566
+ Specialists run with `--no-extensions` and selectively re-enable:
567
+
568
+ - `quality-gates` — lint/typecheck enforcement (non-READ_ONLY only)
569
+ - `service-skills` — service catalog activation
570
+ - `pi-gitnexus` — call-chain tracing, blast radius analysis (resolved from global npm)
571
+ - `pi-serena-tools` — token-efficient LSP reads/edits (resolved from global npm)
572
+
573
+ When gitnexus tools are used during a run, the supervisor accumulates a `gitnexus_summary`
574
+ in the `run_complete` event: `files_touched`, `symbols_analyzed`, `highest_risk`,
575
+ `tool_invocations`.
147
576
 
148
577
  ---
149
578
 
@@ -152,178 +581,207 @@ Specialists run with `--no-extensions` and only selectively re-enable `quality-g
152
581
  ### Steer — redirect any running job
153
582
 
154
583
  `steer` sends a message to a running specialist. Delivered after the current tool call
155
- finishes, before the next LLM call. Works for **all running jobs**.
584
+ finishes, before the next LLM call.
156
585
 
157
586
  ```bash
158
- # Specialist is going off track — redirect it
159
587
  specialists steer a1b2c3 "STOP what you are doing. Focus only on supervisor.ts"
160
-
161
- # Specialist is auditing when it should be writing
162
588
  specialists steer a1b2c3 "Do NOT audit. Write the actual file to disk now."
163
589
  ```
164
590
 
165
- Real example from today: an explorer was reading every file in src/cli/ when we only needed
166
- confirmation that steering worked. Sent `specialists steer 763ff4 "STOP. Just output:
167
- STEERING WORKS"` — message delivered, output confirmed in 2 seconds.
591
+ ### Resume continue a keep-alive session
168
592
 
169
- ### Resume continue an interactive session
593
+ `resume` sends a new prompt to a specialist in `waiting` state. Retains full conversation history.
170
594
 
171
- `resume` sends a new prompt to a specialist that has finished its turn and is `waiting`.
172
- Works for jobs started with keep-alive behavior (including specialists with `execution.interactive: true`).
173
- The session retains full conversation history.
595
+ **Specialists that always use `--keep-alive`:**
174
596
 
175
- ```bash
176
- # Start an overthinker for multi-turn design work
177
- # overthinker is interactive by default, so no extra flag is required
178
- specialists run overthinker --bead unitAI-xyz &
179
- # -> Job started: d4e5f6 (completes Phase 4, enters waiting state)
597
+ | Specialist | Enters `waiting` after | What to send via `resume` |
598
+ |-----------|----------------------|--------------------------|
599
+ | **executor** | First turn completion (may be partial if bailed early) | "proceed, this is additive", "address the risk warning and continue", or "done, close bead" |
600
+ | **researcher** | Delivering research findings | Follow-up question, new angle, or "done, thanks" |
601
+ | **reviewer** | Delivering verdict (PASS/PARTIAL/FAIL) | Your response, clarification, or "accepted, close out" |
602
+ | **overthinker** | Phase 4 conclusion | Follow-up question, counter-argument, or "done, thanks" |
603
+ | **debugger** | Phase 3 fix attempt or Phase 4 verify result | Follow-up fix, "try different approach", or "done" |
604
+ | **sync-docs** | Audit report or targeted update result | "approve", "deny", or specific instructions |
180
605
 
181
- # Read the design output
182
- specialists result d4e5f6
606
+ > **Warning:** A job in `waiting` looks identical to a stalled job. **Always check with `sp ps`
607
+ > before killing a keep-alive job.**
183
608
 
184
- # Ask follow-up questions
185
- specialists resume d4e5f6 "What about backward compatibility with existing YAML files?"
186
- specialists resume d4e5f6 "How would you handle migration from the old schema?"
187
- ```
609
+ ```bash
610
+ # Check before stopping
611
+ specialists ps d4e5f6
612
+ # -> status: waiting ← healthy, expecting input
188
613
 
189
- Use interactive specialists when you plan to iterate: design reviews, multi-phase analysis,
190
- investigation that may need follow-up questions based on findings.
191
- Use `--no-keep-alive` only when you want to force single-turn behavior.
614
+ specialists resume d4e5f6 "What about backward compatibility?"
615
+ specialists stop d4e5f6 # only when truly done iterating
616
+ ```
192
617
 
193
618
  ---
194
619
 
195
620
  ## Wave Orchestration
196
621
 
197
- For multiple independent tasks, dispatch specialists in parallel waves.
622
+ For multi-step work, dispatch specialists in **waves**.
198
623
 
199
- ### Planning a wave
624
+ A **wave** is a set of specialist jobs that may run in parallel **only if they are independent**.
625
+ Waves are strictly sequential: **never start wave N+1 before wave N completes AND is merged**.
200
626
 
201
- Group tasks by dependency:
202
- 1. **Wave 1**: Bug fixes and blockers (unblock downstream work)
203
- 2. **Wave 2**: Features and design (now that the surface is stable)
204
- 3. **Wave 3**: Documentation (after code changes land — use executors, not sync-docs)
627
+ ### Wave rules
205
628
 
206
- ### Dispatching a wave
629
+ 1. **Sequence between waves.** Exploration → implementation → review → doc sync.
630
+ 2. **Parallelize only within a wave.** Jobs that don't depend on each other may run together.
631
+ 3. **Do not overlap waves.** Wait for every job, read results, update beads, merge.
632
+ 4. **Bead deps encode the pipeline.** The dependency graph should match wave order.
633
+ 5. **`--context-depth 2` for all chained runs.** Each specialist sees parent + predecessor.
634
+ 6. **Merge between waves is mandatory.** See Merge Protocol above.
635
+
636
+ ### Polling a wave
207
637
 
208
638
  ```bash
209
- # Fire multiple specialists in parallel (--background for reliable detach)
210
- specialists run executor --bead unitAI-abc --background
211
- specialists run executor --bead unitAI-def --background
212
- specialists run overthinker --bead unitAI-ghi --background
639
+ specialists ps # list all jobs shows status, specialist, elapsed, bead
640
+ specialists ps abc123 # inspect specific job (full detail)
641
+ specialists ps abc123 def456 ghi789 # inspect multiple jobs
213
642
  ```
214
643
 
215
- ### Monitoring a wave
644
+ A wave is complete when every job is `completed` or `error` AND you have:
645
+ 1. Read results: `specialists result <job-id>` for each
646
+ 2. Updated/closed beads as needed
647
+ 3. Merged all worktree branches into master
216
648
 
217
- ```bash
218
- # Quick status check on all jobs
219
- for job in abc123 def456 ghi789; do
220
- python3 -c "import json; d=json.load(open('.specialists/jobs/$job/status.json')); \
221
- print(f'$job {d[\"specialist\"]:12} {d[\"status\"]:10} {d.get(\"elapsed_s\",\"?\")}s')"
222
- done
649
+ ### Canonical multi-wave example
223
650
 
224
- # Or use feed for event-level detail
225
- specialists feed <job-id>
651
+ ```bash
652
+ # 0. Parent bead
653
+ bd create --title "Add worktree isolation to executor" --type feature --priority 1
654
+ # -> unitAI-root
655
+
656
+ # 1. Chained child beads
657
+ bd create --title "Explore: map job run architecture" --type task --priority 2 # -> unitAI-exp
658
+ bd dep add exp root
659
+ bd create --title "Implement: worktree isolation" --type task --priority 2 # -> unitAI-impl
660
+ bd dep add impl exp
661
+ # Note: reviewer runs via --job, test-runner gets its own bead
662
+
663
+ # Wave 1 — Explorer
664
+ specialists run explorer --bead unitAI-exp --context-depth 2 --background
665
+ # -> Job started: job1
666
+ specialists result job1
667
+
668
+ # [MERGE] Nothing to merge from READ_ONLY wave
669
+
670
+ # Wave 2 — Executor
671
+ specialists run executor --worktree --bead unitAI-impl --context-depth 2 --background
672
+ # -> Job started: job2 (worktree: .worktrees/unitAI-impl/unitAI-impl-executor)
673
+ specialists result job2
674
+
675
+ # [MERGE] Merge worktree branch into master (FIFO)
676
+ git merge feature/unitAI-impl-executor
677
+ npm run lint && npx tsc --noEmit && npm run build
678
+
679
+ # Wave 3 — Reviewer (no bead, uses --job)
680
+ specialists run reviewer --job job2 --keep-alive --background
681
+ # -> Job started: job3
682
+ specialists result job3
683
+ # PASS → Wave 4. PARTIAL → fix loop.
684
+
685
+ # Wave 4 — Tests (if needed)
686
+ bd create --title "Test: worktree isolation" --type task --priority 2 # -> unitAI-tests
687
+ bd dep add tests impl
688
+ specialists run test-runner --bead unitAI-tests --context-depth 2 --background
689
+
690
+ # Close
691
+ bd close root --reason "Worktree isolation implemented. Reviewer PASS. Tests green."
226
692
  ```
227
693
 
228
- ### Between waves
229
-
230
- After each wave completes:
231
- 1. **Read results**: `specialists result <job-id>` for each
232
- 2. **Validate**: run lint + tests on the combined output
233
- 3. **Commit**: stage, commit, push — clean git before next wave
234
- 4. **Close beads**: `bd close <id> --reason "..."`
235
-
236
- ### Real wave example (from a 6-wave session)
694
+ ### Within-wave parallelism
237
695
 
238
- ```
239
- Wave 1: 2x executor stabilized background job execution and supervisor lifecycle
240
- Wave 2: overthinker + 2x executor output contract design + retry logic + footer fix
241
- Wave 3: 4x sync-docs + 3x explorer docs audit (produced reports, not files)
242
- Wave 4: 5x executor + 2x explorer → output contract impl + READ_ONLY auto-append + 4 fixes
243
- Wave 5: 4x executor rewrote 4 doc files (executors write files, sync-docs only audits)
244
- Wave 6: 4x executor + overthinker (interactive) → cleanup + manifest design with follow-ups
696
+ ```bash
697
+ # Parallel executors disjoint files, same parent explorer
698
+ specialists run executor --worktree --bead unitAI-impl-a --context-depth 2 --background
699
+ specialists run executor --worktree --bead unitAI-impl-b --context-depth 2 --background
700
+ # Each runs in its own worktree.
701
+ # Do NOT start next wave until BOTH complete AND BOTH are merged.
245
702
  ```
246
703
 
247
- Key insight: **executors write files, sync-docs audits**. When you need docs written
248
- to disk, use executor with bead notes containing "INSTRUCTION: Write <file>...".
249
-
250
704
  ---
251
705
 
252
706
  ## Coordinator Responsibilities
253
707
 
254
- As the orchestrator, you own things specialists cannot do:
708
+ ### 1. Route work don't explore or implement yourself
709
+ Discovery goes to **explorer** first; implementation goes to **executor** only after discovery is done.
255
710
 
256
- ### 1. Validate combined output across specialists
257
- Multiple specialists writing to the same worktree can conflict. After each wave:
711
+ ### 2. Validate combined output after each wave
258
712
  ```bash
259
- npm run lint # or project-specific quality gate
260
- bun test # run affected tests
713
+ npm run lint # project quality gate
714
+ npx tsc --noEmit # type check
261
715
  git diff --stat # review what changed
262
716
  ```
263
717
 
264
- ### 2. Handle failures — don't silently fall back
265
- If a specialist stalls or errors, surface it. Don't quietly do the work yourself.
718
+ ### 3. Handle failures — don't silently fall back
266
719
  ```bash
267
720
  specialists feed <job-id> # see what happened
268
721
  specialists doctor # check for systemic issues
269
722
  ```
270
723
 
271
724
  Options when a specialist fails:
272
- - **Steer** it back on track: `specialists steer <id> "Focus on X instead"`
273
- - **Switch specialist** (e.g., sync-docs stalls → try explorer or executor)
725
+ - **Steer**: `specialists steer <id> "Focus on X instead"`
726
+ - **Switch**: e.g. sync-docs stalls → try executor
274
727
  - **Stop and report** to the user before doing it yourself
275
728
 
276
- ### 3. Close beads and commit between waves
277
- Keep git clean between waves. Specialists write to the same worktree, so stacking
278
- uncommitted changes from multiple waves creates merge pain.
729
+ ### 4. Merge between waves (CRITICAL)
730
+ See Merge Protocol above. No exceptions.
279
731
 
280
- ### 4. Run drift detection after doc-heavy sessions
732
+ ### 5. Run drift detection after doc-heavy sessions
281
733
  ```bash
282
- python3 .agents/skills/sync-docs/scripts/drift_detector.py scan --json
283
- # Then dispatch executor for any stale docs, stamp synced_at on fresh ones:
284
- python3 .agents/skills/sync-docs/scripts/drift_detector.py update-sync <file>
734
+ python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --json
735
+ python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py update-sync <file>
285
736
  ```
286
737
 
287
738
  ---
288
739
 
289
740
  ## MCP Tools (Claude Code)
290
741
 
291
- Available after `specialists init` and session restart.
292
-
293
742
  | Tool | Purpose |
294
743
  |------|---------|
295
- | `use_specialist` | Foreground run; pass `bead_id` for tracked work and get final output directly in conversation context |
744
+ | `use_specialist` | Foreground run; pass `bead_id` for tracked work, get final output in conversation context |
296
745
 
297
- MCP is intentionally minimal. Use CLI commands for orchestration, monitoring, steering,
298
- resume, and cancellation.
299
- If you encounter legacy `start_specialist`, treat it as deprecated and migrate to
300
- `specialists run <name> --prompt "..." --background`.
301
-
302
- ---
746
+ MCP is intentionally minimal. Use CLI for orchestration, monitoring, steering, resume, and cancellation.
303
747
 
304
748
  ---
305
749
 
306
750
  ## Known Issues
307
751
 
308
- - **sync-docs audit-first behavior is expected** for interactive review/audit flow.
309
- Start normally, read the audit output, then `specialists resume <job-id> "approved: execute phase 4-5"`
310
- if you want it to apply fixes.
311
- - **READ_ONLY output auto-appends** to the input bead after completion. No manual piping
312
- needed (fixed in the Supervisor). But the output also lives in `specialists result`.
752
+ - **READ_ONLY output auto-appends** to the input bead after completion (via Supervisor). Output also available via `specialists result`.
753
+ - **`--bead` and `--prompt` conflict** by design. For tracked work, update bead notes: `bd update <id> --notes "INSTRUCTION: ..."` then `--bead` only.
754
+ - **Job in `waiting` now shows magenta status** with resume hint in `status`, WAIT banner in `feed`, and resume footer in `result`. Always check before stopping a keep-alive job.
755
+ - **Explorer (qwen) may produce empty output** the model sometimes completes tool calls but fails to emit a final text summary. The bead notes will be empty. If this happens, either re-run with a different model or do the investigation yourself.
756
+ - **`specialists init` requires xtrm** `.xtrm/` directory and `xt` CLI must exist. Use `--no-xtrm-check` to bypass in CI/testing.
757
+ - **`specialists doctor` now detects skill drift** — compares `config/skills/` hashes against `.xtrm/skills/default/` and validates symlink chains.
313
758
 
314
759
  ---
315
760
 
316
- ## Setup and Troubleshooting
761
+ ## Troubleshooting
317
762
 
318
763
  ```bash
319
- specialists init # first-time setup: creates .specialists/, wires AGENTS.md/CLAUDE.md
320
- specialists doctor # health check: hooks, MCP, zombie jobs
321
- specialists edit <name> # edit a specialist's YAML config
764
+ specialists doctor # health check: hooks, MCP, zombie jobs, skill drift detection
765
+ specialists edit <name> # edit specialist config (dot-path, --preset)
766
+ specialists clean --processes # kill stale/zombie specialist processes
322
767
  ```
323
768
 
769
+ - **RPC timeout on worktree job start** (30s, `command id=1`) → pi runs `npm install` in fresh
770
+ worktrees if `.pi/settings.json` lists local packages. Root cause: worktree gets a stale copy
771
+ of `.pi/settings.json` from the branch point. Fix: ensure `.pi/settings.json` has
772
+ `"packages": []` (packages are global now). `provisionWorktree()` also symlinks
773
+ `.pi/npm/node_modules` to the main repo's as a safety net.
774
+ - **RPC timeout on non-worktree job** → check for: (1) zombie vitest/tinypool processes
775
+ (`ps aux | grep vitest`, then `kill`), (2) stale dist (`npm run build`),
776
+ (3) model provider issues (try a different model to isolate).
324
777
  - **"specialist not found"** → `specialists list` (project-scope only)
325
778
  - **Job hangs** → `specialists steer <id> "finish up"` or `specialists stop <id>`
326
- - **MCP tools missing** → `specialists init` then restart Claude Code
327
- - **YAML skipped** → stderr shows `[specialists] skipping <file>: <reason>`
328
- - **Stall timeout** → specialist hit 120s inactivity. Check `specialists feed <id>`, then retry or switch specialist.
779
+ - **Config skipped** → stderr shows `[specialists] skipping <file>: <reason>`
780
+ - **Stall timeout** → specialist hit 120s inactivity. Check `specialists feed <id>`, then retry or switch.
329
781
  - **`--prompt` and `--bead` conflict** → use bead notes: `bd update <id> --notes "INSTRUCTION: ..."` then `--bead` only.
782
+ - **Worktree already exists** → it will be reused (not recreated). Safe to re-run.
783
+ - **`--job` fails: worktree_path missing** → target job was not started with `--worktree`. Use `--worktree` on the next run.
784
+ - **`--job` without `--prompt` or `--bead`** → reviewer/executor requires one of these. Use `--prompt "Review the X implementation"` with `--job`.
785
+ - **Stale specialist processes** → SessionStart hook warns about old binary versions. Run `specialists clean --processes` to kill them all.
786
+ - **`specialists init` fails with xtrm error** → xtrm must be installed first: `npm install -g xtrm-tools && xt install`. Use `--no-xtrm-check` in CI.
787
+ - **Skill drift detected by doctor** → Run `specialists init --sync-skills` to re-sync canonical skills to `.xtrm/skills/default/` and refresh active symlinks.