cclaw-cli 7.7.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +210 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +90 -508
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -766
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -132
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/install.d.ts +27 -15
  73. package/dist/install.js +230 -1342
  74. package/dist/knowledge-store.d.ts +19 -163
  75. package/dist/knowledge-store.js +56 -590
  76. package/dist/logger.d.ts +8 -3
  77. package/dist/logger.js +13 -4
  78. package/dist/orchestrator-routing.d.ts +29 -0
  79. package/dist/orchestrator-routing.js +156 -0
  80. package/dist/run-persistence.d.ts +7 -118
  81. package/dist/run-persistence.js +29 -845
  82. package/dist/runtime/run-hook.entry.d.ts +1 -3
  83. package/dist/runtime/run-hook.entry.js +19 -4
  84. package/dist/runtime/run-hook.mjs +13 -1024
  85. package/dist/types.d.ts +25 -261
  86. package/dist/types.js +8 -36
  87. package/package.json +6 -3
  88. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  89. package/dist/artifact-linter/brainstorm.js +0 -353
  90. package/dist/artifact-linter/design.d.ts +0 -18
  91. package/dist/artifact-linter/design.js +0 -444
  92. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  93. package/dist/artifact-linter/findings-dedup.js +0 -232
  94. package/dist/artifact-linter/plan.d.ts +0 -2
  95. package/dist/artifact-linter/plan.js +0 -826
  96. package/dist/artifact-linter/review-army.d.ts +0 -49
  97. package/dist/artifact-linter/review-army.js +0 -520
  98. package/dist/artifact-linter/review.d.ts +0 -2
  99. package/dist/artifact-linter/review.js +0 -113
  100. package/dist/artifact-linter/scope.d.ts +0 -2
  101. package/dist/artifact-linter/scope.js +0 -158
  102. package/dist/artifact-linter/shared.d.ts +0 -637
  103. package/dist/artifact-linter/shared.js +0 -2163
  104. package/dist/artifact-linter/ship.d.ts +0 -2
  105. package/dist/artifact-linter/ship.js +0 -250
  106. package/dist/artifact-linter/spec.d.ts +0 -2
  107. package/dist/artifact-linter/spec.js +0 -176
  108. package/dist/artifact-linter/tdd.d.ts +0 -118
  109. package/dist/artifact-linter/tdd.js +0 -1404
  110. package/dist/artifact-linter.d.ts +0 -15
  111. package/dist/artifact-linter.js +0 -517
  112. package/dist/codex-feature-flag.d.ts +0 -58
  113. package/dist/codex-feature-flag.js +0 -193
  114. package/dist/content/closeout-guidance.d.ts +0 -14
  115. package/dist/content/closeout-guidance.js +0 -44
  116. package/dist/content/diff-command.d.ts +0 -1
  117. package/dist/content/diff-command.js +0 -43
  118. package/dist/content/harness-doc.d.ts +0 -1
  119. package/dist/content/harness-doc.js +0 -65
  120. package/dist/content/hook-events.d.ts +0 -9
  121. package/dist/content/hook-events.js +0 -23
  122. package/dist/content/hook-manifest.d.ts +0 -81
  123. package/dist/content/hook-manifest.js +0 -156
  124. package/dist/content/hooks.d.ts +0 -11
  125. package/dist/content/hooks.js +0 -1972
  126. package/dist/content/idea.d.ts +0 -60
  127. package/dist/content/idea.js +0 -416
  128. package/dist/content/language-policy.d.ts +0 -2
  129. package/dist/content/language-policy.js +0 -13
  130. package/dist/content/learnings.d.ts +0 -6
  131. package/dist/content/learnings.js +0 -141
  132. package/dist/content/observe.d.ts +0 -19
  133. package/dist/content/observe.js +0 -86
  134. package/dist/content/opencode-plugin.d.ts +0 -1
  135. package/dist/content/opencode-plugin.js +0 -635
  136. package/dist/content/review-prompts.d.ts +0 -1
  137. package/dist/content/review-prompts.js +0 -104
  138. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  139. package/dist/content/runtime-shared-snippets.js +0 -80
  140. package/dist/content/session-hooks.d.ts +0 -7
  141. package/dist/content/session-hooks.js +0 -107
  142. package/dist/content/skills-elicitation.d.ts +0 -1
  143. package/dist/content/skills-elicitation.js +0 -167
  144. package/dist/content/stage-command.d.ts +0 -2
  145. package/dist/content/stage-command.js +0 -17
  146. package/dist/content/stage-schema.d.ts +0 -117
  147. package/dist/content/stage-schema.js +0 -955
  148. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  149. package/dist/content/stages/_lint-metadata/index.js +0 -97
  150. package/dist/content/stages/brainstorm.d.ts +0 -2
  151. package/dist/content/stages/brainstorm.js +0 -184
  152. package/dist/content/stages/design.d.ts +0 -2
  153. package/dist/content/stages/design.js +0 -288
  154. package/dist/content/stages/index.d.ts +0 -8
  155. package/dist/content/stages/index.js +0 -11
  156. package/dist/content/stages/plan.d.ts +0 -2
  157. package/dist/content/stages/plan.js +0 -191
  158. package/dist/content/stages/review.d.ts +0 -2
  159. package/dist/content/stages/review.js +0 -240
  160. package/dist/content/stages/schema-types.d.ts +0 -203
  161. package/dist/content/stages/schema-types.js +0 -1
  162. package/dist/content/stages/scope.d.ts +0 -2
  163. package/dist/content/stages/scope.js +0 -254
  164. package/dist/content/stages/ship.d.ts +0 -2
  165. package/dist/content/stages/ship.js +0 -159
  166. package/dist/content/stages/spec.d.ts +0 -2
  167. package/dist/content/stages/spec.js +0 -170
  168. package/dist/content/stages/tdd.d.ts +0 -4
  169. package/dist/content/stages/tdd.js +0 -273
  170. package/dist/content/state-contracts.d.ts +0 -1
  171. package/dist/content/state-contracts.js +0 -63
  172. package/dist/content/status-command.d.ts +0 -4
  173. package/dist/content/status-command.js +0 -109
  174. package/dist/content/subagent-context-skills.d.ts +0 -4
  175. package/dist/content/subagent-context-skills.js +0 -279
  176. package/dist/content/subagents.d.ts +0 -3
  177. package/dist/content/subagents.js +0 -997
  178. package/dist/content/templates.d.ts +0 -26
  179. package/dist/content/templates.js +0 -1692
  180. package/dist/content/track-render-context.d.ts +0 -18
  181. package/dist/content/track-render-context.js +0 -53
  182. package/dist/content/tree-command.d.ts +0 -1
  183. package/dist/content/tree-command.js +0 -64
  184. package/dist/content/utility-skills.d.ts +0 -30
  185. package/dist/content/utility-skills.js +0 -160
  186. package/dist/content/view-command.d.ts +0 -2
  187. package/dist/content/view-command.js +0 -92
  188. package/dist/delegation.d.ts +0 -649
  189. package/dist/delegation.js +0 -1539
  190. package/dist/early-loop.d.ts +0 -70
  191. package/dist/early-loop.js +0 -302
  192. package/dist/execution-topology.d.ts +0 -36
  193. package/dist/execution-topology.js +0 -73
  194. package/dist/gate-evidence.d.ts +0 -85
  195. package/dist/gate-evidence.js +0 -631
  196. package/dist/harness-adapters.d.ts +0 -151
  197. package/dist/harness-adapters.js +0 -756
  198. package/dist/harness-selection.d.ts +0 -31
  199. package/dist/harness-selection.js +0 -214
  200. package/dist/hook-schema.d.ts +0 -6
  201. package/dist/hook-schema.js +0 -114
  202. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  203. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  204. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  205. package/dist/init-detect.d.ts +0 -2
  206. package/dist/init-detect.js +0 -50
  207. package/dist/internal/advance-stage/advance.d.ts +0 -89
  208. package/dist/internal/advance-stage/advance.js +0 -655
  209. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  210. package/dist/internal/advance-stage/cancel-run.js +0 -19
  211. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  212. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  213. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  214. package/dist/internal/advance-stage/helpers.js +0 -145
  215. package/dist/internal/advance-stage/hook.d.ts +0 -8
  216. package/dist/internal/advance-stage/hook.js +0 -40
  217. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  218. package/dist/internal/advance-stage/parsers.js +0 -357
  219. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  220. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  221. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  222. package/dist/internal/advance-stage/review-loop.js +0 -199
  223. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  224. package/dist/internal/advance-stage/rewind.js +0 -108
  225. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  226. package/dist/internal/advance-stage/start-flow.js +0 -241
  227. package/dist/internal/advance-stage/verify.d.ts +0 -21
  228. package/dist/internal/advance-stage/verify.js +0 -185
  229. package/dist/internal/advance-stage.d.ts +0 -7
  230. package/dist/internal/advance-stage.js +0 -138
  231. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  232. package/dist/internal/cohesion-contract-stub.js +0 -148
  233. package/dist/internal/compound-readiness.d.ts +0 -23
  234. package/dist/internal/compound-readiness.js +0 -102
  235. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  236. package/dist/internal/detect-public-api-changes.js +0 -45
  237. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  238. package/dist/internal/detect-supply-chain-changes.js +0 -138
  239. package/dist/internal/early-loop-status.d.ts +0 -7
  240. package/dist/internal/early-loop-status.js +0 -93
  241. package/dist/internal/envelope-validate.d.ts +0 -7
  242. package/dist/internal/envelope-validate.js +0 -66
  243. package/dist/internal/flow-state-repair.d.ts +0 -20
  244. package/dist/internal/flow-state-repair.js +0 -104
  245. package/dist/internal/plan-split-waves.d.ts +0 -190
  246. package/dist/internal/plan-split-waves.js +0 -764
  247. package/dist/internal/runtime-integrity.d.ts +0 -7
  248. package/dist/internal/runtime-integrity.js +0 -268
  249. package/dist/internal/slice-commit.d.ts +0 -7
  250. package/dist/internal/slice-commit.js +0 -619
  251. package/dist/internal/tdd-loop-status.d.ts +0 -14
  252. package/dist/internal/tdd-loop-status.js +0 -68
  253. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  254. package/dist/internal/tdd-red-evidence.js +0 -153
  255. package/dist/internal/waiver-grant.d.ts +0 -62
  256. package/dist/internal/waiver-grant.js +0 -294
  257. package/dist/internal/wave-status.d.ts +0 -63
  258. package/dist/internal/wave-status.js +0 -450
  259. package/dist/managed-resources.d.ts +0 -53
  260. package/dist/managed-resources.js +0 -313
  261. package/dist/policy.d.ts +0 -10
  262. package/dist/policy.js +0 -167
  263. package/dist/retro-gate.d.ts +0 -9
  264. package/dist/retro-gate.js +0 -47
  265. package/dist/run-archive.d.ts +0 -61
  266. package/dist/run-archive.js +0 -391
  267. package/dist/runs.d.ts +0 -2
  268. package/dist/runs.js +0 -2
  269. package/dist/stack-detection.d.ts +0 -116
  270. package/dist/stack-detection.js +0 -489
  271. package/dist/streaming/event-stream.d.ts +0 -31
  272. package/dist/streaming/event-stream.js +0 -114
  273. package/dist/tdd-cycle.d.ts +0 -107
  274. package/dist/tdd-cycle.js +0 -289
  275. package/dist/tdd-verification-evidence.d.ts +0 -17
  276. package/dist/tdd-verification-evidence.js +0 -122
  277. package/dist/track-heuristics.d.ts +0 -27
  278. package/dist/track-heuristics.js +0 -154
  279. package/dist/util/slice-id.d.ts +0 -58
  280. package/dist/util/slice-id.js +0 -89
  281. package/dist/worktree-manager.d.ts +0 -20
  282. package/dist/worktree-manager.js +0 -108
@@ -1,997 +0,0 @@
1
- import { stageDelegationSummary } from "./stage-schema.js";
2
- import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
3
- /**
4
- * Markdown content generators for Cclaw’s subagent orchestration skills and enhanced
5
- * specialist payloads. Cclaw materializes static instructions — this module does not
6
- * execute orchestration logic at install time beyond string assembly.
7
- */
8
- const MARKDOWN_CODE_FENCE = "```";
9
- function formatAgentList(agents) {
10
- return agents.length > 0 ? agents.join(", ") : "none";
11
- }
12
- function automaticStageDelegationTable() {
13
- const summary = stageDelegationSummary("standard");
14
- const rows = summary.map((row) => {
15
- return `| ${row.stage} | ${formatAgentList(row.mandatoryAgents)} | ${formatAgentList(row.proactiveAgents)} |`;
16
- }).join("\n");
17
- return `| Stage | Mandatory agents | Proactive agents |
18
- |---|---|---|
19
- ${rows}
20
-
21
- > **Track-aware skip:** mandatory agents are skipped entirely when \`track === "quick"\` OR \`taskClass === "software-bugfix"\`. Use \`mandatoryAgentsFor(stage, track, taskClass)\` from \`src/content/stage-schema.ts\` for the authoritative list at runtime. Proactive agents are trigger-driven opportunities, not a blanket completion gate, and lean/lightweight early-stage runs may intentionally record none.`;
22
- }
23
- function stageSummary(stage) {
24
- return stageDelegationSummary("standard").find((row) => row.stage === stage)
25
- ?? { stage, mandatoryAgents: [], proactiveAgents: [], primaryAgents: [], dispatchRules: [], stackAwareRoutes: [] };
26
- }
27
- export function subagentDrivenDevSkill() {
28
- return `---
29
- name: subagent-driven-development
30
- description: "Orchestrate implementation via isolated subagents — one fresh agent per task with two-stage review."
31
- ---
32
-
33
- # Subagent-Driven Development (SDD)
34
-
35
- ## Overview
36
-
37
- Use a **controller -> coder -> overseer** loop when building multi-step software work.
38
-
39
- - **Controller (parent agent):** owns the plan, gating, sequencing, and dispatch decisions; never mixes deep implementation context with review evidence.
40
- - **Coder / slice-builder (subagent):** receives a **single feature-atomic implementation unit/slice** and edits code only within that scope; exits with a structured status contract.
41
- - **Overseer / reviewer (subagent):** validates outputs against the specification **by reading code** and never edits during the overseer pass.
42
-
43
- This pattern is intentionally **Superpowers-style**: cheap parallelism where it doesn’t corrupt state, strict serialization where it would.
44
-
45
- ## Automatic Stage Delegation in Cclaw
46
-
47
- For cclaw flow stages, machine-only specialist work should auto-dispatch without waiting for a manual user request. The table below is generated from the canonical stage dispatch registry:
48
-
49
- ${automaticStageDelegationTable()}
50
-
51
- Human input remains mandatory only at explicit approval gates (plan approval, user challenge resolution, release finalization mode).
52
-
53
- ### Review dispatch protocol
54
-
55
- In review stage, run mandatory specialists \`${formatAgentList(stageSummary("review").mandatoryAgents)}\` by default:
56
-
57
- 1. \`reviewer\` owns Layer 1 spec compliance plus integrated Layer 2 tags (correctness, performance, architecture, external-safety).
58
- 2. \`security-reviewer\` owns the mandatory security sweep or no-change attestation.
59
- 3. Add \`adversarial-review\` only when trust boundaries changed, Critical/Important ambiguity remains, or the diff is both large and high-risk.
60
-
61
- Reconcile findings into \`.cclaw/artifacts/07-review-army.json\` with explicit source tags per finding.
62
-
63
- ### TDD evidence protocol
64
-
65
- Each delegated feature-atomic slice runs end-to-end inside one \`slice-builder\` delegation, with RED, GREEN, REFACTOR, and per-slice DOC as phase intents on a single span. The slice may contain internal 2-5 minute TDD steps; \`strict-micro\` is the explicit mode for one tiny task per slice:
66
-
67
- - \`--phase red\`: failing tests only, no production writes
68
- - \`--phase green\`: minimal production implementation that passes the matching RED
69
- - \`--phase refactor\` (or \`--phase refactor-deferred --refactor-rationale "<why>"\`): behavior-preserving cleanup, only after GREEN is proven
70
- - \`--phase doc\`: write \`<artifacts-dir>/tdd-slices/S-<id>.md\` for the slice
71
-
72
- Set \`CCLAW_ACTIVE_AGENT\` to the active phase name when possible so workflow-guard
73
- can enforce phase-appropriate write boundaries. The mandatory gate is the evidence-backed \`slice-builder\` row for delegated topologies, not multiple default subagents. When TDD topology is \`inline\`, the controller may skip the builder but must preserve the same RED-before-GREEN, AC traceability, path containment, verification, managed commit/worktree, lockfile twin, and orphan-change gates.
74
-
75
- ## Model & Harness Routing Notes
76
-
77
- ### Harness routing
78
-
79
- | Harness | Fallback | Delegation tool | Structured ask | Capability source |
80
- |---|---|---|---|---|
81
- | Claude | \`native\` | Task (named subagent_type) | AskUserQuestion | \`npx cclaw-cli sync\` |
82
- | Cursor | \`generic-dispatch\` | Task (generic subagent_type: explore/generalPurpose/…) | AskQuestion | \`npx cclaw-cli sync\` |
83
- | OpenCode | \`native\` | generated \`.opencode/agents/<agent>.md\` subagents via Task / \`@agent\` mention | \`question\` (permission-gated; \`permission.question: "allow"\`) | \`npx cclaw-cli sync\` |
84
- | Codex | \`native\` | generated \`.codex/agents/<agent>.toml\` custom agents via native parallel subagent spawning | \`request_user_input\` (experimental; Plan / Collaboration mode) | \`npx cclaw-cli sync\` |
85
-
86
- **Dispatch rules driven by \`subagentFallback\`:**
87
-
88
- - \`native\` — use the harness's own named subagent primitive; delegation entry uses \`fulfillmentMode: "isolated"\`.
89
- - \`generic-dispatch\` — map each cclaw agent onto the generic dispatcher with a role prompt; delegation entry uses \`fulfillmentMode: "generic-dispatch"\`.
90
- - \`role-switch\` — degraded fallback only when the active runtime cannot expose its declared dispatch surface. Announce the role in-session, perform the work, append a delegation row with \`fulfillmentMode: "role-switch"\` and ≥1 \`evidenceRef\`. Without evidenceRefs the \`delegation:mandatory:current_stage\` check reports \`missingEvidence\` and blocks stage completion.
91
-
92
- ### Native dispatch contract
93
-
94
- Use real harness subagents for OpenCode and Codex:
95
-
96
- 1. OpenCode: invoke the generated \`.opencode/agents/<agent>.md\` subagent via Task or \`@<agent>\`. Built-in \`general\` / \`explore\` remain fallback subagent types for ad hoc tasks, but cclaw's core roles are generated by name.
97
- 2. Codex: ask Codex to spawn the generated \`.codex/agents/<agent>.toml\` custom agent(s) by name; for review-style independent lanes, request parallel spawning and wait for all results before reconciliation.
98
- 3. Claude: use the native named Task subagent. Cursor: map the cclaw role onto the generic Task/Subagent surface with a self-contained prompt.
99
- 4. Produce stage output in the current artifact, with anchors suitable for \`evidenceRefs\`.
100
- 5. Append delegation ledger rows with \`stage\`, \`agent\`, \`mode\`, \`status: "completed"\`, and \`fulfillmentMode\` matching the dispatch mode (\`"isolated"\` for Claude/OpenCode/Codex, \`"generic-dispatch"\` for Cursor).
101
-
102
- The only time a \`harness_limitation\` waiver fires automatically is when every installed harness declares \`subagentFallback: "waiver"\`. Do not map Codex or OpenCode onto auto-waiver or default role-switch; they have true subagent surfaces.
103
-
104
- ### Model routing
105
-
106
- - **Use a faster model** for bounded, deterministic tasks (single slice implementation, mechanical refactors, straightforward lint/test fixes).
107
- - **Use a more capable model** for high-ambiguity or high-risk analysis (security review, architecture conflicts, spec contradiction resolution).
108
- - During review-heavy stages, prefer **mixed routing**: faster first-pass triage + escalate only high-severity/low-confidence findings.
109
-
110
- ### Cost-aware routing (tier table)
111
-
112
- | Tier | Use for | Example agents |
113
- |---|---|---|
114
- | \`deep\` | one heavy reasoning pass per stage (planner, final reconciliation) | planner |
115
- | \`balanced\` | spec compliance + code/security review with enough context | reviewer, security-reviewer, slice-builder |
116
- | \`fast\` | bounded maintenance updates and doc hygiene | doc-updater |
117
-
118
- **Routing rules:**
119
- - At most ONE \`deep\` agent per stage (planner OR final reconciliation, not both).
120
- - \`balanced\` agents are default for review-stage specialists.
121
- - \`fast\` agents are the only tier you should fan out in parallel (3-5 at a time is fine).
122
- - Never escalate a \`fast\` agent's output directly to ship decisions — always have a \`balanced\` reviewer consume the evidence first.
123
-
124
- ### Per-stage routing triggers
125
-
126
- Concrete per-stage rules so the controller does not have to guess which tier fits each dispatch. These are defaults; explicit user overrides always win.
127
-
128
- | Stage | Deep slot | Balanced slot(s) | Fast fan-out | Trigger to escalate |
129
- |---|---|---|---|---|
130
- | brainstorm | planner (only if ambiguity spans >1 module) | product-discovery / critic when product value or premise is uncertain | run in-thread research playbooks | promote to \`balanced\` critic if the do-nothing path may beat the idea |
131
- | scope | planner (always) | product-discovery / critic when mode changes value, trajectory, or boundaries | run \`research/git-history.md\` in-thread when churn is high | promote to \`balanced\` critic if scope mode is disputed |
132
- | design | planner (always) | critic, security-reviewer when alternatives/trust apply | run \`research/framework-docs-lookup.md\` + \`research/best-practices-lookup.md\` in-thread | escalate one specialist to \`deep\` only if a failure mode is Critical-severity |
133
- | spec | — | spec-validator / spec-document-reviewer / reviewer (for long or high-risk specs) | — | escalate to \`deep\` only for spec ↔ design contradictions |
134
- | plan | planner (solo, always) | — | — | never fan out at plan stage; one owner for dependency graph |
135
- | tdd | — | ${formatAgentList(stageSummary("tdd").primaryAgents)} (per slice, carrying RED/GREEN/REFACTOR evidence) · reviewer (slice-local only when sliceReview triggers) | doc-updater (API surface changes) | escalate to \`deep\` only when a RED test cannot be expressed (design leak) |
136
- | review | — | ${formatAgentList(stageSummary("review").mandatoryAgents)} (both mandatory) | doc-updater for release-note drift checks | escalate a \`balanced\` reviewer to \`deep\` only when two reviewers disagree on severity |
137
- | ship | — | ${formatAgentList(stageSummary("ship").proactiveAgents)} (if blast radius is high) | doc-updater (changelog/migration notes) | escalate to \`balanced\` reviewer only if preflight finds a regression |
138
-
139
- **De-escalation rules (avoid over-spending):**
140
- - If a \`deep\` planner run returns low-uncertainty output (single unambiguous plan), do **not** add a second \`deep\` pass in the same stage.
141
- - If a \`fast\` researcher's evidence is the only input to a decision, the consuming agent must be \`balanced\` or higher.
142
- - Review-stage reviewers should default to \`balanced\`; bump to \`deep\` only when findings cite architectural contradictions.
143
- - Refactor-only TDD slices (state-based, no behavioral change) can drop \`slice-builder\` to \`fast\` if the test pyramid stays green.
144
-
145
- ## HARD-GATE
146
-
147
- ${conversationLanguagePolicyMarkdown()}
148
- **Never dispatch a subagent without a concrete, self-contained task description pasted into the prompt. Do not pass file references the subagent must read to understand its task.**
149
-
150
- If you catch yourself writing “read PLAN.md Task 3” or “implement the next unchecked item,” stop: expand the work into explicit text in the Task body before dispatching.
151
-
152
- ## Anti-Drift Team Defaults
153
-
154
- Borrow the good part of Team/Ruflo-style orchestration without adding a swarm runtime:
155
-
156
- - **One controller owns alignment.** The parent keeps the task list, gate state, and final synthesis.
157
- - **Small fan-out by topology.** Run at most configured \`maxBuilders\` parallel builders, and only for independent substantial units or independent read-only research/review lenses.
158
- - **No parallel writes to adjacent surfaces.** If tasks may touch the same module, serialize them.
159
- - **Checkpoint before synthesis.** Each agent returns status, files inspected/changed, evidence, and blockers before the parent acts.
160
- - **Consensus is for hard calls only.** Use two reviewers when severity or architecture is disputed; otherwise one evidence-backed reviewer is enough.
161
- - **Multi-wave persistence uses the executing-waves skill.** For 2+ wave efforts, maintain \`.cclaw/wave-plans/\` and run carry-forward drift audits in brainstorm.
162
-
163
- ## Parallelization Decision Gate
164
-
165
- Before parallel dispatch, answer yes to all gates: tasks are independent, write sets do not overlap, outputs can be reconciled by evidence, and failure in one lane will not invalidate hidden assumptions in another. If any answer is no, serialize. Coder/overseer work is contract-first: the coder implements only the pasted contract, the overseer reads code and verifies acceptance evidence before the controller marks work complete.
166
-
167
- ## When to Use
168
-
169
- - Mid/large plans with multiple discrete tasks, dependencies, or risky overlap.
170
- - Complex features where isolation prevents parent-session context pollution.
171
- - Situations where **fresh tool context** is cheaper than incremental patching in one mega-thread.
172
- - When reviews should be adversarial to claims (“show me the code”), not collegial summaries.
173
-
174
- ## Full Protocol
175
-
176
- 1. **Read plan, extract all tasks with full text**
177
- - Copy each task verbatim into a working queue (checklist is fine).
178
- - Normalize each task so it includes: goal, acceptance criteria, constraints, and explicit “out of scope.”
179
-
180
- 2. **For each unit — cheapest safe topology first; parallel only with cohesion controls:**
181
- - Implementation subagents are sequential by default. Parallel implementers
182
- are allowed only when ALL three conditions hold:
183
- - (a) the lanes touch non-overlapping files (verify via the plan's task
184
- file-set list before dispatch),
185
- - (b) the controller passes \`--allow-parallel\` on each ledger row, and
186
- - (c) an \`integration-overseer\` is dispatched after the parallel lanes
187
- complete and writes cohesion-evidence (cross-file integration tests,
188
- contract checks, or merge-conflict scan) into the artifact before any
189
- gate is marked passed.
190
- If any of the three conditions are unmet, serialize.
191
- 1. **Dispatch implementer subagent** with the **full task text pasted in** (not a file reference).
192
- 2. **Check return status:** \`DONE\` / \`DONE_WITH_CONCERNS\` / \`NEEDS_CONTEXT\` / \`BLOCKED\`
193
- 3. If \`DONE\`: dispatch **reviewer** subagent to verify actual code matches spec and quality expectations.
194
- 4. If spec review **FAIL**: dispatch **fixer subagent** (a **new** agent — not an inline patch from the parent — to avoid context pollution).
195
- 5. Dispatch **code-quality reviewer** (maintainability/PR hygiene).
196
- 6. **Mark task complete** only after concerns are triaged or explicitly accepted with rationale.
197
-
198
- 3. **After all tasks:** dispatch **final code reviewer** for a full-repo / full-surface pass (what escaped local task boundaries).
199
-
200
- 4. **Transition to finishing workflow** (ship checklist, changelog, migration notes) once reviewers show no unresolved Criticals.
201
-
202
- ## Status Contract
203
-
204
- | Status | Meaning | Controller action |
205
- |---|---|---|
206
- | DONE | Implementation complete; tests orchestrated per prompt; no known material risks | Proceed to reviewers |
207
- | DONE_WITH_CONCERNS | Shippable but with documented tradeoffs/risks | Proceed with reviewer + explicit notes; do not dismiss concerns |
208
- | NEEDS_CONTEXT | Missing authoritative information only the parent/user can supply | Parent gathers context, then re-dispatch implementer with augmented prompt |
209
- | BLOCKED | Hard stop (permissions, tool failure, conflicting requirements, unsafe state) | Parent escalates to user; do not stack speculative guesses |
210
-
211
- ## Strict Worker Return Schemas
212
-
213
- Every delegated worker must return one terminal status and the listed evidence fields. Prefer JSON fenced as \`json\`; prose may follow only after the object.
214
-
215
- ### Implementer / fixer return
216
-
217
- ${MARKDOWN_CODE_FENCE}json
218
- {
219
- "status": "DONE|DONE_WITH_CONCERNS|NEEDS_CONTEXT|BLOCKED",
220
- "filesChanged": ["path"],
221
- "testsRun": [{ "command": "string", "result": "PASS|FAIL|NOT_RUN", "evidence": "short excerpt or reason" }],
222
- "evidenceRefs": [".cclaw/artifacts/<file>#anchor"],
223
- "concerns": ["string"],
224
- "needsContext": ["string"],
225
- "blockers": ["string"]
226
- }
227
- ${MARKDOWN_CODE_FENCE}
228
-
229
- ### Reviewer return
230
-
231
- ${MARKDOWN_CODE_FENCE}json
232
- {
233
- "status": "PASS|PASS_WITH_GAPS|FAIL|BLOCKED",
234
- "findings": [{ "severity": "Critical|Important|Suggestion", "location": "file:line", "problem": "string", "recommendation": "string" }],
235
- "criteria": [{ "id": "string", "verdict": "PASS|PARTIAL|FAIL", "evidence": "file:line" }],
236
- "evidenceRefs": [".cclaw/artifacts/<file>#anchor"],
237
- "blockers": ["string"]
238
- }
239
- ${MARKDOWN_CODE_FENCE}
240
-
241
- ### Lifecycle evidence
242
-
243
- Before dispatch, create or reserve a delegation span (\`status: "scheduled"\`, \`spanId\`, \`startTs\`, optional \`taskId\`). On return, append a terminal row for the same \`spanId\` with \`endTs\`, \`status\`, \`fulfillmentMode\`, and non-empty \`evidenceRefs\` whenever the worker was generic-dispatch or role-switch. A scheduled span without a terminal row in the current run is stale and must be resolved before claiming the stage is complete.
244
-
245
- ## Implementer Prompt Template (paste into Task tool)
246
-
247
- ${MARKDOWN_CODE_FENCE}
248
- You are implementing a single task from a development plan.
249
-
250
- TASK: {paste full task text here}
251
- CONTEXT: {paste relevant file paths, types, patterns}
252
- CONSTRAINTS: {paste from spec — what NOT to do}
253
-
254
- After implementation:
255
- 0. Write user-facing narrative in the parent/user language; keep status tokens unchanged.
256
- 1. Run the relevant test suite or explain why it was not run.
257
- 2. Return the strict implementer/fixer JSON schema first.
258
- 3. If DONE_WITH_CONCERNS, list each concern in \`concerns\`.
259
- 4. If NEEDS_CONTEXT, specify exactly what you need in \`needsContext\`.
260
- ${MARKDOWN_CODE_FENCE}
261
-
262
- ## Spec-Reviewer Prompt Template (paste into Task tool)
263
-
264
- ${MARKDOWN_CODE_FENCE}
265
- Review the implementation against the specification.
266
-
267
- SPEC CRITERIA: {paste acceptance criteria}
268
- FILES CHANGED: {list files}
269
-
270
- For each criterion: PASS / FAIL / PARTIAL with evidence (file:line).
271
- Do NOT trust the implementer's self-report — read the actual code.
272
- ${MARKDOWN_CODE_FENCE}
273
-
274
- ## Anti-patterns
275
-
276
- - Launching **parallel implementation** subagents that may touch the same files or adjacent modules.
277
- - Passing a **plan file path** instead of pasting the **exact task text** for the subagent.
278
- - Accepting implementer “done” claims without **spec review evidence** grounded in code.
279
- - **Patching inline** in the parent when review fails — instead of dispatching a **fresh fixer** subagent.
280
-
281
- ## Critical Rules
282
-
283
- - **Context isolation:** subagent receives crafted instructions only — **not** the parent session’s scratchpad/history.
284
- - **Never trust the implementer:** reviewers verify against **code** and tests, not narrative self-report.
285
- - **One task at a time:** sequential implementations prevent conflicting writes; keep parallelism for analysis/review patterns only (see \`dispatching-parallel-agents\`).
286
- - **Fixer = new agent:** if spec review fails, dispatch a fresh fixer subagent; avoid “repair drift” in the parent context.
287
-
288
- ## Common Rationalizations
289
-
290
- | Rationalization | Reality |
291
- |---|---|
292
- | “They can read the plan file — it’s faster.” | File indirection hides scope and invites partial reads; paste task text. |
293
- | “I'll spin up two implementers — they're independent.” | False independence causes merge conflicts and duplicated edits. |
294
- | “The implementer ran tests and said PASS.” | Re-run or have reviewers demand fresh evidence; narratives lie by omission. |
295
- | “I'll patch quickly myself; same outcome.” | Parent context fills with fix chatter, undermining later reviews. |
296
-
297
- ## Red Flags
298
-
299
- - Task prompts shorter than the acceptance criteria they are supposed to satisfy.
300
- - Implementer returns PASS with **no** commands run or outputs excerpted.
301
- - Multiple agents concurrently editing overlapping directories.
302
- - Review summaries without \`file:line\` anchors for FAIL/PARTIAL.
303
- - “Done” without a spec reviewer pass when requirements were non-trivial.
304
-
305
- ## Controller Responsibilities (non-delegatable)
306
-
307
- - Maintain the **authoritative task queue** and ensure each dispatch uses **verbatim** task text.
308
- - Decide when concerns are **acceptable** vs require rework; record that decision explicitly for auditability.
309
- - Keep parent-session narration **thin**: prefer pointers to artifacts (diffs, logs) over long prose.
310
- - After any fixer pass, **re-run** spec review until PASS or explicit user acceptance of residual gaps.
311
-
312
- ## Evidence Requirements
313
-
314
- - **Tests:** implementer must name the command and show representative output (pass/fail excerpt).
315
- - **Reviews:** every FAIL/PARTIAL cites \`file:line\` and quotes the smallest code span needed.
316
- - **Fixers:** must restate the failing criterion and demonstrate closure with new evidence (not “trust me”).
317
-
318
- ## Code-Quality Reviewer Prompt Template (paste into Task tool)
319
-
320
- ${MARKDOWN_CODE_FENCE}
321
- You are a code-quality reviewer (subagent) after a single SDD task.
322
-
323
- SCOPE: {files touched by this task}
324
- RISK CONTEXT: {data sensitivity, concurrency, backwards compatibility notes}
325
-
326
- Review for maintainability and ship hygiene across:
327
- - correctness edges not covered by spec language
328
- - readability and naming coherence with surrounding code
329
- - architecture fit (layering, boundaries)
330
- - obvious security/perf smells (deep dives belong elsewhere)
331
-
332
- Output:
333
- - FINDINGS: severity, file:line, issue, recommendation
334
- - VERDICT: APPROVE | APPROVE_WITH_NITS | REWORK_REQUIRED
335
- ${MARKDOWN_CODE_FENCE}
336
-
337
- ## Fixer Subagent Prompt Template (after spec review FAIL)
338
-
339
- ${MARKDOWN_CODE_FENCE}
340
- You are a fixer subagent. You are NOT the original implementer.
341
-
342
- FAILING CRITERION (verbatim): {paste failed criterion}
343
- EVIDENCE: {reviewer citations: file:line + short quotes}
344
- ALLOWED FILES: {explicit list — do not expand scope silently}
345
- FORBIDDEN CHANGES: {compatibility / API stability constraints}
346
-
347
- Process:
348
- 1) Reproduce the gap with a test or minimal repro as appropriate.
349
- 2) Implement the smallest fix that satisfies the criterion.
350
- 3) Run the full test suite.
351
- 4) Report STATUS: DONE / DONE_WITH_CONCERNS / NEEDS_CONTEXT / BLOCKED with evidence excerpts.
352
- ${MARKDOWN_CODE_FENCE}
353
-
354
- ## Final Code Reviewer Prompt Template (post-queue sweep)
355
-
356
- ${MARKDOWN_CODE_FENCE}
357
- You are the final code-quality reviewer after ALL SDD tasks completed.
358
-
359
- ENTIRE CHANGESET: {summary + primary entrypoints}
360
- INTEGRATION RISKS: {cross-module assumptions, migrations, rollout}
361
-
362
- Goals:
363
- - Find issues that only appear at integration scale (duplicated helpers, drift, inconsistent error handling).
364
- - Confirm global invariants (build, types, lint policy) were not violated opportunistically.
365
-
366
- Deliver:
367
- - TOP_FINDINGS (merge blockers first)
368
- - CONSISTENCY_PASS/FAIL with rationale
369
- - SHIP_RECOMMENDATION: SHIP | SHIP_WITH_FOLLOWUPS | NO_SHIP
370
- ${MARKDOWN_CODE_FENCE}
371
-
372
- ## Glossary
373
-
374
- - **Controller:** parent agent orchestrating dispatches (this document assumes you).
375
- - **Implementer:** single-task coding subagent.
376
- - **Spec reviewer:** acceptance-criteria auditor over code.
377
- - **Code-quality reviewer:** PR hygiene / maintainability auditor.
378
- - **Fixer:** fresh subagent after failed spec review (never “parent hotfix” by default).
379
- `;
380
- }
381
- export function parallelAgentsSkill() {
382
- return `---
383
- name: dispatching-parallel-agents
384
- description: "Launch multiple investigation or review agents in parallel for independent problem domains."
385
- ---
386
-
387
- # Dispatching Parallel Agents
388
-
389
- ## Overview
390
-
391
- Parallel agents are a **fan-out / fan-in** tactic: split a problem into **independent lenses**, delegate each lens in **parallel**, then **reconcile** outputs into a single coherent decision record.
392
-
393
- This document bridges **Superpowers-style task isolation** with the **gstack “Review Army”** pattern: many cheap specialists, structured outputs, and confidence-scored synthesis.
394
-
395
- ## HARD-GATE
396
-
397
- ${conversationLanguagePolicyMarkdown()}
398
- **Default rule:** parallel implementation agents are SAFE for investigation, analysis, review, and the **TDD wave-fanout** path; otherwise keep implementation sequential.
399
-
400
- **TDD wave-fanout is the supported parallel-implementation path.** When \`cclaw-cli internal wave-status --json\` reports \`topology: parallel-builders\` and \`pathConflicts: []\`, fan out one \`slice-builder\` span per ready feature-atomic unit/slice in a single controller message, capped by \`maxBuilders\`. Each span owns its disjoint \`claimedPaths\`; the dispatcher rejects overlapping spans with \`DispatchOverlapError\` inline, so the disjoint-paths invariant is enforced for you.
401
-
402
- **Outside wave-fanout** — for ad-hoc parallel implementation that touches shared source trees — keep work **sequential** unless you have proven disjoint filesystem ownership and an explicit merge protocol.
403
-
404
- ## When to Use
405
-
406
- - **Independent investigations** (perf vs correctness vs dependency hygiene) with separated code neighborhoods.
407
- - **Multi-specialist review** where reviewers must not contaminate each other’s first impressions.
408
- - **Parallel test/log analysis** across unrelated failures (distinct subsystems).
409
-
410
- ## Model & Harness Routing Notes
411
-
412
- ### Harness routing
413
-
414
- - Launch all parallel Task calls in a **single message** only on harnesses that support concurrent delegation.
415
- - If the harness cannot safely fan out parallel delegations, run lenses sequentially and preserve the same reconciliation schema.
416
- - For harnesses without structured ask tools, put reconciliation decisions as explicit numbered options in chat and wait for user selection on blockers.
417
-
418
- ### Model routing
419
-
420
- - **Faster model:** broad first-pass scans, duplicate detection, low-risk normalization.
421
- - **More capable model:** conflict reconciliation, architectural contradiction analysis, security-critical tie-breaks.
422
- - Escalation trigger: any finding that is \`Critical\`, contradictory across specialists, or confidence <5 with potential ship impact.
423
-
424
- ## Dispatch Protocol
425
-
426
- 1. **Identify independent problem domains** (no file overlap; no shared mutable working assumptions).
427
- 2. **Author a cohesion contract** only when fan-out touches **shared interfaces or shared types** between slices in the same wave. For TDD wave-fanout where every member's \`claimedPaths\` are disjoint, a cohesion contract is NOT required — the disjoint-paths invariant plus the \`integration-overseer\` post-fan-in audit cover the integration risk.
428
- 3. **Craft one prompt per domain** with **full context pasted** — same HARD-GATE as SDD: no “go read X to learn why.”
429
- 4. **Launch ALL agents in a single controller message** (multiple Task tool calls) so they start with comparable timelines.
430
- 5. **Wait for all to return** before synthesis (avoid incremental confirmation bias).
431
- 6. **Run integration-overseer after fan-in** to verify touchpoints, boundary types, invariants, and integration-test outcomes.
432
- 7. **Reconcile results:** deduplicate findings, merge overlaps, and **conflict-check** contradictions explicitly.
433
- 8. **Run the full test suite after any code changes** — parallel analysis may propose edits; verification stays mandatory.
434
-
435
- ## Review Army Pattern (gstack)
436
-
437
- - **Select specialists based on diff content** (security vs data model vs UX vs API compatibility).
438
- - **Launch in parallel** via multiple Task tool calls (one specialist = one Task payload).
439
- - **Collect findings as structured data** (severity, location, confidence, repro brief).
440
- - **Fingerprint dedup:** if the same finding is reported by **two or more** independent specialists, mark it **MULTI-SPECIALIST CONFIRMED** and **+1** confidence vs a singleton.
441
- - **Confidence bands (presentation):**
442
- - **7+:** headline in the main report / merge-blocking if severity warrants
443
- - **5–6:** headline with explicit caveat language (“single-lens evidence”)
444
- - **3–4:** appendix / “worth tracking” section (not merge-blocking alone)
445
- - **1–2:** suppress from primary narrative unless paired with stronger evidence
446
-
447
- ### Review Army Artifact Contract (required in review stage via /cc)
448
-
449
- Write a structured reconciliation artifact at \`.cclaw/artifacts/07-review-army.json\` using this schema:
450
-
451
- ${MARKDOWN_CODE_FENCE}json
452
- {
453
- "version": 1,
454
- "generatedAt": "ISO timestamp",
455
- "scope": { "base": "branch", "head": "branch", "files": ["..."] },
456
- "findings": [
457
- {
458
- "id": "stable-id",
459
- "severity": "Critical|Important|Suggestion",
460
- "confidence": 1,
461
- "fingerprint": "hash-or-stable-key",
462
- "reportedBy": ["reviewer", "security-reviewer"],
463
- "status": "open|accepted|resolved",
464
- "location": { "file": "path", "line": 123 },
465
- "recommendation": "..."
466
- }
467
- ],
468
- "reconciliation": {
469
- "duplicatesCollapsed": 0,
470
- "conflicts": [],
471
- "multiSpecialistConfirmed": [],
472
- "shipBlockers": []
473
- }
474
- }
475
- ${MARKDOWN_CODE_FENCE}
476
-
477
- Contract rules:
478
- - \`id\` and \`fingerprint\` must be stable between reruns if the finding is unchanged.
479
- - \`reportedBy\` must include every specialist that independently flagged the issue.
480
- - \`multiSpecialistConfirmed\` lists finding IDs confirmed by 2+ specialists.
481
- - \`shipBlockers\` must include all unresolved \`Critical\` finding IDs.
482
-
483
- ## Reconciliation Protocol
484
-
485
- 1. **Normalize** each agent output into a finding list with stable IDs (hash of filepath + rule + message).
486
- 2. **Merge duplicates** by fingerprint; annotate confirmations from multiple specialists.
487
- 3. **Resolve conflicts** where agents disagree: prefer **evidence-backed** conclusions; if inconclusive, state **UNKNOWN** and propose a single follow-up measurement (bench, test, threat model detail).
488
- 4. **Prioritize** by ship risk (data loss, authz, corruption) then by blast radius.
489
- 5. **Emit** a single “Decision Record” the implementer can execute sequentially.
490
-
491
- ## Anti-patterns
492
-
493
- - Treating parallel Task launches as a **race to commit**.
494
- - **Parallel implementation agents** sharing a repo without strict file partitioning.
495
- - **Shared mutable state** between agents (scratchpads in the same artifact without merge rules).
496
-
497
- ## When NOT to Use
498
-
499
- - Any task that **implements** production behavior (use SDD sequential implementers instead).
500
- - Workstreams with **hard file dependencies** (Agent B needs Agent A’s edits to compile).
501
- - Small single-file tweaks where orchestration overhead exceeds benefit.
502
-
503
- ## Quick Reference Table
504
-
505
- | Mode | Parallel allowed? | Typical tooling |
506
- |---|---|---|
507
- | Investigation | Yes (disjoint) | Multiple Task calls |
508
- | Review | Yes (disjoint lenses) | Multiple Task calls |
509
- | Implementation | **No** (same codebase) | Sequential Task calls |
510
-
511
- ## Controller Checklist (before parallel launch)
512
-
513
- - Each prompt contains **all** needed instructions (no “read plan” indirection).
514
- - Domains are **provably non-overlapping** in touched paths.
515
- - You have a reconciliation plan (dedupe + conflict rules + confidence bands).
516
-
517
- ## Task Payload Hygiene (parallel-safe)
518
-
519
- - Start each payload with **ROLE + SCOPE + OUTPUT SCHEMA** (same order every time).
520
- - Include **hard boundaries**: directories allowed/forbidden to read, max depth, and “do not edit.”
521
- - Ask for **structured sections** (\`FINDINGS\`, \`CONFIDENCE\`, \`UNKNOWN\`) to simplify merging.
522
- - Prefer **deterministic prompts** over creative prose — you are building evidence, not vibes.
523
-
524
- ## Specialist Roster (examples — pick what matches the diff)
525
-
526
- | Specialist lens | Looks for… | Typical inputs |
527
- |---|---|---|
528
- | Security | authz, injection, SSRF, secrets, trust boundaries | routes, parsers, middleware |
529
- | Data model | invariants, migrations, idempotency, consistency | schema, repositories, jobs |
530
- | API compatibility | breaking changes, versioning, error contracts | public types, OpenAPI, clients |
531
- | Performance | hot loops, IO, caching mistakes | hotspots, benchmarks, traces |
532
- | UX / a11y | state bugs, focus traps, i18n | components, flows |
533
- | Observability | logs/metrics/traces correctness | instrumentation, alerts |
534
-
535
- ## Confidence Scoring Rubric (0–10)
536
-
537
- - **10:** reproduced locally with deterministic steps + code citation + multi-specialist confirmation.
538
- - **8–9:** strong code citation + plausible exploit/bug class; single specialist but excellent evidence.
539
- - **5–7:** plausible issue worth tracking; needs confirmation test or owner review.
540
- - **3–4:** hypothesis-level; do not merge-block without corroboration.
541
- - **0–2:** intuition / style; suppress unless paired with stronger evidence.
542
-
543
- ## Merge-Blocking Rules (after reconciliation)
544
-
545
- - Any **MULTI-SPECIALIST CONFIRMED** **Critical** is merge-blocking until resolved or explicitly waived by the user.
546
- - Conflicting conclusions at **Critical** severity require a tie-break experiment (test/bench) — never guess.
547
- - If reconciliation yields **UNKNOWN** for ship safety, treat as **BLOCKED** until measured.
548
-
549
- ## Post-Reconcile Actions (controller)
550
-
551
- 1. Publish a single **merged report** with headline / caveat / appendix bands applied.
552
- 2. Convert findings into **sequential SDD tasks** if code changes are required.
553
- 3. If no code changes: still run **sanity checks** appropriate to the repo (typecheck/lint spot).
554
-
555
- ## Parallel Review Task Template (paste into Task tool)
556
-
557
- ${MARKDOWN_CODE_FENCE}
558
- You are an independent review/investigation subagent.
559
-
560
- LENS: {security|data|perf|api|ux|observability — pick one}
561
- SCOPE: {explicit paths/modules}
562
- QUESTION: {one primary question — falsifiable}
563
- DELIVERABLE: structured findings with confidence 0–10 each
564
-
565
- Rules:
566
- - Do not edit files unless explicitly authorized in this prompt.
567
- - Cite evidence as file:line for every finding.
568
- - If uncertain, emit CONFIDENCE <= 4 and label as hypothesis.
569
- ${MARKDOWN_CODE_FENCE}
570
-
571
- ## Worked Example (narrative)
572
-
573
- A large refactor touches **auth middleware** and **repository queries**. The controller launches parallel reviewers: **security**, **data model**, **API compatibility**. Security finds a possible IDOR (confidence 6); data model finds a migration hazard (confidence 7); API finds a breaking error shape (confidence 8). Fingerprints show no duplicates. Reconciliation merge-blocks on the API break (single specialist but high confidence + citation). Security’s IDOR is downgraded to appendix until a second specialist confirms — later confirmed by **perf** reviewer noticing an extra query path — now **MULTI-SPECIALIST CONFIRMED**, confidence becomes **8** and moves to headline.
574
-
575
- ## Relationship to SDD
576
-
577
- - Parallel agents produce **evidence and prioritized tasks**.
578
- - SDD **implements** those tasks **one at a time** with sequential implementers.
579
- - Never parallelize **writers** on the same codebase; parallelize **readers/analysts** with disjoint scopes.
580
- `;
581
- }
582
- function researcherEnhancedBody() {
583
- return `
584
-
585
- ## Task Tool Delegation
586
-
587
- Use this payload when a stage needs context-readiness or search-before-read evidence:
588
-
589
- ${MARKDOWN_CODE_FENCE}
590
- You are a researcher subagent.
591
-
592
- SCOPE — External plus internal research: search official docs/libraries/prior art and current best practices (use web or package-index tooling whenever it is live; cite URLs or authoritative references). Internally scan the repo for commits, manifests, conventions, migrations, configuration, and latent decisions—even when the workspace is sparse, external benchmarking stays mandatory.
593
-
594
- QUESTION: {one falsifiable research question}
595
- SCOPE: {repo paths, docs, references, providers to inspect}
596
- CONTEXT READINESS: {graph/search/provider status if known}
597
-
598
- Required output:
599
- - SEARCH_SUMMARY: queries/patterns/providers tried before large reads
600
- - FACTS: evidence-backed findings with refs
601
- - STALE_OR_MISSING_CONTEXT: gaps and recommended recovery
602
- - DECISION_IMPACT: what stage decision this changes
603
- ${MARKDOWN_CODE_FENCE}
604
-
605
- `;
606
- }
607
- function architectEnhancedBody() {
608
- return `
609
-
610
- ## Task Tool Delegation
611
-
612
- ${MARKDOWN_CODE_FENCE}
613
- You are an architect subagent.
614
-
615
- DESIGN_DECISION: {architecture decision to validate}
616
- SCOPE_CONTRACT: {approved boundaries}
617
- BLAST_RADIUS: {paths/modules/interfaces}
618
-
619
- Required output:
620
- - BOUNDARIES: chosen ownership and interface contracts
621
- - ALTERNATIVES: rejected alternatives and revival signals
622
- - FAILURE_MODES: method/exception/rescue/user-visible impact
623
- - SPEC_HANDOFF: requirements and verification evidence downstream spec must carry
624
- ${MARKDOWN_CODE_FENCE}
625
-
626
- `;
627
- }
628
- function specValidatorEnhancedBody() {
629
- return `
630
-
631
- ## Task Tool Delegation
632
-
633
- ${MARKDOWN_CODE_FENCE}
634
- You are a spec-validator subagent.
635
-
636
- ACCEPTANCE_CRITERIA: {criteria to validate}
637
- UPSTREAM_DECISIONS: {design/scope refs}
638
-
639
- Required output:
640
- - CRITERIA_AUDIT: PASS/PARTIAL/FAIL per AC with reason
641
- - EDGE_CASE_GAPS: boundary/error cases missing
642
- - ASSUMPTION_GAPS: assumptions requiring approval or rewrite
643
- - TESTABILITY_MAP: concrete test level and command/manual evidence per AC
644
- ${MARKDOWN_CODE_FENCE}
645
-
646
- `;
647
- }
648
- function specDocumentReviewerEnhancedBody() {
649
- return `
650
-
651
- ## Task Tool Delegation
652
-
653
- Use this payload for final spec-document quality checks before plan handoff:
654
-
655
- ${MARKDOWN_CODE_FENCE}
656
- You are a spec-document-reviewer subagent.
657
-
658
- SPEC_ARTIFACT: {04-spec excerpt or full body}
659
- UPSTREAM_CONTEXT: {scope/design refs used by the spec}
660
-
661
- Required output:
662
- - DOCUMENT_VERDICT: PASS | PASS_WITH_GAPS | FAIL | BLOCKED
663
- - COMPLETENESS_CHECK: missing required sections or weakly populated rows
664
- - CONSISTENCY_CHECK: contradictions across ACs, assumptions, mapping, and approval
665
- - CLARITY_CHECK: ambiguity/placeholders/two-way wording to rewrite
666
- - SCOPE_FIT_CHECK: whether the artifact still maps to one coherent subsystem/plan slice
667
- - PATCH_RECOMMENDATIONS: minimal edits to make the spec plan-ready
668
- ${MARKDOWN_CODE_FENCE}
669
-
670
- `;
671
- }
672
- function performanceReviewerEnhancedBody() {
673
- return `${codeReviewerEnhancedBody()}
674
-
675
- ## Performance Lens
676
-
677
- Focus on hot paths, IO/network calls, repeated work, caching, data volume, rendering, and algorithmic complexity. Include measurement evidence or a concrete measurement plan for every non-trivial finding.
678
- `;
679
- }
680
- function compatibilityReviewerEnhancedBody() {
681
- return `${codeReviewerEnhancedBody()}
682
-
683
- ## Compatibility Lens
684
-
685
- Focus on public APIs, CLI/config shape, persisted data, migrations, generated clients, dependency/runtime versions, and backwards-compatibility obligations. Distinguish shipped behavior from in-branch churn.
686
- `;
687
- }
688
- function observabilityReviewerEnhancedBody() {
689
- return `${codeReviewerEnhancedBody()}
690
-
691
- ## Observability Lens
692
-
693
- Focus on logs, metrics, traces, alerts, debug paths, rollout visibility, and support handoff. Block only when missing visibility affects diagnosis, rollback, or user/data safety.
694
- `;
695
- }
696
- function releaseReviewerEnhancedBody() {
697
- return `
698
-
699
- ## Task Tool Delegation
700
-
701
- ${MARKDOWN_CODE_FENCE}
702
- You are a release-reviewer subagent.
703
-
704
- SHIP_ARTIFACT: {ship/preflight evidence}
705
- REVIEW_VERDICT: {review status and blockers}
706
- FINALIZATION_MODE: {selected enum}
707
-
708
- Required output:
709
- - PREFLIGHT: commands and PASS/FAIL evidence freshness
710
- - VICTORY_DETECTOR: feature coverage, evaluator evidence, clean state, learnings, handoff
711
- - ROLLBACK: trigger, steps, owner, and no-VCS handoff if applicable
712
- - SHIP_VERDICT: SHIP | SHIP_WITH_CONCERNS | BLOCKED
713
- ${MARKDOWN_CODE_FENCE}
714
-
715
- `;
716
- }
717
- function plannerEnhancedBody() {
718
- return `
719
-
720
- ## Task Tool Delegation
721
-
722
- When a planning problem is too broad for one message, delegate **planning subtasks** via the Task tool — still without parallelizing conflicting file reads if your harness shares caches.
723
-
724
- Paste the template below verbatim and fill \`{placeholders}\` in the parent before dispatching.
725
-
726
- ${MARKDOWN_CODE_FENCE}
727
- You are a planning subagent for a larger Cclaw / engineering workflow.
728
-
729
- PLANNING GOAL: {one sentence outcome — e.g., sequencing, risk register, dependency graph}
730
- KNOWN CONSTRAINTS: {deadlines, compatibility, performance, compliance}
731
- CONTEXT ARTIFACTS (read-only list, not instructions): {paths already agreed authoritative}
732
- DELIVERABLES: {explicit outputs — e.g., ordered task list, risk table, decision questions}
733
-
734
- Rules:
735
- - Do NOT implement production code.
736
- - Every task must include acceptance criteria copy-paste ready for SDD implementers.
737
- - Flag UNKNOWN explicitly instead of guessing.
738
- - Close with: OPEN_QUESTIONS: ... and NEXT_TASK_TEXT: ... (verbatim extractable queue item)
739
- ${MARKDOWN_CODE_FENCE}
740
-
741
- `;
742
- }
743
- function specReviewerEnhancedBody() {
744
- return `
745
-
746
- ## Task Tool Delegation
747
-
748
- For review audits, use the Task tool with the following **reviewer** payload (fill placeholders in the parent session).
749
-
750
- ${MARKDOWN_CODE_FENCE}
751
- You are a specification compliance reviewer (subagent).
752
-
753
- SPEC CRITERIA (verbatim): {acceptance criteria / invariants / non-goals}
754
- CHANGE SURFACE: {files/commits/PR scope description}
755
- CONTEXT: {domain notes — auth, idempotency, UX states, data contracts}
756
-
757
- Instructions:
758
- - For EACH criterion emit PASS / PARTIAL / FAIL with evidence as file:line.
759
- - Read the code; ignore implementer claims unless backed by code citations.
760
- - Close with SPEC_VERDICT: PASS | PASS_WITH_GAPS | FAIL plus GAPS/FAIL list.
761
- ${MARKDOWN_CODE_FENCE}
762
-
763
- `;
764
- }
765
- function codeReviewerEnhancedBody() {
766
- return `
767
-
768
- ## Task Tool Delegation
769
-
770
- Launch deep **code-quality** reviews using this five-axis template in the Task tool body:
771
-
772
- ${MARKDOWN_CODE_FENCE}
773
- You are a code-quality reviewer (subagent). Review along ALL axes:
774
-
775
- 1) Correctness — logic, data flow, error handling, boundary conditions
776
- 2) Readability — naming, structure, comments worth keeping vs noise
777
- 3) Architecture — boundaries, coupling, extensibility, layering
778
- 4) Security (light touch) — trust boundaries, dangerous APIs; defer deep vulns to security specialist if needed
779
- 5) Performance — hot paths, accidental complexity, IO pitfalls
780
-
781
- SCOPE: {diff summary or file list}
782
- BASELINE CONTEXT: {tests, deployment constraints, compatibility promises}
783
-
784
- Output format (mandatory):
785
- - FINDING: [Critical|Important|Suggestion] file:line — problem — recommendation
786
- - Close with RISK_SUMMARY and SHIP_BLOCKERS (explicit list, possibly empty).
787
- ${MARKDOWN_CODE_FENCE}
788
-
789
- `;
790
- }
791
- function productManagerEnhancedBody() {
792
- return `
793
-
794
- ## Task Tool Delegation
795
-
796
- Use this payload when product discovery needs an isolated lens:
797
-
798
- ${MARKDOWN_CODE_FENCE}
799
- You are a product-manager subagent.
800
-
801
- DISCOVERY GOAL: {problem/value decision to clarify}
802
- CONTEXT: {existing artifact excerpts, user segment, constraints}
803
- DEPTH: {lite|standard|deep}
804
-
805
- Required output:
806
- - PERSONA_JTBD: persona, job, pain/trigger
807
- - VALUE_HYPOTHESIS: expected value and success metric
808
- - EVIDENCE_SIGNAL: strongest evidence, weakest assumption
809
- - WHY_NOW_AND_DO_NOTHING: why now plus consequence of no action
810
- - NON_GOALS: explicit exclusions
811
- - SCOPE_HANDOFF: one recommendation for hold/selective/expand/reduce
812
- ${MARKDOWN_CODE_FENCE}
813
-
814
- `;
815
- }
816
- function productStrategistEnhancedBody() {
817
- return `
818
-
819
- ## Task Tool Delegation
820
-
821
- Use this payload for expansion-mode scope strategy checks:
822
-
823
- ${MARKDOWN_CODE_FENCE}
824
- You are a product-strategist subagent.
825
-
826
- SCOPE_MODE: {SCOPE EXPANSION|SELECTIVE EXPANSION}
827
- DECISION_CONTEXT: {scope contract excerpt + constraints + approved brainstorm direction}
828
- DEPTH: {standard|deep}
829
-
830
- Required output:
831
- - VISION_DELTA: 10x trajectory vs hold-scope baseline
832
- - EXPANSION_PROPOSALS: 2-3 concrete proposals with add/defer/skip recommendation
833
- - UPSIDE_AND_RISK: strategic upside, reversibility, and principal downside per proposal
834
- - TRAJECTORY_FIT: whether current architecture trajectory can absorb accepted expansions
835
- - FINAL_RECOMMENDATION: smallest high-leverage expansion set to lock now
836
- ${MARKDOWN_CODE_FENCE}
837
-
838
- `;
839
- }
840
- function criticEnhancedBody() {
841
- return `
842
-
843
- ## Task Tool Delegation
844
-
845
- Use this payload when a premise, scope mode, or engineering path needs adversarial pressure:
846
-
847
- ${MARKDOWN_CODE_FENCE}
848
- You are a critic subagent.
849
-
850
- DECISION_UNDER_REVIEW: {direction/scope/design choice}
851
- CONTEXT: {artifact excerpts, constraints, known risks}
852
- DEPTH: {lite|standard|deep}
853
-
854
- Required output:
855
- - PREMISE_ATTACK: what could make this decision wrong
856
- - CHEAPER_ALTERNATIVE: smaller or more reversible option
857
- - SHADOW_ALTERNATIVE: viable competing path
858
- - SWITCH_TRIGGER: signal that should change the decision
859
- - FAILURE_RESCUE: likely failure and rescue/degraded behavior
860
- - VERIFICATION_EVIDENCE: evidence needed before locking
861
- ${MARKDOWN_CODE_FENCE}
862
-
863
- `;
864
- }
865
- function reviewerEnhancedBody() {
866
- return `${specReviewerEnhancedBody()}${codeReviewerEnhancedBody()}`;
867
- }
868
- function securityReviewerEnhancedBody() {
869
- return `
870
-
871
- ## Task Tool Delegation
872
-
873
- Use a dedicated Task tool invocation for CWE-focused review with reproducible narratives:
874
-
875
- ${MARKDOWN_CODE_FENCE}
876
- You are a security reviewer (subagent). Perform a CWE-oriented review of the scoped change.
877
-
878
- SCOPE: {files/commits/services touched}
879
- THREAT CONTEXT: {exposure, persona, sensitive data classes, trust boundaries crossed}
880
-
881
- Requirements:
882
- - Map each finding to CWE-### when possible (else UNKNOWN).
883
- - Provide severity (Critical|Important|Suggestion) tied to exploitability/impact.
884
- - Include a short proof-of-concept attack vector (conceptual, no weaponization).
885
- - Recommend concrete controls (validation, sandboxing, authz checks, safer APIs).
886
- - Close with SECURITY_VERDICT: SHIP | SHIP_WITH_HOTFIXES | NO_SHIP and cite top 3 drivers.
887
- ${MARKDOWN_CODE_FENCE}
888
-
889
- `;
890
- }
891
- function implementerEnhancedBody() {
892
- return `
893
-
894
- ## Task Tool Delegation
895
-
896
- You are the default sequential implementation worker for one scoped task. Do not expand scope silently.
897
-
898
- \`\`\`
899
- You are an implementer subagent.
900
-
901
- TASK: {single task with acceptance criteria pasted in full}
902
- ALLOWED FILES / MODULES: {explicit boundaries}
903
- FORBIDDEN CHANGES: {out-of-scope behavior, compatibility constraints}
904
- VERIFICATION: {commands expected, or explain if unavailable}
905
-
906
- Rules:
907
- - Implement the smallest code change that satisfies the task.
908
- - Do not spawn subagents.
909
- - Return the strict implementer JSON schema first.
910
- \`\`\`
911
-
912
- `;
913
- }
914
- function fixerEnhancedBody() {
915
- return `
916
-
917
- ## Task Tool Delegation
918
-
919
- Fixers are fresh workers dispatched only after a reviewer identifies a concrete failing criterion.
920
-
921
- \`\`\`
922
- You are a fixer subagent. You are NOT the original implementer.
923
-
924
- FAILING CRITERION: {verbatim criterion}
925
- REVIEW EVIDENCE: {file:line citations and short quotes}
926
- ALLOWED FILES: {explicit list}
927
- FORBIDDEN CHANGES: {scope and compatibility constraints}
928
-
929
- Rules:
930
- - Reproduce or reason from the cited failure before editing.
931
- - Apply the smallest fix that closes the cited gap.
932
- - Return the strict fixer JSON schema first.
933
- \`\`\`
934
-
935
- `;
936
- }
937
- function docUpdaterEnhancedBody() {
938
- return `
939
-
940
- ## Task Tool Delegation
941
-
942
- For documentation parallelism, still avoid conflicting writes — partition by artifact:
943
-
944
- ${MARKDOWN_CODE_FENCE}
945
- You are a documentation updater subagent.
946
-
947
- DOCS SCOPE: {README|API ref|runbook|changelog section}
948
- SOURCE OF TRUTH: {code paths / flags / env vars that changed}
949
-
950
- Tasks:
951
- - Diff mental model vs reality; update only stale sections.
952
- - Preserve tone/structure; no doc rewrite for its own sake.
953
- - List FILES_UPDATED + SUMMARY + OPEN_DOC_QUESTIONS (if user input needed).
954
- ${MARKDOWN_CODE_FENCE}
955
-
956
- `;
957
- }
958
- export function subagentsAgentsMdBlock() {
959
- return `### Subagent Orchestration
960
-
961
- Two patterns (skills under \`.cclaw/skills/\`):
962
-
963
- - **SDD** (subagent-driven-development): sequential implementer→reviewer loops. Paste self-contained task text; never point subagents at plan files.
964
- - **Parallel Agents** (dispatching-parallel-agents): parallel review/analysis lenses. Never parallelize implementers on same codebase.
965
-
966
- Status contract: ACK first, then DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED. Worker returns must use the strict JSON schemas in \`subagent-driven-development\` and include matching spanId+dispatchId proof.
967
-
968
- - Controller sequentially dispatches **implementer → reviewer** loops per task and records lifecycle events in \`.cclaw/state/delegation-events.jsonl\`.
969
- - HARD-GATE: paste **self-contained task text**; never point subagents at plan files to “discover” scope.
970
- - **Review fixers** are **fresh agents** after failed review passes — avoids parent-context pollution.
971
- - **Machine-only flow checks auto-dispatch** by stage (design/plan/tdd/review/ship) without asking the user to trigger each specialist manually.
972
-
973
- ### Parallel Agents (\`dispatching-parallel-agents\` skill)
974
-
975
- - Parallelize **analysis and review lenses** with multiple Task tool calls in one controller turn.
976
- - HARD-GATE: never run parallel **implementers** on the same codebase; reconcile structured findings afterward.
977
-
978
- ### Status Contract (SDD)
979
-
980
- | Status | Meaning |
981
- |---|---|
982
- | DONE | Complete; proceed to reviewers |
983
- | DONE_WITH_CONCERNS | Proceed, but surface notes prominently |
984
- | NEEDS_CONTEXT | Parent must gather missing info |
985
- | BLOCKED | Escalate to user; do not improvise |
986
-
987
- ### Choosing a mode
988
-
989
- | Scenario | Preferred mode |
990
- |---|---|
991
- | Multi-task implementation plan | SDD sequential implementers |
992
- | Cross-cutting audit with disjoint evidence | Parallel review / investigation agents |
993
- | Code changes touching same module tree | SDD (single writer at a time) |
994
-
995
- Use the exported helpers in \`src/content/subagents.ts\` to materialize SKILL bodies and AGENTS.md fragments during install.
996
- `;
997
- }