cclaw-cli 0.51.24 → 0.51.26

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 (45) hide show
  1. package/README.md +135 -414
  2. package/dist/artifact-linter.js +10 -6
  3. package/dist/config.d.ts +1 -1
  4. package/dist/config.js +28 -3
  5. package/dist/content/core-agents.d.ts +110 -0
  6. package/dist/content/core-agents.js +255 -3
  7. package/dist/content/examples.js +8 -5
  8. package/dist/content/harness-doc.d.ts +1 -0
  9. package/dist/content/harness-doc.js +3 -0
  10. package/dist/content/hooks.d.ts +1 -0
  11. package/dist/content/hooks.js +189 -0
  12. package/dist/content/next-command.js +10 -6
  13. package/dist/content/reference-patterns.d.ts +18 -0
  14. package/dist/content/reference-patterns.js +391 -0
  15. package/dist/content/skills.js +42 -36
  16. package/dist/content/stage-common-guidance.js +19 -3
  17. package/dist/content/stage-schema.d.ts +12 -0
  18. package/dist/content/stage-schema.js +184 -28
  19. package/dist/content/stages/_lint-metadata/index.js +3 -2
  20. package/dist/content/stages/brainstorm.js +7 -3
  21. package/dist/content/stages/design.js +12 -3
  22. package/dist/content/stages/review.js +7 -5
  23. package/dist/content/stages/schema-types.d.ts +9 -2
  24. package/dist/content/stages/scope.js +8 -2
  25. package/dist/content/stages/ship.js +3 -2
  26. package/dist/content/stages/tdd.js +18 -13
  27. package/dist/content/start-command.js +3 -2
  28. package/dist/content/status-command.js +17 -6
  29. package/dist/content/subagents.js +286 -40
  30. package/dist/content/templates.js +64 -3
  31. package/dist/content/tree-command.js +7 -1
  32. package/dist/delegation.d.ts +34 -1
  33. package/dist/delegation.js +168 -8
  34. package/dist/doctor-registry.js +9 -0
  35. package/dist/doctor.js +121 -6
  36. package/dist/gate-evidence.js +25 -2
  37. package/dist/harness-adapters.d.ts +6 -0
  38. package/dist/harness-adapters.js +28 -4
  39. package/dist/install.js +5 -10
  40. package/dist/internal/advance-stage.js +179 -26
  41. package/dist/run-persistence.js +21 -3
  42. package/dist/tdd-verification-evidence.d.ts +17 -0
  43. package/dist/tdd-verification-evidence.js +43 -0
  44. package/dist/types.d.ts +10 -0
  45. package/package.json +1 -1
package/README.md CHANGED
@@ -1,471 +1,192 @@
1
1
  # cclaw
2
2
 
3
- **Install once, ship every time.** cclaw is an installer-first workflow
4
- runtime that gives your AI coding agent one inspectable path from idea to
5
- shipped PR — **plus an automatic closeout chain** that turns every ship
6
- into reusable knowledge:
3
+ **cclaw is a file-backed flow runtime for coding agents.** It turns Claude Code, Cursor, OpenCode, and Codex into one repeatable path from idea to shipped change: visible stages, hard gates, real subagent evidence, and resumable closeout in your repo.
7
4
 
8
- > **brainstorm → scope → design → spec → plan → tdd → review → ship**
9
- > **↳ auto-closeout: retro → compound → archive** *(resumable, never manual)*
5
+ ```text
6
+ idea
7
+ |
8
+ v
9
+ +-------------+ +--------+ +--------+ +------+ +------+ +-----+
10
+ | brainstorm | ---> | scope | ---> | design | ---> | spec | ---> | plan | ---> | tdd |
11
+ +-------------+ +--------+ +--------+ +------+ +------+ +-----+
12
+ |
13
+ v
14
+ +--------+ +------+
15
+ | review | ---> | ship |
16
+ +--------+ +------+
17
+ |
18
+ v
19
+ retro -> compound -> archive
20
+ ```
10
21
 
11
- Every stage has real gates the agent cannot skip, every decision leaves a
12
- file-backed audit trail, and the same slash commands work across Claude
13
- Code, Cursor, OpenCode, and OpenAI Codex.
22
+ The promise is simple: at any point you can ask **where are we, what is blocked, what evidence exists, and what should run next?**
14
23
 
15
- You install cclaw **once** from the terminal, then everything happens
16
- inside your harness — no hidden control plane, no background daemon, no
17
- operational knobs to memorise.
24
+ ## First 5 Minutes
18
25
 
19
- ---
26
+ Requirements: Node.js 20+ and a git project root.
20
27
 
21
- ## Who this is for
28
+ ```bash
29
+ cd /path/to/your/repo
30
+ npx cclaw-cli
31
+ ```
22
32
 
23
- - Solo builders who want **shipped outcomes** instead of endless chat.
24
- - Engineering teams that need a **single, repeatable path** for AI-assisted
25
- changes across multiple harnesses and languages.
26
- - Staff engineers and tech leads who want **enforceable discipline**:
27
- locked-in decisions, no placeholders, mandatory TDD, traceable plans.
28
- - Maintainers who want a compact, file-backed flow their harness agents can actually follow.
33
+ Then work from your coding harness:
29
34
 
30
- ---
35
+ ```text
36
+ /cc <idea> start a tracked flow
37
+ /cc-next resume or advance the current flow
38
+ /cc-view status inspect current state without changing it
39
+ ```
31
40
 
32
- ## How it works
41
+ For scripted setup:
33
42
 
34
- ```
35
- ┌─────────┐ ┌──────┐ ┌────────┐ ┌──────┐ ┌──────┐
36
- │ Idea │ → │ /cc │ → │Classify│ → │Track │ → │Stages│
37
- └─────────┘ └──────┘ └────────┘ └──────┘ └──┬───┘
38
-
39
- ┌───────────────────────────────────────────────┘
40
-
41
- brainstorm → scope → design → spec → plan → tdd → review → ship
42
- │ │ │ │ │ │ │ │
43
- ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
44
- 01.md 02.md 03.md 04.md 05.md 06.md 07.md 08.md
45
- │ │
46
- └──── gates + subagents + knowledge capture │
47
- happen at every step │
48
-
49
- ┌─────────────────────────┐
50
- │ automatic closeout │
51
- │ (resumable state │
52
- │ machine, never manual)│
53
- └────────────┬────────────┘
54
-
55
- retro ──► compound ──► archive
56
- 09.md (knowledge (runs/
57
- promoted) <slug>/)
43
+ ```bash
44
+ npx cclaw-cli init --harnesses=claude,cursor --no-interactive
58
45
  ```
59
46
 
60
- Every stage reads and writes real files under `.cclaw/`. `flow-state.json`
61
- holds the single source of truth for "where are we" — including
62
- `closeout.shipSubstate` so a ship → retro → compound → archive chain
63
- resumes at the exact step after any interruption. `knowledge.jsonl`
64
- accumulates reusable lessons **throughout** the flow, not only at the
65
- end; stage artifacts live under `.cclaw/artifacts/` until archive rolls
66
- them into `.cclaw/runs/<date-slug>/`.
47
+ If generated files or hooks look stale, run `cclaw doctor`. If they need to be regenerated, run `npx cclaw-cli sync`.
67
48
 
68
- ```
69
- You ──► /cc <idea>
70
-
71
-
72
- harness loads stage contract + HARD-GATE
73
-
74
-
75
- cclaw reads state + knowledge, guides execution
76
-
77
-
78
- artifacts written, handoff captured
79
-
80
-
81
- next stage is explicit in flow-state.json
82
- ```
49
+ ## Why cclaw
83
50
 
84
- ---
51
+ AI coding sessions fail when decisions live only in chat. cclaw puts the operating truth in files:
85
52
 
86
- ## 30-second install
53
+ ```text
54
+ .cclaw/
55
+ artifacts/ active stage docs: 00-idea.md through 09-retro.md
56
+ state/flow-state.json current stage, gates, stale markers, closeout.shipSubstate
57
+ state/delegation-log.json
58
+ subagent dispatches, waivers, evidence refs
59
+ knowledge.jsonl reusable lessons harvested from stage artifacts
60
+ runs/ archived run snapshots
61
+ ```
87
62
 
88
- Requirements:
63
+ That gives you:
89
64
 
90
- - Node.js **20+** (matches the package `engines` field).
91
- - Run from the **git project root** you want cclaw to manage, not from `~`
92
- or a nested package directory.
65
+ - **One path** from idea to ship, with `quick`, `medium`, and `standard` tracks.
66
+ - **Real gates** for evidence, tests, review, delegation, stale-stage recovery, and closeout.
67
+ - **Subagents with accountability**: controller owns state, workers do bounded tasks, overseers validate, evidence lands in `delegation-log.json`.
68
+ - **Recovery instead of confusion**: `/cc-view status` tells you the blocker and the next command.
69
+ - **Portable harness behavior** across Claude Code, Cursor, OpenCode, and Codex.
93
70
 
94
- ```bash
95
- cd /path/to/your/repo
96
- npx cclaw-cli
97
- ```
71
+ ## The Daily Loop
98
72
 
99
- Interactive setup will pick which harnesses to install into. For CI or
100
- scripted installs:
73
+ ```text
74
+ 1. Start or resume
75
+ /cc <idea> or /cc-next
101
76
 
102
- ```bash
103
- npx cclaw-cli init --harnesses=claude,cursor --no-interactive
104
- ```
77
+ 2. Work the current stage
78
+ The agent writes/updates .cclaw/artifacts/<stage>.md
79
+
80
+ 3. Prove the gate
81
+ stage-complete records evidence in flow-state.json
105
82
 
106
- That's the entire required CLI interaction for the normal workflow.
107
- Everything day-to-day happens inside your harness (Claude Code, Cursor,
108
- OpenCode, or Codex); optional maintenance commands are listed in the
109
- CLI reference.
83
+ 4. Inspect when stuck
84
+ /cc-view status
110
85
 
111
- If cclaw says it is not installed, either run `npx cclaw-cli init` in the
112
- repo root or `cd` to the project that already contains `.cclaw/`.
86
+ 5. Close out after ship
87
+ /cc-next continues retro -> compound -> archive
88
+ ```
113
89
 
114
- ### What gets generated
90
+ Tracks keep the flow proportional:
115
91
 
116
92
  ```text
117
- .cclaw/
118
- ├── commands/ # four entrypoints: /cc, /cc-next, /cc-ideate, /cc-view
119
- ├── skills/ # flow-critical skills loaded by the harness
120
- ├── templates/ # artifact skeletons for each stage
121
- ├── rules/ # opt-in language rule packs
122
- ├── agents/ # subagent definitions
123
- ├── hooks/ # harness-agnostic hook runtime
124
- ├── artifacts/ # active run artifacts (00-idea.md -> 09-retro.md)
125
- ├── runs/ # archived run snapshots: YYYY-MM-DD-slug/
126
- ├── state/ # flow-state.json + stage activity log
127
- └── knowledge.jsonl # append-only lessons + patterns
93
+ quick spec -> tdd -> review -> ship
94
+ medium brainstorm -> spec -> plan -> tdd -> review -> ship
95
+ standard brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship
128
96
  ```
129
97
 
130
- Plus harness-specific shims:
131
-
132
- - `.claude/commands/cc*.md` + `.claude/hooks/hooks.json`
133
- - `.cursor/commands/cc*.md` + `.cursor/hooks.json` + `.cursor/rules/cclaw-workflow.mdc`
134
- - `.opencode/commands/cc*.md` + `.opencode/plugins/cclaw-plugin.mjs`
135
- - `.agents/skills/cc*/SKILL.md` + `.codex/hooks.json` (Codex; skills are
136
- activated via `/use cc` or description-based auto-matching. Hooks
137
- require Codex CLI ≥ v0.114 and `[features] codex_hooks = true` in
138
- `~/.codex/config.toml`; `cclaw init --codex` offers to patch that flag
139
- for you. `cclaw doctor` reports stale legacy Codex layouts.)
140
- - `AGENTS.md` with a managed routing block (includes a Codex-specific note)
141
- — see [`docs/agents-block.example.md`](./docs/agents-block.example.md)
142
- for a static example of what the harness reads.
143
-
144
- ### `.cclaw/config.yaml` — the minimal surface
145
-
146
- `cclaw init` writes five keys, on purpose:
147
-
148
- ```yaml
149
- version: ${CCLAW_VERSION}
150
- flowVersion: 1.0.0
151
- harnesses:
152
- - claude
153
- - cursor
154
- - opencode
155
- - codex
156
- strictness: advisory # advisory | strict — one knob for prompt-guard + TDD
157
- gitHookGuards: false # opt in to managed .git/hooks/pre-commit + pre-push
158
- ```
98
+ Track selection is **model-guided and advisory** during `/cc`. Runtime enforcement begins after state is written: `/cc-next` follows the selected track, required gates, delegation rules, stale-stage markers, and `closeout.shipSubstate`.
159
99
 
160
- If cclaw detects a Node / Python / Go project at init time, a sixth
161
- `languageRulePacks` line appears (auto-populated from `package.json`,
162
- `pyproject.toml` / `requirements.txt`, `go.mod`). That is the full
163
- default surface — a new user sees nothing they need to understand yet.
100
+ ## When Blocked
164
101
 
165
- Advanced knobs (`ironLaws.strictLaws` per-law escapes,
166
- `tdd.testPathPatterns` / `tdd.productionPathPatterns`,
167
- `compound.recurrenceThreshold`, `defaultTrack`, `trackHeuristics`,
168
- `sliceReview`) are **opt-in**: add them by hand when you need them.
169
- `cclaw upgrade` preserves exactly what you wrote — it never silently
170
- reintroduces defaults you removed.
102
+ Start here:
103
+
104
+ ```text
105
+ /cc-view status
106
+ ```
171
107
 
172
- Full key-by-key reference: [`docs/config.md`](./docs/config.md).
108
+ A useful status should read like an operator note, not a raw dump:
173
109
 
174
- ---
110
+ ```text
111
+ Current: tdd (standard)
112
+ Blocked by: NO_SOURCE_CONTEXT
113
+ Next: cclaw internal rewind plan "add bootstrap slice", then /cc-next
114
+ Evidence needed: fresh RED/GREEN/REFACTOR slice and verification output
115
+ ```
175
116
 
176
- ## The four commands you actually use
117
+ Common exits:
177
118
 
178
- All four appear as slash commands in every supported harness. This is the
179
- top-level user surface: `/cc`, `/cc-next`, `/cc-ideate`, and `/cc-view status`
180
- cover the happy path. Operator/support tools stay separate so the harness
181
- does not feel like a command framework.
182
119
 
183
- | Command | What it does |
184
- |---|---|
185
- | **`/cc <idea>`** | Classify the task, discover origin docs (`docs/prd/**`, ADRs, root `PRD.md`, …), sniff the stack, recommend a track, then start the first stage of that track. `/cc` without arguments resumes the current flow. |
186
- | **`/cc-next`** | The one progression primitive. Reads `flow-state.json`, checks gates + mandatory subagent delegations, and either resumes the current stage or advances to the next. `/cc-next` in a new session is how you **resume**. |
187
- | **`/cc-ideate`** | Repository improvement ideate mode. Scans for TODOs, flaky tests, oversized modules, docs drift, and recurring knowledge-store lessons, **persists the ranked backlog** to `.cclaw/artifacts/ideate-<date>-<slug>.md`, and ends with a concrete handoff: launch `/cc` on the selected candidate in the same session, save-and-close, or discard. Resume check on next run reuses any ideate artifact younger than 30 days. Never mutates `flow-state.json`. |
188
- | **`/cc-view`** | Read-only flow visibility. `/cc-view status` (default) shows stage progress, mandatory delegations with their fulfillment mode (isolated / generic-dispatch / role-switch), the ship closeout substate (retro → compound → archive), and the active harness parity row. `/cc-view tree` renders the same picture as a tree with a closeout sub-branch under ship and harness capability status from `cclaw doctor --explain`. `/cc-view diff` shows stage/gate/closeout/delegation changes from visible state and git evidence. Never mutates state. |
120
+ | Situation | Next action |
121
+ | ------------------------------------------------- | ------------------------------------------------------------------------------------ |
122
+ | Missing gates | Run `/cc-next`, finish the stage, then complete with evidence. |
123
+ | Mandatory delegation missing evidence | Dispatch the worker/overseer or waive explicitly with rationale. |
124
+ | `NO_SOURCE_CONTEXT` or `NO_TEST_SURFACE` | Rewind to `plan`/`spec`, define the source or test surface, then resume TDD. |
125
+ | `NO_IMPLEMENTABLE_SLICE` or `RED_NOT_EXPRESSIBLE` | Rework `design`/`spec`/`plan` until one vertical slice is testable. |
126
+ | `NO_VCS_MODE` | Restore git, set `vcs: none` with hash evidence, or configure `tdd.verificationRef`. |
127
+ | Review blocked | `cclaw internal rewind tdd "review_blocked_by_critical <finding-ids>"`. |
128
+ | Stale stage after rewind | Redo the marked stage, then `cclaw internal rewind --ack <stage>`. |
129
+ | Broken hooks or generated files | `cclaw doctor`, then `npx cclaw-cli sync` if needed. |
189
130
 
190
- Operational extras stay off the main surface: `/cc-next` handles progression
191
- and closeout, `cclaw archive` handles explicit archival/reset, and
192
- `cclaw doctor` verifies install/runtime wiring. Doctor is not a replacement
193
- for a real harness smoke test; it catches broken files, stale hooks, and
194
- schema drift before the user loses a run.
195
131
 
196
- ### Example first-run
132
+ ## Subagents Without Theater
197
133
 
198
134
  ```text
199
- > /cc Add rate limiting to the public /api/v1/search endpoint
200
-
201
- cclaw: Classifying task…
202
- Class: software-medium
203
- Discovered context: docs/rfcs/rate-limit-strategy.md (rate-limit policy draft)
204
- Stack: node 20.10.0 (pnpm), fastify 4.26, redis 7
205
- Recommended track: medium (matched triggers: "add endpoint")
206
- Override? (A) keep medium (B) switch track (C) cancel
207
- > A
208
- cclaw: Persisting flow-state.json, seeding 00-idea.md, entering brainstorm…
135
+ user goal
136
+ |
137
+ v
138
+ controller ---------------> worker: bounded implementation/test/doc task
139
+ | |
140
+ | v
141
+ +----------------------> overseer: read-only validation
142
+ |
143
+ v
144
+ evidence refs + terminal status
145
+ |
146
+ v
147
+ .cclaw/state/delegation-log.json
209
148
  ```
210
149
 
211
- After this `flow-state.json` contains:
150
+ The controller owns `flow-state.json`, sequencing, synthesis, and the final answer. Workers own scoped work. Overseers verify. A waiver means the work was **not** done by a real worker and must say why proceeding is acceptable.
212
151
 
213
- ```json
214
- {
215
- "currentStage": "brainstorm",
216
- "track": "medium",
217
- "skippedStages": ["scope", "design"],
218
- "stageGateCatalog": { "brainstorm": { "passed": [], "blocked": [] } },
219
- "completedStages": []
220
- }
221
- ```
152
+ ## What Is Enforced
222
153
 
223
- And `00-idea.md` starts with:
154
+ Enforced by generated helpers and state checks:
224
155
 
225
- ```text
226
- Class: software-medium
227
- Track: medium (matched: "add endpoint")
228
- Stack: node 20.10.0, fastify 4.26, redis 7
156
+ - Stage completion goes through `node .cclaw/hooks/stage-complete.mjs <stage>`.
157
+ - Required gates need evidence before advancement.
158
+ - Mandatory delegations need terminal evidence or explicit waiver.
159
+ - Stale stages block until redone and acknowledged.
160
+ - Review criticals route back to TDD.
161
+ - Ship continues through `retro -> compound -> archive` with `closeout.shipSubstate`.
229
162
 
230
- ## Discovered context
163
+ Advisory/model-guided:
231
164
 
232
- - docs/rfcs/rate-limit-strategy.md rate-limit policy draft (Q2 2026)
165
+ - Initial track heuristic wording.
166
+ - Proactive subagents that are not mandatory for the active stage/tier.
167
+ - Reference patterns that shape prompts but do not add runtime states.
233
168
 
234
- ## User prompt
169
+ ## The Deeper Contract
235
170
 
236
- Add rate limiting to the public /api/v1/search endpoint
237
- ```
171
+ The README is the front door. The full operating contract lives here:
238
172
 
239
- No magic. No ambiguity about where you are.
240
-
241
- ---
242
-
243
- ## The eight stages, the three tracks, and auto-closeout
244
-
245
- cclaw has eight **critical-path** stages plus an automatic three-step
246
- closeout chain (retro → compound → archive). A single prompt rarely needs
247
- all eight critical-path stages, so `/cc` picks a **track** up front so
248
- the flow matches the task.
249
-
250
- | Track | Critical path | Typical trigger |
251
- |---|---|---|
252
- | **quick** | `spec → tdd → review → ship` | `bug`, `hotfix`, `typo`, `rename`, `bump`, `docs only`, one-liners |
253
- | **medium** | `brainstorm → spec → plan → tdd → review → ship` | `add endpoint`, `add field`, `extend existing`, `wire integration` |
254
- | **standard** _(default)_ | all 8 stages (+ mandatory design-time parallel research fleet) | `new feature`, `refactor`, `migration`, `platform`, `schema`, `architecture` |
255
-
256
- **Every track ends with the same auto-closeout chain.** Once ship
257
- completes, `/cc-next` automatically drives
258
- `retro → compound → archive` — with `closeout.shipSubstate` carrying the
259
- exact step across sessions, so a crashed or backgrounded run resumes
260
- without re-drafting retros or re-asking structured questions. See
261
- [Ship and closeout](#ship-and-closeout--automatic-resumable).
262
-
263
- Each critical-path stage produces a dated artifact under
264
- `.cclaw/artifacts/`: `00-idea.md` (seed), `01-brainstorm.md`, `02-scope.md`,
265
- `02a-research.md` (design research fleet synthesis), `03-design.md` through
266
- `08-ship.md`. Closeout adds `09-retro.md`; archive then rolls the whole
267
- bundle into `.cclaw/runs/<YYYY-MM-DD-slug>/` and resets the active flow for
268
- the next run.
269
-
270
- ### Track heuristics are configurable (advisory)
271
-
272
- Every team has its own vocabulary. Override the built-in trigger lists in
273
- `.cclaw/config.yaml`:
274
-
275
- ```yaml
276
- trackHeuristics:
277
- fallback: standard
278
- tracks:
279
- quick:
280
- triggers: [hotfix, rollback, prod-incident]
281
- veto: [schema, migration] # never route quick even if a trigger hits
282
- standard:
283
- triggers: [epic, platform-team, core-infra]
284
- ```
173
+ - [Scheme of Work](./docs/scheme-of-work.md): stages, gates, recovery, closeout, state files.
174
+ - [Configuration](./docs/config.md): strictness, tracks, TDD, compound, language packs, hooks.
175
+ - [Harnesses](./docs/harnesses.md): Claude, Cursor, OpenCode, Codex capabilities and fallbacks.
176
+ - [Generated Agent Block Example](./docs/agents-block.example.md): what gets injected into harness guidance.
285
177
 
286
- Honest caveat: this config is **advisory**. cclaw surfaces these lists in
287
- the `/cc` skill and contract prose so the LLM applies them during
288
- classification — there is no Node-level router that mechanically enforces
289
- the outcome. That is why the knobs are deliberately minimal: per-track
290
- `triggers` + `veto` on top of defaults, plus `fallback`. Evaluation order is
291
- fixed (`standard -> medium -> quick`, narrow-to-broad); regex `patterns`
292
- and a `priority` override were removed in v0.38.0 because nothing in
293
- runtime consumed them.
294
-
295
- ### Mid-flow reclassification
296
-
297
- If you seed a task as `quick` and evidence in spec shows it actually needs a
298
- schema migration, cclaw **stops and asks** before quietly advancing.
299
- Reclassification is append-only: the old decision stays in history.
300
-
301
- ---
302
-
303
- ## Guardrails that ship in the box
304
-
305
- These are the things that make cclaw "enterprise-strong" without turning
306
- it into ceremony:
307
-
308
- - **Locked decisions (D-XX IDs).** Scope decisions are numbered and must
309
- reappear in plan + TDD artifacts. The artifact linter catches any
310
- silent drift.
311
- - **No placeholders.** `TBD`, `TODO`, `similar to task`, and "static for
312
- now"-style scope reduction are flagged before a stage completes.
313
- - **Stale-stage detection.** If an upstream artifact changes after a
314
- downstream stage is already complete, cclaw marks the downstream stage
315
- stale and refuses to advance until you re-run it (or explicitly
316
- acknowledge via a manual override).
317
- - **Mandatory subagent delegation** at TDD, with per-harness waivers.
318
- - **Turn Announce Discipline.** Every stage entry/exit emits a visible
319
- line so users can see what the agent is doing, not just what it says.
320
- - **Inline protocols.** Decision, Completion, and Ethos discipline is embedded in the active stage skill so users do not need to chase generated reference files.
321
- - **Knowledge capture throughout the flow.** Every stage completion
322
- protocol emits typed entries (`rule` / `pattern` / `lesson`) to
323
- `.cclaw/knowledge.jsonl` as the flow progresses — not only at retro.
324
- Retro itself adds a `compound` entry, and the automatic compound pass
325
- after ship promotes recurring entries into first-class
326
- rules/protocols/skills (base threshold from
327
- `compound.recurrenceThreshold`, temporarily lowered to 2 for repositories
328
- with <5 archived runs, plus a critical-severity single-hit override) so
329
- the **next** run is easier. Strict JSONL schema keeps the whole thing
330
- machine-queryable.
331
- - **Automatic integrity checks.** Runtime health is verified on every
332
- stage transition — no command you need to remember to run.
333
-
334
- ---
335
-
336
- ## TDD that actually runs
337
-
338
- The `tdd` stage is not prose guidance. It requires:
339
-
340
- - an explicit **RED** test run (captured in `.cclaw/artifacts/06-tdd.md`)
341
- - a mandatory **`test-author`** subagent dispatch (logged to
342
- `.cclaw/state/delegation-log.json`)
343
- - a **GREEN** full-suite run before exit
344
- - optional **REFACTOR** pass with coverage preservation
345
-
346
- `/cc-next` will not advance past `tdd` until the delegation log shows the
347
- subagent as `completed`. Codex and OpenCode use generated native subagents
348
- by default; a role-switch row is only a degraded fallback and must include
349
- `evidenceRefs` — see [Harness support](#harness-support).
350
-
351
- ---
352
-
353
- ## Ship and closeout — automatic, resumable
354
-
355
- Shipping writes `08-ship.md`. `/cc-next` then automatically walks the
356
- run through a deterministic three-step closeout without extra
357
- commands from you:
358
-
359
- 1. **Retro (`09-retro.md`).** cclaw drafts a retrospective from your
360
- stage artifacts, the delegation log, and the knowledge entries
361
- recorded during the run. It then asks exactly **one** structured
362
- question:
363
- - **accept** *(default)* — keep the draft, record one `compound`
364
- knowledge entry, advance.
365
- - **edit** — you edit `09-retro.md` in place, then `/cc-next` again.
366
- - **skip** — record a one-line reason, continue (archive will
367
- surface the skip in the run manifest).
368
- 2. **Compound pass.** If the knowledge store has clusters recurring 3+
369
- times, cclaw proposes concrete lifts into rules/protocols/skills and
370
- asks once: apply-all / apply-selected / skip. An empty pass advances
371
- silently.
372
- 3. **Archive.** Moves artifacts into `.cclaw/runs/YYYY-MM-DD-<slug>/`,
373
- snapshots `state/`, writes a manifest, and resets `flow-state.json`
374
- to the track's initial stage.
375
-
376
- The chain is driven by `closeout.shipSubstate` inside `flow-state.json`
377
- (`retro_review` → `compound_review` → `ready_to_archive` → `archived`).
378
- If your session dies mid-closeout, a new `/cc-next` resumes at the
379
- exact step — retro drafts are not regenerated and no structured ask is
380
- repeated silently.
381
-
382
- For the default path, `/cc-next` is the only command; explicit archival/reset remains available through `cclaw archive`.
383
-
384
- ---
385
-
386
- ## Harness support
387
-
388
- cclaw is honest about what each harness can and cannot do, and it
389
- closes every real gap with a documented fallback — not a silent waiver.
390
-
391
- | Harness | Dispatch | Fallback | Hook surface | Structured ask |
392
- |---|---|---|---|---|
393
- | Claude Code | full (named subagents) | `native` | full | `AskUserQuestion` |
394
- | Cursor | generic Task dispatcher | `generic-dispatch` | full | `AskQuestion` |
395
- | OpenCode | native subagents (`.opencode/agents`) | `native` | plugin | `question` (permission-gated; `permission.question: "allow"`) |
396
- | OpenAI Codex | native parallel subagents (`.codex/agents`) | `native` | limited (Bash-only `PreToolUse`/`PostToolUse`; requires `codex_hooks` feature flag) | `request_user_input` (experimental; Plan / Collaboration mode) |
397
-
398
- What the fallbacks mean:
399
-
400
- - `native` — Claude, OpenCode, and Codex run mandatory delegations in
401
- isolated subagent workers; cclaw records them with `fulfillmentMode: "isolated"`.
402
- - `generic-dispatch` — Cursor has a real Task tool with a fixed
403
- vocabulary of `subagent_type`s (`explore`, `generalPurpose`, …).
404
- cclaw maps each named agent (planner / reviewer / test-author /
405
- security-reviewer / doc-updater) onto the generic dispatcher with a
406
- structured role prompt.
407
- - `role-switch` — degraded fallback only when the active runtime cannot
408
- expose its declared dispatch surface. The agent announces
409
- `## cclaw role-switch: <stage>/<agent> (<mode>)`, loads
410
- `.cclaw/agents/<agent>.md`, writes outputs to the stage artifact, and
411
- records a delegation row with `fulfillmentMode: "role-switch"` plus at
412
- least one `evidenceRef`. A role-switch `completed` row without
413
- evidenceRefs is classified as `missingEvidence` by `cclaw doctor`.
414
- - `waiver` — reserved. Only fires auto-waivers if every installed
415
- harness declares it. Currently unused — v0.33 removed the old
416
- Codex-only auto-waiver path.
417
-
418
- > **Codex note (v0.40+).** Codex CLI deprecated custom prompts in v0.89
419
- > (Jan 2026), but Codex ≥ v0.114 (Mar 2026) grew an experimental
420
- > lifecycle hooks API. cclaw installs Codex entry points as native
421
- > **skills** under `.agents/skills/cc*/SKILL.md` (invoke with `/use cc`,
422
- > `/use cc-next`, `/use cc-view`, `/use cc-ideate`, or
423
- > by typing `/cc …` in plain text — Codex auto-matches from the skill
424
- > description) **and** writes `.codex/hooks.json` so session-start
425
- > rehydration, stop-handoff, prompt-guard, workflow-guard, and
426
- > context-monitor fire automatically — as long as you enable the
427
- > `codex_hooks` feature flag in `~/.codex/config.toml`. `cclaw init
428
- > --codex` asks for consent before patching that file. Codex's
429
- > `PreToolUse`/`PostToolUse` are Bash-only; the stage skills compensate
430
- > for `Write`/`Edit`/`MCP` tool calls with explicit in-turn checks. Run
431
- > `cclaw doctor` to see the current state of hooks, the feature flag,
432
- > and any legacy layout to clean up.
433
-
434
- The full capability matrix lives in
435
- [`docs/harnesses.md`](./docs/harnesses.md). Harness capability gaps are
436
- reported by `cclaw doctor` instead of generating reference files into the
437
- user project.
438
-
439
- Runtime state stays small: `flow-state.json` is the source of truth, while
440
- stage activity is an append-only trace for what happened during the run.
441
- Derived diagnostics are produced on demand by `cclaw doctor`.
442
-
443
- ---
444
-
445
- ## CLI reference
446
-
447
- `cclaw-cli` is deliberately small: it installs, syncs, upgrades, diagnoses, and removes the generated harness runtime. Day-to-day flow work happens inside your harness via `/cc*` commands and Node hooks.
178
+ ## CLI Reference
448
179
 
449
180
  ```bash
450
- npx cclaw-cli # launches interactive setup (or prints
451
- # a one-line status hint if already installed)
452
- npx cclaw-cli sync # re-materialize generated runtime from config.yaml
453
- npx cclaw-cli upgrade # refresh generated files; preserves .cclaw/config.yaml
454
- npx cclaw-cli archive # explicit/manual archive; normal post-ship closeout uses /cc-next
455
- npx cclaw-cli uninstall # remove .cclaw + generated harness shims
181
+ npx cclaw-cli # interactive setup or installed status hint
182
+ npx cclaw-cli init --harnesses=<list> --no-interactive
183
+ npx cclaw-cli sync # regenerate managed runtime files
184
+ npx cclaw-cli upgrade # refresh generated files while preserving config
185
+ npx cclaw-cli archive # explicit archive/reset; normal closeout uses /cc-next
186
+ npx cclaw-cli uninstall # remove .cclaw and generated harness shims
456
187
  npx cclaw-cli --version
457
188
  ```
458
189
 
459
- The generated `node .cclaw/hooks/stage-complete.mjs <stage>` helper is the canonical stage-closeout path and must not require a runtime `cclaw` binary in `PATH`.
460
-
461
- For CI or scripted installs, `cclaw-cli init --harnesses=<list>
462
- --no-interactive` is the non-interactive form. All other tunables
463
- (prompt-guard strictness, TDD enforcement, language rule packs, track
464
- heuristics) are set by editing `.cclaw/config.yaml` directly — see
465
- [`docs/config.md`](./docs/config.md) for the full key reference.
466
-
467
- ---
468
-
469
190
  ## License
470
191
 
471
- [MIT](./LICENSE)
192
+ [MIT](./LICENSE)
@@ -1762,12 +1762,15 @@ export async function lintArtifact(projectRoot, stage, track = "standard") {
1762
1762
  }
1763
1763
  else {
1764
1764
  const learnings = parseLearningsSection(learningsBody);
1765
+ const meaningfulStageNoneWarning = learnings.ok && learnings.none && ["design", "tdd", "review"].includes(stage)
1766
+ ? " Warning: design/tdd/review usually produce reusable decisions, test patterns, or review lessons; keep `None this stage` only for truly mechanical work."
1767
+ : "";
1765
1768
  findings.push({
1766
1769
  section: "Learnings",
1767
1770
  required: requireLearnings,
1768
1771
  rule: "`## Learnings` must contain either a single `- None this stage.` bullet or JSON bullets compatible with knowledge.jsonl fields (type/trigger/action/confidence required).",
1769
1772
  found: learnings.ok,
1770
- details: learnings.details
1773
+ details: `${learnings.details}${meaningfulStageNoneWarning}`
1771
1774
  });
1772
1775
  }
1773
1776
  if (stage === "brainstorm") {
@@ -2479,13 +2482,14 @@ export async function checkReviewSecurityNoChangeAttestation(projectRoot) {
2479
2482
  const securityTableRowPattern = /^\|\s*[^|\n]+\|\s*[^|\n]+\|\s*security\s*\|\s*[^|\n]+\|\s*[^|\n]+\|/imu;
2480
2483
  const securityBulletPattern = /^[*-]\s+.*\b(?:security|auth|injection|secret|credential|permission)\b/imu;
2481
2484
  const hasSecurityFinding = securityTableRowPattern.test(securityBody) || securityBulletPattern.test(securityBody);
2482
- const attestationMatch = /NO_CHANGE_ATTESTATION\s*:\s*(.*)/iu.exec(securityBody);
2483
- const hasNoChangeAttestation = Boolean(attestationMatch && attestationMatch[1]?.trim().length > 0);
2484
- if (attestationMatch && attestationMatch[1]?.trim().length === 0) {
2485
- errors.push("NO_CHANGE_ATTESTATION must include a non-empty rationale.");
2485
+ const attestationMatch = /\b(NO_CHANGE_ATTESTATION|NO_SECURITY_IMPACT)\b\s*:\s*(.*)/iu.exec(securityBody);
2486
+ const attestationToken = attestationMatch?.[1] ?? "NO_CHANGE_ATTESTATION";
2487
+ const hasNoChangeAttestation = Boolean(attestationMatch && attestationMatch[2]?.trim().length > 0);
2488
+ if (attestationMatch && attestationMatch[2]?.trim().length === 0) {
2489
+ errors.push(`${attestationToken} must include a non-empty rationale.`);
2486
2490
  }
2487
2491
  if (!hasSecurityFinding && !hasNoChangeAttestation) {
2488
- errors.push("Layer 2 security evidence missing: include at least one security finding or `NO_CHANGE_ATTESTATION: <reason>`.");
2492
+ errors.push("Layer 2 security evidence missing: include at least one security finding or `NO_CHANGE_ATTESTATION: <reason>` / `NO_SECURITY_IMPACT: <reason>`.");
2489
2493
  }
2490
2494
  return {
2491
2495
  ok: errors.length === 0,