cclaw-cli 0.51.19 → 0.51.22

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 (44) hide show
  1. package/dist/artifact-linter.js +89 -6
  2. package/dist/config.d.ts +8 -1
  3. package/dist/config.js +9 -6
  4. package/dist/content/examples.js +1 -0
  5. package/dist/content/hook-events.js +1 -5
  6. package/dist/content/hook-manifest.d.ts +2 -4
  7. package/dist/content/hook-manifest.js +4 -3
  8. package/dist/content/meta-skill.js +7 -9
  9. package/dist/content/next-command.js +2 -2
  10. package/dist/content/node-hooks.js +15 -16
  11. package/dist/content/observe.js +2 -4
  12. package/dist/content/opencode-plugin.js +5 -6
  13. package/dist/content/review-loop.js +15 -5
  14. package/dist/content/review-prompts.js +1 -1
  15. package/dist/content/skills.js +3 -2
  16. package/dist/content/stage-schema.d.ts +0 -1
  17. package/dist/content/stage-schema.js +2 -5
  18. package/dist/content/stages/brainstorm.js +3 -3
  19. package/dist/content/stages/design.js +18 -17
  20. package/dist/content/stages/plan.js +2 -1
  21. package/dist/content/stages/review.js +10 -10
  22. package/dist/content/stages/scope.js +13 -13
  23. package/dist/content/stages/spec.js +7 -5
  24. package/dist/content/stages/tdd.js +2 -2
  25. package/dist/content/start-command.d.ts +4 -3
  26. package/dist/content/start-command.js +21 -17
  27. package/dist/content/templates.d.ts +1 -1
  28. package/dist/content/templates.js +49 -29
  29. package/dist/content/view-command.js +3 -1
  30. package/dist/delegation.d.ts +0 -1
  31. package/dist/delegation.js +29 -11
  32. package/dist/doctor.js +148 -24
  33. package/dist/gate-evidence.js +19 -7
  34. package/dist/harness-adapters.js +1 -5
  35. package/dist/install.js +111 -24
  36. package/dist/internal/advance-stage.js +90 -11
  37. package/dist/knowledge-store.d.ts +4 -1
  38. package/dist/knowledge-store.js +24 -14
  39. package/dist/retro-gate.d.ts +1 -0
  40. package/dist/retro-gate.js +9 -9
  41. package/dist/run-archive.js +19 -1
  42. package/dist/run-persistence.js +12 -5
  43. package/dist/tdd-cycle.js +6 -3
  44. package/package.json +1 -1
@@ -6,7 +6,7 @@ import { decisionProtocolInstruction } from "../decision-protocol.js";
6
6
  export const DESIGN = {
7
7
  schemaShape: "v2",
8
8
  stage: "design",
9
- complexityTier: "deep",
9
+ complexityTier: "standard",
10
10
  skillFolder: "engineering-design-lock",
11
11
  skillName: "engineering-design-lock",
12
12
  skillDescription: "Engineering lock-in stage. Build a concrete technical spine before spec and planning, with section-by-section interactive review.",
@@ -42,7 +42,7 @@ export const DESIGN = {
42
42
  checklist: [
43
43
  "Compact design lock — for simple greenfield/product slices, produce a tight but complete design spine: codebase investigation, architecture boundary, one labeled diagram, data flow, failure/rescue table, test/perf expectations, and handoff. Do not run a sprawling workshop when a strong engineering lock fits on one page.",
44
44
  "Trivial-Change Escape Hatch — for <=3 files, no new interfaces, and no cross-module data flow, produce a mini-design (rationale, changed files, one risk) and proceed to spec.",
45
- "Tiered Research Fleet run `research/research-fleet.md` before lock; record `.cclaw/artifacts/02a-research.md` and summarize concrete decisions in `## Research Fleet Synthesis`.",
45
+ "Tiered Research — for simple/medium work, do compact inline codebase/research synthesis in `Research Fleet Synthesis`; write `.cclaw/artifacts/02a-research.md` and run the full fleet only for deep/high-risk work or when external framework/architecture uncertainty exists.",
46
46
  "Design Doc Check — read upstream artifacts and current design docs; latest superseding doc wins.",
47
47
  "Investigator pass — before design decisions, read blast-radius code and record touched files, responsibilities, reuse candidates, and existing patterns.",
48
48
  "Scope Challenge + Search Before Building — find existing solutions, minimum change set, and complexity smells before custom architecture.",
@@ -59,14 +59,14 @@ export const DESIGN = {
59
59
  "If a section has no issues, say 'No issues found' and move on.",
60
60
  "Do not skip failure-mode mapping; use Method/Exception/Rescue/UserSees and treat silent user impact without rescue as critical.",
61
61
  "Take a firm position, push back on weak framing, and call out suboptimal architecture with concrete alternatives.",
62
- "Classify ambiguity before acting: ask, enumerate-and-pick, or propose a hypothesis with validation path.",
62
+ "Classify ambiguity before acting. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope, architecture, security, data loss, public API, migration, auth/pricing, or required user approval. Design hypotheses must name validation path, rollback trigger, and owner before they can be carried forward.",
63
63
  "Before final approval, run the critic pass, reconcile material findings, and bound retries with the review-loop policy.",
64
64
  "For baseline approval, present the full design plus exact spec handoff and **STOP** until explicit approval.",
65
65
  "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` must be completed or explicitly waived, then close via `node .cclaw/hooks/stage-complete.mjs design`."
66
66
  ],
67
67
  process: [
68
68
  "Read upstream artifacts and current design docs.",
69
- "Run tiered research fleet and write `.cclaw/artifacts/02a-research.md` before architecture lock.",
69
+ "Run compact research by default; write `.cclaw/artifacts/02a-research.md` only when deep/high-risk uncertainty requires a separate research artifact.",
70
70
  "Run investigator pass plus scope challenge/search-before-building.",
71
71
  "Walk review sections interactively and lock boundaries, data flow, state transitions, edge cases, and failure modes.",
72
72
  "Cover security, observability, deployment, tests, and performance for Standard+ changes.",
@@ -76,17 +76,17 @@ export const DESIGN = {
76
76
  "Write design lock artifact for downstream spec/plan."
77
77
  ],
78
78
  requiredGates: [
79
- { id: "design_research_complete", description: "Parallel research artifact is complete and synthesized into design decisions." },
79
+ { id: "design_research_complete", description: "Research is complete: compact inline synthesis by default, or a separate research artifact for deep/high-risk work, and findings are mapped to design decisions." },
80
80
  { id: "design_architecture_locked", description: "Architecture boundaries are explicit and approved." },
81
81
  { id: "design_data_flow_mapped", description: "Data/state flow includes edge-case paths." },
82
82
  { id: "design_failure_modes_mapped", description: "Failure modes and mitigations are documented." },
83
83
  { id: "design_test_and_perf_defined", description: "Test strategy and performance budget are defined." }
84
84
  ],
85
85
  requiredEvidence: [
86
- "Research artifact written to `.cclaw/artifacts/02a-research.md` with stack/features/architecture/pitfalls sections plus synthesis.",
86
+ "Research Fleet Synthesis is filled in `03-design.md`; for deep/high-risk work, `.cclaw/artifacts/02a-research.md` is also written with stack/features/architecture/pitfalls sections plus synthesis.",
87
87
  "Artifact written to `.cclaw/artifacts/03-design-<slug>.md`.",
88
88
  "Failure-mode table exists in Method/Exception/Rescue/UserSees format.",
89
- "Tier-required diagram markers are present: architecture (all tiers), +shadow/error (Standard+), +state-machine/rollback/deployment-sequence (Deep).",
89
+ "Tier-required diagram markers are present: architecture (all tiers). Standard/Deep add-ons (shadow/error) and Deep add-ons (state-machine/rollback/deployment-sequence) are included only when risk warrants them.",
90
90
  "When `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is true, stale diagram audit finding is clear (no blast-radius file newer than diagram markers without explicit update).",
91
91
  "Security & threat model findings are documented with mitigations.",
92
92
  "Observability and deployment plans are explicit for critical flows.",
@@ -101,7 +101,7 @@ export const DESIGN = {
101
101
  ],
102
102
  inputs: ["scope agreement artifact", "system constraints", "non-functional requirements"],
103
103
  requiredContext: [
104
- "parallel research synthesis from `.cclaw/artifacts/02a-research.md`",
104
+ "compact inline Research Fleet Synthesis, plus `.cclaw/artifacts/02a-research.md` only when deep/high-risk research was needed",
105
105
  "existing architecture and boundaries",
106
106
  "operational constraints",
107
107
  "security and reliability expectations"
@@ -143,16 +143,16 @@ export const DESIGN = {
143
143
  },
144
144
  artifactValidation: [
145
145
  { section: "Upstream Handoff", required: false, validationRule: "Summarizes scope/research decisions, constraints, open questions, and explicit drift before design choices." },
146
- { section: "Research Fleet Synthesis", required: true, validationRule: "Must summarize the tiered lenses actually run (Lightweight=pitfalls, Standard=architecture+pitfalls, Deep=all four) and map findings to concrete design decisions." },
146
+ { section: "Research Fleet Synthesis", required: true, validationRule: "Must summarize the tiered lenses actually run and map findings to concrete design decisions. Default may be compact inline synthesis; full separate research pack is Deep/high-risk only." },
147
147
  { section: "Codebase Investigation", required: false, validationRule: "Investigator pass: list blast-radius files with current responsibilities, discovered patterns, and reuse candidates." },
148
148
  { section: "Search Before Building", required: false, validationRule: "For each technical choice: Layer 1 (exact match), Layer 2 (partial match), Layer 3 (inspiration), EUREKA labels with reuse-first default." },
149
149
  { section: "Architecture Boundaries", required: true, validationRule: "Must list component boundaries with ownership." },
150
150
  { section: "Architecture Diagram", required: true, validationRule: "Must include `<!-- diagram: architecture -->` marker. Diagram must label concrete nodes, label arrows, mark direction, distinguish sync/async edges, and include at least one failure/degraded edge." },
151
- { section: "Data-Flow Shadow Paths", required: false, validationRule: "Standard/Deep: include `<!-- diagram: data-flow-shadow-paths -->` marker plus a table for high-risk choices: chosen path, shadow alternative, switch trigger, fallback/degrade behavior, and verification evidence." },
152
- { section: "Error Flow Diagram", required: false, validationRule: "Standard/Deep: include `<!-- diagram: error-flow -->` marker and failure-detection -> rescue -> user-visible outcome flow." },
153
- { section: "State Machine Diagram", required: false, validationRule: "Deep: include `<!-- diagram: state-machine -->` marker and state transitions for critical flow lifecycle." },
154
- { section: "Rollback Flowchart", required: false, validationRule: "Deep: include `<!-- diagram: rollback-flowchart -->` marker with trigger -> rollback actions -> verification." },
155
- { section: "Deployment Sequence Diagram", required: false, validationRule: "Deep: include `<!-- diagram: deployment-sequence -->` marker with rollout order and guard checks." },
151
+ { section: "Data-Flow Shadow Paths", required: false, validationRule: "Standard/Deep add-on: include `<!-- diagram: data-flow-shadow-paths -->` marker plus a table for high-risk choices: chosen path, shadow alternative, switch trigger, fallback/degrade behavior, and verification evidence." },
152
+ { section: "Error Flow Diagram", required: false, validationRule: "Standard/Deep add-on: include `<!-- diagram: error-flow -->` marker and failure-detection -> rescue -> user-visible outcome flow." },
153
+ { section: "State Machine Diagram", required: false, validationRule: "Deep add-on: include `<!-- diagram: state-machine -->` marker and state transitions for critical flow lifecycle." },
154
+ { section: "Rollback Flowchart", required: false, validationRule: "Deep add-on: include `<!-- diagram: rollback-flowchart -->` marker with trigger -> rollback actions -> verification." },
155
+ { section: "Deployment Sequence Diagram", required: false, validationRule: "Deep add-on: include `<!-- diagram: deployment-sequence -->` marker with rollout order and guard checks." },
156
156
  { section: "Data Flow", required: false, validationRule: "Must include happy path, nil input, empty input, upstream error paths, plus Interaction Edge Case matrix rows for: double-click, nav-away-mid-request, 10K-result dataset, background-job abandonment, zombie connection. Each row must declare handled yes/no and deferred item when not handled." },
157
157
  { section: "Stale Diagram Audit", required: false, validationRule: "When `.cclaw/config.yaml::optInAudits.staleDiagramAudit` is true: blast-radius files from Codebase Investigation must not be newer than the current design diagram-marker baseline unless explicitly refreshed." },
158
158
  { section: "Failure Mode Table", required: true, validationRule: "Use Method/Exception/Rescue/UserSees columns and treat silent user impact without rescue as critical." },
@@ -163,10 +163,11 @@ export const DESIGN = {
163
163
  { section: "Deployment & Rollout", required: true, validationRule: "Must define migration/flag strategy, rollback plan, and post-deploy verification steps." },
164
164
  { section: "What Already Exists", required: false, validationRule: "For each sub-problem: existing code/library found (Layer 1-3/EUREKA label), reuse decision, and adaptation needed." },
165
165
  { section: "Outside Voice Findings", required: false, validationRule: "Critic pass: list adversarial findings and disposition (accept/reject/defer) with rationale per material finding." },
166
- { section: "Spec Review Loop", required: false, validationRule: `Record iteration table with quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("design")}` },
166
+ { section: "Design Outside Voice Loop", required: false, validationRule: `Record iteration table with quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("design")}` },
167
167
  { section: "NOT in scope", required: false, validationRule: "Work considered and explicitly deferred with one-line rationale." },
168
- { section: "Parallelization Strategy", required: false, validationRule: "If multi-module: dependency table, parallel lanes, conflict flags." },
169
- { section: "Unresolved Decisions", required: false, validationRule: "If any: what info is missing, who provides it, default if unanswered." },
168
+ { section: "Parallelization Strategy", required: false, validationRule: "Standard/Deep add-on when multi-module: dependency table, parallel lanes, conflict flags." },
169
+ { section: "Interface Contracts", required: false, validationRule: "Standard/Deep add-on when module boundaries or APIs change: producers, consumers, and payload/interface expectations." },
170
+ { section: "Unresolved Decisions", required: false, validationRule: "Standard/Deep add-on if any: what info is missing, who provides it, default if unanswered." },
170
171
  { section: "Completion Dashboard", required: true, validationRule: "Lists every review section with status (clear / issues-found-resolved / issues-open), critical/open gap counts, decision count, and unresolved items (or 'None')." }
171
172
  ],
172
173
  trivialOverrideSections: ["Architecture Boundaries", "NOT in scope", "Completion Dashboard"]
@@ -49,7 +49,7 @@ export const PLAN = {
49
49
  "Map scope Locked Decisions — every LD#hash anchor from scope is referenced by at least one plan task (or explicitly marked deferred with reason).",
50
50
  "Run anti-placeholder + anti-scope-reduction scans — block `TODO/TBD/...` and phrasing like `v1`, `for now`, `later` for locked boundaries.",
51
51
  "Define validation points — mark where progress must be checked before continuing, with concrete command and expected evidence.",
52
- "Define execution posture — record whether execution should be sequential, dependency-batched, parallel-safe, or blocked; include risk triggers and RED/GREEN/REFACTOR checkpoint/commit expectations when the repo workflow supports them.",
52
+ "Define execution posture — record whether execution should be sequential, dependency-batched, parallel-safe, or blocked; include risk triggers and RED/GREEN/REFACTOR checkpoint/commit expectations when the repo workflow supports them. This fulfills the `plan_execution_posture_recorded` gate.",
53
53
  "WAIT_FOR_CONFIRM — write plan artifact and explicitly pause. **STOP.** Do NOT proceed until user confirms. Then close the stage with `node .cclaw/hooks/stage-complete.mjs plan` and tell user to run `/cc-next`."
54
54
  ],
55
55
  interactionProtocol: [
@@ -75,6 +75,7 @@ export const PLAN = {
75
75
  { id: "plan_tasks_sliced_2_5_min", description: "Tasks are small, executable slices." },
76
76
  { id: "plan_dependency_batches_defined", description: "Tasks are grouped into executable batches with gate checks and execution posture." },
77
77
  { id: "plan_acceptance_mapped", description: "Each task maps to a spec acceptance criterion." },
78
+ { id: "plan_execution_posture_recorded", description: "Execution posture is recorded before implementation handoff." },
78
79
  { id: "plan_wait_for_confirm", description: "Execution blocked until explicit user confirmation." }
79
80
  ],
80
81
  requiredEvidence: [
@@ -35,8 +35,8 @@ export const REVIEW = {
35
35
  "Diff Scope — Run `git diff` against base branch. If no diff, exit early with APPROVED (no changes to review). Scope the review to changed files unless blast-radius analysis requires wider inspection.",
36
36
  "Change-Size Check — ~100 lines = normal. ~300 lines = consider splitting. ~1000+ lines = strongly recommend stacked PRs. Flag large diffs to the user.",
37
37
  "Risk-Based Second Opinion — compute changed-line count, files-touched count, and trust-boundary movement. Dispatch an adversarial reviewer only when trust boundaries changed, Critical/Important ambiguity remains, or the diff is both large and high-risk; otherwise record `not triggered`.",
38
- "Load upstream evidence — read TDD artifact (RED + GREEN + REFACTOR), spec, and plan. Verify evidence chain is unbroken.",
39
- "Run traceability matrix execute `cclaw internal trace-matrix` (or equivalent helper) and confirm there are no orphaned criteria/tasks/tests before declaring ship readiness.",
38
+ "Load upstream evidence — read TDD artifact (RED + GREEN + REFACTOR), spec, and plan when present. On quick track, use spec acceptance items / bug reproduction slices instead of nonexistent plan artifacts.",
39
+ "Run traceability matrix when plan artifacts exist or the active track enforces it; on quick, confirm spec acceptance/reproduction slices are covered without requiring plan-task coverage.",
40
40
  "Layer 1: Spec Compliance — check every acceptance criterion against implementation. Verdict: pass/fail per criterion.",
41
41
  "Layer 2: Integrated findings — one structured pass tagged by category: correctness, security, performance, architecture, external-safety.",
42
42
  "Security sweep — mandatory dedicated security-reviewer pass across diff + touched modules. A zero-finding pass must include `NO_CHANGE_ATTESTATION` with rationale.",
@@ -45,14 +45,14 @@ export const REVIEW = {
45
45
  "Meta-Review — Were tests actually run? Do test names match what they test? Are there real assertions?",
46
46
  "Classify findings — Critical (blocks ship), Important (should fix), Suggestion (optional improvement).",
47
47
  "Produce verdict — APPROVED, APPROVED_WITH_CONCERNS, or BLOCKED.",
48
- "If verdict is BLOCKED, emit remediation route token `ROUTE_BACK_TO_TDD` and include `cclaw internal rewind tdd \"review_blocked_by_critical\"` with the blocking finding IDs."
48
+ "If verdict is BLOCKED, emit remediation route token `ROUTE_BACK_TO_TDD`, include `cclaw internal rewind tdd \"review_blocked_by_critical\"` with the blocking finding IDs, and satisfy the special transition guard `review_verdict_blocked` instead of `review_criticals_resolved`."
49
49
  ],
50
50
  interactionProtocol: [
51
51
  "Run Layer 1 (spec compliance) completely before starting Layer 2.",
52
52
  "In each review section, present findings ONE AT A TIME. Do NOT batch.",
53
53
  "Classify every finding as Critical, Important, or Suggestion.",
54
54
  decisionProtocolInstruction("each Critical finding", "present resolution options (A/B/C) with trade-offs, and mark one as (recommended)", "recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius", STRUCTURED_ASK_TOOL_LIST_REVIEW),
55
- "Resolve all critical blockers before ship.",
55
+ "Resolve all critical blockers before ship. If verdict is BLOCKED, do not pass `review_criticals_resolved`; pass only the remediation route gate `review_verdict_blocked` when routing back to TDD.",
56
56
  "When verdict is BLOCKED, do not end with a passive stop: explicitly route remediation to TDD via `ROUTE_BACK_TO_TDD` and point to `cclaw internal rewind tdd` with the blocking IDs.",
57
57
  structuredAskSingleChoiceInstruction("final verdict", "verdict (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED)"),
58
58
  "**STOP.** Do NOT proceed to ship until the user provides an explicit verdict."
@@ -70,7 +70,7 @@ export const REVIEW = {
70
70
  { id: "review_layer1_spec_compliance", description: "Spec compliance check completed with per-criterion verdict." },
71
71
  { id: "review_layer2_security", description: "Security review completed." },
72
72
  { id: "review_layer_coverage_complete", description: "Layer coverage map in 07-review-army.json confirms spec/correctness/security/performance/architecture/external-safety tags were considered." },
73
- { id: "review_criticals_resolved", description: "No unresolved critical blockers remain." },
73
+ { id: "review_criticals_resolved", description: "Normal APPROVED or APPROVED_WITH_CONCERNS path only: no unresolved critical blockers remain. BLOCKED routes use review_verdict_blocked instead." },
74
74
  { id: "review_army_json_valid", description: "07-review-army.json passes schema validation (validateReviewArmy)." },
75
75
  { id: "review_trace_matrix_clean", description: "Trace matrix has no orphaned criteria/tasks/test slices for the active run, and evidence cites a discovered real test command before ship handoff." }
76
76
  ],
@@ -79,7 +79,7 @@ export const REVIEW = {
79
79
  "Artifact written to `.cclaw/artifacts/07-review-army.json`.",
80
80
  "Traceability matrix run recorded (no orphaned criteria/tasks/tests for enforced tracks).",
81
81
  "Layer 1 verdict captured with per-criterion pass/fail.",
82
- "Layer 2 sections completed with findings.",
82
+ "Layer 2 sections completed across correctness, security, performance, architecture, and external-safety findings.",
83
83
  "Severity log includes critical/important/suggestion buckets.",
84
84
  "Explicit final verdict: APPROVED, APPROVED_WITH_CONCERNS, or BLOCKED.",
85
85
  "Fresh verification command discovery recorded, and the command cited in `review_trace_matrix_clean` evidence before ship handoff.",
@@ -95,8 +95,8 @@ export const REVIEW = {
95
95
  exitCriteria: [
96
96
  "both layers completed",
97
97
  "all review sections evaluated",
98
- "critical blockers resolved",
99
- "ship readiness explicitly stated"
98
+ "critical blockers resolved for APPROVED paths, or BLOCKED routes through review_verdict_blocked",
99
+ "ship readiness or remediation route explicitly stated"
100
100
  ],
101
101
  platformNotes: [
102
102
  "When citing file locations in findings, use repo-relative forward-slash paths with a line number (`src/foo/bar.ts:42`). Avoid IDE-generated hyperlinks that embed absolute machine-specific paths.",
@@ -115,7 +115,7 @@ export const REVIEW = {
115
115
  artifactValidation: [
116
116
  { section: "Upstream Handoff", required: false, validationRule: "Summarizes spec/plan/tdd decisions, constraints, open questions, and explicit drift before review verdicts." },
117
117
  { section: "Layer 1 Verdict", required: true, validationRule: "Per-criterion pass/fail with references." },
118
- { section: "Layer 2 Findings", required: false, validationRule: "Each finding has severity, description, and resolution status. Security coverage must include either explicit security findings or `NO_CHANGE_ATTESTATION: <reason>` when no security-relevant changes were found." },
118
+ { section: "Layer 2 Findings", required: false, validationRule: "Each finding has severity, description, and resolution status across correctness, security, performance, architecture, and external-safety. Security coverage must include either explicit security findings or `NO_CHANGE_ATTESTATION: <reason>` when no security-relevant changes were found." },
119
119
  { section: "Review Findings Contract", required: true, validationRule: "Structured findings in 07-review-army.json include id/severity/confidence/fingerprint/reportedBy/status and source tags from {spec, correctness, security, performance, architecture, external-safety} with dedup reconciliation summary." },
120
120
  { section: "Review Readiness Snapshot", required: false, validationRule: "Optional compact summary: completed checks, delegation-log status, staleness signal, open critical blockers, and ship recommendation." },
121
121
  { section: "Completeness Snapshot", required: false, validationRule: "Optional compact coverage summary for AC coverage, task coverage, test-slice coverage, and adversarial-review status when triggered." },
@@ -140,7 +140,7 @@ export const REVIEW = {
140
140
  stopGate: true
141
141
  },
142
142
  {
143
- title: "Layer 2: Integrated Correctness / Performance / Architecture",
143
+ title: "Layer 2: Integrated Correctness / Security / Performance / Architecture / External-Safety",
144
144
  evaluationPoints: [
145
145
  "Logic errors and boundary violations",
146
146
  "Race conditions and concurrency issues",
@@ -45,13 +45,13 @@ export const SCOPE = {
45
45
  },
46
46
  executionModel: {
47
47
  checklist: [
48
- "**Compact CEO pass first** — read brainstorm, name the job-to-be-done, challenge whether this is the right product slice, and propose the highest-leverage scope in one pass. For simple apps, keep this to a tight scope contract instead of a full strategy workshop.",
48
+ "**Scope contract first** — read brainstorm, name the job-to-be-done, draft the explicit in-scope/out-of-scope/deferred contract, select one mode, and write the rationale. This is the default path; use dream/10-star/temporal/deep strategy sections only when risk, novelty, or user ambition justifies them.",
49
49
  "**Premise and leverage check** — answer in the artifact: *Right problem? Direct path? What if nothing? Where can we leverage existing code? What is the reversibility cost?* Take a position; do not hedge.",
50
- "**Draft the 10-star vs current-slice boundary** — show what would make the product meaningfully better, then explicitly choose what ships now, what is deferred, and what is excluded without using vague `later/for now` placeholders.",
50
+ "**Conditional 10-star boundary** — for deep/high-risk/product-strategy work, show what would make the product meaningfully better, then explicitly choose what ships now, what is deferred, and what is excluded without vague `later/for now` placeholders. Skip this for straightforward repair work and record `not needed: compact scope`.",
51
51
  "**Pick one of four gstack modes with the user** — SCOPE EXPANSION, SELECTIVE EXPANSION, HOLD SCOPE, or SCOPE REDUCTION. Recommend one, state why and what signal would change it, then STOP for the user's mode/scope approval before writing the final artifact.",
52
- "**Run mode-specific analysis** — match the analysis to the chosen mode: SCOPE EXPANSION enumerates 10x opportunities + delight features; SELECTIVE EXPANSION lists baseline + cherry-picked additions with leverage rationale; HOLD SCOPE proves rigor on the current slice; SCOPE REDUCTION names the smallest useful wedge and what is cut, with follow-up split.",
52
+ "**Run mode-specific analysis only to needed depth** — ordinary path is a selected-mode row plus rationale tied to the scope contract. For deep/high-risk work, expand the analysis to match the chosen mode: SCOPE EXPANSION enumerates 10x opportunities + delight features; SELECTIVE EXPANSION lists baseline + cherry-picked additions; HOLD SCOPE proves rigor on the current slice; SCOPE REDUCTION names the smallest useful wedge.",
53
53
  "**Compare implementation alternatives** — include minimum viable, product-grade, and ideal architecture options with effort (S/M/L/XL), risk (Low/Med/High), pros, cons, and reuses. Recommend one and tie it to mode.",
54
- "**Run outside voice before final approval** — for simple/low-risk scope, record one concise adversarial self-check row; for complex/high-risk/configured scope, iterate until threshold. Record the loop summary in `## Spec Review Loop`, but do not treat it as user approval.",
54
+ "**Run outside voice before final approval** — for simple/low-risk scope, record one concise adversarial self-check row; for complex/high-risk/configured scope, iterate until threshold. Record the loop summary in `## Scope Outside Voice Loop`, but do not treat it as user approval.",
55
55
  "**Ask only one decision-changing question** — if the user rejects the contract but is unsure, offer 3-4 concrete scope moves instead of open-ended interrogation.",
56
56
  "**Write the scope contract after approval** — include in-scope/out-of-scope, discretion areas, deferred items, locked decisions, error/rescue notes, completion dashboard, scope summary (with canonical mode token + next-stage handoff), and explicit approval evidence."
57
57
  ],
@@ -61,18 +61,18 @@ export const SCOPE = {
61
61
  "For simple web-app flows, default to HOLD SCOPE or SELECTIVE EXPANSION, show the exact in/out/deferred contract as a proposal, and STOP for one explicit approval before writing the final scope artifact or completing the stage.",
62
62
  "Challenge premise first, take a firm position, and name one concrete condition that would change it.",
63
63
  "Push back on weak framing: vague scope needs a specific user/problem, platform vision needs a narrow wedge, social proof needs behavioral evidence.",
64
- "Resolve one structural scope issue at a time; otherwise state the assumption and move on.",
64
+ "Resolve one structural scope issue at a time. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope boundary, architecture commitment, security, data loss, public API, migration, auth/pricing, or required user approval.",
65
65
  "If the user says no but cannot name the change, offer concrete moves: keep scope, add one obvious adjacent capability, reduce to wedge, or re-open stack/product direction.",
66
- `Before final approval, record outside-voice findings and a \`## Spec Review Loop\` table using ${reviewLoopPolicySummary("scope")}`,
66
+ `Before final approval, record outside-voice findings and a \`## Scope Outside Voice Loop\` table using ${reviewLoopPolicySummary("scope")}`,
67
67
  "**STOP.** Wait for explicit user approval of the scope mode and scope contract before writing final approval language or advancing.",
68
68
  "**STOP BEFORE ADVANCE.** Mandatory delegation `planner` must be completed or explicitly waived. If no isolated planner is available, use `--waive-delegation=planner --waiver-reason=\"role-switch scope self-review completed\"`. Then close with `node .cclaw/hooks/stage-complete.mjs scope --passed=scope_mode_selected,scope_contract_written,scope_user_approved --evidence-json '{\"scope_mode_selected\":\"<user-approved mode + rationale>\",\"scope_contract_written\":\"<artifact path + sections>\",\"scope_user_approved\":\"<explicit user approval quote or summary>\"}'`. `scope_user_approved` must cite the user's approval; review-loop evidence alone is not approval."
69
69
  ],
70
70
  process: [
71
71
  "Run configured pre-scope audit only when enabled.",
72
- "Run the gstack-style CEO scope pass scaled to risk: job-to-be-done, premise challenge, 10-star upside, smallest useful wedge, and what would change the recommendation.",
72
+ "Run the scope pass scaled to risk: default to job-to-be-done plus explicit scope contract; add premise challenge, 10-star upside, smallest useful wedge, and change conditions only for deep/high-risk scope.",
73
73
  "Compare minimum viable, product-grade, and ideal architecture scope alternatives with explicit reuse/effort/risk.",
74
74
  "Recommend a scope mode with explicit rationale, then ask for user opt-in before treating it as selected.",
75
- "Run outside voice / adversarial self-check before final approval and record a valid `## Spec Review Loop` table.",
75
+ "Run outside voice / adversarial self-check before final approval and record a valid `## Scope Outside Voice Loop` table.",
76
76
  "Write explicit scope contract, discretion areas, deferred items, error/rescue registry, and D-XX locked decisions.",
77
77
  "Produce scope summary, completion dashboard, and exact next-stage handoff before asking final approval."
78
78
  ],
@@ -90,7 +90,7 @@ export const SCOPE = {
90
90
  "Locked Decisions section lists stable LD#hash anchors for non-negotiable boundaries.",
91
91
  "Premise challenge findings documented.",
92
92
  "Outside Voice findings and dispositions are recorded (accept/reject/defer with rationale) before final approval.",
93
- `Spec review loop summary includes a table with columns Iteration, Quality Score, Findings, plus Stop reason, Target score, and Max iterations. This is outside-voice evidence only; it does not satisfy user approval. ${reviewLoopPolicySummary("scope")}`,
93
+ `Scope outside-voice loop summary includes a table with columns Iteration, Quality Score, Findings, plus Stop reason, Target score, and Max iterations. This is outside-voice evidence only; it does not satisfy user approval. ${reviewLoopPolicySummary("scope")}`,
94
94
  reviewLoopSecondOpinionSummary("scope"),
95
95
  "Deferred items list with one-line rationale for each.",
96
96
  "When an upside deferred idea is parked, a seed file is created under `.cclaw/seeds/` and referenced in the artifact.",
@@ -146,17 +146,17 @@ export const SCOPE = {
146
146
  { section: "Locked Decisions (LD#hash)", required: false, validationRule: "List of stable locked decisions with unique `LD#<sha8>` anchors. Each anchor is derived from the normalized Decision cell and is referenced downstream for cross-stage traceability." },
147
147
  { section: "Implementation Alternatives", required: false, validationRule: "2-3 options with Name, Summary, Effort, Risk, Pros, Cons, and Reuses. Must include minimal viable and ideal architecture options." },
148
148
  { section: "Scope Mode", required: true, validationRule: "Must state selected mode and rationale with default heuristic justification." },
149
- { section: "Mode-Specific Analysis", required: false, validationRule: "Deep/complex scope only: document the analysis matching the selected mode. Default path may record a concise mode rationale instead." },
149
+ { section: "Mode-Specific Analysis", required: false, validationRule: "Default path: one selected-mode row with rationale. Deep/complex scope only: document the expanded analysis matching the selected mode." },
150
150
  { section: "In Scope / Out of Scope", required: true, validationRule: "Two separate explicit lists. Canonical form is one `## In Scope / Out of Scope` section with `### In Scope` and `### Out of Scope`; legacy split `## In Scope` and `## Out of Scope` headings are accepted. Out-of-scope must not be empty." },
151
151
  { section: "Discretion Areas", required: false, validationRule: "Explicit list of implementer decision zones, or 'None' if scope is fully locked." },
152
152
  { section: "Deferred Items", required: false, validationRule: "Each item has one-line rationale. If empty, state 'None' explicitly." },
153
153
  { section: "Error & Rescue Registry", required: false, validationRule: "Each scoped capability has: failure mode, detection method, fallback decision." },
154
154
  { section: "Outside Voice Findings", required: false, validationRule: "Must list external/adversarial findings and disposition (accept/reject/defer) with rationale." },
155
- { section: "Spec Review Loop", required: false, validationRule: `Must record iterations, quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("scope")}` },
155
+ { section: "Scope Outside Voice Loop", required: false, validationRule: `Must record iterations, quality score per iteration, stop reason, and unresolved concerns. Enforce ${reviewLoopPolicySummary("scope")}` },
156
156
  { section: "Completion Dashboard", required: true, validationRule: "Lists per-review-section status, count of critical/open gaps, resolved decisions, and unresolved decisions (or 'None')." },
157
157
  { section: "Scope Summary", required: true, validationRule: "Compact recap of the locked scope. Must name the selected mode using one of the canonical tokens (`SCOPE EXPANSION`, `SELECTIVE EXPANSION`, `HOLD SCOPE`, `SCOPE REDUCTION`) and record the track-aware next-stage handoff (`design` for standard, `spec` for medium); the linter checks structure, not English wording." },
158
- { section: "Dream State Mapping", required: false, validationRule: "If present (complex projects): CURRENT STATE, THIS PLAN, 12-MONTH IDEAL, and alignment verdict." },
159
- { section: "Temporal Interrogation", required: false, validationRule: "If present (complex projects): timeline simulation table with decision pressures and lock-now vs defer verdicts." }
158
+ { section: "Dream State Mapping", required: false, validationRule: "Deep/optional only: CURRENT STATE, THIS PLAN, 12-MONTH IDEAL, and alignment verdict. Omit for compact scope." },
159
+ { section: "Temporal Interrogation", required: false, validationRule: "Deep/optional only: timeline simulation table with decision pressures and lock-now vs defer verdicts. Omit for compact scope." }
160
160
  ]
161
161
  },
162
162
  reviewLens: {
@@ -36,10 +36,10 @@ export const SPEC = {
36
36
  },
37
37
  executionModel: {
38
38
  checklist: [
39
- "Read upstream — load design artifact and scope contract. Cross-reference architecture decisions.",
39
+ "Read upstream — standard track loads design + scope; medium loads brainstorm/spec handoff; quick loads `00-idea.md` plus any reproduction context. Cross-reference only artifacts that exist on the active track.",
40
40
  "Define measurable acceptance criteria — each criterion must be observable and falsifiable. No vague adjectives.",
41
41
  "Capture edge cases — for each criterion, define at least one boundary condition and one error condition.",
42
- "Document constraints and assumptions — regulatory, system, integration, and performance boundaries. Surface implicit assumptions explicitly.",
42
+ "Document constraints and assumptions — regulatory, system, integration, and performance boundaries. Only non-critical preference/default assumptions may continue; STOP on uncertainty about scope, architecture, security, data loss, public API, migration, auth/pricing, or required user approval.",
43
43
  "Surface assumptions before finalization — list each assumption with source/confidence, validation path, and whether it is accepted, rejected, or still open.",
44
44
  "Build the Acceptance Mapping contract — for each AC, map upstream design decision, observable evidence, verification method, and likely test level. If any column is unclear, rewrite the criterion.",
45
45
  "Present acceptance criteria to the user in 3-5-item batches, pausing for explicit ACK between batches (see Interaction Protocol).",
@@ -53,7 +53,7 @@ export const SPEC = {
53
53
  "**Chunk acceptance criteria for review.** When presenting the spec to the user for sign-off, deliver acceptance criteria in batches of 3-5 and **pause for explicit ACK** (via Decision Protocol) before sending the next batch. Do not dump the full criteria wall in one message — small batches surface objections earlier and keep the sign-off meaningful. Full spec writeup still lands in `04-spec.md`, but the conversation itself must be digestible.",
54
54
  "Require user confirmation on the written spec. **STOP.** Do NOT proceed to plan until user approves.",
55
55
  "For each criterion, ask: what exact evidence proves this passed? If the evidence or verification command/manual step is vague, rewrite.",
56
- "When encountering ambiguity, classify it before acting: (A) ask user for missing info, (B) enumerate interpretations and pick one with justification, (C) propose hypothesis with validation path. Do NOT silently resolve ambiguity."
56
+ "When encountering ambiguity, classify it before acting: (A) ask user for missing info, (B) enumerate non-critical interpretations and pick one with justification, (C) propose hypothesis with validation path. Do NOT silently resolve ambiguity. STOP on scope, architecture, security, data loss, public API, migration, auth/pricing, or user-approval uncertainty."
57
57
  ],
58
58
  process: [
59
59
  "Define measurable acceptance criteria.",
@@ -75,7 +75,8 @@ export const SPEC = {
75
75
  "Each acceptance criterion maps to upstream design decision, observable evidence, verification method, and likely test level.",
76
76
  "Edge cases documented per criterion.",
77
77
  "Assumptions Before Finalization section records source/confidence, validation path, and accepted/rejected/open disposition.",
78
- "Approval marker captured in artifact."
78
+ "Approval marker captured in artifact.",
79
+ "For quick bug-fix specs, reproduction contract records symptom, repro steps, expected RED test, and acceptance criterion."
79
80
  ],
80
81
  inputs: ["design artifact", "business constraints", "quality requirements"],
81
82
  requiredContext: [
@@ -112,7 +113,8 @@ export const SPEC = {
112
113
  },
113
114
  artifactValidation: [
114
115
  { section: "Upstream Handoff", required: false, validationRule: "Summarizes scope/design decisions, constraints, open questions, and explicit drift before acceptance criteria." },
115
- { section: "Acceptance Criteria", required: true, validationRule: "Each criterion is observable, measurable, and falsifiable. Table must include a Requirement Ref column linking to R# IDs in 02-scope-<slug>.md (legacy 02-scope.md is accepted during migration) and a Design Decision Ref column tracing back to design artifact. AC IDs (AC-1, AC-2…) are stable across revisions — dropped ACs stay with Priority `DROPPED`." },
116
+ { section: "Acceptance Criteria", required: true, validationRule: "Each criterion is observable, measurable, and falsifiable. Standard track should include Requirement Ref and Design Decision Ref columns; quick track may instead link each AC to the reproduction contract or bug slice. AC IDs (AC-1, AC-2…) are stable across revisions — dropped ACs stay with Priority `DROPPED`." },
117
+ { section: "Quick Reproduction Contract", required: false, validationRule: "Quick bug-fix specs own the reproduction contract: symptom, repro steps, expected RED test behavior, and acceptance criterion." },
116
118
  { section: "Edge Cases", required: true, validationRule: "At least one boundary and one error condition per criterion." },
117
119
  { section: "Constraints and Assumptions", required: false, validationRule: "All implicit assumptions surfaced. Constraints have sources." },
118
120
  { section: "Assumptions Before Finalization", required: true, validationRule: "Each assumption has source/confidence, validation path, and accepted/rejected/open disposition before the Approval section is finalized." },
@@ -50,7 +50,7 @@ export const TDD = {
50
50
  "Run verification-before-completion discipline for the slice — capture a fresh test command, commit SHA, and explicit PASS/FAIL status before completion claims.",
51
51
  "REFACTOR: continue the `test-author` evidence cycle (or a dedicated refactor mode when available) to improve code quality without behavior changes. Set `CCLAW_ACTIVE_AGENT=tdd-refactor` when the harness supports phase labels.",
52
52
  "Record evidence — capture test discovery, system-wide impact check, RED failure, GREEN output, and REFACTOR notes in the TDD artifact. When logging a `green` row, attach the closed acceptance-criterion IDs in `acIds` so Ralph Loop status counts them.",
53
- "Annotate traceability — link to plan task ID and spec criterion.",
53
+ "Annotate traceability — link to the active track's source: plan task ID + spec criterion on standard/medium, or spec acceptance item / bug reproduction slice on quick.",
54
54
  "Per-Slice Review (conditional) — if `.cclaw/config.yaml::sliceReview.enabled` is true and the slice meets any trigger (touchCount >= filesChangedThreshold, touchPaths match touchTriggers, or highRisk=true), append a `## Per-Slice Review` entry for this slice before moving on (see the dedicated section below).",
55
55
  "Repeat for each slice — return to step 1 for the next plan slice."
56
56
  ],
@@ -286,7 +286,7 @@ function tddStageVariantForTrack(track) {
286
286
  if (row.section === "Traceability") {
287
287
  return {
288
288
  ...row,
289
- validationRule: "Acceptance criterion IDs are linked to RED/GREEN evidence."
289
+ validationRule: "Spec acceptance item IDs and, for bug fixes, reproduction slice IDs are linked to RED/GREEN evidence. No plan artifact is required on quick."
290
290
  };
291
291
  }
292
292
  return {
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Command contract for /cc — the unified entry point.
3
- * No args → behaves like /cc-next (resume or start the flow at its first stage).
4
- * With prompt classifies the idea, selects a track, and starts the first
5
- * stage of that track (brainstorm for medium/standard, spec for quick).
3
+ * No args → reads existing flow state and behaves like /cc-next only when a
4
+ * tracked flow already exists; missing state/fresh placeholder state blocks with
5
+ * init/start guidance. With prompt classifies the idea, selects a track, and
6
+ * starts the first stage of that track (brainstorm for medium/standard, spec for quick).
6
7
  */
7
8
  export declare function startCommandContract(): string;
8
9
  /**
@@ -7,9 +7,10 @@ function flowStatePath() {
7
7
  }
8
8
  /**
9
9
  * Command contract for /cc — the unified entry point.
10
- * No args → behaves like /cc-next (resume or start the flow at its first stage).
11
- * With prompt classifies the idea, selects a track, and starts the first
12
- * stage of that track (brainstorm for medium/standard, spec for quick).
10
+ * No args → reads existing flow state and behaves like /cc-next only when a
11
+ * tracked flow already exists; missing state/fresh placeholder state blocks with
12
+ * init/start guidance. With prompt classifies the idea, selects a track, and
13
+ * starts the first stage of that track (brainstorm for medium/standard, spec for quick).
13
14
  */
14
15
  export function startCommandContract() {
15
16
  const flowPath = flowStatePath();
@@ -19,7 +20,7 @@ export function startCommandContract() {
19
20
 
20
21
  **The unified entry point for the cclaw flow.**
21
22
 
22
- - \`/cc\` (no arguments) → behaves exactly like \`/cc-next\`: reads flow state and resumes the current stage, or starts brainstorm if the flow is fresh.
23
+ - \`/cc\` (no arguments) → reads existing flow state and resumes/progresses it through \`/cc-next\`. If flow state is missing or still a fresh init placeholder, stop and guide the user to run \`/cc <prompt>\` or \`cclaw init\`; do not silently create a brainstorm run.
23
24
  - \`/cc <prompt>\` (with an idea/description) → saves the prompt as idea context and starts the first stage of the resolved track.
24
25
 
25
26
  This is the **recommended way to start** working with cclaw. Use \`/cc-next\` for subsequent stage progression.
@@ -41,8 +42,8 @@ ${conversationLanguagePolicyMarkdown()}
41
42
  |---|---|---|
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. |
43
44
  | **pure-question** | "how does X work?", "explain Y", "what are the trade-offs of Z?" | Answer directly, do NOT open a stage. |
44
- | **trivial** | typo, one-liner, rename, config tweak, copy change, version bump with zero behavior change | Fast-path: skip \`brainstorm\` and \`scope\`, seed \`00-idea.md\`, move straight to \`design\` or \`spec\` depending on whether an interface change is involved. |
45
- | **software — bug fix with repro** | regression / hotfix / named symptom + repro steps | Fast-path: set track to \`quick\`, seed \`04-spec.md\` with the reproduction, enter \`tdd\` with a RED reproduction test first. |
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. |
46
47
  | **software — medium** | additive feature following existing architecture | medium track (\`brainstorm → spec → plan → tdd → review → ship\`). |
47
48
  | **software — standard** | feature, refactor, migration, integration, architecture change | Full 8-stage flow starting at \`brainstorm\`. |
48
49
 
@@ -92,7 +93,7 @@ ${conversationLanguagePolicyMarkdown()}
92
93
  12. Load the **first-stage skill for the chosen track** and its command file:
93
94
  - quick → \`.cclaw/skills/specification-authoring/SKILL.md\`
94
95
  - medium/standard → \`.cclaw/skills/brainstorming/SKILL.md\`
95
- - trivial fast-path → design or spec skill per Phase 0 decision.
96
+ - trivial fast-path → quick track spec skill per Phase 0 decision.
96
97
  13. Execute that stage with the prompt + Phase 1/Phase 2 + seed context as initial input.
97
98
 
98
99
  ### Reclassification on discovery
@@ -107,8 +108,9 @@ If during any stage the agent discovers evidence that contradicts the initial Ph
107
108
  ### Without prompt (\`/cc\`)
108
109
 
109
110
  1. Read \`${flowPath}\`.
110
- 2. If flow state is missing → run \`cclaw init\` guidance and stop.
111
- 3. Behave exactly like \`/cc-next\`: check current stage gates, resume if incomplete, advance if complete.
111
+ 2. If flow state is missing → guide the user to run \`cclaw init\` and stop.
112
+ 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.
113
+ 4. Otherwise behave exactly like \`/cc-next\`: check current stage gates, resume if incomplete, advance if complete.
112
114
 
113
115
  ## Headless mode
114
116
 
@@ -116,7 +118,7 @@ When called by another skill or subagent in machine mode, emit exactly one
116
118
  JSON envelope (no prose) and stop:
117
119
 
118
120
  \`\`\`json
119
- {"version":"1","kind":"stage-output","stage":"brainstorm","payload":{"command":"/cc","track":"standard","action":"start_or_resume"},"emittedAt":"<ISO-8601>"}
121
+ {"version":"1","kind":"stage-output","stage":"<currentStage>","payload":{"command":"/cc","track":"<track>","action":"start_or_resume"},"emittedAt":"<ISO-8601>"}
120
122
  \`\`\`
121
123
 
122
124
  Validate envelopes with:
@@ -147,7 +149,7 @@ description: "Unified entry point for the cclaw flow. No args = resume/next. Wit
147
149
 
148
150
  \`/cc\` is the **starting command** for cclaw. It intelligently routes:
149
151
 
150
- - **No arguments** → acts as \`/cc-next\` (resume current stage or advance to next)
152
+ - **No arguments** → acts as \`/cc-next\` only for an existing tracked flow; missing/fresh placeholder state blocks with start guidance
151
153
  - **With a prompt** → classifies the task, picks a track (quick/medium/standard), and starts the **first stage of that track** (not always brainstorm — e.g. the \`quick\` track starts at \`spec\`)
152
154
 
153
155
  ## HARD-GATE
@@ -159,7 +161,7 @@ ${conversationLanguagePolicyMarkdown()}
159
161
 
160
162
  ### Path A: \`/cc <prompt>\`
161
163
 
162
- 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.
164
+ 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.
163
165
  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\`.
164
166
  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.
165
167
  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.
@@ -191,13 +193,15 @@ If mid-stage evidence contradicts the initial Class/Track decision (the "trivial
191
193
 
192
194
  ### Path B: \`/cc\` (no arguments)
193
195
 
194
- Delegate entirely to \`/cc-next\` behavior:
196
+ Delegate to \`/cc-next\` behavior only when a tracked flow exists:
195
197
 
196
198
  1. Read \`${flowPath}\`.
197
- 2. Check gates for \`currentStage\`.
198
- 3. If incomplete load current stage skill and execute.
199
- 4. If complete advance to next stage and execute.
200
- 5. If flow is done report completion.
199
+ 2. If missing, guide the user to run \`cclaw init\` and stop.
200
+ 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.
201
+ 4. Check gates for \`currentStage\`.
202
+ 5. If incomplete load current stage skill and execute.
203
+ 6. If complete → advance to next stage and execute.
204
+ 7. If flow is done → report completion.
201
205
 
202
206
  ## When to use \`/cc\` vs \`/cc-next\`
203
207
 
@@ -1,4 +1,4 @@
1
1
  export declare const ARTIFACT_TEMPLATES: Record<string, string>;
2
2
  export declare const RULEBOOK_MARKDOWN = "# Cclaw Rulebook\n\n## MUST_ALWAYS\n- Follow flow order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\n- Require explicit user confirmation after plan before TDD\n- Keep evidence artifacts in `.cclaw/artifacts/`\n- Enforce RED before GREEN in TDD\n- Run two-layer review (spec_compliance and code_quality) before ship\n- Validate all inputs before processing \u2014 never trust external data without sanitization\n- Prefer immutable data patterns and pure functions where the language supports them\n- Follow existing repo conventions, patterns, and directory structure \u2014 match the codebase\n- Verify claims with fresh evidence: \"tests pass\" requires running tests in this message\n- Use conventional commits: `type(scope): description` (feat, fix, refactor, test, docs, chore)\n\n## MUST_NEVER\n- Skip RED phase and jump directly to GREEN in TDD\n- Ship with critical review findings\n- Start implementation during /brainstorm\n- Modify generated cclaw files manually when CLI can regenerate them\n- Commit `.cclaw/` or generated shim files\n- Expose secrets, tokens, API keys, or absolute system paths in agent output\n- Duplicate existing functionality without explicit justification \u2014 search before building\n- Bypass security checks, linting hooks, or type checking to \"move faster\"\n- Claim success (\"Done,\" \"All good,\" \"Tests pass\") without running verification in this message\n- Make changes outside the blast radius of the current task without user consent\n\n## DELEGATION\nWhen a task requires specialist knowledge (security audit, performance profiling, database review),\ndelegate to a specialized agent or skill if the harness supports it. The primary agent should:\n1. Identify the specialist domain\n2. Provide focused context (relevant files, the specific concern)\n3. Evaluate the specialist output before acting on it \u2014 do not blindly apply recommendations\n";
3
- export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc-next`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick or medium track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc-next` = only progression path.\n- Knowledge capture and recall use the `learnings` skill when requested.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive via `npx cclaw-cli archive`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Stage behavior: current stage skill plus `.cclaw/state/flow-state.json`.\n- Preamble budget: keep role/status announcements brief and avoid repeating\n them unless the stage or role changes.\n";
3
+ export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc-next`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc-next` = only progression path.\n- Knowledge capture and recall use the `learnings` skill when requested.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive via `npx cclaw-cli archive`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Stage behavior: current stage skill plus `.cclaw/state/flow-state.json`.\n- Preamble budget: keep role/status announcements brief and avoid repeating\n them unless the stage or role changes.\n";
4
4
  export declare function buildRulesJson(): Record<string, unknown>;