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 +7 -7
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +6 -3
- package/dist/content/agents.d.ts +1 -1
- package/dist/content/agents.js +12 -16
- package/dist/content/contracts.js +2 -3
- package/dist/content/examples.js +4 -3
- package/dist/content/hooks.js +4 -6
- package/dist/content/learnings.js +1 -1
- package/dist/content/meta-skill.js +21 -32
- package/dist/content/next-command.d.ts +3 -3
- package/dist/content/next-command.js +78 -63
- package/dist/content/observe.js +22 -8
- package/dist/content/session-hooks.js +1 -1
- package/dist/content/skills.js +42 -52
- package/dist/content/stage-schema.d.ts +1 -1
- package/dist/content/stage-schema.js +75 -160
- package/dist/content/start-command.d.ts +10 -0
- package/dist/content/start-command.js +109 -0
- package/dist/content/subagents.js +3 -3
- package/dist/content/templates.d.ts +2 -2
- package/dist/content/templates.js +5 -5
- package/dist/content/utility-skills.js +2 -2
- package/dist/doctor.js +10 -41
- package/dist/harness-adapters.js +13 -42
- package/dist/install.js +10 -6
- package/dist/policy.js +1 -10
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -2
- package/package.json +1 -1
- package/dist/content/autoplan.d.ts +0 -7
- package/dist/content/autoplan.js +0 -344
package/dist/content/observe.js
CHANGED
|
@@ -226,10 +226,9 @@ stage_index() {
|
|
|
226
226
|
design) echo 3 ;;
|
|
227
227
|
spec) echo 4 ;;
|
|
228
228
|
plan) echo 5 ;;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
ship) echo 9 ;;
|
|
229
|
+
tdd) echo 6 ;;
|
|
230
|
+
review) echo 7 ;;
|
|
231
|
+
ship) echo 8 ;;
|
|
233
232
|
*) echo 0 ;;
|
|
234
233
|
esac
|
|
235
234
|
}
|
|
@@ -262,8 +261,8 @@ is_preimplementation_stage() {
|
|
|
262
261
|
|
|
263
262
|
detect_target_stage() {
|
|
264
263
|
local text="$1"
|
|
265
|
-
for stage in brainstorm scope design spec plan
|
|
266
|
-
if printf '%s' "$text" | grep -Eq "(/cc-$stage|cc-$stage)
|
|
264
|
+
for stage in brainstorm scope design spec plan tdd review ship; do
|
|
265
|
+
if printf '%s' "$text" | grep -Eq "(/cc-$stage|cc-$stage)([^[:alnum:]_-]|$)"; then
|
|
267
266
|
printf '%s' "$stage"
|
|
268
267
|
return 0
|
|
269
268
|
fi
|
|
@@ -272,7 +271,22 @@ detect_target_stage() {
|
|
|
272
271
|
return 0
|
|
273
272
|
}
|
|
274
273
|
|
|
274
|
+
is_flow_progression_command() {
|
|
275
|
+
local text="$1"
|
|
276
|
+
if printf '%s' "$text" | grep -Eq '(/cc-next|cc-next)([^[:alnum:]_-]|$)'; then
|
|
277
|
+
return 0
|
|
278
|
+
fi
|
|
279
|
+
if printf '%s' "$text" | grep -Eq '/cc([^[:alnum:]_-]|$)'; then
|
|
280
|
+
return 0
|
|
281
|
+
fi
|
|
282
|
+
return 1
|
|
283
|
+
}
|
|
284
|
+
|
|
275
285
|
TARGET_STAGE=$(detect_target_stage "$PAYLOAD_LOWER")
|
|
286
|
+
FLOW_COMMAND_INVOKED=0
|
|
287
|
+
if is_flow_progression_command "$PAYLOAD_LOWER"; then
|
|
288
|
+
FLOW_COMMAND_INVOKED=1
|
|
289
|
+
fi
|
|
276
290
|
if [ -n "$TARGET_STAGE" ] && [ "$CURRENT_STAGE" != "none" ]; then
|
|
277
291
|
CURRENT_IDX=$(stage_index "$CURRENT_STAGE")
|
|
278
292
|
TARGET_IDX=$(stage_index "$TARGET_STAGE")
|
|
@@ -305,7 +319,7 @@ if is_preimplementation_stage "$CURRENT_STAGE" && ! is_plan_mode_safe_tool "$TOO
|
|
|
305
319
|
fi
|
|
306
320
|
fi
|
|
307
321
|
|
|
308
|
-
if [ -n "$TARGET_STAGE" ]; then
|
|
322
|
+
if [ -n "$TARGET_STAGE" ] || [ "$FLOW_COMMAND_INVOKED" -eq 1 ]; then
|
|
309
323
|
if [ "$LAST_FLOW_READ_AT" -le 0 ] || [ "$NOW_EPOCH" -le 0 ] || [ $((NOW_EPOCH - LAST_FLOW_READ_AT)) -gt "$MAX_FLOW_READ_AGE_SEC" ]; then
|
|
310
324
|
if [ -n "$REASONS" ]; then
|
|
311
325
|
REASONS="$REASONS,stage_invocation_without_recent_flow_read"
|
|
@@ -357,7 +371,7 @@ PY
|
|
|
357
371
|
fi
|
|
358
372
|
|
|
359
373
|
if [ -n "$REASONS" ]; then
|
|
360
|
-
NOTE="Cclaw workflow guard: detected potential flow violation (\${REASONS}). Re-read ${RUNTIME_ROOT}/state/flow-state.json, avoid source edits before
|
|
374
|
+
NOTE="Cclaw workflow guard: detected potential flow violation (\${REASONS}). Re-read ${RUNTIME_ROOT}/state/flow-state.json, avoid source edits before tdd stage, and continue from current stage ordering."
|
|
361
375
|
if command -v jq >/dev/null 2>&1; then
|
|
362
376
|
ENTRY=$(jq -n -c \
|
|
363
377
|
--arg ts "$TS" \
|
package/dist/content/skills.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RUNTIME_ROOT } from "../constants.js";
|
|
2
2
|
import { stageExamples } from "./examples.js";
|
|
3
3
|
import { selfImprovementBlock } from "./learnings.js";
|
|
4
|
-
import {
|
|
4
|
+
import { QUESTION_FORMAT_SPEC, ERROR_BUDGET_SPEC, stageAutoSubagentDispatch, stageSchema } from "./stage-schema.js";
|
|
5
5
|
function artifactFileName(artifactPath) {
|
|
6
6
|
const parts = artifactPath.split("/");
|
|
7
7
|
return parts[parts.length - 1] ?? artifactPath;
|
|
@@ -133,7 +133,7 @@ Mandatory agents for this stage: ${mandatoryList}. Stage transition is BLOCKED u
|
|
|
133
133
|
On session stop or stage completion, the agent should write delegation entries to \`${delegationLogRel}\` for audit.
|
|
134
134
|
`;
|
|
135
135
|
}
|
|
136
|
-
const VERIFICATION_STAGES = ["
|
|
136
|
+
const VERIFICATION_STAGES = ["tdd", "review", "ship"];
|
|
137
137
|
function waveExecutionModeBlock(stage) {
|
|
138
138
|
const schema = stageSchema(stage);
|
|
139
139
|
if (!schema.waveExecutionAllowed) {
|
|
@@ -145,55 +145,50 @@ After plan approval (**WAIT_FOR_CONFIRM** / \`plan_wait_for_confirm\` satisfied)
|
|
|
145
145
|
|
|
146
146
|
`;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
function stageTransitionAutoAdvanceBlock(schema, nextCommand) {
|
|
168
|
-
if (schema.next === "done") {
|
|
169
|
-
return "";
|
|
148
|
+
function stageCompletionProtocol(schema) {
|
|
149
|
+
const stage = schema.stage;
|
|
150
|
+
const gateIds = schema.requiredGates.map((g) => g.id);
|
|
151
|
+
const gateList = gateIds.map((id) => `\`${id}\``).join(", ");
|
|
152
|
+
const nextStage = schema.next === "done" ? null : schema.next;
|
|
153
|
+
const stateUpdate = nextStage
|
|
154
|
+
? ` - Set \`currentStage\` to \`"${nextStage}"\`
|
|
155
|
+
- Add \`"${stage}"\` to \`completedStages\` array
|
|
156
|
+
- Move all gate IDs for this stage (${gateList}) into \`stageGateCatalog.${stage}.passed\`
|
|
157
|
+
- Clear \`stageGateCatalog.${stage}.blocked\``
|
|
158
|
+
: ` - Add \`"${stage}"\` to \`completedStages\` array
|
|
159
|
+
- Move all gate IDs for this stage (${gateList}) into \`stageGateCatalog.${stage}.passed\`
|
|
160
|
+
- Clear \`stageGateCatalog.${stage}.blocked\``;
|
|
161
|
+
let nextAction;
|
|
162
|
+
if (nextStage) {
|
|
163
|
+
const nextSchema = stageSchema(nextStage);
|
|
164
|
+
const nextDescription = nextSchema.skillDescription.charAt(0).toLowerCase() + nextSchema.skillDescription.slice(1);
|
|
165
|
+
nextAction = `3. Tell the user:\n\n > **Stage \`${stage}\` complete.** Next: **${nextStage}** — ${nextDescription}\n >\n > Run \`/cc-next\` to continue.`;
|
|
170
166
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
**STOP.** This stage requires explicit user confirmation before advancing.
|
|
175
|
-
Even if project config has \`autoAdvance: true\`, this stage's pause rule takes precedence.
|
|
176
|
-
Do NOT auto-advance after gates pass. Present a summary of completed gates and suggest \`${nextCommand}\`, then wait for explicit user approval.
|
|
177
|
-
|
|
178
|
-
`;
|
|
167
|
+
else {
|
|
168
|
+
nextAction = `3. Tell the user:\n\n > **Flow complete.** All stages finished. The project is ready for release.`;
|
|
179
169
|
}
|
|
180
|
-
return `## Stage
|
|
170
|
+
return `## Stage Completion Protocol
|
|
171
|
+
|
|
172
|
+
When all required gates are satisfied and the artifact is written:
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
1. **Update \`${RUNTIME_ROOT}/state/flow-state.json\`:**
|
|
175
|
+
${stateUpdate}
|
|
176
|
+
2. **Sync artifact** to \`${RUNTIME_ROOT}/runs/<activeRunId>/artifacts/${schema.artifactFile}\`
|
|
177
|
+
${nextAction}
|
|
185
178
|
|
|
179
|
+
**STOP.** Do not load the next stage skill yourself. The user will run \`/cc-next\` when ready (same session or new session).
|
|
186
180
|
`;
|
|
187
181
|
}
|
|
188
|
-
function
|
|
182
|
+
function stageTransitionAutoAdvanceBlock(schema) {
|
|
183
|
+
return stageCompletionProtocol(schema);
|
|
184
|
+
}
|
|
185
|
+
function progressiveDisclosureBlock(stage) {
|
|
189
186
|
const schema = stageSchema(stage);
|
|
190
187
|
const stageSpecificRefs = {
|
|
191
188
|
brainstorm: [
|
|
192
|
-
"- `.cclaw/skills/autoplan/SKILL.md` — when the user wants brainstorm→plan orchestration in one flow",
|
|
193
189
|
"- `.cclaw/skills/learnings/SKILL.md` — to capture durable framing insights early"
|
|
194
190
|
],
|
|
195
191
|
scope: [
|
|
196
|
-
"- `.cclaw/skills/autoplan/SKILL.md` — for coordinated premise challenge across early stages",
|
|
197
192
|
"- `.cclaw/skills/learnings/SKILL.md` — to persist rejected assumptions and constraints"
|
|
198
193
|
],
|
|
199
194
|
design: [
|
|
@@ -208,12 +203,9 @@ function progressiveDisclosureBlock(stage, nextCommand) {
|
|
|
208
203
|
"- `.cclaw/skills/subagent-dev/SKILL.md` — for specialist delegation prompts by task slice",
|
|
209
204
|
"- `.cclaw/skills/parallel-dispatch/SKILL.md` — for multi-agent review planning and reconciliation setup"
|
|
210
205
|
],
|
|
211
|
-
|
|
212
|
-
"- `.cclaw/skills/debugging/SKILL.md` — when RED behavior is unclear or
|
|
213
|
-
"- `.cclaw/skills/subagent-dev/SKILL.md` — for machine-only test-slice delegation"
|
|
214
|
-
],
|
|
215
|
-
build: [
|
|
216
|
-
"- `.cclaw/skills/debugging/SKILL.md` — for root-cause workflow when implementation fails tests",
|
|
206
|
+
tdd: [
|
|
207
|
+
"- `.cclaw/skills/debugging/SKILL.md` — when RED behavior is unclear, flakes appear, or implementation fails tests",
|
|
208
|
+
"- `.cclaw/skills/subagent-dev/SKILL.md` — for machine-only test-slice delegation",
|
|
217
209
|
"- `.cclaw/skills/performance/SKILL.md` — when implementation choices impact latency/throughput"
|
|
218
210
|
],
|
|
219
211
|
review: [
|
|
@@ -237,7 +229,7 @@ function progressiveDisclosureBlock(stage, nextCommand) {
|
|
|
237
229
|
- Meta routing and activation rules: \`.cclaw/skills/using-cclaw/SKILL.md\`
|
|
238
230
|
- Session continuity and checkpoint behavior: \`.cclaw/skills/session/SKILL.md\`
|
|
239
231
|
${stageSpecificRefs[stage].join("\n")}
|
|
240
|
-
-
|
|
232
|
+
- Progression command: \`/cc-next\` (reads flow-state, loads the next stage)
|
|
241
233
|
`;
|
|
242
234
|
}
|
|
243
235
|
function verificationBlock(stage) {
|
|
@@ -282,7 +274,6 @@ export function stageSkillFolder(stage) {
|
|
|
282
274
|
}
|
|
283
275
|
function quickStartBlock(stage) {
|
|
284
276
|
const schema = stageSchema(stage);
|
|
285
|
-
const nextCommand = nextCclawCommand(stage);
|
|
286
277
|
const topGates = schema.requiredGates.slice(0, 3).map((g) => `\`${g.id}\``).join(", ");
|
|
287
278
|
return `## Quick Start (minimum compliance)
|
|
288
279
|
|
|
@@ -291,12 +282,11 @@ function quickStartBlock(stage) {
|
|
|
291
282
|
> 2. Complete every checklist step in order and write the artifact to \`.cclaw/artifacts/${schema.artifactFile}\` (canonical run copy: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`).
|
|
292
283
|
> 3. Do not claim completion without satisfying gates: ${topGates}${schema.requiredGates.length > 3 ? ` (+${schema.requiredGates.length - 3} more)` : ""}.
|
|
293
284
|
>
|
|
294
|
-
> **
|
|
285
|
+
> **After this stage:** update \`flow-state.json\` and tell the user to run \`/cc-next\`.
|
|
295
286
|
`;
|
|
296
287
|
}
|
|
297
288
|
export function stageSkillMarkdown(stage) {
|
|
298
289
|
const schema = stageSchema(stage);
|
|
299
|
-
const nextCommand = nextCclawCommand(stage);
|
|
300
290
|
const gateList = schema.requiredGates
|
|
301
291
|
.map((g) => `- \`${g.id}\` — ${g.description}`)
|
|
302
292
|
.join("\n");
|
|
@@ -382,11 +372,11 @@ ${completionStatusBlock(stage)}
|
|
|
382
372
|
## Verification
|
|
383
373
|
${schema.exitCriteria.map((item) => `- [ ] ${item}`).join("\n")}
|
|
384
374
|
|
|
385
|
-
${stageTransitionAutoAdvanceBlock(schema
|
|
386
|
-
${progressiveDisclosureBlock(stage
|
|
375
|
+
${stageTransitionAutoAdvanceBlock(schema)}
|
|
376
|
+
${progressiveDisclosureBlock(stage)}
|
|
387
377
|
${selfImprovementBlock(stage)}
|
|
388
378
|
## Handoff
|
|
389
|
-
- Next command:
|
|
379
|
+
- Next command: \`/cc-next\` (loads whatever stage is current in flow-state)
|
|
390
380
|
- Required artifact: \`.cclaw/artifacts/${schema.artifactFile}\` (canonical: \`.cclaw/runs/<activeRunId>/artifacts/${schema.artifactFile}\`)
|
|
391
381
|
- Stage stays blocked if any required gate is unsatisfied
|
|
392
382
|
`;
|
|
@@ -69,7 +69,7 @@ export interface StageSchema {
|
|
|
69
69
|
artifactValidation: ArtifactValidation[];
|
|
70
70
|
namedAntiPattern?: NamedAntiPattern;
|
|
71
71
|
decisionRecordFormat?: string;
|
|
72
|
-
/** When true, stage skill includes wave auto-execute guidance (
|
|
72
|
+
/** When true, stage skill includes wave auto-execute guidance (tdd). */
|
|
73
73
|
waveExecutionAllowed?: boolean;
|
|
74
74
|
/** Agent names that MUST be dispatched (or waived) before stage transition — derived from mandatory auto-subagent rows. */
|
|
75
75
|
mandatoryDelegations: string[];
|
|
@@ -44,7 +44,7 @@ const BRAINSTORM = {
|
|
|
44
44
|
"Write design doc — save to `.cclaw/artifacts/01-brainstorm.md`.",
|
|
45
45
|
"Self-review — scan for placeholders, TBDs, contradictions, ambiguity, scope creep. Fix inline.",
|
|
46
46
|
"User reviews written artifact — ask user to review before proceeding. **STOP.** Do NOT proceed until user responds.",
|
|
47
|
-
"
|
|
47
|
+
"Stage complete — update `flow-state.json` per the Stage Completion Protocol. Tell user to run `/cc-next` to continue to scope."
|
|
48
48
|
],
|
|
49
49
|
interactionProtocol: [
|
|
50
50
|
"Explore context first (files, docs, existing behavior).",
|
|
@@ -679,7 +679,7 @@ const PLAN = {
|
|
|
679
679
|
],
|
|
680
680
|
whenNotToUse: [
|
|
681
681
|
"Specification is unapproved or lacks measurable acceptance criteria",
|
|
682
|
-
"Execution is already in
|
|
682
|
+
"Execution is already in TDD stage with active slice evidence",
|
|
683
683
|
"The request is only release packaging with no task decomposition needed"
|
|
684
684
|
],
|
|
685
685
|
checklist: [
|
|
@@ -689,15 +689,15 @@ const PLAN = {
|
|
|
689
689
|
"Slice into vertical tasks — each task targets 2-5 minutes, produces one testable outcome, and touches one coherent area.",
|
|
690
690
|
"Attach verification — every task has an acceptance criterion mapping and a concrete verification command.",
|
|
691
691
|
"Define checkpoints — mark points where progress should be validated before continuing.",
|
|
692
|
-
"WAIT_FOR_CONFIRM — write plan artifact and explicitly pause. **STOP.** Do NOT proceed
|
|
692
|
+
"WAIT_FOR_CONFIRM — write plan artifact and explicitly pause. **STOP.** Do NOT proceed until user confirms. Then update `flow-state.json` and tell user to run `/cc-next`."
|
|
693
693
|
],
|
|
694
694
|
interactionProtocol: [
|
|
695
695
|
"Plan in read-only mode relative to implementation.",
|
|
696
696
|
"Split work into small vertical slices (target 2-5 minute tasks).",
|
|
697
697
|
"Publish explicit dependency waves with entry and exit checks for each wave.",
|
|
698
698
|
"Attach verification step to every task.",
|
|
699
|
-
"Enforce WAIT_FOR_CONFIRM
|
|
700
|
-
"**STOP.** Do NOT proceed
|
|
699
|
+
"Enforce WAIT_FOR_CONFIRM: present the plan summary with options (A) Approve / (B) Revise / (C) Reject.",
|
|
700
|
+
"**STOP.** Do NOT proceed until user explicitly approves. Then update `flow-state.json` and tell user to run `/cc-next`."
|
|
701
701
|
],
|
|
702
702
|
process: [
|
|
703
703
|
"Build dependency graph and ordered slices.",
|
|
@@ -760,7 +760,7 @@ const PLAN = {
|
|
|
760
760
|
],
|
|
761
761
|
policyNeedles: ["WAIT_FOR_CONFIRM", "Task Graph", "Dependency Waves", "Acceptance Mapping", "verification steps"],
|
|
762
762
|
artifactFile: "05-plan.md",
|
|
763
|
-
next: "
|
|
763
|
+
next: "tdd",
|
|
764
764
|
cognitivePatterns: [
|
|
765
765
|
{ name: "Vertical Slice Thinking", description: "Each task delivers one thin end-to-end slice of value. Horizontal layers (all models, then all controllers) create integration risk. Vertical slices (one feature through all layers) reduce it." },
|
|
766
766
|
{ name: "Two-Minute Smell Test", description: "If a competent engineer cannot understand and start a task in two minutes, the task is too large or too vague. Break it down further." },
|
|
@@ -782,202 +782,124 @@ const PLAN = {
|
|
|
782
782
|
]
|
|
783
783
|
};
|
|
784
784
|
// ---------------------------------------------------------------------------
|
|
785
|
-
//
|
|
785
|
+
// TDD — RED → GREEN → REFACTOR cycle (merged test + build)
|
|
786
786
|
// ---------------------------------------------------------------------------
|
|
787
|
-
const
|
|
788
|
-
stage: "
|
|
789
|
-
skillFolder: "
|
|
790
|
-
skillName: "
|
|
791
|
-
skillDescription: "TDD RED
|
|
792
|
-
hardGate: "Do NOT
|
|
793
|
-
purpose: "
|
|
787
|
+
const TDD = {
|
|
788
|
+
stage: "tdd",
|
|
789
|
+
skillFolder: "test-driven-development",
|
|
790
|
+
skillName: "test-driven-development",
|
|
791
|
+
skillDescription: "Full TDD cycle: RED (failing tests), GREEN (minimal implementation), REFACTOR (cleanup). One plan slice at a time with strict traceability.",
|
|
792
|
+
hardGate: "Do NOT merge, ship, or skip review. Follow RED → GREEN → REFACTOR strictly for each plan slice. Do NOT write implementation code before RED tests exist. Do NOT skip the REFACTOR step.",
|
|
793
|
+
purpose: "Implement features through the TDD cycle: write failing tests, make them pass with minimal code, then refactor.",
|
|
794
794
|
whenToUse: [
|
|
795
795
|
"After plan confirmation",
|
|
796
|
-
"
|
|
797
|
-
"
|
|
796
|
+
"For every behavior change in scope",
|
|
797
|
+
"Before review stage"
|
|
798
798
|
],
|
|
799
799
|
whenNotToUse: [
|
|
800
800
|
"Plan approval is still pending WAIT_FOR_CONFIRM",
|
|
801
801
|
"The change is docs-only and does not alter behavior",
|
|
802
|
-
"
|
|
802
|
+
"The stage intent is review/ship sign-off rather than implementation"
|
|
803
803
|
],
|
|
804
804
|
checklist: [
|
|
805
805
|
"Select plan slice — pick one task from the plan. Do not batch multiple tasks.",
|
|
806
806
|
"Map to acceptance criterion — identify the specific spec criterion this test proves.",
|
|
807
|
-
"Write behavior-focused test — test the expected behavior, not implementation details.
|
|
808
|
-
"
|
|
809
|
-
"
|
|
807
|
+
"RED: Write behavior-focused test — test the expected behavior, not implementation details. Tests MUST fail.",
|
|
808
|
+
"RED: Capture failure output — copy the exact failure output as RED evidence. Record in artifact.",
|
|
809
|
+
"GREEN: Minimal implementation — write the smallest code change that makes the RED tests pass. No extra features.",
|
|
810
|
+
"GREEN: Run full suite — execute ALL tests, not just the ones you wrote. The full suite must be GREEN.",
|
|
811
|
+
"GREEN: Verify no regressions — if any existing test breaks, fix the regression before proceeding.",
|
|
812
|
+
"REFACTOR: Improve code quality — without changing behavior. Document what you changed and why.",
|
|
813
|
+
"Record evidence — capture RED failure, GREEN output, and REFACTOR notes in the TDD artifact.",
|
|
814
|
+
"Annotate traceability — link to plan task ID and spec criterion.",
|
|
810
815
|
"Repeat for each slice — return to step 1 for the next plan slice."
|
|
811
816
|
],
|
|
812
817
|
interactionProtocol: [
|
|
813
818
|
"Pick one planned slice at a time.",
|
|
814
|
-
"Write behavior-focused tests before changing implementation.",
|
|
819
|
+
"Write behavior-focused tests before changing implementation (RED).",
|
|
815
820
|
"Capture and store failing output as RED evidence.",
|
|
816
|
-
"
|
|
821
|
+
"Apply minimal change to satisfy RED tests (GREEN).",
|
|
822
|
+
"Run full suite, not partial checks, for GREEN validation.",
|
|
823
|
+
"Refactor without changing behavior and document rationale (REFACTOR).",
|
|
824
|
+
"Stop if regressions appear and fix before proceeding.",
|
|
817
825
|
"If a test passes unexpectedly, investigate: does the behavior already exist, or is the test wrong?"
|
|
818
826
|
],
|
|
819
827
|
process: [
|
|
820
828
|
"Select slice and map to acceptance criterion.",
|
|
821
|
-
"Write test(s) that fail for expected reason.",
|
|
829
|
+
"Write test(s) that fail for expected reason (RED).",
|
|
822
830
|
"Run tests and capture failure output.",
|
|
823
|
-
"Record RED evidence in TDD artifact.",
|
|
824
|
-
"Verify failure reason matches expected missing behavior."
|
|
825
|
-
],
|
|
826
|
-
requiredGates: [
|
|
827
|
-
{ id: "tdd_red_test_written", description: "Failing tests exist before implementation changes." },
|
|
828
|
-
{ id: "tdd_red_failure_captured", description: "Failure output is captured as evidence." },
|
|
829
|
-
{ id: "tdd_trace_to_acceptance", description: "RED tests trace to explicit acceptance criteria." },
|
|
830
|
-
{ id: "tdd_red_failure_reason_verified", description: "Failure is for the expected reason, not an unrelated error." }
|
|
831
|
-
],
|
|
832
|
-
requiredEvidence: [
|
|
833
|
-
"Artifact updated at `.cclaw/artifacts/06-tdd.md` RED section.",
|
|
834
|
-
"Failing command output captured.",
|
|
835
|
-
"Acceptance mapping documented.",
|
|
836
|
-
"Failure reason analysis recorded."
|
|
837
|
-
],
|
|
838
|
-
inputs: ["approved plan slice", "spec acceptance criterion", "test harness configuration"],
|
|
839
|
-
requiredContext: ["plan artifact", "spec artifact", "existing test patterns"],
|
|
840
|
-
outputs: ["failing test set", "captured RED evidence", "ready signal for GREEN stage"],
|
|
841
|
-
blockers: [
|
|
842
|
-
"tests pass before behavior change",
|
|
843
|
-
"failure reason does not match expected behavior",
|
|
844
|
-
"no evidence recorded"
|
|
845
|
-
],
|
|
846
|
-
exitCriteria: [
|
|
847
|
-
"RED evidence exists and is traceable",
|
|
848
|
-
"required gates marked satisfied",
|
|
849
|
-
"no implementation changes made in this stage",
|
|
850
|
-
"failure reason verified for each test"
|
|
851
|
-
],
|
|
852
|
-
antiPatterns: [
|
|
853
|
-
"Writing code before failing test",
|
|
854
|
-
"Asserting implementation details instead of behavior",
|
|
855
|
-
"Skipping evidence capture",
|
|
856
|
-
"Testing multiple slices without recording evidence for each"
|
|
857
|
-
],
|
|
858
|
-
rationalizations: [
|
|
859
|
-
{ claim: "This change is obvious, tests can be added later.", reality: "Without RED proof, regressions hide behind optimistic assumptions." },
|
|
860
|
-
{ claim: "A passing baseline is enough to continue.", reality: "Baseline pass does not prove new behavior requirements." },
|
|
861
|
-
{ claim: "One broad integration test is enough.", reality: "Slice-level RED tests are required for precise failure signal." }
|
|
862
|
-
],
|
|
863
|
-
redFlags: [
|
|
864
|
-
"No failing test output",
|
|
865
|
-
"No acceptance linkage",
|
|
866
|
-
"Implementation edits appear before RED evidence",
|
|
867
|
-
"Test passes without behavior change"
|
|
868
|
-
],
|
|
869
|
-
policyNeedles: ["RED", "failing test", "acceptance criteria", "no implementation changes"],
|
|
870
|
-
artifactFile: "06-tdd.md",
|
|
871
|
-
next: "build",
|
|
872
|
-
cognitivePatterns: [
|
|
873
|
-
{ name: "Behavior Over Implementation", description: "Tests describe WHAT the system does, not HOW. Test the observable behavior from outside the unit. If you need to test internals, the design needs work." },
|
|
874
|
-
{ name: "Failure-First Thinking", description: "The failing test IS the specification. Until you see the right failure, you do not understand what you are building. Wrong failures are information." },
|
|
875
|
-
{ name: "Proof Before Claim", description: "Do not claim a feature works without evidence. RED output is proof of what is missing. GREEN output is proof it was added. Both are required." }
|
|
876
|
-
],
|
|
877
|
-
reviewSections: [],
|
|
878
|
-
completionStatus: ["DONE", "DONE_WITH_CONCERNS", "BLOCKED"],
|
|
879
|
-
crossStageTrace: {
|
|
880
|
-
readsFrom: [".cclaw/artifacts/05-plan.md", ".cclaw/artifacts/04-spec.md"],
|
|
881
|
-
writesTo: [".cclaw/artifacts/06-tdd.md"],
|
|
882
|
-
traceabilityRule: "Every RED test traces to a plan task. Every plan task traces to a spec criterion. Evidence chain: spec -> plan -> RED test -> failure output."
|
|
883
|
-
},
|
|
884
|
-
artifactValidation: [
|
|
885
|
-
{ section: "RED Evidence", required: true, validationRule: "Failing test output captured per slice." },
|
|
886
|
-
{ section: "Acceptance Mapping", required: true, validationRule: "Each RED test links to a plan task and spec criterion." },
|
|
887
|
-
{ section: "Failure Analysis", required: true, validationRule: "Failure reason matches expected missing behavior." }
|
|
888
|
-
],
|
|
889
|
-
waveExecutionAllowed: true
|
|
890
|
-
};
|
|
891
|
-
// ---------------------------------------------------------------------------
|
|
892
|
-
// BUILD — TDD GREEN + REFACTOR stage
|
|
893
|
-
// ---------------------------------------------------------------------------
|
|
894
|
-
const BUILD = {
|
|
895
|
-
stage: "build",
|
|
896
|
-
skillFolder: "incremental-implementation",
|
|
897
|
-
skillName: "incremental-implementation",
|
|
898
|
-
skillDescription: "TDD GREEN and REFACTOR stage with strict traceability to plan slices.",
|
|
899
|
-
hardGate: "Do NOT merge, ship, or skip review. This stage produces GREEN and REFACTOR evidence for one plan slice at a time. If you are touching files unrelated to the current slice, STOP.",
|
|
900
|
-
purpose: "Implement minimal passing change, run full suite GREEN, then refactor safely.",
|
|
901
|
-
whenToUse: [
|
|
902
|
-
"After RED evidence is complete",
|
|
903
|
-
"For one accepted plan slice at a time",
|
|
904
|
-
"Before review stage"
|
|
905
|
-
],
|
|
906
|
-
whenNotToUse: [
|
|
907
|
-
"RED evidence is missing or failure reason is unverified",
|
|
908
|
-
"Multiple unrelated slices are being merged into one build pass",
|
|
909
|
-
"The stage intent is review/ship sign-off rather than implementation"
|
|
910
|
-
],
|
|
911
|
-
checklist: [
|
|
912
|
-
"Minimal GREEN change — implement the smallest code change that makes the RED tests pass. No extra features.",
|
|
913
|
-
"Run full suite — execute ALL tests, not just the ones you wrote. The full suite must be GREEN.",
|
|
914
|
-
"Verify no regressions — if any existing test breaks, fix the regression before proceeding.",
|
|
915
|
-
"Refactor pass — improve code quality without changing behavior. Document what you changed and why.",
|
|
916
|
-
"Record evidence — capture GREEN output and REFACTOR notes in the TDD artifact.",
|
|
917
|
-
"Annotate traceability — link the implementation to the plan task ID and spec criterion."
|
|
918
|
-
],
|
|
919
|
-
interactionProtocol: [
|
|
920
|
-
"Apply minimal change to satisfy RED tests.",
|
|
921
|
-
"Run full suite, not partial checks, for GREEN validation.",
|
|
922
|
-
"Refactor without changing behavior and document rationale.",
|
|
923
|
-
"Stop if regressions appear and return to prior step.",
|
|
924
|
-
"Record traceability to plan slice explicitly."
|
|
925
|
-
],
|
|
926
|
-
process: [
|
|
927
831
|
"Implement smallest change needed for GREEN.",
|
|
928
832
|
"Run full tests and build checks.",
|
|
929
833
|
"Perform refactor pass preserving behavior.",
|
|
930
|
-
"Record GREEN and REFACTOR evidence in artifact.",
|
|
834
|
+
"Record RED, GREEN, and REFACTOR evidence in artifact.",
|
|
931
835
|
"Annotate traceability to plan task and spec criterion."
|
|
932
836
|
],
|
|
933
837
|
requiredGates: [
|
|
934
|
-
{ id: "
|
|
838
|
+
{ id: "tdd_red_test_written", description: "Failing tests exist before implementation changes." },
|
|
839
|
+
{ id: "tdd_red_failure_captured", description: "Failure output is captured as evidence." },
|
|
840
|
+
{ id: "tdd_trace_to_acceptance", description: "RED tests trace to explicit acceptance criteria." },
|
|
841
|
+
{ id: "tdd_red_failure_reason_verified", description: "Failure is for the expected reason, not an unrelated error." },
|
|
935
842
|
{ id: "tdd_green_full_suite", description: "Full relevant suite passes in GREEN state." },
|
|
936
843
|
{ id: "tdd_refactor_completed", description: "Refactor pass completed with behavior preservation verified." },
|
|
937
844
|
{ id: "tdd_refactor_notes_written", description: "Refactor decisions and outcomes are documented." },
|
|
938
|
-
{ id: "
|
|
845
|
+
{ id: "tdd_traceable_to_plan", description: "Change traceability to plan slice is explicit." }
|
|
939
846
|
],
|
|
940
847
|
requiredEvidence: [
|
|
941
|
-
"Artifact `.cclaw/artifacts/06-tdd.md`
|
|
942
|
-
"
|
|
943
|
-
"
|
|
944
|
-
"
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
848
|
+
"Artifact updated at `.cclaw/artifacts/06-tdd.md` with RED, GREEN, and REFACTOR sections.",
|
|
849
|
+
"Failing command output captured (RED).",
|
|
850
|
+
"Full test/build output recorded (GREEN).",
|
|
851
|
+
"Acceptance mapping documented.",
|
|
852
|
+
"Failure reason analysis recorded.",
|
|
853
|
+
"Refactor rationale captured.",
|
|
854
|
+
"Traceability to task identifier is documented."
|
|
855
|
+
],
|
|
856
|
+
inputs: ["approved plan slice", "spec acceptance criterion", "test harness configuration", "coding standards and constraints"],
|
|
857
|
+
requiredContext: ["plan artifact", "spec artifact", "existing test patterns"],
|
|
858
|
+
outputs: ["failing test set", "passing implementation", "refactor evidence", "review-ready change set"],
|
|
949
859
|
blockers: [
|
|
950
|
-
"
|
|
860
|
+
"tests pass before behavior change (RED failure missing)",
|
|
951
861
|
"full suite not green",
|
|
952
|
-
"behavior changed during refactor"
|
|
862
|
+
"behavior changed during refactor",
|
|
863
|
+
"no evidence recorded"
|
|
953
864
|
],
|
|
954
865
|
exitCriteria: [
|
|
955
|
-
"
|
|
866
|
+
"RED evidence exists and is traceable",
|
|
867
|
+
"GREEN evidence captured with full suite pass",
|
|
956
868
|
"REFACTOR evidence captured",
|
|
957
869
|
"required gates marked satisfied",
|
|
958
870
|
"traceability annotated"
|
|
959
871
|
],
|
|
960
872
|
antiPatterns: [
|
|
873
|
+
"Writing code before failing test",
|
|
874
|
+
"Asserting implementation details instead of behavior",
|
|
961
875
|
"Big-bang implementation across multiple slices",
|
|
962
876
|
"Partial test runs presented as GREEN",
|
|
877
|
+
"Skipping evidence capture",
|
|
963
878
|
"Undocumented refactor changes",
|
|
964
879
|
"Adding features beyond what RED tests require"
|
|
965
880
|
],
|
|
966
881
|
rationalizations: [
|
|
882
|
+
{ claim: "This change is obvious, tests can be added later.", reality: "Without RED proof, regressions hide behind optimistic assumptions." },
|
|
883
|
+
{ claim: "A passing baseline is enough to continue.", reality: "Baseline pass does not prove new behavior requirements." },
|
|
884
|
+
{ claim: "One broad integration test is enough.", reality: "Slice-level RED tests are required for precise failure signal." },
|
|
967
885
|
{ claim: "Refactor can be skipped for speed.", reality: "Skipping refactor accumulates debt and weakens maintainability." },
|
|
968
886
|
{ claim: "Only changed tests need to pass.", reality: "Full-suite checks are needed to detect regressions." },
|
|
969
887
|
{ claim: "Traceability is implied by commit diff.", reality: "Explicit mapping avoids ambiguity in review and rollback." }
|
|
970
888
|
],
|
|
971
889
|
redFlags: [
|
|
890
|
+
"No failing test output (RED missing)",
|
|
891
|
+
"Implementation edits appear before RED evidence",
|
|
972
892
|
"No full-suite GREEN evidence",
|
|
973
893
|
"No refactor notes",
|
|
974
894
|
"Multiple tasks implemented in one pass without justification",
|
|
975
895
|
"Files changed outside current slice scope"
|
|
976
896
|
],
|
|
977
|
-
policyNeedles: ["GREEN", "full test suite", "
|
|
897
|
+
policyNeedles: ["RED", "GREEN", "REFACTOR", "failing test", "full test suite", "acceptance criteria", "traceable to plan slice"],
|
|
978
898
|
artifactFile: "06-tdd.md",
|
|
979
899
|
next: "review",
|
|
980
900
|
cognitivePatterns: [
|
|
901
|
+
{ name: "Behavior Over Implementation", description: "Tests describe WHAT the system does, not HOW. Test the observable behavior from outside the unit. If you need to test internals, the design needs work." },
|
|
902
|
+
{ name: "Failure-First Thinking", description: "The failing test IS the specification. Until you see the right failure, you do not understand what you are building. Wrong failures are information." },
|
|
981
903
|
{ name: "Minimal Viable Change", description: "The best implementation is the smallest one that passes all RED tests. Every extra line is risk. Resist the urge to 'improve while you are here.'" },
|
|
982
904
|
{ name: "Regression Paranoia", description: "Assume every change breaks something until the full suite proves otherwise. Partial test runs are lies of omission." },
|
|
983
905
|
{ name: "Refactor-as-Hygiene", description: "Refactoring is not optional cleanup — it is the third leg of TDD. GREEN without REFACTOR accumulates mess. REFACTOR without GREEN breaks things." }
|
|
@@ -985,11 +907,14 @@ const BUILD = {
|
|
|
985
907
|
reviewSections: [],
|
|
986
908
|
completionStatus: ["DONE", "DONE_WITH_CONCERNS", "BLOCKED"],
|
|
987
909
|
crossStageTrace: {
|
|
988
|
-
readsFrom: [".cclaw/artifacts/
|
|
910
|
+
readsFrom: [".cclaw/artifacts/05-plan.md", ".cclaw/artifacts/04-spec.md"],
|
|
989
911
|
writesTo: [".cclaw/artifacts/06-tdd.md"],
|
|
990
|
-
traceabilityRule: "Every GREEN change traces to a RED test. Every
|
|
912
|
+
traceabilityRule: "Every RED test traces to a plan task. Every GREEN change traces to a RED test. Every plan task traces to a spec criterion. Evidence chain must be unbroken."
|
|
991
913
|
},
|
|
992
914
|
artifactValidation: [
|
|
915
|
+
{ section: "RED Evidence", required: true, validationRule: "Failing test output captured per slice." },
|
|
916
|
+
{ section: "Acceptance Mapping", required: true, validationRule: "Each RED test links to a plan task and spec criterion." },
|
|
917
|
+
{ section: "Failure Analysis", required: true, validationRule: "Failure reason matches expected missing behavior." },
|
|
993
918
|
{ section: "GREEN Evidence", required: true, validationRule: "Full suite pass output captured." },
|
|
994
919
|
{ section: "REFACTOR Notes", required: true, validationRule: "What changed, why, behavior preservation confirmed." },
|
|
995
920
|
{ section: "Traceability", required: true, validationRule: "Plan task ID and spec criterion linked." }
|
|
@@ -1007,13 +932,13 @@ const REVIEW = {
|
|
|
1007
932
|
hardGate: "Do NOT ship, merge, or release until both review layers complete with an explicit verdict. No exceptions for urgency. Critical blockers MUST be resolved before handoff.",
|
|
1008
933
|
purpose: "Validate that implementation matches spec and meets quality/security/performance bar through structured two-layer review.",
|
|
1009
934
|
whenToUse: [
|
|
1010
|
-
"After
|
|
935
|
+
"After TDD stage completes",
|
|
1011
936
|
"Before any ship action",
|
|
1012
937
|
"When release risk must be assessed explicitly"
|
|
1013
938
|
],
|
|
1014
939
|
whenNotToUse: [
|
|
1015
940
|
"There is no implementation diff to review",
|
|
1016
|
-
"
|
|
941
|
+
"TDD stage evidence is missing or stale",
|
|
1017
942
|
"The goal is direct release execution without layered quality checks"
|
|
1018
943
|
],
|
|
1019
944
|
checklist: [
|
|
@@ -1364,8 +1289,7 @@ const STAGE_SCHEMA_MAP = {
|
|
|
1364
1289
|
design: DESIGN,
|
|
1365
1290
|
spec: SPEC,
|
|
1366
1291
|
plan: PLAN,
|
|
1367
|
-
|
|
1368
|
-
build: BUILD,
|
|
1292
|
+
tdd: TDD,
|
|
1369
1293
|
review: REVIEW,
|
|
1370
1294
|
ship: SHIP
|
|
1371
1295
|
};
|
|
@@ -1422,21 +1346,12 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1422
1346
|
requiresUserGate: false
|
|
1423
1347
|
}
|
|
1424
1348
|
],
|
|
1425
|
-
|
|
1426
|
-
{
|
|
1427
|
-
agent: "test-author",
|
|
1428
|
-
mode: "mandatory",
|
|
1429
|
-
when: "Always during RED stage.",
|
|
1430
|
-
purpose: "Guarantee failing tests are created before implementation.",
|
|
1431
|
-
requiresUserGate: false
|
|
1432
|
-
}
|
|
1433
|
-
],
|
|
1434
|
-
build: [
|
|
1349
|
+
tdd: [
|
|
1435
1350
|
{
|
|
1436
1351
|
agent: "test-author",
|
|
1437
1352
|
mode: "mandatory",
|
|
1438
|
-
when: "Always during GREEN
|
|
1439
|
-
purpose: "
|
|
1353
|
+
when: "Always during TDD cycle (RED → GREEN → REFACTOR).",
|
|
1354
|
+
purpose: "Guarantee failing tests, traceable implementation, and full-suite verification.",
|
|
1440
1355
|
requiresUserGate: false
|
|
1441
1356
|
},
|
|
1442
1357
|
{
|