xtrm-tools 0.7.12 → 0.7.13

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 (26) hide show
  1. package/.xtrm/hooks/specialists/specialists-memory-cache-sync.mjs +57 -0
  2. package/.xtrm/registry.json +477 -389
  3. package/.xtrm/skills/default/premortem/SKILL.md +218 -0
  4. package/.xtrm/skills/default/releasing/SKILL.md +90 -0
  5. package/.xtrm/skills/default/sync-docs/SKILL.md +88 -208
  6. package/.xtrm/skills/default/sync-docs/scripts/pre-context.sh +17 -0
  7. package/.xtrm/skills/default/update-specialists/SKILL.md +228 -36
  8. package/.xtrm/skills/default/update-xt/SKILL.md +34 -0
  9. package/.xtrm/skills/default/using-kpi/SKILL.md +150 -0
  10. package/.xtrm/skills/default/using-specialists-v2/SKILL.md +683 -0
  11. package/cli/dist/index.cjs +839 -429
  12. package/cli/dist/index.cjs.map +1 -1
  13. package/cli/package.json +1 -1
  14. package/package.json +2 -2
  15. package/packages/pi-extensions/.serena/project.yml +119 -0
  16. package/packages/pi-extensions/extensions/pi-serena-compact/index.ts +4 -12
  17. package/packages/pi-extensions/extensions/xtrm-loader/index.ts +0 -1
  18. package/packages/pi-extensions/extensions/xtrm-ui/index.ts +201 -36
  19. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-dark-flattools.json +79 -0
  20. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-dark.json +85 -0
  21. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-light-flattools.json +79 -0
  22. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-light.json +85 -0
  23. package/packages/pi-extensions/package.json +1 -1
  24. package/packages/pi-extensions/themes/xtrm-ui/pidex-dark-flattools.json +79 -0
  25. package/packages/pi-extensions/themes/xtrm-ui/pidex-dark.json +3 -3
  26. package/packages/pi-extensions/themes/xtrm-ui/pidex-light-flattools.json +79 -0
@@ -0,0 +1,683 @@
1
+ ---
2
+ name: using-specialists-v2
3
+ description: >
4
+ Use this skill to orchestrate substantial work through project specialists with
5
+ a bead-first workflow. It covers when to delegate, how to write complete bead
6
+ task contracts, how to run explorer/executor/reviewer/test chains, how to use
7
+ --worktree/--job/--epic/--context-depth, and how to merge or recover specialist
8
+ work without drift. Trigger for code review, debugging, implementation,
9
+ planning, test generation, doc sync, multi-chain epics, and any question about
10
+ specialist orchestration.
11
+ version: 1.1
12
+ ---
13
+
14
+ # Specialists V2
15
+
16
+ You are the orchestrator. Your job is to specify the work, choose the right specialist, launch the right chain, monitor progress, and synthesize results. Do not turn orchestration into vague delegation: `--bead` is the prompt.
17
+
18
+ Use this skill for substantial work: codebase exploration, debugging, implementation, review, testing, documentation sync, planning, specialist authoring, and multi-chain orchestration. Do small deterministic edits directly when the scope is already clear and delegation would add ceremony.
19
+
20
+ For one-shot synchronous specialist invocations from services or scripts (template + variables, READ_ONLY, JSON out), use `using-script-specialists` instead. That runtime (`sp script` / `sp serve`) is unrelated to bead-first orchestration.
21
+
22
+ ## Update Awareness On Skill Load
23
+
24
+ On first activation in a session, before substantial work, check whether the local specialists install is current:
25
+
26
+ ```bash
27
+ LOCAL=$(node -p "require('./package.json').version" 2>/dev/null)
28
+ LATEST=$(git ls-remote --tags --refs origin 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 | sed 's/^v//')
29
+ [ -n "$LATEST" ] && [ "$LOCAL" != "$LATEST" ] && echo "specialists v$LOCAL is local; v$LATEST published — consider /update-specialists before substantial work."
30
+ ```
31
+
32
+ Skip the check entirely when `SPECIALISTS_OFFLINE=1` is set, when stdin is not a TTY (specialist-spawned subagent context), or when the previous turn already surfaced this notice. Surface at most one line — never block, never spam, never auto-update. The operator decides whether to run `/update-specialists`.
33
+
34
+ When the local version is behind, the latest CHANGELOG entry can be summarized via `head -50 CHANGELOG.md` to anchor what changed; cross-link to the `update-specialists` skill for the actual reconcile flow.
35
+
36
+ ## Hard Rules
37
+
38
+ 1. `--bead` is the prompt for tracked work.
39
+ 2. Do not dispatch until the bead is a complete task contract.
40
+ 3. Never use `--prompt` to supplement tracked work. Update bead notes instead.
41
+ 4. Use explorer only when the implementation path is unknown.
42
+ 5. Use executor only after scope, constraints, and validation are clear enough to act.
43
+ 6. Edit-capable specialists with `--bead` auto-provision a worktree. `--worktree` is still accepted for clarity but not required (the deprecated `--no-worktree` flag is gone).
44
+ 7. Reviewer gets its own bead and enters the executor workspace with `--job <exec-job>`. `--job` auto-resolves the bead if `--bead` is omitted.
45
+ 8. `--context-depth` defaults to 3 (parent task + predecessor + own bead). Override only when the chain needs less or more upstream context.
46
+ 9. Keep executor/debugger jobs alive through review so they can be resumed.
47
+ 10. Merge specialist branches with `sp merge` or `sp epic merge`, never manual `git merge`.
48
+ 11. Specialists must not perform destructive or irreversible actions.
49
+ 12. If a specialist fails, inspect feed/result and either steer, resume, rerun with a better bead, or report the blocker.
50
+ 13. Drive chains autonomously. Do not ask the operator to approve routine stage transitions. Escalate only on critical events (see Autonomous Drive section).
51
+ 14. Stale-base guard: dispatch refuses to provision a worktree when sibling epic chains have unmerged substantive commits. Override only with explicit `--force-stale-base` and a reason. Merge-time rebase happens automatically.
52
+ 15. Auto-checkpoint: executor and debugger commit substantive worktree changes on `waiting` by default (`auto_commit: checkpoint_on_waiting`). Noise paths (`.xtrm/`, `.wolf/`, `.specialists/jobs/`, `.beads/`) are filtered.
53
+ 16. Per-turn output appends to the input bead notes for **all** specialists on every `run_complete`, with `[WAITING — more output may follow]` or `[DONE]` headers. `bd show <bead-id>` is a valid path to read intermediate output.
54
+
55
+ ## Autonomous Drive
56
+
57
+ Once the operator has approved a plan or specified a task, push the chain to completion without pausing for per-stage confirmation. Dispatch, wait with `sleep`, read results, dispatch the next stage, review, and merge. Treat each stage transition as a mechanical step — not a decision point.
58
+
59
+ Escalate to the operator only for:
60
+
61
+ - Reviewer verdict `FAIL` (not `PARTIAL` — fix those autonomously via resume).
62
+ - Destructive/irreversible action required (history rewrite, force push, credential rotation, mass delete, prod-impacting op).
63
+ - Repeated specialist crashes on the same chain (2+ in a row with same failure mode).
64
+ - Context-exhaustion risk above 80% with no clean handoff available.
65
+ - Ambiguous requirements the bead cannot resolve (rare — fix by updating the bead contract first and retrying).
66
+ - Explicit user-facing question embedded in reviewer output that needs human judgment.
67
+
68
+ Anything else — stage transitions, routine reviewer `PARTIAL` with concrete findings, merge gates passing, test retries — proceed without asking.
69
+
70
+ ### Sleep-Based Polling
71
+
72
+ Use `sleep` between dispatch and status check. Size the sleep to the observed median for the specialist and adjust by polling once and checking `sp ps <job-id>`:
73
+
74
+ | Specialist | First sleep | Poll interval after |
75
+ | --- | --- | --- |
76
+ | executor | `sleep 180` (3m) | 60-120s |
77
+ | reviewer | `sleep 120` (2m) | 60s |
78
+ | explorer | `sleep 180` (3m) | 60s |
79
+ | debugger | `sleep 480` (8m) | 120s |
80
+ | overthinker | `sleep 240` (4m) | 60s |
81
+ | planner | `sleep 300` (5m) | 60s |
82
+ | sync-docs | `sleep 180` (3m) | 60s |
83
+ | researcher | `sleep 120` (2m) | 60s |
84
+ | test-runner | `sleep 120` (2m) | 60s |
85
+
86
+ Medians are empirical (derived from run history). Adjust for observed run complexity. If `sp ps` shows `running` after the first sleep, poll once more before assuming stuck. If `waiting`, read `sp result` — reviewer verdicts and READ_ONLY outputs land in the bead notes automatically.
87
+
88
+ Do not busy-loop `sp ps` in tight intervals. One sleep + one confirmation poll is enough for routine runs.
89
+
90
+ ### Drive Loop Pattern
91
+
92
+ ```bash
93
+ # Dispatch
94
+ JOB=$(sp run <specialist> --bead <bead-id> --context-depth 3 --background 2>&1 | tail -1)
95
+
96
+ # Sleep for median
97
+ sleep 180
98
+
99
+ # Check
100
+ sp ps "$JOB"
101
+
102
+ # Still running? Short follow-up sleep, then re-check
103
+ # Waiting or done? Read result
104
+ sp result "$JOB"
105
+
106
+ # Advance to next stage based on output — no operator prompt
107
+ ```
108
+
109
+ Launch sleeps in the background when other orchestration work can proceed in parallel; the harness will notify on completion. Return to `sp ps`/`sp result` after the median interval elapses.
110
+
111
+ ## Bead Task Contract
112
+
113
+ Every specialist-bound bead must be a usable prompt. Title-only beads are not acceptable.
114
+
115
+ Required fields:
116
+
117
+ ```text
118
+ PROBLEM: What is wrong or needed.
119
+ SUCCESS: Observable completion criteria.
120
+ SCOPE: Files, symbols, commands, docs, or discovery area.
121
+ NON_GOALS: Explicitly out of scope.
122
+ CONSTRAINTS: Compatibility, safety, style, permissions, sequencing.
123
+ VALIDATION: Checks/tests/review expected before closure.
124
+ OUTPUT: Expected handoff format.
125
+ ```
126
+
127
+ Use `bd update <id> --notes "CONTRACT: ..."` when an existing bead is too vague.
128
+
129
+ ### Contract By Bead Type
130
+
131
+ Task/epic bead:
132
+
133
+ ```text
134
+ PROBLEM: User-facing or project-facing objective.
135
+ SUCCESS: End-state across all child beads.
136
+ SCOPE: Area of project affected.
137
+ NON_GOALS: Boundaries for the entire effort.
138
+ CONSTRAINTS: Sequencing, compatibility, branch/merge rules.
139
+ VALIDATION: Final checks before close.
140
+ OUTPUT: What the orchestrator reports back.
141
+ ```
142
+
143
+ Explorer bead:
144
+
145
+ ```text
146
+ PROBLEM: What is unknown.
147
+ SUCCESS: Questions answered with evidence.
148
+ SCOPE: Code areas, docs, commands, or symbols to inspect.
149
+ NON_GOALS: No implementation, no broad audit outside scope.
150
+ CONSTRAINTS: READ_ONLY, prefer GitNexus/code intelligence when available.
151
+ VALIDATION: Findings cite files/symbols/flows.
152
+ OUTPUT: Findings, risks, recommended implementation track, stop condition.
153
+ ```
154
+
155
+ Executor bead:
156
+
157
+ ```text
158
+ PROBLEM: Exact behavior or artifact to change.
159
+ SUCCESS: Observable acceptance criteria.
160
+ SCOPE: Target files/symbols; include "do not touch" boundaries.
161
+ NON_GOALS: Related improvements explicitly excluded.
162
+ CONSTRAINTS: API compatibility, style, migrations, safety.
163
+ VALIDATION: Lint/typecheck/tests or manual checks.
164
+ OUTPUT: Changed files, verification, residual risks.
165
+ ```
166
+
167
+ Reviewer bead:
168
+
169
+ ```text
170
+ PROBLEM: Verify executor output against requirements.
171
+ SUCCESS: PASS only if requirements and validation are satisfied.
172
+ SCOPE: Executor job, diff, task bead, acceptance criteria.
173
+ NON_GOALS: Do not rewrite unless explicitly asked.
174
+ CONSTRAINTS: Code-review mindset; findings first.
175
+ VALIDATION: Run or inspect required checks where feasible.
176
+ OUTPUT: PASS/PARTIAL/FAIL with file/line findings.
177
+ ```
178
+
179
+ Test bead:
180
+
181
+ ```text
182
+ PROBLEM: Validate one or more implementation chains.
183
+ SUCCESS: Relevant tests/checks pass or failures are diagnosed.
184
+ SCOPE: Commands and implementation beads covered.
185
+ NON_GOALS: No broad unrelated suite expansion unless requested.
186
+ CONSTRAINTS: Avoid destructive cleanup; report flaky/infra failures separately.
187
+ VALIDATION: Command output and failure interpretation.
188
+ OUTPUT: Pass/fail summary, failing tests, likely owner.
189
+ ```
190
+
191
+ ## Choosing The Specialist
192
+
193
+ Run `specialists list` if you need the live registry. Choose by task, not by habit.
194
+
195
+ | Need | Specialist | Use when |
196
+ | --- | --- | --- |
197
+ | Architecture/code mapping | `explorer` | You need evidence and a scoped implementation track. |
198
+ | Root-cause analysis | `debugger` | There is a symptom, stack trace, failing test, or regression. |
199
+ | Planning/decomposition | `planner` | You need beads, dependencies, file scopes, or sequencing. |
200
+ | Design/tradeoffs | `overthinker` | The approach is risky, ambiguous, or needs critique. |
201
+ | Implementation | `executor` | The contract is clear enough to write code or docs. |
202
+ | Compliance/code review | `reviewer` | An executor/debugger produced changes that need a verdict. |
203
+ | Multiple review perspectives | `parallel-review` | A critical diff needs independent review passes. |
204
+ | Test execution | `test-runner` | You need suites run and failures interpreted. |
205
+ | Docs audit/sync | `sync-docs` | Docs may be stale or need targeted synchronization. |
206
+ | External/live research | `researcher` | Current library/docs/media lookup is needed. |
207
+ | Specialist config | `specialists-creator` | Creating or changing specialist JSON/config. |
208
+ | Release changelog drafting | `changelog-keeper` | A new tag is being cut and a `[X.Y.Z] - YYYY-MM-DD` section is needed. Driven by `sp release prepare`, not invoked directly. |
209
+
210
+ Selection rules:
211
+
212
+ - Explorer is READ_ONLY and should answer specific questions.
213
+ - Debugger is better than explorer for failures because it traces causes and remediation.
214
+ - Executor does not own full test validation; use reviewer/test-runner for that phase.
215
+ - Reviewer always uses its own bead plus `--job <executor-job>`.
216
+ - Sync-docs is for audit/sync; executor is for heavy doc rewrites.
217
+ - Specialists-creator should precede specialist config/schema edits.
218
+
219
+ ## Command Surface
220
+
221
+ Daily commands:
222
+
223
+ ```bash
224
+ specialists list
225
+ specialists list-rules # rule × specialist matrix
226
+ specialists doctor
227
+ specialists run <name> --bead <id> --background
228
+ specialists run executor --bead <impl-bead> --background # worktree auto-provisioned
229
+ specialists run reviewer --bead <review-bead> --job <exec-job> --keep-alive --background
230
+ specialists ps
231
+ specialists ps <job-id>
232
+ specialists feed <job-id>
233
+ specialists feed -f
234
+ specialists result <job-id> # works on done/error/waiting
235
+ specialists result <job-id> --wait --timeout 600
236
+ specialists steer <job-id> "new direction"
237
+ specialists resume <job-id> "next task"
238
+ specialists stop <job-id>
239
+ ```
240
+
241
+ Publication commands:
242
+
243
+ ```bash
244
+ sp merge <chain-root-bead>
245
+ sp epic status <epic-id>
246
+ sp epic sync <epic-id> --apply
247
+ sp epic merge <epic-id>
248
+ sp end
249
+ ```
250
+
251
+ `sp result <job-id>` returns the most recent completed turn for `waiting` jobs with a `Session is waiting for your input` footer — use it to inspect a keep-alive job before deciding whether to resume. For `running` jobs, `sp feed <job-id>` is the right tool; `sp poll` is deprecated. Avoid `specialists status --job` for normal monitoring; prefer `sp ps <job-id>`.
252
+
253
+ ## Flag Semantics
254
+
255
+ `--bead <id>` is the task prompt and tracked work identity.
256
+
257
+ `--context-depth N` controls parent/ancestor bead context. Default is **3** (own bead + predecessor + parent task). Lower it when the chain is shallow or the parent context is noisy.
258
+
259
+ `--worktree` provisions a new isolated workspace and branch for edit-capable work. Optional when `--bead` is provided to an edit-capable specialist — a worktree is auto-provisioned. Pass `--worktree` explicitly only when you want it without a bead, or for emphasis. The deprecated `--no-worktree` flag is removed and now errors out.
260
+
261
+ `--job <id>` reuses an existing job's workspace. Use it for reviewer and fix passes. If `--bead` is omitted, bead_id is inferred from the target job's status; explicit `--bead` always wins.
262
+
263
+ `--force-job` overrides the concurrency lock that blocks edit-capable specialists from entering an owner workspace while it is `starting`/`running`. Use only when you accept the write race; prefer `sp stop` on dead jobs first.
264
+
265
+ `--force-stale-base` bypasses the dispatch-time stale-base guard that blocks `--worktree` provisioning when sibling epic chains have unmerged substantive commits. Use only with a clear reason; the guard prevents merge-conflict cascades.
266
+
267
+ `--epic <id>` explicitly associates a job with an epic. Use it for prep jobs whose parent is not the epic but should appear in epic status/readiness.
268
+
269
+ `--keep-alive` keeps interactive specialists waiting after a turn. Use for reviewer, overthinker, researcher, sync-docs, and any job expected to receive follow-up.
270
+
271
+ `--worktree` and `--job` are mutually exclusive.
272
+
273
+ ## Golden Path: Single Implementation Chain
274
+
275
+ Use this when one implementation branch can solve the task.
276
+
277
+ Create a root task bead:
278
+
279
+ ```bash
280
+ bd create --title "Fix token refresh retry on 401" --type bug --priority 2 \
281
+ --description "PROBLEM: API clients fail permanently when token refresh receives a transient 401.
282
+ SUCCESS: Refresh retries are bounded, observable, and callers receive the same public error shape after exhaustion.
283
+ SCOPE: src/auth/refresh.ts, src/auth/client.ts, related auth tests.
284
+ NON_GOALS: Do not redesign auth storage or change public client API.
285
+ CONSTRAINTS: Preserve existing telemetry names and backward compatibility.
286
+ VALIDATION: lint, tsc, auth refresh tests or documented targeted equivalent.
287
+ OUTPUT: Changed files, validation results, residual risk."
288
+ ```
289
+
290
+ Create explorer only if the implementation path is unclear:
291
+
292
+ ```bash
293
+ bd create --title "Explore token refresh retry path" --type task --priority 2 \
294
+ --description "PROBLEM: Need exact refresh call graph and retry insertion point.
295
+ SUCCESS: Identify caller/callee path, current retry behavior, and safest files to modify.
296
+ SCOPE: auth refresh/client modules and tests only.
297
+ NON_GOALS: No implementation.
298
+ CONSTRAINTS: READ_ONLY; cite files/symbols.
299
+ VALIDATION: Findings include recommended executor scope and risks.
300
+ OUTPUT: Evidence-backed implementation plan."
301
+ bd dep add <explore> <task>
302
+ specialists run explorer --bead <explore> --context-depth 3 --background
303
+ specialists result <explore-job>
304
+ ```
305
+
306
+ Create implementation bead:
307
+
308
+ ```bash
309
+ bd create --title "Implement bounded token refresh retry" --type task --priority 2 \
310
+ --description "PROBLEM: Implement the retry behavior identified by exploration.
311
+ SUCCESS: 401 refresh retry is bounded and preserves public errors after exhaustion.
312
+ SCOPE: src/auth/refresh.ts, src/auth/client.ts, auth refresh tests.
313
+ NON_GOALS: No storage redesign, no public API change.
314
+ CONSTRAINTS: Keep telemetry names stable; avoid broad refactor.
315
+ VALIDATION: npm run lint, npx tsc --noEmit, targeted auth tests if available.
316
+ OUTPUT: Diff summary, checks run, follow-up risks."
317
+ bd dep add <impl> <explore-or-task>
318
+ specialists run executor --worktree --bead <impl> --context-depth 3 --background
319
+ specialists result <exec-job>
320
+ ```
321
+
322
+ Create review bead:
323
+
324
+ ```bash
325
+ bd create --title "Review token refresh retry implementation" --type task --priority 2 \
326
+ --description "PROBLEM: Verify executor changes satisfy token refresh retry contract.
327
+ SUCCESS: PASS only if behavior, scope, constraints, and validation are satisfied.
328
+ SCOPE: executor job <exec-job>, implementation bead, root task contract.
329
+ NON_GOALS: Do not request unrelated auth redesign.
330
+ CONSTRAINTS: Findings first with file/line references.
331
+ VALIDATION: Inspect diff and available checks.
332
+ OUTPUT: PASS/PARTIAL/FAIL verdict with required fixes."
333
+ bd dep add <review> <impl>
334
+ specialists run reviewer --bead <review> --job <exec-job> --context-depth 3 --keep-alive --background
335
+ specialists result <review-job>
336
+ ```
337
+
338
+ If reviewer returns `PARTIAL`, prefer resuming the same executor:
339
+
340
+ ```bash
341
+ specialists resume <exec-job> "Reviewer PARTIAL. Fix only these findings: ..."
342
+ ```
343
+
344
+ Then create a new re-review bead and run reviewer again with the same `--job <exec-job>`.
345
+
346
+ After reviewer `PASS`, publish:
347
+
348
+ ```bash
349
+ sp merge <impl>
350
+ bd close <task> --reason "Fixed token refresh retry. Reviewer PASS. Merged."
351
+ ```
352
+
353
+ ## Golden Path: Multi-Chain Epic
354
+
355
+ Use this when multiple independent implementation chains must publish together.
356
+
357
+ Create a top-level epic with the complete contract:
358
+
359
+ ```bash
360
+ bd create --title "Add specialist bead contract enforcement" --type epic --priority 1 \
361
+ --description "PROBLEM: Specialists drift when --bead issues are under-specified.
362
+ SUCCESS: Docs and runtime guidance require complete bead contracts before dispatch.
363
+ SCOPE: docs/workflow guidance, skill docs, optional validation entry point.
364
+ NON_GOALS: No database migration, no breaking CLI changes.
365
+ CONSTRAINTS: Keep examples canonical and avoid title-only beads.
366
+ VALIDATION: docs review, lint/typecheck for runtime changes, reviewer PASS per chain.
367
+ OUTPUT: Merged epic with documented contract and verification."
368
+ ```
369
+
370
+ Create a shared prep bead:
371
+
372
+ ```bash
373
+ bd create --title "Plan bead contract enforcement tracks" --type task --priority 2 \
374
+ --description "PROBLEM: Need file-disjoint implementation tracks for the epic.
375
+ SUCCESS: Identify independent chains, dependencies, risks, and validation per chain.
376
+ SCOPE: workflow docs, CLI/run validation surfaces, tests.
377
+ NON_GOALS: No implementation.
378
+ CONSTRAINTS: READ_ONLY; produce dependency plan.
379
+ VALIDATION: Plan names file scopes and merge order.
380
+ OUTPUT: Parallel track plan."
381
+ bd dep add <plan> <epic>
382
+ specialists run planner --bead <plan> --epic <epic> --context-depth 3 --background
383
+ ```
384
+
385
+ Create independent implementation beads only when write scopes are disjoint:
386
+
387
+ ```bash
388
+ bd create --title "Implement CLI bead contract warning" --type task --priority 2 \
389
+ --description "PROBLEM: CLI allows specialist dispatch from vague beads.
390
+ SUCCESS: Dispatch warns or blocks according to agreed contract policy.
391
+ SCOPE: src/cli/run.ts, src/specialist/beads.ts, related tests.
392
+ NON_GOALS: No schema migration.
393
+ CONSTRAINTS: Preserve --prompt behavior for explicit ad-hoc runs.
394
+ VALIDATION: lint, tsc, targeted run/beads tests.
395
+ OUTPUT: Diff summary and verification."
396
+ bd dep add <impl-cli> <plan>
397
+
398
+ bd create --title "Update workflow docs for bead contract" --type task --priority 2 \
399
+ --description "PROBLEM: Docs teach title-only specialist beads.
400
+ SUCCESS: Canonical examples use complete task contracts.
401
+ SCOPE: config/skills/using-specialists/SKILL.md, CLAUDE.md, docs/features.md.
402
+ NON_GOALS: No runtime code.
403
+ CONSTRAINTS: Keep docs concise and current.
404
+ VALIDATION: Review examples for contract fields and stale commands.
405
+ OUTPUT: Updated docs summary."
406
+ bd dep add <impl-docs> <plan>
407
+ ```
408
+
409
+ Run parallel executors only if scopes are disjoint:
410
+
411
+ ```bash
412
+ specialists run executor --worktree --bead <impl-cli> --context-depth 3 --background
413
+ specialists run executor --worktree --bead <impl-docs> --context-depth 3 --background
414
+ ```
415
+
416
+ Review each chain with its own review bead and `--job`.
417
+
418
+ After every chain has reviewer `PASS`:
419
+
420
+ ```bash
421
+ sp epic status <epic>
422
+ sp epic merge <epic>
423
+ bd close <epic> --reason "All chains reviewer PASS. Epic merged."
424
+ ```
425
+
426
+ ## Review And Fix Loop
427
+
428
+ A chain stays alive until merge or abandonment.
429
+
430
+ Standard loop:
431
+
432
+ ```text
433
+ executor --worktree --bead impl
434
+ -> waiting after turn
435
+ reviewer --bead review --job exec-job
436
+ -> PASS: verify commit, publish, stop members if needed
437
+ -> PARTIAL: resume executor with exact findings
438
+ -> FAIL: decide whether to resume, replace, or abandon
439
+ ```
440
+
441
+ Prefer `sp resume <exec-job>` over a new fix executor when the original job is waiting and context is healthy. Use a new fix bead with `--job <exec-job>` only when the original executor is dead, context exhausted, or a separate audit trail is required.
442
+
443
+ Reviewer output must be consumed before publishing. Do not treat job completion as equivalent to acceptance.
444
+
445
+ ## Dependency Mapping
446
+
447
+ The bead graph should mirror execution order.
448
+
449
+ Simple chain:
450
+
451
+ ```text
452
+ task -> explore -> impl -> review
453
+ ```
454
+
455
+ Fix loop:
456
+
457
+ ```text
458
+ task -> explore -> impl -> review -> re-review
459
+ ^ |
460
+ | v
461
+ resume executor with findings
462
+ ```
463
+
464
+ Epic:
465
+
466
+ ```text
467
+ epic -> shared prep -> impl-a -> review-a
468
+ -> impl-b -> review-b
469
+ -> test-batch
470
+ -> epic merge
471
+ ```
472
+
473
+ Use `bd dep add <issue> <depends-on>` so downstream beads are blocked until upstream context exists. Test beads can depend on multiple implementation beads.
474
+
475
+ ## Monitoring
476
+
477
+ Use `sp ps` instead of ad-hoc polling.
478
+
479
+ ```bash
480
+ sp ps
481
+ sp ps <job-id>
482
+ sp ps --follow
483
+ sp feed <job-id>
484
+ sp result <job-id>
485
+ ```
486
+
487
+ Read results at every stage. Every specialist (not just READ_ONLY) auto-appends per-turn output to the input bead notes on each `run_complete`, with `[WAITING]` or `[DONE]` headers — `bd show <bead-id>` shows the full handoff trail. `sp result <job-id>` works on `waiting` jobs and returns the most recent turn plus a "Session is waiting for your input" footer; use it to decide whether to resume. If result is empty, inspect feed and rerun or switch specialists before relying on it.
488
+
489
+ Context percentage in `sp ps`/feed is an action signal:
490
+
491
+ - 0-40%: healthy.
492
+ - 40-65%: monitor.
493
+ - 65-80%: steer toward conclusion.
494
+ - Above 80%: finish, summarize, or replace the job.
495
+
496
+ ## Steering And Resume
497
+
498
+ Use `steer` for running jobs:
499
+
500
+ ```bash
501
+ sp steer <job-id> "Stop broad audit. Answer only the three questions in the bead."
502
+ ```
503
+
504
+ Use `resume` for waiting keep-alive jobs:
505
+
506
+ ```bash
507
+ sp resume <job-id> "Reviewer PARTIAL. Fix only findings 1 and 2; do not refactor."
508
+ ```
509
+
510
+ Do not use `resume` as a substitute for a missing bead contract on a new tracked task. Create or update the bead first.
511
+
512
+ ## Merge Rules
513
+
514
+ Standalone chain:
515
+
516
+ ```bash
517
+ sp merge <chain-root-bead>
518
+ ```
519
+
520
+ Epic-owned chains:
521
+
522
+ ```bash
523
+ sp epic status <epic-id>
524
+ sp epic merge <epic-id>
525
+ ```
526
+
527
+ Rules:
528
+
529
+ - Merge only after reviewer `PASS`.
530
+ - Use `sp epic merge` for unresolved epic chains.
531
+ - Do not merge within a chain between executor and reviewer.
532
+ - Merge between stages only when later stages need the code on the main line.
533
+ - Run or confirm required gates before closing the root bead or epic.
534
+
535
+ ## Release Publication
536
+
537
+ Tagged releases go through `sp release`, not manual `git tag`:
538
+
539
+ ```bash
540
+ sp release prepare [--major | --minor | --patch] # default: --patch
541
+ sp release publish
542
+ ```
543
+
544
+ `prepare` invokes the `changelog-keeper` specialist to draft a Keep-a-Changelog section between the previous tag and the next tag, bumps `package.json`, and stages `CHANGELOG.md` + `package.json` + `dist/index.js`. It does not commit — operator reviews and commits with `release: v<version>`.
545
+
546
+ `publish` validates the staged commit (dirty-tree refusal, HEAD message match, version match, top-section match in `CHANGELOG.md`), creates the annotated tag, pushes to origin, and optionally creates a GitHub release via `gh`. Re-emits the empty `[Unreleased]` placeholder for the next cycle.
547
+
548
+ The `changelog-keeper` specialist is READ_ONLY; the CLI is the file mutator. See `docs/release.md` for the operator runbook.
549
+
550
+ ## Epic Lifecycle
551
+
552
+ Epics are merge-gated identities with a persisted state machine:
553
+
554
+ ```text
555
+ open -> resolving -> merge_ready -> merged
556
+ -> failed
557
+ -> abandoned
558
+ ```
559
+
560
+ | State | Meaning | Chains mergeable? |
561
+ | --- | --- | --- |
562
+ | `open` | Epic created, chains not yet running. | No |
563
+ | `resolving` | Chains actively running. | No |
564
+ | `merge_ready` | All chains terminal, reviewer PASS, tsc gate passes. | Yes via `sp epic merge` |
565
+ | `merged` | Publication complete. | — |
566
+ | `failed` | One or more chains failed. | Resolve or abandon. |
567
+ | `abandoned` | Cancelled without merge. | — |
568
+
569
+ Operator transitions:
570
+
571
+ ```bash
572
+ sp epic resolve <epic-id> # open -> resolving (marks epic as merge-ready target)
573
+ sp epic merge <epic-id> # merge_ready -> merged (canonical publication)
574
+ sp epic merge <epic-id> --pr # PR mode (publish via pull request)
575
+ sp epic sync <epic-id> --apply # reconcile DB vs live job state when stuck
576
+ sp epic abandon <epic-id> --reason <t> # terminal close for unrecoverable epic
577
+ sp epic abandon <epic-id> --reason <t> --force # force when active pointers still exist
578
+ ```
579
+
580
+ `sp merge <chain>` refuses if the chain belongs to an unresolved epic. Use
581
+ `sp epic merge` for epic-owned chains.
582
+
583
+ ## Concurrency And Force Flags
584
+
585
+ Edit-capable specialists (MEDIUM/HIGH permission) are blocked from entering a
586
+ workspace while the owner job is `starting` or `running`. This prevents
587
+ concurrent file corruption. READ_ONLY specialists (explorer, etc.) are always
588
+ allowed.
589
+
590
+ Override with `--force-job` only when the caller explicitly accepts the write
591
+ race (e.g. emergency fix into a stalled-but-not-terminal executor):
592
+
593
+ ```bash
594
+ sp run executor --bead <fix-bead> --job <stalled-exec-job> --force-job --context-depth 3 --background
595
+ ```
596
+
597
+ Do not use `--force-job` as a routine unblock. Inspect `sp ps <job-id>` and
598
+ prefer `sp stop <job-id>` on truly dead jobs first.
599
+
600
+ ## Terminology Bridge
601
+
602
+ Historical conversations and docs use "waves" for dispatch batches (e.g. "Wave
603
+ 1" / "Wave 2"). "Waves" are human shorthand only — not persisted. The
604
+ merge-gated identity is the epic. Map mental models as follows:
605
+
606
+ | Legacy speech | Canonical concept |
607
+ | --- | --- |
608
+ | "Wave 1" / prep wave | Stage 1 / shared prep job, `--epic` for membership |
609
+ | "Wave 2" | Implementation chains under one epic |
610
+ | "Between waves merge" | `sp epic merge <epic-id>` |
611
+ | "Parallel in wave" | Parallel chains under the same epic (disjoint scopes) |
612
+
613
+ Treat "wave" as speech, "epic" as truth.
614
+
615
+ ## Failure Handling
616
+
617
+ If a job fails or stalls:
618
+
619
+ ```bash
620
+ sp ps <job-id>
621
+ sp feed <job-id>
622
+ sp result <job-id>
623
+ sp doctor
624
+ ```
625
+
626
+ Then choose one action:
627
+
628
+ - Steer a running job back to scope.
629
+ - Resume a waiting job with exact next instruction.
630
+ - Stop a dead or obsolete job.
631
+ - Rerun with a better bead contract.
632
+ - Switch specialist if the selected role was wrong.
633
+ - Report blocker if destructive/high-risk/manual action is required.
634
+
635
+ Do not silently fall back to doing substantial specialist work yourself unless the user agrees or the work is genuinely small and deterministic.
636
+
637
+ ## Recovery Cheatsheet
638
+
639
+ Dead or zombie process:
640
+
641
+ ```bash
642
+ sp stop <job-id> # explicit single-job stop
643
+ sp clean --processes --dry-run # preview stale non-terminal cancellations (PID-dead OR > --stale-after, default 24h)
644
+ sp clean --processes # apply: cancel stale rows in observability.db
645
+ ```
646
+
647
+ `sp clean --processes` reads from `observability.db` (DB-first) and uses PID liveness as the primary gate — alive PIDs are never cancelled regardless of age. The `--stale-after <hours>` fallback applies only when a row has no recorded PID. `sp clean` with no flags purges terminal rows older than `SPECIALISTS_JOB_TTL_DAYS` (7d default); `--all` purges all terminals; `--keep <n>` retains the N most recent.
648
+
649
+ Epic state unclear:
650
+
651
+ ```bash
652
+ sp epic status <epic-id>
653
+ sp epic sync <epic-id> --apply
654
+ ```
655
+
656
+ Specialist missing or config skipped:
657
+
658
+ ```bash
659
+ specialists list
660
+ specialists doctor
661
+ ```
662
+
663
+ Worktree already exists:
664
+
665
+ ```text
666
+ Rerun with the same bead if it is safe; worktree is reused rather than recreated.
667
+ ```
668
+
669
+ Reviewer cannot enter job workspace:
670
+
671
+ ```text
672
+ Check target job status with sp ps. MEDIUM/HIGH jobs are blocked from entering a running write-capable workspace unless forced.
673
+ ```
674
+
675
+ Explorer produced empty output:
676
+
677
+ ```text
678
+ Inspect feed. If no usable final summary exists, rerun with a clearer explorer bead or switch to debugger/planner as appropriate.
679
+ ```
680
+
681
+ ## What Not To Put In This Skill
682
+
683
+ Do not add historical migration notes, stale model names, exhaustive command references, internal token counts, long stuck-state postmortems, or title-only examples. Put long reference material in docs and keep this skill focused on current canonical orchestration.