cclaw-cli 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  **A focused, installer-first workflow that turns AI coding sessions into predictable shipped outcomes.**
4
4
 
5
5
  `cclaw` gives your agent one clear path:
6
- **brainstorm -> scope -> design -> spec -> plan -> test -> build -> review -> ship**
6
+ **brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship**
7
7
 
8
8
  No giant command jungle. No runtime daemon. No process theater.
9
9
  Just a disciplined flow that stays lightweight and works across major coding harnesses.
@@ -17,10 +17,9 @@ flowchart LR
17
17
  C --> D[Design]
18
18
  D --> E[Spec]
19
19
  E --> F[Plan]
20
- F --> G[Test]
21
- G --> H[Build]
22
- H --> I[Review]
23
- I --> J[Ship]
20
+ F --> G[TDD]
21
+ G --> H[Review]
22
+ H --> I[Ship]
24
23
  ```
25
24
 
26
25
  ```mermaid
@@ -29,7 +28,7 @@ sequenceDiagram
29
28
  participant H as Harness
30
29
  participant V as cclaw Hooks + Skills
31
30
  participant S as State + Learnings
32
- U->>H: /cc-brainstorm
31
+ U->>H: /cc <idea>
33
32
  H->>V: Load stage contract + HARD-GATE
34
33
  V->>S: Read context (state/learnings)
35
34
  V-->>H: Structured execution guidance
@@ -65,7 +64,8 @@ npx cclaw-cli init
65
64
  Then run in your harness:
66
65
 
67
66
  ```text
68
- /cc-brainstorm
67
+ /cc <idea>
68
+ /cc-next
69
69
  ```
70
70
 
71
71
  Core installer lifecycle:
@@ -5,8 +5,8 @@ export declare const CCLAW_VERSION = "0.1.1";
5
5
  export declare const FLOW_VERSION = "1.0.0";
6
6
  export declare const DEFAULT_HARNESSES: HarnessId[];
7
7
  export declare const REQUIRED_DIRS: readonly [".cclaw", ".cclaw/commands", ".cclaw/skills", ".cclaw/contexts", ".cclaw/templates", ".cclaw/artifacts", ".cclaw/state", ".cclaw/runs", ".cclaw/rules", ".cclaw/adapters", ".cclaw/agents", ".cclaw/hooks"];
8
- export declare const REQUIRED_GITIGNORE_PATTERNS: readonly ["# cclaw generated artifacts", ".cclaw/", ".claude/commands/cc-*.md", ".cursor/commands/cc-*.md", ".opencode/commands/cc-*.md", ".codex/commands/cc-*.md", ".claude/hooks/hooks.json", ".cursor/hooks.json", ".codex/hooks.json", ".opencode/plugins/cclaw-plugin.mjs", ".cursor/rules/cclaw-workflow.mdc"];
8
+ export declare const REQUIRED_GITIGNORE_PATTERNS: readonly ["# cclaw generated artifacts", ".cclaw/", ".claude/commands/cc-*.md", ".claude/commands/cc.md", ".cursor/commands/cc-*.md", ".cursor/commands/cc.md", ".opencode/commands/cc-*.md", ".opencode/commands/cc.md", ".codex/commands/cc-*.md", ".codex/commands/cc.md", ".claude/hooks/hooks.json", ".cursor/hooks.json", ".codex/hooks.json", ".opencode/plugins/cclaw-plugin.mjs", ".cursor/rules/cclaw-workflow.mdc"];
9
9
  export declare const COMMAND_FILE_ORDER: FlowStage[];
10
- export declare const UTILITY_COMMANDS: readonly ["learn", "autoplan", "next"];
10
+ export declare const UTILITY_COMMANDS: readonly ["learn", "next"];
11
11
  export declare const SUBAGENT_SKILL_FOLDERS: readonly ["subagent-dev", "parallel-dispatch"];
12
12
  export type UtilityCommand = (typeof UTILITY_COMMANDS)[number];
package/dist/constants.js CHANGED
@@ -26,9 +26,13 @@ export const REQUIRED_GITIGNORE_PATTERNS = [
26
26
  "# cclaw generated artifacts",
27
27
  `${RUNTIME_ROOT}/`,
28
28
  ".claude/commands/cc-*.md",
29
+ ".claude/commands/cc.md",
29
30
  ".cursor/commands/cc-*.md",
31
+ ".cursor/commands/cc.md",
30
32
  ".opencode/commands/cc-*.md",
33
+ ".opencode/commands/cc.md",
31
34
  ".codex/commands/cc-*.md",
35
+ ".codex/commands/cc.md",
32
36
  ".claude/hooks/hooks.json",
33
37
  ".cursor/hooks.json",
34
38
  ".codex/hooks.json",
@@ -41,12 +45,11 @@ export const COMMAND_FILE_ORDER = [
41
45
  "design",
42
46
  "spec",
43
47
  "plan",
44
- "test",
45
- "build",
48
+ "tdd",
46
49
  "review",
47
50
  "ship"
48
51
  ];
49
- export const UTILITY_COMMANDS = ["learn", "autoplan", "next"];
52
+ export const UTILITY_COMMANDS = ["learn", "next"];
50
53
  export const SUBAGENT_SKILL_FOLDERS = [
51
54
  "subagent-dev",
52
55
  "parallel-dispatch"
@@ -30,7 +30,7 @@ export declare const CCLAW_AGENTS: AgentDefinition[];
30
30
  */
31
31
  export declare function agentMarkdown(agent: AgentDefinition): string;
32
32
  /**
33
- * Markdown table mapping Cclaw slash commands to recommended specialist agents.
33
+ * Markdown table mapping Cclaw stage entry points to specialist agents.
34
34
  */
35
35
  export declare function agentRoutingTable(): string;
36
36
  /**
@@ -41,7 +41,7 @@ export const CCLAW_AGENTS = [
41
41
  },
42
42
  {
43
43
  name: "spec-reviewer",
44
- description: "MANDATORY after implementation: MUST BE USED during `/cc-review` (and any review gate) to verify acceptance criteria against the actual codebase — not against claims.",
44
+ description: "MANDATORY after implementation: MUST BE USED during the review stage (via `/cc-next`) to verify acceptance criteria against the actual codebase — not against claims.",
45
45
  tools: ["Read", "Grep", "Glob"],
46
46
  model: "balanced",
47
47
  activation: "mandatory",
@@ -64,7 +64,7 @@ export const CCLAW_AGENTS = [
64
64
  },
65
65
  {
66
66
  name: "code-reviewer",
67
- description: "MANDATORY for all code changes: MUST BE USED during `/cc-review` for any diff/PR-sized work — correctness, maintainability, and ship risk.",
67
+ description: "MANDATORY for all code changes: MUST BE USED during the review stage (via `/cc-next`) for any diff/PR-sized work — correctness, maintainability, and ship risk.",
68
68
  tools: ["Read", "Grep", "Glob"],
69
69
  model: "balanced",
70
70
  activation: "mandatory",
@@ -128,7 +128,7 @@ export const CCLAW_AGENTS = [
128
128
  tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
129
129
  model: "balanced",
130
130
  activation: "proactive",
131
- relatedStages: ["test", "build"],
131
+ relatedStages: ["tdd"],
132
132
  body: [
133
133
  "You are a **test-driven development** guide and implementer.",
134
134
  "",
@@ -157,7 +157,7 @@ export const CCLAW_AGENTS = [
157
157
  tools: ["Read", "Write", "Edit", "Grep", "Glob"],
158
158
  model: "fast",
159
159
  activation: "proactive",
160
- relatedStages: ["build", "ship"],
160
+ relatedStages: ["tdd", "ship"],
161
161
  body: [
162
162
  "You are a **documentation and comment maintenance** specialist.",
163
163
  "",
@@ -208,20 +208,16 @@ ${taskDelegation}
208
208
  `;
209
209
  }
210
210
  /**
211
- * Markdown table mapping Cclaw slash commands to recommended specialist agents.
211
+ * Markdown table mapping Cclaw stage entry points to specialist agents.
212
212
  */
213
213
  export function agentRoutingTable() {
214
- return `| Command | Primary Agent | Supporting Agents |
214
+ return `| Stage Entry | Primary Agent | Supporting Agents |
215
215
  |---|---|---|
216
- | /cc-brainstorm | planner | — |
217
- | /cc-scope | planner | |
218
- | /cc-design | planner, security-reviewer | |
219
- | /cc-spec | planner | spec-reviewer |
220
- | /cc-plan | planner | |
221
- | /cc-test | test-author | — |
222
- | /cc-build | test-author | doc-updater |
223
- | /cc-review | spec-reviewer, code-reviewer | security-reviewer |
224
- | /cc-ship | — | doc-updater |
216
+ | Brainstorm (start with \`/cc <idea>\`) | planner | — |
217
+ | Scope / Design / Spec / Plan (advance via \`/cc-next\`) | planner | security-reviewer on design, spec-reviewer on spec |
218
+ | TDD (via \`/cc-next\`) | test-author | doc-updater |
219
+ | Review (via \`/cc-next\`) | spec-reviewer, code-reviewer | security-reviewer |
220
+ | Ship (via \`/cc-next\`) | | doc-updater |
225
221
  `;
226
222
  }
227
223
  /**
@@ -235,7 +231,7 @@ Cclaw provides specialist agents under \`.cclaw/agents/\` for targeted delegatio
235
231
  ${agentRoutingTable()}
236
232
 
237
233
  **Activation modes:**
238
- - **Mandatory:** MUST be used when the related stage runs (spec-reviewer, code-reviewer during /review)
234
+ - **Mandatory:** MUST be used when the related stage runs (spec-reviewer, code-reviewer during review)
239
235
  - **Proactive:** Should be used automatically when context matches (planner for complex features, security-reviewer for auth code)
240
236
  - **On-demand:** Invoked only when explicitly requested
241
237
 
@@ -1,8 +1,7 @@
1
- import { nextCclawCommand, stageSchema } from "./stage-schema.js";
1
+ import { stageSchema } from "./stage-schema.js";
2
2
  import { stageSkillFolder } from "./skills.js";
3
3
  export function commandContract(stage) {
4
4
  const schema = stageSchema(stage);
5
- const nextCommand = nextCclawCommand(stage);
6
5
  const skillPath = `.cclaw/skills/${stageSkillFolder(stage)}/SKILL.md`;
7
6
  const reads = schema.crossStageTrace.readsFrom;
8
7
  const readsLine = reads.length > 0 ? reads.join(", ") : "(first stage)";
@@ -28,7 +27,7 @@ ${schema.hardGate}
28
27
  ## In / Out
29
28
  - **Reads:** ${readsLine}
30
29
  - **Writes:** \`.cclaw/artifacts/${schema.artifactFile}\` (canonical run copy: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`)
31
- - **Next:** ${nextCommand}
30
+ - **Next:** \`/cc-next\` (updates flow-state and loads the next stage)
32
31
 
33
32
  ## Context Hydration (mandatory before stage work)
34
33
  1. Read \`.cclaw/state/flow-state.json\` and capture \`activeRunId\`.
@@ -167,7 +167,7 @@ T1 ──▶ T2 ──▶ T3
167
167
  ### Risk note
168
168
 
169
169
  If T3 grows too large, split “transport” vs “UI state machine” into two tasks while keeping the dependency graph acyclic.`,
170
- test: `### RED test (Vitest) — written before production code
170
+ tdd: `### RED test (Vitest) — written before production code
171
171
 
172
172
  \`\`\`typescript
173
173
  import { describe, it, expect } from "vitest";
@@ -204,8 +204,9 @@ Error: Cannot find module '../notificationFeed' imported from src/notificationFe
204
204
  ### Common mistakes to avoid
205
205
 
206
206
  - “GREEN” that secretly imports a helper that already implements the behavior (that is skipping RED).
207
- - Assertions that pass because the function returns \`undefined\` and the matcher is too loose.`,
208
- build: `### GREEN (minimal implementation to pass RED)
207
+ - Assertions that pass because the function returns \`undefined\` and the matcher is too loose.
208
+
209
+ ### GREEN (minimal implementation to pass RED)
209
210
 
210
211
  \`\`\`typescript
211
212
  export type FeedItem = { dedupeKey: string; read: boolean };
@@ -270,8 +270,7 @@ if [ "$SUGGESTIONS_ENABLED" = "true" ] && [ "$STAGE_MUTED" != "true" ]; then
270
270
  design) STAGE_SUGGESTION="Suggestion: map failure modes per new codepath and confirm architecture boundaries before moving forward." ;;
271
271
  spec) STAGE_SUGGESTION="Suggestion: ensure every acceptance criterion is measurable and mapped to a concrete test." ;;
272
272
  plan) STAGE_SUGGESTION="Suggestion: group tasks into dependency waves and keep WAIT_FOR_CONFIRM pending until approval." ;;
273
- test) STAGE_SUGGESTION="Suggestion: RED only in this stage capture failing output for each selected slice." ;;
274
- build) STAGE_SUGGESTION="Suggestion: apply minimal GREEN change, run full suite, then document REFACTOR notes." ;;
273
+ tdd) STAGE_SUGGESTION="Suggestion: execute RED GREEN REFACTOR for each selected slice and capture evidence per cycle." ;;
275
274
  review) STAGE_SUGGESTION="Suggestion: run Layer 1 before Layer 2 and reconcile findings into 07-review-army.json." ;;
276
275
  ship) STAGE_SUGGESTION="Suggestion: verify preflight + rollback plan before selecting exactly one finalization mode." ;;
277
276
  *) STAGE_SUGGESTION="" ;;
@@ -401,7 +400,7 @@ if [ "$STAGE" != "none" ] && [ -n "$STAGE_LEARNING_LINES" ] && command -v jq >/d
401
400
  fi
402
401
 
403
402
  # --- Build context message ---
404
- CTX="cclaw loaded. Flow: stage=$STAGE ($COMPLETED/9 completed, run=$ACTIVE_RUN). Active run artifacts: ${RUNTIME_ROOT}/runs/$ACTIVE_RUN/artifacts/"
403
+ CTX="cclaw loaded. Flow: stage=$STAGE ($COMPLETED/8 completed, run=$ACTIVE_RUN). Active run artifacts: ${RUNTIME_ROOT}/runs/$ACTIVE_RUN/artifacts/"
405
404
  if [ -n "$CONTEXT_MODE_NOTE" ]; then
406
405
  CTX="$CTX
407
406
  $CONTEXT_MODE_NOTE"
@@ -932,8 +931,7 @@ export default function cclawPlugin(ctx) {
932
931
  design: "Suggestion: map failure modes per new codepath and confirm architecture boundaries before moving forward.",
933
932
  spec: "Suggestion: ensure every acceptance criterion is measurable and mapped to a concrete test.",
934
933
  plan: "Suggestion: group tasks into dependency waves and keep WAIT_FOR_CONFIRM pending until approval.",
935
- test: "Suggestion: RED only in this stage capture failing output for each selected slice.",
936
- build: "Suggestion: apply minimal GREEN change, run full suite, then document REFACTOR notes.",
934
+ tdd: "Suggestion: execute RED GREEN REFACTOR for each selected slice and capture evidence per cycle.",
937
935
  review: "Suggestion: run Layer 1 before Layer 2 and reconcile findings into 07-review-army.json.",
938
936
  ship: "Suggestion: verify preflight + rollback plan before selecting exactly one finalization mode."
939
937
  };
@@ -995,7 +993,7 @@ export default function cclawPlugin(ctx) {
995
993
  const contextMode = readContextMode();
996
994
  const stageSuggestion = readStageSuggestion(stage);
997
995
  const stageLearnings = readStageLearnings(stage);
998
- const parts = [\`cclaw loaded. Flow: stage=\${stage} (\${completed}/9 completed, run=\${activeRunId}). Active run artifacts: ${RUNTIME_ROOT}/runs/\${activeRunId}/artifacts/\`];
996
+ const parts = [\`cclaw loaded. Flow: stage=\${stage} (\${completed}/8 completed, run=\${activeRunId}). Active run artifacts: ${RUNTIME_ROOT}/runs/\${activeRunId}/artifacts/\`];
999
997
  parts.push(
1000
998
  contextMode.guide
1001
999
  ? \`Context mode: \${contextMode.mode} (guide: \${contextMode.guide})\`
@@ -44,7 +44,7 @@ Treat learnings as durable project memory: patterns, pitfalls, preferences, arch
44
44
  **Minimal valid example (conceptual):**
45
45
 
46
46
  \`\`\`json
47
- {"ts":"2026-04-11T12:00:00Z","skill":"build","type":"pattern","key":"run-migrations-before-seed","insight":"Seed scripts assume schema v7; run sqlx migrate before npm run seed.","confidence":8,"source":"observed","files":["scripts/seed.ts"]}
47
+ {"ts":"2026-04-11T12:00:00Z","skill":"tdd","type":"pattern","key":"run-migrations-before-seed","insight":"Seed scripts assume schema v7; run sqlx migrate before npm run seed.","confidence":8,"source":"observed","files":["scripts/seed.ts"]}
48
48
  \`\`\`
49
49
 
50
50
  ## Confidence Decay Rules
@@ -19,34 +19,26 @@ This meta-skill helps you discover and apply the right cclaw stage for the curre
19
19
 
20
20
  ## Skill Discovery Flowchart
21
21
 
22
- When a task arrives, identify the development phase and invoke the matching command:
22
+ Use \`/cc\` to start or \`/cc-next\` to continue:
23
23
 
24
24
  \`\`\`
25
25
  Task arrives
26
26
  |
27
- +-- Vague idea / needs exploration? --> /cc-brainstorm
28
- +-- Need to shape scope / challenge premises? --> /cc-scope
29
- +-- Have scope, need architecture / design lock? --> /cc-design
30
- +-- Have design, need formal specification? --> /cc-spec
31
- +-- Have spec, need task breakdown / plan? --> /cc-plan
32
- +-- Have plan, need to write tests first? --> /cc-test
33
- +-- Have failing tests, need implementation? --> /cc-build
34
- +-- Have implementation, need review? --> /cc-review
35
- +-- Reviewed and approved, need to ship? --> /cc-ship
36
- |
37
- +-- Cross-cutting:
38
- | +-- Want to check/add project learnings? --> /cc-learn
39
- | +-- Want full brainstorm-to-plan in one shot? --> /cc-autoplan
40
- |
27
+ +-- New idea / starting fresh? --> /cc <idea> (starts brainstorm)
28
+ +-- Resuming / continuing? --> /cc or /cc-next
29
+ +-- Want to check/add project learnings? --> /cc-learn
41
30
  +-- No cclaw stage applies? --> Respond normally
42
31
  \`\`\`
43
32
 
33
+ Stage progression is handled automatically by \`/cc-next\`. The flow moves through:
34
+ brainstorm → scope → design → spec → plan → tdd → review → ship
35
+
44
36
  ## Flow State Check
45
37
 
46
38
  Before starting work, ALWAYS:
47
39
 
48
40
  1. Read \`.cclaw/state/flow-state.json\` for the current stage.
49
- 2. If a stage is active, invoke the matching \`/cc-*\` command.
41
+ 2. If a stage is active, continue with \`/cc\` or \`/cc-next\` (do not jump directly to per-stage commands).
50
42
  3. If no stage applies (e.g. simple question, unrelated task), respond normally.
51
43
 
52
44
  ## Activation Rules
@@ -56,25 +48,24 @@ Before starting work, ALWAYS:
56
48
  3. **One stage at a time.** Complete the current stage before advancing to the next.
57
49
  4. **Gates must pass.** Every stage has required gates — the agent cannot claim completion without satisfying them.
58
50
  5. **Artifacts are mandatory.** Each stage writes to \`.cclaw/artifacts/\` and keeps the active run copy in \`.cclaw/runs/<activeRunId>/artifacts/\` — this is the evidence trail.
59
- 6. **When in doubt, start with brainstorm.** If the task is non-trivial and there's no prior artifact, begin with \`/cc-brainstorm\`.
51
+ 6. **When in doubt, use \`/cc\`.** If the task is non-trivial and there's no prior artifact, run \`/cc <idea>\` to start brainstorming.
60
52
 
61
53
  ## Stage Quick Reference
62
54
 
63
- | Stage | Command | HARD-GATE | Artifact |
64
- |-------|---------|-----------|----------|
65
- | Brainstorm | \`/cc-brainstorm\` | No implementation planning | \`01-brainstorm.md\` |
66
- | Scope | \`/cc-scope\` | Challenge premises first | \`02-scope.md\` |
67
- | Design | \`/cc-design\` | Search before building | \`03-design.md\` |
68
- | Spec | \`/cc-spec\` | Observable + testable criteria | \`04-spec.md\` |
69
- | Plan | \`/cc-plan\` | One task = one purpose | \`05-plan.md\` |
70
- | Test | \`/cc-test\` | RED tests fail first | \`06-tdd.md\` |
71
- | Build | \`/cc-build\` | Minimal code to pass RED | \`06-tdd.md\` (shared with test) |
72
- | Review | \`/cc-review\` | Two-layer review | \`07-review.md\` |
73
- | Ship | \`/cc-ship\` | All tests green on merge | \`08-ship.md\` |
55
+ | Stage | How to enter | HARD-GATE | Artifact |
56
+ |-------|--------------|-----------|----------|
57
+ | Brainstorm | \`/cc <idea>\` (or \`/cc\` on fresh flow) | No implementation planning | \`01-brainstorm.md\` |
58
+ | Scope | via \`/cc-next\` | Challenge premises first | \`02-scope.md\` |
59
+ | Design | via \`/cc-next\` | Search before building | \`03-design.md\` |
60
+ | Spec | via \`/cc-next\` | Observable + testable criteria | \`04-spec.md\` |
61
+ | Plan | via \`/cc-next\` | One task = one purpose | \`05-plan.md\` |
62
+ | TDD | via \`/cc-next\` | RED GREEN REFACTOR per slice | \`06-tdd.md\` |
63
+ | Review | via \`/cc-next\` | Two-layer review | \`07-review.md\` |
64
+ | Ship | via \`/cc-next\` | All tests green on merge | \`08-ship.md\` |
74
65
 
75
66
  ## Skill Loading
76
67
 
77
- Each \`/cc-*\` command loads:
68
+ \`/cc-next\` (and \`/cc\`) automatically loads the right stage files:
78
69
  1. **\`.cclaw/skills/<stage>/SKILL.md\`** — the full procedural guide (read this first and follow it)
79
70
  2. **\`.cclaw/commands/<stage>.md\`** — thin orchestrator (entry/exit summary, gates, anchors)
80
71
 
@@ -118,8 +109,6 @@ Use this loading order to keep context lean while preserving depth:
118
109
  ### See also
119
110
  - \`.cclaw/skills/session/SKILL.md\` for session start/stop/resume behavior
120
111
  - \`.cclaw/skills/learnings/SKILL.md\` for durable memory capture and reuse
121
- - \`.cclaw/skills/autoplan/SKILL.md\` when user requests multi-stage orchestration
122
-
123
112
  ## Decision Protocol
124
113
 
125
114
  When a stage requires user input (approval, choice, direction), use this structured pattern:
@@ -143,7 +132,7 @@ When a stage requires user input (approval, choice, direction), use this structu
143
132
  ## Failure Modes
144
133
 
145
134
  Watch for these anti-patterns:
146
- - **Skipping stages** — jumping from brainstorm to build without design/spec/plan
135
+ - **Skipping stages** — jumping from brainstorm to tdd without design/spec/plan
147
136
  - **Ignoring gates** — claiming completion without evidence
148
137
  - **Premature implementation** — writing code before RED tests exist
149
138
  - **Hollow reviews** — "looks good" without checking spec compliance
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Command contract for /cc-next - agent reads flow state, evaluates gates, advances or reports blockers.
3
- * Wire into install (write to `.cclaw/commands/next.md` + harness shim `cc-next.md`) in a follow-up; not invoked by CLI.
2
+ * Command contract for /cc-next the primary progression command.
3
+ * Reads flow-state, starts the current stage if unfinished, or advances if all gates pass.
4
4
  */
5
5
  export declare function nextCommandContract(): string;
6
6
  /**
7
- * Skill body for /cc-next - flow logic and continue semantics.
7
+ * Skill body for /cc-next the primary flow progression command.
8
8
  */
9
9
  export declare function nextCommandSkillMarkdown(): string;
@@ -6,15 +6,12 @@ const NEXT_SKILL_NAME = "flow-next-step";
6
6
  function flowStatePath() {
7
7
  return `${RUNTIME_ROOT}/state/flow-state.json`;
8
8
  }
9
- function configPathLine() {
10
- return `${RUNTIME_ROOT}/config.yaml`;
11
- }
12
9
  function delegationLogPathLine() {
13
10
  return `${RUNTIME_ROOT}/runs/<activeRunId>/delegation-log.json`;
14
11
  }
15
12
  /**
16
- * Command contract for /cc-next - agent reads flow state, evaluates gates, advances or reports blockers.
17
- * Wire into install (write to `.cclaw/commands/next.md` + harness shim `cc-next.md`) in a follow-up; not invoked by CLI.
13
+ * Command contract for /cc-next the primary progression command.
14
+ * Reads flow-state, starts the current stage if unfinished, or advances if all gates pass.
18
15
  */
19
16
  export function nextCommandContract() {
20
17
  const flowPath = flowStatePath();
@@ -24,115 +21,133 @@ export function nextCommandContract() {
24
21
 
25
22
  ## Purpose
26
23
 
27
- Single **continue** command: read flow state, verify **current stage** gate satisfaction, verify any **mandatory delegations**, then either **hand off to the next stage** (load its skill and proceed) or **list blocking gates / pauses** so the user knows what to finish first.
24
+ **The primary progression command.** Read flow state, determine what to do:
25
+
26
+ - **Current stage not started / in progress** → load its skill and execute it.
27
+ - **Current stage complete (all gates passed)** → advance \`currentStage\` and load the next skill.
28
+ - **Flow complete** → report done.
29
+
30
+ This is the only progression command the user needs to drive the entire flow. Stage command contracts are internal implementation details loaded by \`/cc-next\`.
28
31
 
29
32
  ## HARD-GATE
30
33
 
31
34
  - **Do not** invent gate completion: use only \`${flowPath}\` plus observable evidence in repo artifacts.
32
- - **Do not** skip stages: the only valid advance is from \`currentStage\` to that stage's configured successor in the flow schema (same order as \`/cc-brainstorm\` -> \`/cc-ship\`).
33
- - **Do not** treat \`/cc-next\`, \`autoAdvance\`, or user impatience as permission to bypass \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, explicit approval pauses, or mandatory delegation requirements from the current stage skill.
34
- - If the flow is already at the terminal stage with all ship gates satisfied, **report completion** instead of advancing.
35
+ - **Do not** skip stages: advance only from \`currentStage\` to its configured successor.
36
+ - If the flow is at the terminal stage with all ship gates satisfied, **report completion**.
35
37
 
36
38
  ## Algorithm (mandatory)
37
39
 
38
- 1. Read **\`${flowPath}\`** (create parent dirs only if you are also initializing a broken install - otherwise treat missing file as **BLOCKED**: state missing).
39
- 2. Parse JSON. Capture \`currentStage\`, \`activeRunId\` (must be present), and the current run-scoped context.
40
- 3. Load **\`${skillRel}\`** - canonical semantics for gate evaluation and continuation live there.
41
- 4. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema (authoritative list of gate ids).
42
- 5. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state (if missing, treat all gates as unmet).
43
- 6. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
44
- 7. **Unmet** = gates in \`G\` that are not satisfied **or** appear in \`catalog.blocked\`.
45
- 8. Let \`M\` = \`mandatoryDelegations\` for **\`currentStage\`** from the stage schema.
46
- 9. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. A mandatory delegation counts only if that agent is recorded as **completed** or explicitly **waived** by the user. Missing or in-progress entries are blocking.
47
- 10. Respect explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval"). \`/cc-next\` is a convenience command, not authorization to bypass confirmation gates.
48
- 11. If **any** unmet gates, blocking pause rules, or missing mandatory delegations remain: print a short **Blocking gates** list (id + human description from schema \`requiredGates\`, plus any missing delegation or approval requirement). Do **not** invoke the next stage skill yet.
49
- 12. If **all** required gates and mandatory delegations are satisfied:
50
- - If current stage's \`next\` is **\`done\`**: report **flow complete**; stop.
51
- - Otherwise let \`nextStage\` be the schema successor of \`currentStage\`. Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** using the real \`skillFolder\` and stage id from the schema for \`nextStage\`, then run that stage's protocol in-agent (equivalent to invoking \`/cc-\` + \`nextStage\`) without asking the user to re-type the slash-command. While doing so, obey the current and next stage skills' explicit pause rules; if either skill says to pause, stop and report readiness instead of auto-continuing through that gate.
40
+ 1. Read **\`${flowPath}\`**. If missing **BLOCKED** (state missing).
41
+ 2. Parse JSON. Capture \`currentStage\`, \`activeRunId\`, and \`stageGateCatalog[currentStage]\`.
42
+ 3. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema.
43
+ 4. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state.
44
+ 5. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
45
+ 6. Let \`M\` = \`mandatoryDelegations\` for \`currentStage\`.
46
+ 7. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. Treat as satisfied only if the agent is **completed** or **waived**.
47
+
48
+ ### Path A: Current stage is NOT complete (any gate unmet or delegation missing)
49
+
50
+ Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<currentStage>.md\`** for the current stage.
51
+ → Execute that stage's protocol. The stage skill handles the full interaction including STOP points and gate tracking.
52
+ When the stage completes, the Stage Completion Protocol in the skill updates \`flow-state.json\` automatically.
53
+
54
+ ### Path B: Current stage IS complete (all gates passed, all delegations satisfied)
55
+
56
+ → If current stage's \`next\` is **\`done\`**: report **"Flow complete. All stages finished."** and stop.
57
+ → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** for the successor stage. Execute that stage's protocol.
58
+
59
+ ## Resume Semantics
60
+
61
+ \`/cc-next\` in a **new session** = resume from where you left off:
62
+ - Flow-state records \`currentStage\` and which gates have passed.
63
+ - The stage skill reads upstream artifacts and picks up context.
64
+ - No special resume command needed — \`/cc-next\` IS the resume command.
52
65
 
53
66
  ## Primary skill
54
67
 
55
- **${skillRel}** - full protocol, gate/flow tie-in, and interaction with \`autoAdvance\` in **\`${configPathLine()}\`**.
68
+ **${skillRel}** full protocol and stage table.
56
69
  `;
57
70
  }
58
71
  /**
59
- * Skill body for /cc-next - flow logic and continue semantics.
72
+ * Skill body for /cc-next the primary flow progression command.
60
73
  */
61
74
  export function nextCommandSkillMarkdown() {
62
75
  const flowPath = flowStatePath();
63
- const cfgPath = configPathLine();
64
76
  const delegationPath = delegationLogPathLine();
65
- const stageRows = ["brainstorm", "scope", "design", "spec", "plan", "test", "build", "review", "ship"]
77
+ const stageRows = ["brainstorm", "scope", "design", "spec", "plan", "tdd", "review", "ship"]
66
78
  .map((stage) => {
67
79
  const schema = stageSchema(stage);
68
- const next = schema.next === "done" ? "(terminal)" : `/cc-${schema.next}`;
80
+ const next = schema.next === "done" ? "(terminal)" : schema.next;
69
81
  const skillMd = `${RUNTIME_ROOT}/skills/${stageSkillFolder(stage)}/SKILL.md`;
70
- return `| \`${stage}\` | ${next} | \`${skillMd}\` |`;
82
+ return `| \`${stage}\` | \`${next}\` | \`${skillMd}\` |`;
71
83
  })
72
84
  .join("\n");
73
85
  return `---
74
86
  name: ${NEXT_SKILL_NAME}
75
- description: "Evaluate current stage gates from flow state; advance to the next /cc-* stage or list blockers."
87
+ description: "The primary progression command. Reads flow state, starts/resumes the current stage or advances to the next one."
76
88
  ---
77
89
 
78
- # Flow: /cc-next (gate-aware continuation)
90
+ # /cc-next Flow Progression
91
+
92
+ ## Overview
79
93
 
80
- ## When to use
94
+ \`/cc-next\` is **the only command you need** to drive the entire cclaw flow.
81
95
 
82
- - You want **one command** instead of manually typing the next \`/cc-*\` after a stage.
83
- - You are unsure whether **current stage gates** are satisfied.
84
- - The user said **continue**, **next**, or **pick up where we left off**.
96
+ **How it works:**
97
+ 1. Reads \`flow-state.json\` to find \`currentStage\`
98
+ 2. Checks if all gates for that stage are satisfied
99
+ 3. If **not** → loads the stage skill and starts/resumes execution
100
+ 4. If **yes** → advances to the next stage and loads its skill
101
+
102
+ **Resume:** \`/cc-next\` in a new session picks up from where \`flow-state.json\` says you are.
85
103
 
86
104
  ## HARD-GATE
87
105
 
88
- Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (paths, excerpts) consistent with \`requiredGates\` for \`currentStage\`. If evidence is missing, list the gate as **unmet**. Also treat missing mandatory delegations or unresolved confirmation pauses as blockers even if someone claims the stage is "basically done."
106
+ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (paths, excerpts). If evidence is missing, list the gate as **unmet**. Do **not** skip stages.
107
+
108
+ ## Algorithm
89
109
 
90
- ## Read flow state
110
+ ### Step 1: Read state
91
111
 
92
112
  1. Open **\`${flowPath}\`**.
93
- 2. Record \`currentStage\`, \`activeRunId\`, and \`stageGateCatalog[currentStage]\` (\`required\`, \`passed\`, \`blocked\` arrays).
94
- 3. If the file is missing or invalid JSON -> **BLOCKED** (report; do not advance).
95
- 4. Resolve the current delegation ledger at **\`${delegationPath}\`** using the recorded \`activeRunId\`.
113
+ 2. Record \`currentStage\`, \`activeRunId\`, \`stageGateCatalog[currentStage]\`.
114
+ 3. If the file is missing or invalid JSON **BLOCKED** (report and stop).
96
115
 
97
- ## Evaluate gates for \`currentStage\`
116
+ ### Step 2: Evaluate gates
98
117
 
99
- For each gate id in the stage schema's \`requiredGates\` for \`currentStage\`:
118
+ For each gate id in \`requiredGates\` for \`currentStage\`:
119
+ - **Met** if in \`catalog.passed\` and not in \`catalog.blocked\`.
120
+ - **Unmet** otherwise.
100
121
 
101
- - **Met** if the id is in \`catalog.passed\` and **not** in \`catalog.blocked\`.
102
- - **Blocked** if the id is in \`catalog.blocked\` (always list these first).
103
- - **Unmet** if not met (explain what evidence or artifact action is still needed, using the gate's description from the schema).
122
+ Check \`mandatoryDelegations\` via **\`${delegationPath}\`** satisfied only if **completed** or **waived**.
104
123
 
105
- Also evaluate stage-level transition blockers:
124
+ ### Step 3: Act
106
125
 
107
- - Read \`mandatoryDelegations\` from the current stage schema.
108
- - If any mandatory agent is required, inspect **\`${delegationPath}\`**. Treat that agent as satisfied only if the ledger records it as **completed** or explicitly **waived** by the user.
109
- - Treat explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval") as authoritative. **/cc-next** does not override them.
126
+ **Path A stage NOT complete (any gate unmet):**
110
127
 
111
- If **any** gate is unmet or blocked, or any mandatory delegation / confirmation pause remains unresolved -> output **Blocking gates** (bulleted: \`id\` or agent name - reason). **Stop** without loading the next stage skill.
128
+ Load the current stage's skill and command contract:
129
+ - \`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`
130
+ - \`${RUNTIME_ROOT}/commands/<currentStage>.md\`
112
131
 
113
- ## Advance (all gates satisfied)
132
+ Execute the stage protocol. The stage skill handles interaction, STOP points, gate tracking, and the Stage Completion Protocol (updates \`flow-state.json\` when done).
114
133
 
115
- 1. Look up \`currentStage\` in the transition table below. If next is **terminal**, print **Flow complete** and stop.
116
- 2. Let \`nextStage\` be the \`To\` stage. Read **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** and **\`${RUNTIME_ROOT}/skills/<folder>/SKILL.md\`** for that row.
117
- 3. **Continue semantics:** execute that stage's protocol **in the same session** as a natural handoff (you are now "in" \`nextStage\` until it completes or blocks).
118
- 4. Honor **\`${cfgPath}\`**: \`autoAdvance\` only applies where the stage skill allows it. Explicit pause / confirmation rules in either the current or next stage always win.
119
- 5. If the next stage reaches a confirmation gate or a "do not auto-advance" boundary, stop there and report readiness instead of claiming automatic advancement through that gate.
134
+ **Path B stage IS complete (all gates met, all delegations done):**
120
135
 
121
- ## Stage order (reference)
136
+ If \`next\` is \`done\` → report **"Flow complete. All stages finished."** and stop.
122
137
 
123
- | Stage | Next command | Skill path |
124
- |---|---|---|
125
- ${stageRows}
138
+ Otherwise load the next stage's skill and command contract, begin execution.
126
139
 
127
- ## Relation to per-stage skills
140
+ ## Stage order
128
141
 
129
- Wave auto-execute (\`waveExecutionAllowed\`) applies only to **test** and **build** skills after plan approval - see those SKILL.md files. **/cc-next** does not replace RED/GREEN/REFACTOR discipline; it only removes friction **between** stages.
142
+ | Stage | Next | Skill path |
143
+ |---|---|---|
144
+ ${stageRows}
130
145
 
131
146
  ## Anti-patterns
132
147
 
133
148
  - Advancing when \`blocked\` is non-empty for the current stage.
134
149
  - Treating \`passed\` as trusted when artifact evidence contradicts it.
135
- - Using **/cc-next** to bypass \`WAIT_FOR_CONFIRM\`, explicit approval pauses, or missing mandatory delegations.
136
150
  - Skipping **review** or **ship** because "the code looks fine".
151
+ - Loading a stage skill directly instead of using \`/cc-next\` for progression.
137
152
  `;
138
153
  }