cclaw-cli 7.7.1 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +211 -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 +107 -511
  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 -768
  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 -134
  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/harness-prompt.d.ts +26 -0
  73. package/dist/harness-prompt.js +142 -0
  74. package/dist/install.d.ts +35 -15
  75. package/dist/install.js +238 -1347
  76. package/dist/knowledge-store.d.ts +19 -163
  77. package/dist/knowledge-store.js +56 -590
  78. package/dist/logger.d.ts +8 -3
  79. package/dist/logger.js +13 -4
  80. package/dist/orchestrator-routing.d.ts +29 -0
  81. package/dist/orchestrator-routing.js +156 -0
  82. package/dist/run-persistence.d.ts +7 -118
  83. package/dist/run-persistence.js +29 -845
  84. package/dist/runtime/run-hook.entry.d.ts +1 -3
  85. package/dist/runtime/run-hook.entry.js +19 -4
  86. package/dist/runtime/run-hook.mjs +13 -1024
  87. package/dist/types.d.ts +25 -261
  88. package/dist/types.js +8 -36
  89. package/package.json +6 -3
  90. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  91. package/dist/artifact-linter/brainstorm.js +0 -353
  92. package/dist/artifact-linter/design.d.ts +0 -18
  93. package/dist/artifact-linter/design.js +0 -444
  94. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  95. package/dist/artifact-linter/findings-dedup.js +0 -232
  96. package/dist/artifact-linter/plan.d.ts +0 -2
  97. package/dist/artifact-linter/plan.js +0 -826
  98. package/dist/artifact-linter/review-army.d.ts +0 -49
  99. package/dist/artifact-linter/review-army.js +0 -520
  100. package/dist/artifact-linter/review.d.ts +0 -2
  101. package/dist/artifact-linter/review.js +0 -113
  102. package/dist/artifact-linter/scope.d.ts +0 -2
  103. package/dist/artifact-linter/scope.js +0 -158
  104. package/dist/artifact-linter/shared.d.ts +0 -637
  105. package/dist/artifact-linter/shared.js +0 -2163
  106. package/dist/artifact-linter/ship.d.ts +0 -2
  107. package/dist/artifact-linter/ship.js +0 -250
  108. package/dist/artifact-linter/spec.d.ts +0 -2
  109. package/dist/artifact-linter/spec.js +0 -176
  110. package/dist/artifact-linter/tdd.d.ts +0 -118
  111. package/dist/artifact-linter/tdd.js +0 -1404
  112. package/dist/artifact-linter.d.ts +0 -15
  113. package/dist/artifact-linter.js +0 -517
  114. package/dist/codex-feature-flag.d.ts +0 -58
  115. package/dist/codex-feature-flag.js +0 -193
  116. package/dist/content/closeout-guidance.d.ts +0 -14
  117. package/dist/content/closeout-guidance.js +0 -44
  118. package/dist/content/diff-command.d.ts +0 -1
  119. package/dist/content/diff-command.js +0 -43
  120. package/dist/content/harness-doc.d.ts +0 -1
  121. package/dist/content/harness-doc.js +0 -65
  122. package/dist/content/hook-events.d.ts +0 -9
  123. package/dist/content/hook-events.js +0 -23
  124. package/dist/content/hook-manifest.d.ts +0 -81
  125. package/dist/content/hook-manifest.js +0 -156
  126. package/dist/content/hooks.d.ts +0 -11
  127. package/dist/content/hooks.js +0 -1972
  128. package/dist/content/idea.d.ts +0 -60
  129. package/dist/content/idea.js +0 -416
  130. package/dist/content/language-policy.d.ts +0 -2
  131. package/dist/content/language-policy.js +0 -13
  132. package/dist/content/learnings.d.ts +0 -6
  133. package/dist/content/learnings.js +0 -141
  134. package/dist/content/observe.d.ts +0 -19
  135. package/dist/content/observe.js +0 -86
  136. package/dist/content/opencode-plugin.d.ts +0 -1
  137. package/dist/content/opencode-plugin.js +0 -635
  138. package/dist/content/review-prompts.d.ts +0 -1
  139. package/dist/content/review-prompts.js +0 -104
  140. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  141. package/dist/content/runtime-shared-snippets.js +0 -80
  142. package/dist/content/session-hooks.d.ts +0 -7
  143. package/dist/content/session-hooks.js +0 -107
  144. package/dist/content/skills-elicitation.d.ts +0 -1
  145. package/dist/content/skills-elicitation.js +0 -167
  146. package/dist/content/stage-command.d.ts +0 -2
  147. package/dist/content/stage-command.js +0 -17
  148. package/dist/content/stage-schema.d.ts +0 -117
  149. package/dist/content/stage-schema.js +0 -955
  150. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  151. package/dist/content/stages/_lint-metadata/index.js +0 -97
  152. package/dist/content/stages/brainstorm.d.ts +0 -2
  153. package/dist/content/stages/brainstorm.js +0 -184
  154. package/dist/content/stages/design.d.ts +0 -2
  155. package/dist/content/stages/design.js +0 -288
  156. package/dist/content/stages/index.d.ts +0 -8
  157. package/dist/content/stages/index.js +0 -11
  158. package/dist/content/stages/plan.d.ts +0 -2
  159. package/dist/content/stages/plan.js +0 -191
  160. package/dist/content/stages/review.d.ts +0 -2
  161. package/dist/content/stages/review.js +0 -240
  162. package/dist/content/stages/schema-types.d.ts +0 -203
  163. package/dist/content/stages/schema-types.js +0 -1
  164. package/dist/content/stages/scope.d.ts +0 -2
  165. package/dist/content/stages/scope.js +0 -254
  166. package/dist/content/stages/ship.d.ts +0 -2
  167. package/dist/content/stages/ship.js +0 -159
  168. package/dist/content/stages/spec.d.ts +0 -2
  169. package/dist/content/stages/spec.js +0 -170
  170. package/dist/content/stages/tdd.d.ts +0 -4
  171. package/dist/content/stages/tdd.js +0 -273
  172. package/dist/content/state-contracts.d.ts +0 -1
  173. package/dist/content/state-contracts.js +0 -63
  174. package/dist/content/status-command.d.ts +0 -4
  175. package/dist/content/status-command.js +0 -109
  176. package/dist/content/subagent-context-skills.d.ts +0 -4
  177. package/dist/content/subagent-context-skills.js +0 -279
  178. package/dist/content/subagents.d.ts +0 -3
  179. package/dist/content/subagents.js +0 -997
  180. package/dist/content/templates.d.ts +0 -26
  181. package/dist/content/templates.js +0 -1692
  182. package/dist/content/track-render-context.d.ts +0 -18
  183. package/dist/content/track-render-context.js +0 -53
  184. package/dist/content/tree-command.d.ts +0 -1
  185. package/dist/content/tree-command.js +0 -64
  186. package/dist/content/utility-skills.d.ts +0 -30
  187. package/dist/content/utility-skills.js +0 -160
  188. package/dist/content/view-command.d.ts +0 -2
  189. package/dist/content/view-command.js +0 -92
  190. package/dist/delegation.d.ts +0 -649
  191. package/dist/delegation.js +0 -1539
  192. package/dist/early-loop.d.ts +0 -70
  193. package/dist/early-loop.js +0 -302
  194. package/dist/execution-topology.d.ts +0 -44
  195. package/dist/execution-topology.js +0 -95
  196. package/dist/gate-evidence.d.ts +0 -85
  197. package/dist/gate-evidence.js +0 -631
  198. package/dist/harness-adapters.d.ts +0 -151
  199. package/dist/harness-adapters.js +0 -756
  200. package/dist/harness-selection.d.ts +0 -31
  201. package/dist/harness-selection.js +0 -214
  202. package/dist/hook-schema.d.ts +0 -6
  203. package/dist/hook-schema.js +0 -114
  204. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  205. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  206. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  207. package/dist/init-detect.d.ts +0 -2
  208. package/dist/init-detect.js +0 -50
  209. package/dist/internal/advance-stage/advance.d.ts +0 -89
  210. package/dist/internal/advance-stage/advance.js +0 -655
  211. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  212. package/dist/internal/advance-stage/cancel-run.js +0 -19
  213. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  214. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  215. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  216. package/dist/internal/advance-stage/helpers.js +0 -145
  217. package/dist/internal/advance-stage/hook.d.ts +0 -8
  218. package/dist/internal/advance-stage/hook.js +0 -40
  219. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  220. package/dist/internal/advance-stage/parsers.js +0 -357
  221. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  222. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  223. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  224. package/dist/internal/advance-stage/review-loop.js +0 -199
  225. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  226. package/dist/internal/advance-stage/rewind.js +0 -108
  227. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  228. package/dist/internal/advance-stage/start-flow.js +0 -241
  229. package/dist/internal/advance-stage/verify.d.ts +0 -21
  230. package/dist/internal/advance-stage/verify.js +0 -185
  231. package/dist/internal/advance-stage.d.ts +0 -7
  232. package/dist/internal/advance-stage.js +0 -138
  233. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  234. package/dist/internal/cohesion-contract-stub.js +0 -148
  235. package/dist/internal/compound-readiness.d.ts +0 -23
  236. package/dist/internal/compound-readiness.js +0 -102
  237. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  238. package/dist/internal/detect-public-api-changes.js +0 -45
  239. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  240. package/dist/internal/detect-supply-chain-changes.js +0 -138
  241. package/dist/internal/early-loop-status.d.ts +0 -7
  242. package/dist/internal/early-loop-status.js +0 -93
  243. package/dist/internal/envelope-validate.d.ts +0 -7
  244. package/dist/internal/envelope-validate.js +0 -66
  245. package/dist/internal/flow-state-repair.d.ts +0 -20
  246. package/dist/internal/flow-state-repair.js +0 -104
  247. package/dist/internal/plan-split-waves.d.ts +0 -190
  248. package/dist/internal/plan-split-waves.js +0 -764
  249. package/dist/internal/runtime-integrity.d.ts +0 -7
  250. package/dist/internal/runtime-integrity.js +0 -268
  251. package/dist/internal/slice-commit.d.ts +0 -7
  252. package/dist/internal/slice-commit.js +0 -619
  253. package/dist/internal/tdd-loop-status.d.ts +0 -14
  254. package/dist/internal/tdd-loop-status.js +0 -68
  255. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  256. package/dist/internal/tdd-red-evidence.js +0 -153
  257. package/dist/internal/waiver-grant.d.ts +0 -62
  258. package/dist/internal/waiver-grant.js +0 -294
  259. package/dist/internal/wave-status.d.ts +0 -74
  260. package/dist/internal/wave-status.js +0 -506
  261. package/dist/managed-resources.d.ts +0 -53
  262. package/dist/managed-resources.js +0 -313
  263. package/dist/policy.d.ts +0 -10
  264. package/dist/policy.js +0 -167
  265. package/dist/retro-gate.d.ts +0 -9
  266. package/dist/retro-gate.js +0 -47
  267. package/dist/run-archive.d.ts +0 -61
  268. package/dist/run-archive.js +0 -391
  269. package/dist/runs.d.ts +0 -2
  270. package/dist/runs.js +0 -2
  271. package/dist/stack-detection.d.ts +0 -116
  272. package/dist/stack-detection.js +0 -489
  273. package/dist/streaming/event-stream.d.ts +0 -31
  274. package/dist/streaming/event-stream.js +0 -114
  275. package/dist/tdd-cycle.d.ts +0 -107
  276. package/dist/tdd-cycle.js +0 -289
  277. package/dist/tdd-verification-evidence.d.ts +0 -17
  278. package/dist/tdd-verification-evidence.js +0 -122
  279. package/dist/track-heuristics.d.ts +0 -27
  280. package/dist/track-heuristics.js +0 -154
  281. package/dist/util/slice-id.d.ts +0 -58
  282. package/dist/util/slice-id.js +0 -89
  283. package/dist/worktree-manager.d.ts +0 -20
  284. package/dist/worktree-manager.js +0 -108
@@ -1,236 +1,250 @@
1
- import { RUNTIME_ROOT } from "../constants.js";
2
- import { conversationLanguagePolicyMarkdown } from "./language-policy.js";
3
- const START_SKILL_FOLDER = "flow-start";
4
- const START_SKILL_NAME = "flow-start";
5
- function flowStatePath() {
6
- return `${RUNTIME_ROOT}/state/flow-state.json`;
7
- }
8
- /**
9
- * Command contract for /cc — the unified entry point.
10
- * No args → reads existing flow state and progresses it when a tracked flow
11
- * already exists; missing state/fresh placeholder state blocks with
12
- * init/start guidance. With prompt classifies the idea, asks for one discovery mode,
13
- * resolves the internal track, and starts the first stage of that track (brainstorm for medium/standard, spec for quick).
14
- */
15
- export function startCommandContract() {
16
- const flowPath = flowStatePath();
17
- return `# /cc
18
-
19
- ## Purpose
20
-
21
- **The unified entry point for the cclaw flow.**
22
-
23
- - \`/cc\` (no arguments) → reads existing flow state and resumes/progresses the active flow. If flow state is missing or still a fresh init placeholder, stop and guide the user to run \`/cc <prompt>\` or \`npx cclaw-cli init\`; do not silently create a brainstorm run.
24
- - \`/cc <prompt>\` (with an idea/description) → saves the prompt as idea context, asks for one discovery mode, and starts the first stage of the resolved internal track.
25
-
26
- This is the **recommended way to start, resume, and continue** working with cclaw.
27
-
28
- ## HARD-GATE
29
-
30
- ${conversationLanguagePolicyMarkdown()}
31
- - **Do not** skip reading \`${flowPath}\` always check current state before acting.
32
- - **Do not** start implementation stages directly from \`/cc <prompt>\` — always begin at the first stage of the resolved track (brainstorm for medium/standard, spec for quick).
33
- - **Do not** start a stage pipeline for a task that is not a software change (pure question, non-software task, conversation).
34
-
35
- ## Algorithm
36
-
37
- ### With prompt (\`/cc <text>\`)
38
-
39
- 1. **Phase 0 — Task classification.** Before any stage routing, classify the prompt:
40
-
41
- | Class | Signals | Action |
42
- |---|---|---|
43
- | **non-software** | legal text / docs / marketing copy / meeting notes / therapy-style conversation | Respond directly, do NOT open a stage, do NOT mutate flow state. |
44
- | **pure-question** | "how does X work?", "explain Y", "what are the trade-offs of Z?" | Answer directly, do NOT open a stage. |
45
- | **trivial** | typo, one-liner, rename, config tweak, copy change, version bump with zero behavior change | Fast-path: set track to \`quick\`, seed \`00-idea.md\`, and enter \`spec\`. Runtime quick never starts at design. |
46
- | **software — bug fix with repro** | regression / hotfix / named symptom + repro steps | Fast-path: set track to \`quick\`, enter \`spec\`, and capture a reproduction contract first. TDD later writes the RED reproduction test from that contract. |
47
- | **software medium** | additive feature following existing architecture | medium track (\`brainstorm → spec → plan → tdd → review → ship\`). |
48
- | **software — standard** | feature, refactor, migration, integration, architecture change | Full 8-stage flow starting at \`brainstorm\`. |
49
-
50
- Record the chosen class in \`.cclaw/artifacts/00-idea.md\` on the \`Class:\` line. Do NOT silently treat a non-software task as software.
51
-
52
- 2. **Phase 0.5 — Seed shelf recall.** Before routing, scan \`${RUNTIME_ROOT}/seeds/SEED-*.md\` and match each seed's \`trigger_when\` tokens against the prompt text (substring match is enough). If any match:
53
- - Surface up to 3 matches (file + title + one-line action) as \`Seed recalls\`.
54
- - Ask whether to apply now, keep as reference, or ignore for this run.
55
- - If applied/reference, append selected seeds to \`00-idea.md\` under \`Discovered context\` so downstream stages keep the trace.
56
-
57
- 3. **Phase 1 Origin-document discovery.** Before asking the user for context, scan for existing requirements/plan artifacts and merge them into initial context:
58
- - \`.cclaw/artifacts/00-idea.md\` if it already exists (resumed flow).
59
- - Common origin locations: \`docs/prd/**\`, \`docs/rfcs/**\`, \`docs/adr/**\`, \`docs/design/**\`, \`specs/**\`, \`prd/**\`, \`rfc/**\`, \`design/**\`, root-level \`PRD.md\` / \`SPEC.md\` / \`DESIGN.md\` / \`REQUIREMENTS.md\` / \`ROADMAP.md\`.
60
- - Summarize each discovered doc in \`00-idea.md\` under a \`Discovered context\` section with path + 1-line summary.
61
- - If an origin doc contradicts the prompt, surface the conflict to the user before routing.
62
-
63
- 4. **Phase 2 — Tech-stack + version detection.** Sniff the repo for stack + language versions and record under \`Stack:\`:
64
- - Node: \`package.json\` \`engines\` / \`volta\` / \`packageManager\` / \`devDependencies\`.
65
- - Python: \`pyproject.toml\` / \`requirements*.txt\` / \`.python-version\`.
66
- - Go: \`go.mod\` (module + Go version).
67
- - Rust: \`Cargo.toml\` (\`[package]\` + \`rust-version\`).
68
- - Java/Kotlin: \`pom.xml\` / \`build.gradle*\` + toolchain version.
69
- - Containers: \`Dockerfile\`, \`docker-compose*.yml\`.
70
- - CI: \`.github/workflows\`, \`.gitlab-ci.yml\`.
71
- Skip detection quietly if no markers are found — do NOT invent a stack.
72
-
73
- 5. Read \`${flowPath}\`.
74
- 6. If flow already has completed stages, warn the user that starting a new tracked flow will reset progress. Ask for confirmation before proceeding. A fresh init placeholder state with \`completedStages: []\`, no passed gates, and no \`00-idea.md\` is **not** an active flow; do not ask the user to resume it.
75
- 7. **Internal track heuristic** — classify the idea text and compute an internal track recommendation before any state mutation:
76
- - First, load \`${RUNTIME_ROOT}/config.yaml\`. If \`trackHeuristics\` is defined, apply those per-track vocabulary hints (\`fallback\`, \`tracks.<id>.{triggers,veto}\`) on top of the built-in defaults. Evaluation order is always \`standard -> medium -> quick\` (narrow-to-broad).
77
- - **quick** (\`spec → tdd → review → ship\`) — single-purpose work where the spec is essentially already known. Quick skips ceremony, not safety: spec approval, TDD evidence, review, and ship gates remain mandatory.
78
- Triggers (case-insensitive substring or close variant): \`bug\`, \`bugfix\`, \`fix\`, \`hotfix\`, \`patch\`, \`typo\`, \`regression\`, \`copy change\`, \`rename\`, \`bump\`, \`upgrade dep\`, \`config tweak\`, \`docs only\`, \`comment\`, \`lint\`, \`format\`, \`small\`, \`tiny\`, \`one-liner\`, \`revert\`.
79
- - **medium** (\`brainstorm → spec → plan → tdd → review → ship\`) — additive work that fits existing architecture and still needs product framing.
80
- Triggers: \`add endpoint\`, \`add field\`, \`extend existing\`, \`wire integration\`, \`small migration\`, \`new screen following existing patterns\`.
81
- - **standard** (full 8 stages — default fallback) — anything that introduces a new capability with architecture uncertainty, touches many modules, or has unclear scope.
82
- Triggers: \`new feature\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`schema\`, \`integrate\`, \`workflow\`, \`onboarding\`, or any prompt that does not match quick/medium confidently.
83
- - When triggers conflict, prefer **standard** over **medium**, and **medium** over **quick**.
84
- - Report **track selection confidence** as high/medium/low with the matched trigger or fallback reason, plus one sentence explaining what the selected track skips and what safety gates remain. Be explicit that this recommendation is advisory until the user accepts and the managed helper writes state; after that, \`/cc\` follows the configured track.
85
- 8. Present one compact **Start framing** summary: class, internal track recommendation, track selection confidence, stack, origin docs, seed recalls, and the recommended next action. Ask a single confirmation question only when there is a destructive reset, a real contradiction, or ambiguous software/non-software classification.
86
- 9. Ask one explicit **discovery mode** question and make it the only normal start-of-run user choice:
87
- > \`Choose discovery mode: Lean / Guided / Deep\`.
88
- > \`Lean\` = compact shaping, \`Guided\` = recommended default with enough questions and key specialists before drafting, \`Deep\` = stronger probing and broader specialist/research passes.
89
- > Mention the internal track recommendation only as context, not as the primary decision. Offer track override only when reset, contradiction, or reclassification evidence makes the internal recommendation suspect.
90
- Normalize the user's answer before calling the start helper: \`trim\`, lower-case, map UI labels to \`lean\` / \`guided\` / \`deep\` only; if the answer is not one of those three, re-ask the same question once with the compact definitions. In \`flow-state.json\`, persist only the canonical lowercase token (never \`Deep\`/\`Guided\` casing).
91
- If the user prompt is one short line (at most 12 words) and the workspace matches an empty-repo signal set — either \`flow-state.repoSignals\` from the last successful \`start-flow\` shows \`fileCount < 5\` with \`hasReadme\` and \`hasPackageManifest\` both false, OR (before any \`start-flow\` yet) a shallow scan finds no root \`README.md\`, no root \`package.json\`/\`pyproject.toml\`/\`Cargo.toml\`, and fewer than five relevant files excluding \`node_modules\`/\`.git\` — recommend \`guided\` and ask for explicit confirmation before defaulting to \`deep\`.
92
- If the harness's native ask tool is available (\`AskUserQuestion\` / \`AskQuestion\` / \`question\` / \`request_user_input\`), send exactly ONE question; on schema error, fall back to a plain-text lettered list.
93
- 10. Start the tracked flow only through the managed helper:
94
- \`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --discovery-mode=<lean|guided|deep> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`
95
- If this helper fails, STOP. Report one human-readable failure line from the JSON \`error\` field, include the helper JSON payload in a fenced \`json\` block, and never echo the invoking command line. Do **not** manually edit \`${flowPath}\`.
96
- 11. The helper persists \`${flowPath}\`, computes \`skippedStages\`, sets the first stage for the track, resets the gate catalog, and writes \`.cclaw/artifacts/00-idea.md\`.
97
- 12. Load the **first-stage skill for the chosen track** and its command file:
98
- - quick → \`.cclaw/skills/spec/SKILL.md\`
99
- - medium/standard → \`.cclaw/skills/brainstorm/SKILL.md\`
100
- - trivial fast-path → quick track spec skill per Phase 0 decision.
101
- 13. Execute that stage with the prompt + Phase 1/Phase 2 + seed context as initial input.
102
-
103
- ### Reclassification on discovery
104
-
105
- If during any stage the agent discovers evidence that contradicts the initial Phase 0 / track decision (e.g. a supposedly \`trivial\` change turns out to require schema migration, a \`quick\` bug fix turns out to need design discussion, an origin doc reveals scope 3× larger than the prompt), STOP and re-classify:
106
-
107
- 1. Surface the new evidence in plain text.
108
- 2. Propose the updated \`Class\`, internal \`Track\`, and (when discovery posture should change) \`Discovery mode\` with a one-line reason.
109
- 3. Use the Decision Protocol to let the user accept, override, or cancel.
110
- 4. On acceptance: run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --discovery-mode=<lean|guided|deep> --class=<new-class> --reason=<why>\`. The helper appends a \`Reclassification:\` entry to \`00-idea.md\` and updates flow state atomically. If it fails, STOP and report one human-readable line plus the helper JSON payload in a fenced \`json\` block; never echo the invoking command line. Do NOT manually edit \`flow-state.json\`.
111
-
112
- ### Without prompt (\`/cc\`)
113
-
114
- 1. Read \`${flowPath}\`.
115
- 2. If flow state is missing → guide the user to run \`npx cclaw-cli init\` and stop.
116
- 3. If flow state is only a fresh init placeholder (\`completedStages: []\`, all \`passed\` arrays empty, and no \`00-idea.md\`) → stop and ask for \`/cc <prompt>\` to start a tracked run. Do not create a brainstorm state implicitly.
117
- 4. Otherwise check current stage gates, resume if incomplete, and advance if complete.
118
- 5. **TDD wave dispatch:** When \`currentStage\` is \`tdd\`, run \`node .cclaw/cli.mjs internal wave-status --json\` first, then read the managed **Parallel Execution Plan** block inside \`${RUNTIME_ROOT}/artifacts/05-plan.md\` plus \`${RUNTIME_ROOT}/artifacts/wave-plans/\` for detail. Resume partial waves on remaining members only.
119
-
120
- **The controller preserves TDD evidence.** When \`topology: parallel-builders\` and \`pathConflicts: []\`, fan out the ready independent units in a SINGLE controller message: one harness \`Task(subagent_type=…, description="slice-builder S-<id>", prompt=<full slice context>)\` call per routed builder, **side by side in the same tool batch**. Each \`slice-builder\` span owns the full RED → GREEN → REFACTOR → DOC cycle for its feature-atomic unit and emits its own \`delegation-record --phase=red|green|refactor|refactor-deferred|doc\` rows. RED-before-GREEN is enforced per-slice by the linter.
121
-
122
- When \`mode: blocked\` with \`pathConflicts\`, surface exactly one AskQuestion that lets the user resolve the overlap (drop / split / serialize). When \`topology: single-builder\`, dispatch one \`Task\` for the next ready unit. When \`topology: inline\`, execute inline only if the same RED/GREEN/REFACTOR evidence and path/commit gates can be satisfied.
123
-
124
- 6. **Auto-advance after stage-complete:** when \`stage-complete\` returns \`ok\` with a new \`currentStage\`, immediately load the next stage skill and continue without waiting for the user to retype \`/cc\`. Announce \`Stage <prev> complete → entering <next>. Continuing.\` and proceed.
125
-
126
- ## Headless mode (CI/automation only)
127
-
128
- Headless envelopes are a machine-mode exception for CI/automation orchestration.
129
- In normal interactive runs, respond in natural language instead of emitting an envelope.
130
- When called by another skill or subagent in machine mode, emit exactly one JSON envelope (no prose) and stop:
1
+ import { CORE_AGENTS } from "./core-agents.js";
2
+ import { ironLawsMarkdown } from "./iron-laws.js";
3
+ import { failureModesChecklist } from "./review-loop.js";
4
+ const SPECIALIST_LIST = CORE_AGENTS.map((agent) => `- **${agent.id}** (${agent.modes.join(" / ")}) — ${agent.description}`).join("\n");
5
+ const PLAN_FRONTMATTER_EXAMPLE = `\`\`\`yaml
6
+ ---
7
+ slug: approval-page
8
+ stage: plan
9
+ status: active
10
+ ac:
11
+ - id: AC-1
12
+ text: "User sees an approval status pill on the dashboard."
13
+ status: pending
14
+ - id: AC-2
15
+ text: "Pending approvals show a tooltip with the approver's name."
16
+ status: pending
17
+ last_specialist: null
18
+ refines: null
19
+ shipped_at: null
20
+ ship_commit: null
21
+ review_iterations: 0
22
+ security_flag: false
23
+ ---
24
+ \`\`\``;
25
+ const COMMIT_HELPER_EXAMPLE = `\`\`\`bash
26
+ # RED failing test only, no production edits
27
+ git add tests/unit/approval-pill.test.tsx
28
+ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=red \\
29
+ --message="red(AC-1): pill renders pending status"
30
+
31
+ # GREEN minimal production change, full suite must be green
32
+ git add src/components/ApprovalPill.tsx
33
+ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=green \\
34
+ --message="green(AC-1): minimal pill component for pending state"
35
+
36
+ # REFACTOR — applied or explicitly skipped (silence is not allowed)
37
+ node .cclaw/hooks/commit-helper.mjs --ac=AC-1 --phase=refactor --skipped \\
38
+ --message="refactor(AC-1) skipped: 18-line addition, idiomatic"
39
+ \`\`\``;
40
+ const REFINEMENT_EXAMPLE = `\`\`\`yaml
41
+ ---
42
+ slug: approval-page-tooltips
43
+ stage: plan
44
+ status: active
45
+ ac:
46
+ - id: AC-1
47
+ text: "Approval pill shows a tooltip with the approver's email on hover."
48
+ status: pending
49
+ last_specialist: null
50
+ refines: approval-page # the original shipped slug
51
+ shipped_at: null
52
+ ship_commit: null
53
+ review_iterations: 0
54
+ security_flag: false
55
+ ---
56
+ \`\`\``;
57
+ export const START_COMMAND_BODY = `# /cc cclaw orchestrator
131
58
 
132
- \`\`\`json
133
- {"version":"1","kind":"stage-output","stage":"<currentStage>","payload":{"command":"/cc","track":"<track>","action":"start_or_resume"},"emittedAt":"<ISO-8601>"}
134
- \`\`\`
59
+ You are the cclaw orchestrator. The user's request is: ${"`{{TASK}}`"}.
135
60
 
136
- Validate envelopes with:
137
- \`npx cclaw-cli internal envelope-validate --stdin\`
61
+ This document is your operating manual. Follow it in order. Skipping a step usually surfaces later as a failed gate.
138
62
 
139
- ## Primary skill
63
+ ## Step 0 — Sanity check
140
64
 
141
- **${RUNTIME_ROOT}/skills/${START_SKILL_FOLDER}/SKILL.md**
65
+ 1. Read \`.cclaw/state/flow-state.json\`.
66
+ 2. If the file is missing → it is a fresh session. Continue.
67
+ 3. If \`schemaVersion\` is not \`2\` → **stop**. Surface this verbatim to the user:
142
68
 
143
- ## Surface reference
69
+ > "This project's flow-state.json is from cclaw 7.x. cclaw v8 cannot resume it. Choose: (a) finish or abandon the run with cclaw 7.x; (b) delete \`.cclaw/state/flow-state.json\` and start a new v8 plan; (c) leave it alone and ask me again later."
144
70
 
145
- Use the start skill plus \`.cclaw/state/flow-state.json\` for orientation before \`/cc <prompt>\` runs.
146
- `;
147
- }
148
- /**
149
- * Skill body for /cc the unified entry point.
150
- */
151
- export function startCommandSkillMarkdown() {
152
- const flowPath = flowStatePath();
153
- return `---
154
- name: ${START_SKILL_NAME}
155
- description: "Unified entry point for the cclaw flow. No args = resume/next. With prompt = classify, pick track, start its first stage."
156
- ---
71
+ Do not auto-migrate. Do not delete state on the user's behalf.
72
+
73
+ ## Step 1 — Existing-plan detection
74
+
75
+ Glob \`.cclaw/flows/*/plan.md\` (skip \`shipped/\` and \`cancelled/\`) and \`.cclaw/flows/shipped/*/plan.md\`. For each match:
76
+
77
+ - Compute slug overlap with the new task.
78
+ - Read the YAML frontmatter (use the \`artifact-frontmatter\` skill).
79
+ - Surface to the user: slug, status (\`active\` | \`shipped\` | \`cancelled\`), \`last_specialist\`, AC progress (committed/pending counts), and \`security_flag\`.
80
+
81
+ Then ask the user one of:
82
+
83
+ - **active match** → \`amend\` (add AC) / \`rewrite\` (replace plan body) / \`new\` (separate slug).
84
+ - **shipped match** → \`refine shipped <slug>\` (creates new plan with \`refines: <old-slug>\`) / \`new unrelated\`.
85
+ - **cancelled match** → \`resume from cancelled\` (move artifacts back to active) / \`new\`.
86
+ - **no match** → continue to Phase 0.
87
+
88
+ Refinement always lives inside \`/cc\`. There is no \`/cc-amend\`. There is no auto-merge with the prior plan; the user picks.
89
+
90
+ ## Step 2 — Phase 0 calibration
91
+
92
+ Ask the user **once**:
93
+
94
+ > "Targeted change in one place, or a feature spanning multiple components?"
95
+
96
+ Combine the answer with these heuristics to pick a routing class:
97
+
98
+ | Class | Trigger | Action |
99
+ | --- | --- | --- |
100
+ | trivial | typo / format / rename / docs-only edit, ≤1 file, ≤30 lines | edit + commit per AC, no \`plan.md\` |
101
+ | small / medium | new functionality in 1-3 modules, 1-5 AC, no architectural questions | inline plan/build/review/ship |
102
+ | large / abstract / risky | >5 AC, ambiguous prompt, architectural decision, security-sensitive, multi-component | propose specialists |
103
+
104
+ If the answer disagrees with the heuristic, prefer the **larger** class — agents underestimate scope more often than they overestimate.
105
+
106
+ ## Step 3 — Specialist routing (large / risky only)
107
+
108
+ Ask the user once which specialists to invoke. Default proposal:
109
+
110
+ > "This looks like a larger task. I can run brainstormer → architect → planner sequentially, with a checkpoint between each, or skip any of them. Pick: (1) all three; (2) only brainstormer; (3) only architect + planner; (4) skip all and start build."
111
+
112
+ After the choice, run the selected specialists **sequentially with a checkpoint between each**:
113
+
114
+ 1. \`brainstormer\` writes Context / Frame / Scope into \`plans/<slug>.md\` → user reads → continue with architect?
115
+ 2. \`architect\` writes \`decisions/<slug>.md\` and adds Architecture subsection to \`plans/<slug>.md\` → user reads → continue with planner?
116
+ 3. \`planner\` writes Plan / Phases / Acceptance Criteria / Topology into \`plans/<slug>.md\` → user reads → enter build.
117
+
118
+ The user can stop after any checkpoint and proceed with what is already in \`plan.md\`.
119
+
120
+ Available specialists (with modes):
121
+
122
+ ${SPECIALIST_LIST}
123
+
124
+ \`reviewer\` is a multi-mode specialist. \`security-reviewer\` is separate; invoke it when the diff or task touches authn / authz / secrets / supply chain / data exposure.
157
125
 
158
- # /ccFlow Entry Point
126
+ ## Step 4 Plan template
159
127
 
160
- ## Overview
128
+ If you are starting a new plan (no existing match), seed \`plans/<slug>.md\` from \`.cclaw/lib/templates/plan.md\` and replace \`SLUG-PLACEHOLDER\` with the actual slug. The frontmatter must include all fields below. Do not skip any.
161
129
 
162
- \`/cc\` is the **starting command** for cclaw. It intelligently routes:
130
+ ${PLAN_FRONTMATTER_EXAMPLE}
163
131
 
164
- - **No arguments** resumes or progresses an existing tracked flow; missing/fresh placeholder state blocks with start guidance
165
- - **With a prompt** → classifies the task, asks for one discovery mode (lean/guided/deep), resolves an internal track (quick/medium/standard), and starts the **first stage of that track** (not always brainstorm — e.g. the \`quick\` track starts at \`spec\`)
132
+ For a refinement, set \`refines\` to the parent slug:
166
133
 
167
- ## HARD-GATE
134
+ ${REFINEMENT_EXAMPLE}
168
135
 
169
- Do **not** silently discard an existing flow when the user provides a prompt. If completed stages exist, inform and confirm before resetting. A freshly initialized placeholder state with \`completedStages: []\`, no passed gates, and no \`${RUNTIME_ROOT}/artifacts/00-idea.md\` is not an active flow; classify the prompt and start normally.
136
+ ## Step 5 Build (TDD cycle)
170
137
 
171
- ${conversationLanguagePolicyMarkdown()}
172
- ## Protocol
138
+ **Build is the TDD stage.** Every AC goes through RED → GREEN → REFACTOR. There is no other build mode. Use \`slice-builder\` (or implement inline for small tasks).
173
139
 
174
- ### Path A: \`/cc <prompt>\`
140
+ For each AC:
175
141
 
176
- 1. **Task classification (Phase 0).** Decide whether the prompt is \`software-standard\`, \`software-trivial\`, \`software-bugfix\`, \`pure-question\`, or \`non-software\`. Non-software and pure-question exit immediately — answer directly, do not open a stage. Bugfixes with a clear repro still start on quick \`spec\`: capture the reproduction contract first, then TDD writes the RED reproduction test from that contract.
177
- 2. **Seed shelf recall (Phase 0.5).** Scan \`${RUNTIME_ROOT}/seeds/SEED-*.md\` and match \`trigger_when\` tokens against the prompt text. Surface up to 3 matching seeds with file/title/action and ask whether to apply or ignore. When applied, add them to \`00-idea.md\` under \`Discovered context\`.
178
- 3. **Origin-document discovery (Phase 1).** Scan for \`docs/prd/**\`, \`docs/rfcs/**\`, \`docs/adr/**\`, \`docs/design/**\`, \`specs/**\`, root-level \`PRD.md\` / \`SPEC.md\` / \`DESIGN.md\` / \`REQUIREMENTS.md\`. Summarize any hits in \`00-idea.md\` under \`Discovered context\`. Surface conflicts with the prompt before routing.
179
- 4. **Stack detection (Phase 2).** Inspect \`package.json\` engines, \`pyproject.toml\`, \`go.mod\`, \`Cargo.toml\`, \`pom.xml\`, \`build.gradle*\`, \`Dockerfile\`, \`docker-compose*.yml\`, and CI configs. Record stack + versions on the \`Stack:\` line. Do not invent stack details.
180
- 5. Read \`${flowPath}\`.
181
- 6. If \`completedStages\` is non-empty:
182
- - Inform: "You have an active flow at stage **{currentStage}** with {N} completed stages. Starting a new tracked flow will reset progress."
183
- - Ask: "Continue with reset? (A) Yes, start fresh (B) No, resume current flow"
184
- - If (B) → switch to Path B behavior.
185
- If \`completedStages\` is empty, all gate \`passed\` arrays are empty, and \`${RUNTIME_ROOT}/artifacts/00-idea.md\` is missing, treat it as a fresh init placeholder — do **not** ask whether to continue the current flow.
186
- 7. **Classify the idea** using the heuristic below and present one compact Start framing summary (class, internal track recommendation, stack, origin docs, seed recalls, next action). Wait for explicit confirmation or override before mutating any state only when reset/conflict/ambiguity makes it necessary.
187
- - If \`${RUNTIME_ROOT}/config.yaml\` defines \`trackHeuristics\`, apply those vocabulary hints (\`fallback\`, \`tracks.<id>.{triggers,veto}\`) on top of built-in defaults. Evaluation order is fixed: \`standard -> medium -> quick\`. (Honest note: this is advisory prose; the LLM applies it, not a Node-level router.)
142
+ 1. **Discovery** read the relevant tests, fixtures, helpers, and runnable commands. Cite each finding as \`file:path:line\` in the AC's row in \`builds/<slug>.md\`.
143
+ 2. **RED** write a failing test that encodes the AC's verification line. The test must fail for the **right reason** (the assertion that encodes the AC, not a syntax/import error). **Test file is named after the unit under test, never after the AC id** (\`tests/unit/permissions.test.ts\`, not \`AC-1.test.ts\`). Stage **test files only**, then commit:
188
144
 
189
- **Track heuristic** (lowercase substring match against the user prompt):
145
+ ${COMMIT_HELPER_EXAMPLE}
190
146
 
191
- | Track | Triggers | Use when |
192
- |---|---|---|
193
- | \`quick\` | \`bug\`, \`bugfix\`, \`fix\`, \`hotfix\`, \`patch\`, \`typo\`, \`regression\`, \`rename\`, \`bump\`, \`upgrade dep\`, \`docs only\`, \`comment\`, \`lint\`, \`format\`, \`small\`, \`tiny\`, \`one-liner\`, \`revert\`, \`copy change\` | Single-purpose, spec is essentially known, low blast radius; skips ceremony, not safety |
194
- | \`medium\` | \`add endpoint\`, \`add field\`, \`extend existing\`, \`wire integration\`, \`small migration\`, \`new screen following existing pattern\` | Additive work with existing architecture |
195
- | \`standard\` | \`new feature\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`schema\`, \`integrate\`, \`workflow\`, \`onboarding\` (or no confident quick/medium match) | New or uncertain multi-module work |
147
+ 3. **GREEN** write the smallest production change that turns RED into PASS. Run the **full relevant suite** (not the single test). Stage and commit with \`--phase=green\`.
148
+ 4. **REFACTOR** (mandatory) — either apply a real refactor and commit with \`--phase=refactor\`, or explicitly skip with \`--phase=refactor --skipped --message="refactor(AC-N) skipped: <reason>"\`. Silence fails the gate.
149
+ 5. Append the row to \`builds/<slug>.md\` with all six columns (Discovery, RED proof, GREEN evidence, REFACTOR notes, commits) filled.
196
150
 
197
- - On conflict, prefer \`standard\` over \`medium\`, and \`medium\` over \`quick\`.
198
- - Always state the recommendation as a one-line reason citing matched triggers and a high/medium/low track selection confidence. Clarify that the heuristic is advisory until the managed helper writes state; after that, \`/cc\` follows the selected track. Include override guidance: switch to standard when architecture, schema, migration, security, or unclear scope appears; switch to medium when product framing is needed but architecture is known.
199
- 8. Ask for the single explicit start choice: \`Lean / Guided / Deep\`. Use \`Guided\` as the recommended default unless the user clearly wants compact shaping or unusually deep probing. Keep track internal unless contradiction/reset/reclassification requires surfacing an override.
200
- Normalize the answer (\`trim\`, lower-case) to exactly \`lean\` / \`guided\` / \`deep\` before invoking the start helper; re-ask once if the reply is not one of those. Pass only canonical lowercase tokens to \`--discovery-mode\`.
201
- If the prompt is one short line (at most 12 words) and the workspace matches an empty-repo signal set — either persisted \`repoSignals\` has \`fileCount < 5\` with \`hasReadme\` and \`hasPackageManifest\` false, OR a shallow scan before the first \`start-flow\` shows the same — recommend \`guided\` and confirm before defaulting to \`deep\`.
202
- 9. Run the managed start helper: \`node .cclaw/hooks/start-flow.mjs --track=<quick|medium|standard> --discovery-mode=<lean|guided|deep> --class=<class> --prompt=<prompt> --stack=<stack> --reason=<matched heuristic>\`. The helper writes \`${flowPath}\`, including \`discoveryMode\`, computes \`skippedStages\`, resets the gate catalog, and writes \`${RUNTIME_ROOT}/artifacts/00-idea.md\`. If it fails, STOP, report one human-readable failure line from the JSON \`error\` field, and include the helper JSON payload in a fenced \`json\` block; do not echo the invoking command line, and do not manually edit flow state.
203
- 10. Load and execute the **first stage skill of the chosen track** (\`brainstorm\` for medium/standard, \`spec\` for quick) plus its matching command file.
151
+ \`commit-helper.mjs\` enforces the cycle: GREEN without a prior RED is rejected; REFACTOR without RED+GREEN is rejected; RED commits that contain production files (\`src/\`, \`lib/\`, \`app/\`) are rejected.
204
152
 
205
- ### Reclassification on discovery
153
+ > **Iron Law:** NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. The RED failure is the spec.
154
+
155
+ Never call \`git commit\` directly. The hook is the only path that keeps AC ↔ commit traceability and the TDD cycle intact.
156
+
157
+ ### Step 5a — Parallel-build dispatch (when planner declared it)
158
+
159
+ If \`plans/<slug>.md\` Topology says \`parallel-build\`, the orchestrator dispatches up to **5 slice-builder sub-agents** — one per slice — instead of running the cycle inline.
160
+
161
+ A **slice** is one or more AC sharing a touchSurface. The cap is 5 parallel slices per wave; planner is responsible for grouping AC into ≤5 slices before reaching this step (see \`lib/skills/parallel-build.md\`).
162
+
163
+ For each slice:
164
+
165
+ 1. Create a worktree if the harness supports it: \`git worktree add .cclaw/worktrees/<slug>-<slice-id> -b cclaw/<slug>/<slice-id>\`.
166
+ 2. Dispatch a \`slice-builder\` sub-agent rooted at the worktree path. Pass the slice id, the AC ids it owns, the touchSurface, and the worktree cwd.
167
+ 3. Each slice-builder runs the full RED → GREEN → REFACTOR cycle for every AC it owns, sequentially inside its slice.
168
+
169
+ After all slices return, invoke \`reviewer\` in mode \`integration\` (sub-agent if available, inline otherwise). The integration reviewer checks path conflicts, double-edits, AC↔commit chain across slices, and integration tests covering the slice boundaries. \`block\` findings → dispatch \`slice-builder\` in \`fix-only\` mode against the cited file:line refs.
170
+
171
+ If the harness does not support sub-agent dispatch (or worktree creation fails — non-git repo, permission denied), parallel-build **degrades silently to \`inline\`**: all slices run sequentially in the main working tree. Record the fallback in \`builds/<slug>.md\`. This is not an error.
172
+
173
+ ### When to use sub-agents (and when not to)
174
+
175
+ Use sub-agents for:
176
+
177
+ - **Parallel slice dispatch** during \`parallel-build\` (cap: 5).
178
+ - **Specialist context isolation** for \`architect\`, \`security-reviewer\`, and the integration \`reviewer\` when the harness supports it. A fresh sub-agent reads a small focused filebag instead of the orchestrator's full history.
179
+
180
+ Do **not** use sub-agents for:
181
+
182
+ - Trivial / small / medium slugs (≤4 AC). Run inline. The dispatch overhead is not worth saving 1-2 AC of wall-clock.
183
+ - Sequential work that does not actually parallelize.
184
+ - Routine work the orchestrator can finish in 1-2 turns.
185
+
186
+ ## Step 6 — Review
187
+
188
+ Run \`reviewer\` (and \`security-reviewer\` when relevant). Five Failure Modes are mandatory:
189
+
190
+ ${failureModesChecklist()}
191
+
192
+ Hard cap: 5 review/fix iterations per slug. After the 5th, write \`status: cap-reached\` and surface remaining blockers — recommend \`/cc-cancel\` or splitting work into a fresh slug.
193
+
194
+ Block-level findings → \`slice-builder\` runs in \`fix-only\` mode against the cited file:path:line list, then re-review.
195
+
196
+ ## Step 7 — Ship
197
+
198
+ Write \`ships/<slug>.md\` from \`.cclaw/lib/templates/ship.md\` with release notes, the AC ↔ commit map, and push/PR refs.
199
+
200
+ **Push and PR creation always require explicit user approval in the current turn.** Never run \`git push\` without asking. Never open a PR without asking. \`commit-per-AC\` is auto; everything past commit is not.
201
+
202
+ If the user approves \`git push\`, do that one action and stop. Do not proactively open a PR after pushing unless the user asked.
203
+
204
+ ## Step 8 — Compound (automatic)
205
+
206
+ After ship, automatically check the compound quality gate. Capture \`learnings/<slug>.md\` only if at least one signal is present:
207
+
208
+ - a non-trivial decision was recorded by \`architect\` or \`planner\`;
209
+ - review needed three or more iterations;
210
+ - a security review ran or \`security_flag\` is true;
211
+ - the user explicitly asked to capture (\`/cc <task> --capture-learnings\`).
212
+
213
+ If the gate fails, do not write a learning — silently skip. If it passes:
214
+
215
+ 1. Write \`learnings/<slug>.md\` from \`.cclaw/lib/templates/learnings.md\`.
216
+ 2. Append one line to \`.cclaw/knowledge.jsonl\`:
217
+
218
+ \`\`\`json
219
+ {"slug":"approval-page","ship_commit":"abc1234","shipped_at":"2026-05-07T18:30:00Z","signals":{"hasArchitectDecision":true,"reviewIterations":2,"securityFlag":false,"userRequestedCapture":false}}
220
+ \`\`\`
206
221
 
207
- If mid-stage evidence contradicts the initial Class/Track/Discovery decision (the "trivial" change needs a migration, the "quick" bug fix needs architecture work, an origin doc multiplies scope), STOP and re-classify using the Decision Protocol. On acceptance, run \`node .cclaw/hooks/start-flow.mjs --reclassify --track=<new-track> --discovery-mode=<lean|guided|deep> --class=<new-class> --reason=<why>\`; the helper records \`Reclassification:\` in \`00-idea.md\` and updates state atomically. If it fails, report one human-readable line plus the helper JSON payload in a fenced \`json\` block, never echo the invoking command line, and do not rewrite prior artifacts or manually edit flow-state.
222
+ ## Step 9 Active shipped move
208
223
 
209
- ### Path B: \`/cc\` (no arguments)
224
+ Move every \`<slug>.md\` from \`plans/ builds/ reviews/ ships/ decisions/ learnings/\` into \`.cclaw/flows/shipped/<slug>/\` as \`plan.md\`, \`build.md\`, etc. Write \`shipped/<slug>/manifest.md\` from \`.cclaw/lib/templates/manifest.md\` listing AC and ship_commit. Reset \`flow-state.json\` to \`currentSlug=null, currentStage=null, ac=[]\`.
210
225
 
211
- Progress the tracked flow only when one exists:
226
+ ## Always-ask rules
212
227
 
213
- 1. Read \`${flowPath}\`.
214
- 2. If missing, guide the user to run \`npx cclaw-cli init\` and stop.
215
- 3. If it is only a fresh init placeholder (\`completedStages: []\`, no passed gates, and no \`${RUNTIME_ROOT}/artifacts/00-idea.md\`), stop and ask for \`/cc <prompt>\` to start a tracked run. Do not silently create a brainstorm run.
216
- 4. Check gates for \`currentStage\`.
217
- 5. **TDD:** When \`currentStage\` is \`tdd\`, run \`wave-status --json\`, then reconcile the managed **Parallel Execution Plan** in \`05-plan.md\` with \`wave-plans/wave-NN.md\`. Route by \`nextDispatch.topology\`: \`parallel-builders\` fans out independent units in one controller message, \`single-builder\` dispatches one builder, \`inline\` executes directly only with equivalent evidence, and \`strict-micro\` preserves tiny-slice sequencing. If \`mode: blocked\`, resolve overlaps first. Each delegated \`slice-builder\` span owns its full RED → GREEN → REFACTOR → DOC cycle. Mirror plan \`dependsOn\` ordering between waves.
218
- 6. **Wave resume:** Parallelize unfinished members; never restart completed lanes. Integration-overseer follows \`integrationCheckRequired\`; when skipped, emit \`cclaw_integration_overseer_skipped\` per the hook contract.
219
- 7. If incomplete → load current stage skill and execute.
220
- 8. If complete → advance to next stage and execute. **Auto-advance:** when \`stage-complete\` returns \`ok\`, immediately load the next stage skill and continue without waiting for the user to retype \`/cc\`.
221
- 9. If flow is done → report completion.
228
+ - Always ask once before invoking specialists.
229
+ - Always ask before \`git push\` or PR creation.
230
+ - Always ask before deleting active artifacts (\`/cc-cancel\` is the supported way; do not \`rm\` artifacts directly).
231
+ - Always ask before resuming a refinement that crosses the trivial / medium / large boundary.
222
232
 
223
- ## Public flow habit
233
+ ## Skills attached
224
234
 
225
- Use \`/cc\` for the happy path:
235
+ The following skills auto-trigger during this flow. Do not re-explain them; obey them.
226
236
 
227
- | Scenario | Command |
228
- |---|---|
229
- | Starting work for the first time | \`/cc\` or \`/cc <idea>\` |
230
- | Resuming in a new session | \`/cc\` |
231
- | Progressing after completing a stage | \`/cc\` |
232
- | Starting with a specific idea | \`/cc <idea>\` |
237
+ - **conversation-language** always-on; reply in the user's language but never translate \`AC-N\`, \`D-N\`, \`F-N\`, slugs, paths, frontmatter keys, or hook output.
238
+ - **plan-authoring** — on every edit to \`.cclaw/flows/<slug>/plan.md\`.
239
+ - **ac-traceability** before every commit and before push.
240
+ - **tdd-cycle** always-on while stage=build; enforces RED → GREEN → REFACTOR per AC and the test-file-naming rule.
241
+ - **refinement** when an existing plan match is detected.
242
+ - **parallel-build** when planner topology is \`parallel-build\`; enforces the 5-slice cap and worktree dispatch.
243
+ - **security-review** — when the diff touches sensitive surfaces.
244
+ - **review-loop** — wraps every reviewer / security-reviewer invocation; runs the Concern Ledger + convergence detector.
233
245
 
234
- \`/cc <prompt>\` resolves class + internal track, asks for one discovery mode, and starts the selected track's first stage; \`/cc\` without a prompt follows the current \`flow-state.json\`.
246
+ ${ironLawsMarkdown()}
235
247
  `;
248
+ export function renderStartCommand() {
249
+ return START_COMMAND_BODY;
236
250
  }