@bhargavvc/sdd-cc 1.30.0 → 1.35.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.ja-JP.md +144 -110
- package/README.ko-KR.md +143 -107
- package/README.md +183 -112
- package/README.pt-BR.md +90 -52
- package/README.zh-CN.md +141 -101
- package/agents/sdd-advisor-researcher.md +23 -0
- package/agents/sdd-ai-researcher.md +133 -0
- package/agents/sdd-code-fixer.md +516 -0
- package/agents/sdd-code-reviewer.md +355 -0
- package/agents/sdd-codebase-mapper.md +3 -3
- package/agents/sdd-debugger.md +17 -5
- package/agents/sdd-doc-verifier.md +201 -0
- package/agents/sdd-doc-writer.md +602 -0
- package/agents/sdd-domain-researcher.md +153 -0
- package/agents/sdd-eval-auditor.md +164 -0
- package/agents/sdd-eval-planner.md +154 -0
- package/agents/sdd-executor.md +87 -4
- package/agents/sdd-framework-selector.md +160 -0
- package/agents/sdd-intel-updater.md +314 -0
- package/agents/sdd-nyquist-auditor.md +1 -1
- package/agents/sdd-phase-researcher.md +71 -4
- package/agents/sdd-plan-checker.md +100 -6
- package/agents/sdd-planner.md +145 -206
- package/agents/sdd-project-researcher.md +25 -2
- package/agents/sdd-research-synthesizer.md +3 -3
- package/agents/sdd-roadmapper.md +6 -6
- package/agents/sdd-security-auditor.md +128 -0
- package/agents/sdd-ui-auditor.md +43 -3
- package/agents/sdd-ui-checker.md +5 -5
- package/agents/sdd-ui-researcher.md +27 -4
- package/agents/sdd-user-profiler.md +2 -2
- package/agents/sdd-verifier.md +142 -22
- package/bin/install.js +2151 -551
- package/commands/sdd/add-backlog.md +5 -5
- package/commands/sdd/add-tests.md +2 -2
- package/commands/sdd/ai-integration-phase.md +36 -0
- package/commands/sdd/analyze-dependencies.md +34 -0
- package/commands/sdd/audit-fix.md +33 -0
- package/commands/sdd/autonomous.md +7 -2
- package/commands/sdd/cleanup.md +5 -0
- package/commands/sdd/code-review-fix.md +52 -0
- package/commands/sdd/code-review.md +55 -0
- package/commands/sdd/complete-milestone.md +6 -6
- package/commands/sdd/debug.md +22 -9
- package/commands/sdd/discuss-phase.md +7 -2
- package/commands/sdd/do.md +1 -1
- package/commands/sdd/docs-update.md +48 -0
- package/commands/sdd/eval-review.md +32 -0
- package/commands/sdd/execute-phase.md +4 -0
- package/commands/sdd/explore.md +27 -0
- package/commands/sdd/fast.md +2 -2
- package/commands/sdd/from-sdd2.md +45 -0
- package/commands/sdd/help.md +2 -0
- package/commands/sdd/import.md +36 -0
- package/commands/sdd/intel.md +179 -0
- package/commands/sdd/join-discord.md +2 -1
- package/commands/sdd/manager.md +1 -0
- package/commands/sdd/map-codebase.md +3 -3
- package/commands/sdd/new-milestone.md +1 -1
- package/commands/sdd/new-project.md +5 -1
- package/commands/sdd/new-workspace.md +1 -1
- package/commands/sdd/next.md +2 -0
- package/commands/sdd/plan-milestone-gaps.md +2 -2
- package/commands/sdd/plan-phase.md +6 -1
- package/commands/sdd/plant-seed.md +1 -1
- package/commands/sdd/profile-user.md +1 -1
- package/commands/sdd/quick.md +5 -3
- package/commands/sdd/reapply-patches.md +230 -42
- package/commands/sdd/research-phase.md +3 -3
- package/commands/sdd/review-backlog.md +1 -0
- package/commands/sdd/review.md +6 -3
- package/commands/sdd/scan.md +26 -0
- package/commands/sdd/secure-phase.md +35 -0
- package/commands/sdd/ship.md +1 -1
- package/commands/sdd/thread.md +5 -5
- package/commands/sdd/undo.md +34 -0
- package/commands/sdd/verify-work.md +1 -1
- package/commands/sdd/workstreams.md +17 -11
- package/hooks/dist/sdd-check-update.js +33 -8
- package/hooks/dist/sdd-context-monitor.js +17 -8
- package/hooks/dist/sdd-phase-boundary.sh +27 -0
- package/hooks/dist/sdd-prompt-guard.js +1 -0
- package/hooks/dist/sdd-read-guard.js +82 -0
- package/hooks/dist/sdd-session-state.sh +33 -0
- package/hooks/dist/sdd-statusline.js +137 -15
- package/hooks/dist/sdd-validate-commit.sh +47 -0
- package/hooks/dist/sdd-workflow-guard.js +4 -4
- package/hooks/sdd-check-update.js +139 -0
- package/hooks/sdd-context-monitor.js +165 -0
- package/hooks/sdd-phase-boundary.sh +27 -0
- package/hooks/sdd-prompt-guard.js +97 -0
- package/hooks/sdd-read-guard.js +82 -0
- package/hooks/sdd-session-state.sh +33 -0
- package/hooks/sdd-statusline.js +241 -0
- package/hooks/sdd-validate-commit.sh +47 -0
- package/hooks/sdd-workflow-guard.js +94 -0
- package/package.json +3 -3
- package/scripts/build-hooks.js +18 -7
- package/scripts/prompt-injection-scan.sh +1 -0
- package/scripts/rebrand-gsd-to-sdd.sh +221 -220
- package/scripts/run-tests.cjs +5 -1
- package/scripts/sync-upstream.sh +1 -1
- package/sdd/bin/lib/commands.cjs +79 -17
- package/sdd/bin/lib/config.cjs +90 -48
- package/sdd/bin/lib/core.cjs +452 -87
- package/sdd/bin/lib/docs.cjs +267 -0
- package/sdd/bin/lib/frontmatter.cjs +381 -336
- package/sdd/bin/lib/init.cjs +110 -16
- package/sdd/bin/lib/intel.cjs +660 -0
- package/sdd/bin/lib/learnings.cjs +378 -0
- package/sdd/bin/lib/milestone.cjs +42 -11
- package/sdd/bin/lib/model-profiles.cjs +17 -15
- package/sdd/bin/lib/phase.cjs +367 -288
- package/sdd/bin/lib/profile-output.cjs +106 -10
- package/sdd/bin/lib/roadmap.cjs +146 -115
- package/sdd/bin/lib/schema-detect.cjs +238 -0
- package/sdd/bin/lib/sdd2-import.cjs +511 -0
- package/sdd/bin/lib/security.cjs +124 -3
- package/sdd/bin/lib/state.cjs +648 -264
- package/sdd/bin/lib/template.cjs +8 -4
- package/sdd/bin/lib/verify.cjs +209 -28
- package/sdd/bin/lib/workstream.cjs +7 -3
- package/sdd/bin/sdd-tools.cjs +184 -12
- package/sdd/contexts/dev.md +21 -0
- package/sdd/contexts/research.md +22 -0
- package/sdd/contexts/review.md +22 -0
- package/sdd/references/agent-contracts.md +79 -0
- package/sdd/references/ai-evals.md +156 -0
- package/sdd/references/ai-frameworks.md +186 -0
- package/sdd/references/artifact-types.md +113 -0
- package/sdd/references/common-bug-patterns.md +114 -0
- package/sdd/references/context-budget.md +49 -0
- package/sdd/references/continuation-format.md +25 -25
- package/sdd/references/domain-probes.md +125 -0
- package/sdd/references/few-shot-examples/plan-checker.md +73 -0
- package/sdd/references/few-shot-examples/verifier.md +109 -0
- package/sdd/references/gate-prompts.md +100 -0
- package/sdd/references/gates.md +70 -0
- package/sdd/references/git-integration.md +1 -1
- package/sdd/references/ios-scaffold.md +123 -0
- package/sdd/references/model-profile-resolution.md +2 -0
- package/sdd/references/model-profiles.md +24 -18
- package/sdd/references/planner-gap-closure.md +62 -0
- package/sdd/references/planner-reviews.md +39 -0
- package/sdd/references/planner-revision.md +87 -0
- package/sdd/references/planning-config.md +252 -0
- package/sdd/references/revision-loop.md +97 -0
- package/sdd/references/thinking-models-debug.md +44 -0
- package/sdd/references/thinking-models-execution.md +50 -0
- package/sdd/references/thinking-models-planning.md +62 -0
- package/sdd/references/thinking-models-research.md +50 -0
- package/sdd/references/thinking-models-verification.md +55 -0
- package/sdd/references/thinking-partner.md +96 -0
- package/sdd/references/ui-brand.md +4 -4
- package/sdd/references/universal-anti-patterns.md +63 -0
- package/sdd/references/verification-overrides.md +227 -0
- package/sdd/references/workstream-flag.md +56 -3
- package/sdd/templates/AI-SPEC.md +246 -0
- package/sdd/templates/DEBUG.md +1 -1
- package/sdd/templates/SECURITY.md +61 -0
- package/sdd/templates/UAT.md +4 -4
- package/sdd/templates/VALIDATION.md +4 -4
- package/sdd/templates/claude-md.md +32 -9
- package/sdd/templates/config.json +4 -0
- package/sdd/templates/debug-subagent-prompt.md +1 -1
- package/sdd/templates/dev-preferences.md +1 -1
- package/sdd/templates/discovery.md +2 -2
- package/sdd/templates/phase-prompt.md +1 -1
- package/sdd/templates/planner-subagent-prompt.md +3 -3
- package/sdd/templates/project.md +1 -1
- package/sdd/templates/research.md +1 -1
- package/sdd/templates/state.md +2 -2
- package/sdd/workflows/add-phase.md +8 -8
- package/sdd/workflows/add-tests.md +12 -9
- package/sdd/workflows/add-todo.md +5 -3
- package/sdd/workflows/ai-integration-phase.md +284 -0
- package/sdd/workflows/analyze-dependencies.md +96 -0
- package/sdd/workflows/audit-fix.md +157 -0
- package/sdd/workflows/audit-milestone.md +11 -11
- package/sdd/workflows/audit-uat.md +2 -2
- package/sdd/workflows/autonomous.md +195 -27
- package/sdd/workflows/check-todos.md +12 -10
- package/sdd/workflows/cleanup.md +2 -0
- package/sdd/workflows/code-review-fix.md +497 -0
- package/sdd/workflows/code-review.md +515 -0
- package/sdd/workflows/complete-milestone.md +56 -22
- package/sdd/workflows/diagnose-issues.md +10 -3
- package/sdd/workflows/discovery-phase.md +5 -3
- package/sdd/workflows/discuss-phase-assumptions.md +24 -6
- package/sdd/workflows/discuss-phase-power.md +291 -0
- package/sdd/workflows/discuss-phase.md +173 -21
- package/sdd/workflows/do.md +23 -21
- package/sdd/workflows/docs-update.md +1155 -0
- package/sdd/workflows/eval-review.md +155 -0
- package/sdd/workflows/execute-phase.md +594 -38
- package/sdd/workflows/execute-plan.md +67 -96
- package/sdd/workflows/explore.md +139 -0
- package/sdd/workflows/fast.md +5 -5
- package/sdd/workflows/forensics.md +2 -2
- package/sdd/workflows/health.md +4 -4
- package/sdd/workflows/help.md +122 -119
- package/sdd/workflows/import.md +276 -0
- package/sdd/workflows/inbox.md +387 -0
- package/sdd/workflows/insert-phase.md +7 -7
- package/sdd/workflows/list-phase-assumptions.md +4 -4
- package/sdd/workflows/list-workspaces.md +2 -2
- package/sdd/workflows/manager.md +35 -32
- package/sdd/workflows/map-codebase.md +7 -5
- package/sdd/workflows/milestone-summary.md +2 -2
- package/sdd/workflows/new-milestone.md +17 -9
- package/sdd/workflows/new-project.md +50 -25
- package/sdd/workflows/new-workspace.md +7 -5
- package/sdd/workflows/next.md +67 -11
- package/sdd/workflows/note.md +9 -7
- package/sdd/workflows/pause-work.md +75 -12
- package/sdd/workflows/plan-milestone-gaps.md +8 -8
- package/sdd/workflows/plan-phase.md +294 -42
- package/sdd/workflows/plant-seed.md +6 -3
- package/sdd/workflows/pr-branch.md +42 -14
- package/sdd/workflows/profile-user.md +9 -7
- package/sdd/workflows/progress.md +45 -45
- package/sdd/workflows/quick.md +195 -47
- package/sdd/workflows/remove-phase.md +6 -6
- package/sdd/workflows/remove-workspace.md +3 -1
- package/sdd/workflows/research-phase.md +2 -2
- package/sdd/workflows/resume-project.md +12 -12
- package/sdd/workflows/review.md +109 -9
- package/sdd/workflows/scan.md +102 -0
- package/sdd/workflows/secure-phase.md +166 -0
- package/sdd/workflows/session-report.md +2 -2
- package/sdd/workflows/settings.md +38 -12
- package/sdd/workflows/ship.md +21 -9
- package/sdd/workflows/stats.md +1 -1
- package/sdd/workflows/transition.md +23 -23
- package/sdd/workflows/ui-phase.md +15 -7
- package/sdd/workflows/ui-review.md +29 -4
- package/sdd/workflows/undo.md +314 -0
- package/sdd/workflows/update.md +171 -20
- package/sdd/workflows/validate-phase.md +6 -4
- package/sdd/workflows/verify-phase.md +210 -6
- package/sdd/workflows/verify-work.md +83 -9
- package/sdd/commands/sdd/workstreams.md +0 -63
|
@@ -25,6 +25,10 @@ via filesystem and git state.
|
|
|
25
25
|
|
|
26
26
|
<required_reading>
|
|
27
27
|
Read STATE.md before any operation to load project context.
|
|
28
|
+
|
|
29
|
+
@~/.claude/sdd/references/agent-contracts.md
|
|
30
|
+
@~/.claude/sdd/references/context-budget.md
|
|
31
|
+
@~/.claude/sdd/references/gates.md
|
|
28
32
|
</required_reading>
|
|
29
33
|
|
|
30
34
|
<available_agent_types>
|
|
@@ -66,7 +70,28 @@ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
|
|
|
66
70
|
AGENT_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-executor 2>/dev/null)
|
|
67
71
|
```
|
|
68
72
|
|
|
69
|
-
Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`.
|
|
73
|
+
Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
|
|
74
|
+
|
|
75
|
+
**If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
|
|
76
|
+
|
|
77
|
+
Read worktree config:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
USE_WORKTREES=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
|
|
84
|
+
|
|
85
|
+
Read context window size for adaptive prompt enrichment:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
CONTEXT_WINDOW=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get context_window 2>/dev/null || echo "200000")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
|
|
92
|
+
- Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
|
|
93
|
+
- Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
|
|
94
|
+
- This enables cross-phase awareness and history-aware verification
|
|
70
95
|
|
|
71
96
|
**If `phase_found` is false:** Error — phase directory not found.
|
|
72
97
|
**If `plan_count` is 0:** Error — no plans found in phase.
|
|
@@ -91,6 +116,30 @@ fi
|
|
|
91
116
|
```
|
|
92
117
|
</step>
|
|
93
118
|
|
|
119
|
+
<step name="check_blocking_antipatterns" priority="first">
|
|
120
|
+
**MANDATORY — Check for blocking anti-patterns before any other work.**
|
|
121
|
+
|
|
122
|
+
Look for a `.continue-here.md` in the current phase directory:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
ls ${phase_dir}/.continue-here.md 2>/dev/null || true
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
|
|
129
|
+
|
|
130
|
+
**If one or more `blocking` anti-patterns are found:**
|
|
131
|
+
|
|
132
|
+
This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
|
|
133
|
+
|
|
134
|
+
1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
|
|
135
|
+
2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
|
|
136
|
+
3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
|
|
137
|
+
|
|
138
|
+
Write these answers inline before continuing. If a blocking anti-pattern cannot be answered from the context in `.continue-here.md`, stop and ask the user for clarification.
|
|
139
|
+
|
|
140
|
+
**If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
|
|
141
|
+
</step>
|
|
142
|
+
|
|
94
143
|
<step name="check_interactive_mode">
|
|
95
144
|
**Parse `--interactive` flag from $ARGUMENTS.**
|
|
96
145
|
|
|
@@ -199,7 +248,41 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
199
248
|
|
|
200
249
|
**For each wave:**
|
|
201
250
|
|
|
202
|
-
1. **
|
|
251
|
+
1. **Intra-wave files_modified overlap check (BEFORE spawning):**
|
|
252
|
+
|
|
253
|
+
Before spawning any agents for this wave, inspect the `files_modified` list of all plans
|
|
254
|
+
in the wave. Check every pair of plans in the wave — if any two plans share even one file
|
|
255
|
+
in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
|
|
256
|
+
in parallel.
|
|
257
|
+
|
|
258
|
+
**Detection algorithm (pseudocode):**
|
|
259
|
+
```
|
|
260
|
+
seen_files = {}
|
|
261
|
+
overlapping_plans = []
|
|
262
|
+
for each plan in wave_plans:
|
|
263
|
+
for each file in plan.files_modified:
|
|
264
|
+
if file in seen_files:
|
|
265
|
+
overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
|
|
266
|
+
else:
|
|
267
|
+
seen_files[file] = plan
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**If overlap is detected:**
|
|
271
|
+
- Warn the user:
|
|
272
|
+
```
|
|
273
|
+
⚠ Intra-wave files_modified overlap detected in Wave {N}:
|
|
274
|
+
Plan {A} and Plan {B} both modify {file}
|
|
275
|
+
Running these plans sequentially to avoid parallel worktree conflicts.
|
|
276
|
+
```
|
|
277
|
+
- Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
|
|
278
|
+
sequentially regardless of the global parallelization setting.
|
|
279
|
+
- This is a safety net for plans that were incorrectly assigned to the same wave.
|
|
280
|
+
The planner should have caught this; flag it as a planning defect so the user can
|
|
281
|
+
replan the phase if desired.
|
|
282
|
+
|
|
283
|
+
**If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
|
|
284
|
+
|
|
285
|
+
2. **Describe what's being built (BEFORE spawning):**
|
|
203
286
|
|
|
204
287
|
Read each plan's `<objective>`. Extract what's being built and why.
|
|
205
288
|
|
|
@@ -217,29 +300,94 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
217
300
|
- Bad: "Executing terrain generation plan"
|
|
218
301
|
- Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
|
|
219
302
|
|
|
220
|
-
|
|
303
|
+
3. **Spawn executor agents:**
|
|
221
304
|
|
|
222
305
|
Pass paths only — executors read files themselves with their fresh context window.
|
|
223
306
|
For 200k models, this keeps orchestrator context lean (~10-15%).
|
|
224
307
|
For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
|
|
225
308
|
|
|
309
|
+
**Worktree mode** (`USE_WORKTREES` is not `false`):
|
|
310
|
+
|
|
311
|
+
Before spawning, capture the current HEAD:
|
|
312
|
+
```bash
|
|
313
|
+
EXPECTED_BASE=$(git rev-parse HEAD)
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Sequential dispatch for parallel execution (waves with 2+ agents):**
|
|
317
|
+
When spawning multiple agents in a wave, dispatch each `Task()` call **one at a time
|
|
318
|
+
with `run_in_background: true`** — do NOT send all Task calls in a single message.
|
|
319
|
+
`git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
|
|
320
|
+
calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
|
|
321
|
+
creation before the next begins (the round-trip latency of each tool call provides
|
|
322
|
+
natural spacing), while all agents still **run in parallel** once created.
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
# CORRECT: dispatch one Task() per message, each with run_in_background: true
|
|
326
|
+
# → worktrees created sequentially, agents execute in parallel
|
|
327
|
+
#
|
|
328
|
+
# WRONG: multiple Task() calls in a single message
|
|
329
|
+
# → simultaneous git worktree add → .git/config.lock contention → failures
|
|
330
|
+
```
|
|
331
|
+
|
|
226
332
|
```
|
|
227
333
|
Task(
|
|
228
334
|
subagent_type="sdd-executor",
|
|
335
|
+
description="Execute plan {plan_number} of phase {phase_number}",
|
|
229
336
|
model="{executor_model}",
|
|
230
337
|
isolation="worktree",
|
|
231
338
|
prompt="
|
|
232
339
|
<objective>
|
|
233
340
|
Execute plan {plan_number} of phase {phase_number}-{phase_name}.
|
|
234
|
-
Commit each task atomically. Create SUMMARY.md.
|
|
341
|
+
Commit each task atomically. Create SUMMARY.md.
|
|
342
|
+
Do NOT update STATE.md or ROADMAP.md — the orchestrator owns those writes after all worktree agents in the wave complete.
|
|
235
343
|
</objective>
|
|
236
344
|
|
|
345
|
+
<worktree_branch_check>
|
|
346
|
+
FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
|
|
347
|
+
|
|
348
|
+
Run:
|
|
349
|
+
```bash
|
|
350
|
+
ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
|
|
354
|
+
base such as `main` instead of the feature branch HEAD), hard-reset to the correct base:
|
|
355
|
+
```bash
|
|
356
|
+
# Safe: this runs before any agent work, so no uncommitted changes to lose
|
|
357
|
+
git reset --hard {EXPECTED_BASE}
|
|
358
|
+
# Verify correction succeeded
|
|
359
|
+
if [ "$(git rev-parse HEAD)" != "{EXPECTED_BASE}" ]; then
|
|
360
|
+
echo "ERROR: Could not correct worktree base — aborting to prevent data loss"
|
|
361
|
+
exit 1
|
|
362
|
+
fi
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
`reset --hard` is safe here because this is a fresh worktree with no user changes. It
|
|
366
|
+
resets both the HEAD pointer AND the working tree to the correct base commit (#2015).
|
|
367
|
+
|
|
368
|
+
If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
|
|
369
|
+
|
|
370
|
+
This check fixes a known issue where `EnterWorktree` creates branches from
|
|
371
|
+
`main` instead of the current feature branch HEAD (affects all platforms).
|
|
372
|
+
</worktree_branch_check>
|
|
373
|
+
|
|
237
374
|
<parallel_execution>
|
|
238
|
-
You are running as a PARALLEL executor agent
|
|
239
|
-
commits to avoid pre-commit hook contention
|
|
240
|
-
orchestrator validates hooks once after all agents complete.
|
|
375
|
+
You are running as a PARALLEL executor agent in a git worktree.
|
|
376
|
+
Use --no-verify on all git commits to avoid pre-commit hook contention
|
|
377
|
+
with other agents. The orchestrator validates hooks once after all agents complete.
|
|
241
378
|
For sdd-tools commits: add --no-verify flag.
|
|
242
379
|
For direct git commits: use git commit --no-verify -m "..."
|
|
380
|
+
|
|
381
|
+
IMPORTANT: Do NOT modify STATE.md or ROADMAP.md. execute-plan.md
|
|
382
|
+
auto-detects worktree mode (`.git` is a file, not a directory) and skips
|
|
383
|
+
shared file updates automatically. The orchestrator updates them centrally
|
|
384
|
+
after merge.
|
|
385
|
+
|
|
386
|
+
REQUIRED: SUMMARY.md MUST be committed before you return. In worktree mode the
|
|
387
|
+
git_commit_metadata step in execute-plan.md commits SUMMARY.md and REQUIREMENTS.md
|
|
388
|
+
only (STATE.md and ROADMAP.md are excluded automatically). Do NOT skip or defer
|
|
389
|
+
this commit — the orchestrator force-removes the worktree after you return, and
|
|
390
|
+
any uncommitted SUMMARY.md will be permanently lost (#2070).
|
|
243
391
|
</parallel_execution>
|
|
244
392
|
|
|
245
393
|
<execution_context>
|
|
@@ -255,6 +403,11 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
255
403
|
- .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
|
|
256
404
|
- .planning/STATE.md (State)
|
|
257
405
|
- .planning/config.json (Config, if exists)
|
|
406
|
+
${CONTEXT_WINDOW >= 500000 ? `
|
|
407
|
+
- ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
|
|
408
|
+
- ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
|
|
409
|
+
- ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
|
|
410
|
+
` : ''}
|
|
258
411
|
- ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
|
|
259
412
|
- .claude/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
|
|
260
413
|
</files_to_read>
|
|
@@ -272,14 +425,38 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
272
425
|
- [ ] All tasks executed
|
|
273
426
|
- [ ] Each task committed individually
|
|
274
427
|
- [ ] SUMMARY.md created in plan directory
|
|
275
|
-
- [ ]
|
|
276
|
-
- [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
|
|
428
|
+
- [ ] No modifications to shared orchestrator artifacts (the orchestrator handles all post-wave shared-file writes)
|
|
277
429
|
</success_criteria>
|
|
278
430
|
"
|
|
279
431
|
)
|
|
280
432
|
```
|
|
281
433
|
|
|
282
|
-
|
|
434
|
+
**Sequential mode** (`USE_WORKTREES` is `false`):
|
|
435
|
+
|
|
436
|
+
Omit `isolation="worktree"` from the Task call. Replace the `<parallel_execution>` block with:
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
<sequential_execution>
|
|
440
|
+
You are running as a SEQUENTIAL executor agent on the main working tree.
|
|
441
|
+
Use normal git commits (with hooks). Do NOT use --no-verify.
|
|
442
|
+
</sequential_execution>
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
The sequential mode Task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
|
|
446
|
+
|
|
447
|
+
```
|
|
448
|
+
<success_criteria>
|
|
449
|
+
- [ ] All tasks executed
|
|
450
|
+
- [ ] Each task committed individually
|
|
451
|
+
- [ ] SUMMARY.md created in plan directory
|
|
452
|
+
- [ ] STATE.md updated with position and decisions
|
|
453
|
+
- [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
|
|
454
|
+
</success_criteria>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
|
|
458
|
+
|
|
459
|
+
4. **Wait for all agents in wave to complete.**
|
|
283
460
|
|
|
284
461
|
**Completion signal fallback (Copilot and runtimes where Task() may not return):**
|
|
285
462
|
|
|
@@ -293,17 +470,17 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
293
470
|
```
|
|
294
471
|
|
|
295
472
|
**If SUMMARY.md exists AND commits are found:** The agent completed successfully —
|
|
296
|
-
treat as done and proceed to step
|
|
473
|
+
treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
|
|
297
474
|
|
|
298
475
|
**If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
|
|
299
476
|
running or may have failed silently. Check `git log --oneline -5` for recent
|
|
300
477
|
activity. If commits are still appearing, wait longer. If no activity, report
|
|
301
|
-
the plan as failed and route to the failure handler in step
|
|
478
|
+
the plan as failed and route to the failure handler in step 6.
|
|
302
479
|
|
|
303
480
|
**This fallback applies automatically to all runtimes.** Claude Code's Task() normally
|
|
304
481
|
returns synchronously, but the fallback ensures resilience if it doesn't.
|
|
305
482
|
|
|
306
|
-
|
|
483
|
+
5. **Post-wave hook validation (parallel mode only):**
|
|
307
484
|
|
|
308
485
|
When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
|
|
309
486
|
```bash
|
|
@@ -313,7 +490,210 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
313
490
|
```
|
|
314
491
|
If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
|
|
315
492
|
|
|
316
|
-
5. **
|
|
493
|
+
5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
|
|
494
|
+
|
|
495
|
+
When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
# List worktrees created by this wave's agents
|
|
499
|
+
WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
|
|
500
|
+
|
|
501
|
+
for WT in $WORKTREES; do
|
|
502
|
+
# Get the branch name for this worktree
|
|
503
|
+
WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
504
|
+
if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
|
|
505
|
+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
506
|
+
|
|
507
|
+
# --- Orchestrator file protection (#1756) ---
|
|
508
|
+
# Snapshot orchestrator-owned files BEFORE merge. If the worktree
|
|
509
|
+
# branch outlived a milestone transition, its versions of STATE.md
|
|
510
|
+
# and ROADMAP.md are stale. Main always wins for these files.
|
|
511
|
+
STATE_BACKUP=$(mktemp)
|
|
512
|
+
ROADMAP_BACKUP=$(mktemp)
|
|
513
|
+
git show HEAD:.planning/STATE.md > "$STATE_BACKUP" 2>/dev/null || true
|
|
514
|
+
git show HEAD:.planning/ROADMAP.md > "$ROADMAP_BACKUP" 2>/dev/null || true
|
|
515
|
+
|
|
516
|
+
# Snapshot list of files on main BEFORE merge to detect resurrections
|
|
517
|
+
PRE_MERGE_FILES=$(git ls-files .planning/)
|
|
518
|
+
|
|
519
|
+
# Pre-merge deletion check: warn if the worktree branch deletes tracked files
|
|
520
|
+
DELETIONS=$(git diff --diff-filter=D --name-only HEAD..."$WT_BRANCH" 2>/dev/null || true)
|
|
521
|
+
if [ -n "$DELETIONS" ]; then
|
|
522
|
+
echo "BLOCKED: Worktree branch $WT_BRANCH contains file deletions: $DELETIONS"
|
|
523
|
+
echo "Review these deletions before merging. If intentional, remove this guard and re-run."
|
|
524
|
+
rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
|
|
525
|
+
continue
|
|
526
|
+
fi
|
|
527
|
+
|
|
528
|
+
# Merge the worktree branch into the current branch
|
|
529
|
+
git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
|
|
530
|
+
echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
|
|
531
|
+
rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
|
|
532
|
+
continue
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
# Restore orchestrator-owned files (main always wins)
|
|
536
|
+
if [ -s "$STATE_BACKUP" ]; then
|
|
537
|
+
cp "$STATE_BACKUP" .planning/STATE.md
|
|
538
|
+
fi
|
|
539
|
+
if [ -s "$ROADMAP_BACKUP" ]; then
|
|
540
|
+
cp "$ROADMAP_BACKUP" .planning/ROADMAP.md
|
|
541
|
+
fi
|
|
542
|
+
rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
|
|
543
|
+
|
|
544
|
+
# Detect files deleted on main but re-added by worktree merge
|
|
545
|
+
# (e.g., archived phase directories that were intentionally removed)
|
|
546
|
+
DELETED_FILES=$(git diff --diff-filter=A --name-only HEAD~1 -- .planning/ 2>/dev/null || true)
|
|
547
|
+
for RESURRECTED in $DELETED_FILES; do
|
|
548
|
+
# Check if this file was NOT in main's pre-merge tree
|
|
549
|
+
if ! echo "$PRE_MERGE_FILES" | grep -qxF "$RESURRECTED"; then
|
|
550
|
+
git rm -f "$RESURRECTED" 2>/dev/null || true
|
|
551
|
+
fi
|
|
552
|
+
done
|
|
553
|
+
|
|
554
|
+
# Amend merge commit with restored files if any changed
|
|
555
|
+
if ! git diff --quiet .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || \
|
|
556
|
+
[ -n "$DELETED_FILES" ]; then
|
|
557
|
+
# Only amend the commit with .planning/ files if commit_docs is enabled (#1783)
|
|
558
|
+
COMMIT_DOCS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get commit_docs 2>/dev/null || echo "true")
|
|
559
|
+
if [ "$COMMIT_DOCS" != "false" ]; then
|
|
560
|
+
git add .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || true
|
|
561
|
+
git commit --amend --no-edit 2>/dev/null || true
|
|
562
|
+
fi
|
|
563
|
+
fi
|
|
564
|
+
|
|
565
|
+
# Safety net: commit any uncommitted SUMMARY.md before force-removing the worktree.
|
|
566
|
+
# This guards against executors that skipped the git_commit_metadata step (#2070).
|
|
567
|
+
UNCOMMITTED_SUMMARY=$(git -C "$WT" ls-files --modified --others --exclude-standard -- "*SUMMARY.md" 2>/dev/null || true)
|
|
568
|
+
if [ -n "$UNCOMMITTED_SUMMARY" ]; then
|
|
569
|
+
echo "⚠ SUMMARY.md was not committed by executor — committing now to prevent data loss"
|
|
570
|
+
git -C "$WT" add -- "*SUMMARY.md" 2>/dev/null || true
|
|
571
|
+
git -C "$WT" commit --no-verify -m "docs(recovery): rescue uncommitted SUMMARY.md before worktree removal (#2070)" 2>/dev/null || true
|
|
572
|
+
# Re-merge the recovery commit
|
|
573
|
+
git merge "$WT_BRANCH" --no-edit -m "chore: merge rescued SUMMARY.md from executor worktree ($WT_BRANCH)" 2>/dev/null || true
|
|
574
|
+
fi
|
|
575
|
+
|
|
576
|
+
# Remove the worktree
|
|
577
|
+
git worktree remove "$WT" --force 2>/dev/null || true
|
|
578
|
+
|
|
579
|
+
# Delete the temporary branch
|
|
580
|
+
git branch -D "$WT_BRANCH" 2>/dev/null || true
|
|
581
|
+
fi
|
|
582
|
+
done
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
**If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
|
|
586
|
+
|
|
587
|
+
**If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
|
|
588
|
+
|
|
589
|
+
5.6. **Post-merge test gate (parallel mode only):**
|
|
590
|
+
|
|
591
|
+
After merging all worktrees in a wave, run the project's test suite to catch
|
|
592
|
+
cross-plan integration issues that individual worktree self-checks cannot detect
|
|
593
|
+
(e.g., conflicting type definitions, removed exports, import changes).
|
|
594
|
+
|
|
595
|
+
This addresses the Generator self-evaluation blind spot identified in Anthropic's
|
|
596
|
+
harness engineering research: agents reliably report Self-Check: PASSED even when
|
|
597
|
+
merging their work creates failures.
|
|
598
|
+
|
|
599
|
+
```bash
|
|
600
|
+
# Detect test runner and run quick smoke test (timeout: 5 minutes)
|
|
601
|
+
TEST_EXIT=0
|
|
602
|
+
timeout 300 bash -c '
|
|
603
|
+
if [ -f "package.json" ]; then
|
|
604
|
+
npm test 2>&1
|
|
605
|
+
elif [ -f "Cargo.toml" ]; then
|
|
606
|
+
cargo test 2>&1
|
|
607
|
+
elif [ -f "go.mod" ]; then
|
|
608
|
+
go test ./... 2>&1
|
|
609
|
+
elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
|
|
610
|
+
python -m pytest -x -q --tb=short 2>&1 || uv run python -m pytest -x -q --tb=short 2>&1
|
|
611
|
+
else
|
|
612
|
+
echo "⚠ No test runner detected — skipping post-merge test gate"
|
|
613
|
+
exit 0
|
|
614
|
+
fi
|
|
615
|
+
'
|
|
616
|
+
TEST_EXIT=$?
|
|
617
|
+
if [ "${TEST_EXIT}" -eq 0 ]; then
|
|
618
|
+
echo "✓ Post-merge test gate passed — no cross-plan conflicts"
|
|
619
|
+
elif [ "${TEST_EXIT}" -eq 124 ]; then
|
|
620
|
+
echo "⚠ Post-merge test gate timed out after 5 minutes"
|
|
621
|
+
else
|
|
622
|
+
echo "✗ Post-merge test gate failed (exit code ${TEST_EXIT})"
|
|
623
|
+
WAVE_FAILURE_COUNT=$((WAVE_FAILURE_COUNT + 1))
|
|
624
|
+
fi
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
**If `TEST_EXIT` is 0 (pass):** `✓ Post-merge test gate: {N} tests passed — no cross-plan conflicts` → continue to orchestrator tracking update.
|
|
628
|
+
|
|
629
|
+
**If `TEST_EXIT` is 124 (timeout):** Log warning, treat as non-blocking, continue. Tests may need a longer budget or manual run.
|
|
630
|
+
|
|
631
|
+
**If `TEST_EXIT` is non-zero (test failure):** Increment `WAVE_FAILURE_COUNT` to track
|
|
632
|
+
cumulative failures across waves. Subsequent waves should report:
|
|
633
|
+
`⚠ Note: ${WAVE_FAILURE_COUNT} prior wave(s) had test failures`
|
|
634
|
+
|
|
635
|
+
5.7. **Post-wave shared artifact update (worktree mode only, skip if tests failed):**
|
|
636
|
+
|
|
637
|
+
When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once.
|
|
638
|
+
|
|
639
|
+
**Only update tracking when tests passed (TEST_EXIT=0).**
|
|
640
|
+
If tests failed or timed out, skip the tracking update — plans should
|
|
641
|
+
not be marked as complete when integration tests are failing or inconclusive.
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
# Guard: only update tracking if post-merge tests passed
|
|
645
|
+
# Timeout (124) is treated as inconclusive — do NOT mark plans complete
|
|
646
|
+
if [ "${TEST_EXIT}" -eq 0 ]; then
|
|
647
|
+
# Update ROADMAP plan progress for each completed plan in this wave
|
|
648
|
+
for plan_id in {completed_plan_ids}; do
|
|
649
|
+
node "$HOME/.claude/sdd/bin/sdd-tools.cjs" roadmap update-plan-progress "${PHASE_NUMBER}" "${plan_id}" "complete"
|
|
650
|
+
done
|
|
651
|
+
|
|
652
|
+
# Only commit tracking files if they actually changed
|
|
653
|
+
if ! git diff --quiet .planning/ROADMAP.md .planning/STATE.md 2>/dev/null; then
|
|
654
|
+
node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-${PHASE_NUMBER}): update tracking after wave ${N}" --files .planning/ROADMAP.md .planning/STATE.md
|
|
655
|
+
fi
|
|
656
|
+
elif [ "${TEST_EXIT}" -eq 124 ]; then
|
|
657
|
+
echo "⚠ Skipping tracking update — test suite timed out. Plans remain in-progress. Run tests manually to confirm."
|
|
658
|
+
else
|
|
659
|
+
echo "⚠ Skipping tracking update — post-merge tests failed (exit ${TEST_EXIT}). Plans remain in-progress until tests pass."
|
|
660
|
+
fi
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
|
|
664
|
+
|
|
665
|
+
**If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
|
|
666
|
+
|
|
667
|
+
5.8. **Handle test gate failures (when `WAVE_FAILURE_COUNT > 0`):**
|
|
668
|
+
|
|
669
|
+
```
|
|
670
|
+
## ⚠ Post-Merge Test Failure (cumulative failures: ${WAVE_FAILURE_COUNT})
|
|
671
|
+
|
|
672
|
+
Wave {N} worktrees merged successfully, but {M} tests fail after merge.
|
|
673
|
+
This typically indicates conflicting changes across parallel plans
|
|
674
|
+
(e.g., type definitions, shared imports, API contracts).
|
|
675
|
+
|
|
676
|
+
Failed tests:
|
|
677
|
+
{first 10 lines of failure output}
|
|
678
|
+
|
|
679
|
+
Options:
|
|
680
|
+
1. Fix now (recommended) — resolve conflicts before next wave
|
|
681
|
+
2. Continue — failures may compound in subsequent waves
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
Note: If `WAVE_FAILURE_COUNT > 1`, strongly recommend "Fix now" — compounding
|
|
685
|
+
failures across multiple waves become exponentially harder to diagnose.
|
|
686
|
+
|
|
687
|
+
If "Fix now": diagnose failures (typically import conflicts, missing types,
|
|
688
|
+
or changed function signatures from parallel plans modifying the same module).
|
|
689
|
+
Fix, commit as `fix: resolve post-merge conflicts from wave {N}`, re-run tests.
|
|
690
|
+
|
|
691
|
+
**Why this matters:** Worktree isolation means each agent's Self-Check passes
|
|
692
|
+
in isolation. But when merged, add/add conflicts in shared files (models, registries,
|
|
693
|
+
CLI entry points) can silently drop code. The post-merge gate catches this before
|
|
694
|
+
the next wave builds on a broken foundation.
|
|
695
|
+
|
|
696
|
+
6. **Report completion — spot-check claims first:**
|
|
317
697
|
|
|
318
698
|
For each SUMMARY.md:
|
|
319
699
|
- Verify first 2 files from `key-files.created` exist on disk
|
|
@@ -338,13 +718,13 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
338
718
|
- Bad: "Wave 2 complete. Proceeding to Wave 3."
|
|
339
719
|
- Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
|
|
340
720
|
|
|
341
|
-
|
|
721
|
+
7. **Handle failures:**
|
|
342
722
|
|
|
343
|
-
**Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a SDD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step
|
|
723
|
+
**Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a SDD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
|
|
344
724
|
|
|
345
725
|
For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
|
|
346
726
|
|
|
347
|
-
|
|
727
|
+
7b. **Pre-wave dependency check (waves 2+ only):**
|
|
348
728
|
|
|
349
729
|
Before spawning wave N+1, for each plan in the upcoming wave:
|
|
350
730
|
```bash
|
|
@@ -365,9 +745,9 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
|
|
|
365
745
|
|
|
366
746
|
Key-links referencing files in the CURRENT (upcoming) wave are skipped.
|
|
367
747
|
|
|
368
|
-
|
|
748
|
+
8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
|
|
369
749
|
|
|
370
|
-
|
|
750
|
+
9. **Proceed to next wave.**
|
|
371
751
|
</step>
|
|
372
752
|
|
|
373
753
|
<step name="checkpoint_handling">
|
|
@@ -436,6 +816,27 @@ After all waves:
|
|
|
436
816
|
### Issues Encountered
|
|
437
817
|
[Aggregate from SUMMARYs, or "None"]
|
|
438
818
|
```
|
|
819
|
+
|
|
820
|
+
**Security gate check:**
|
|
821
|
+
```bash
|
|
822
|
+
SECURITY_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
|
|
823
|
+
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
If `SECURITY_CFG` is `false`: skip.
|
|
827
|
+
|
|
828
|
+
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
|
|
829
|
+
Include in the next-steps routing output:
|
|
830
|
+
```
|
|
831
|
+
⚠ Security enforcement enabled — run before advancing:
|
|
832
|
+
/sdd-secure-phase {PHASE} ${SDD_WS}
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
|
|
836
|
+
```
|
|
837
|
+
⚠ Security gate: {threats_open} threats open
|
|
838
|
+
/sdd-secure-phase {PHASE} — resolve before advancing
|
|
839
|
+
```
|
|
439
840
|
</step>
|
|
440
841
|
|
|
441
842
|
<step name="handle_partial_wave_execution">
|
|
@@ -460,8 +861,8 @@ Apply the same "incomplete" filtering rules as earlier:
|
|
|
460
861
|
|
|
461
862
|
Selected wave finished successfully. This phase still has incomplete plans, so phase-level verification and completion were intentionally skipped.
|
|
462
863
|
|
|
463
|
-
/sdd
|
|
464
|
-
/sdd
|
|
864
|
+
/sdd-execute-phase {phase} ${SDD_WS} # Continue remaining waves
|
|
865
|
+
/sdd-execute-phase {phase} --wave {next} ${SDD_WS} # Run the next wave explicitly
|
|
465
866
|
```
|
|
466
867
|
|
|
467
868
|
**If no incomplete plans remain after the selected wave finishes:**
|
|
@@ -469,6 +870,39 @@ Selected wave finished successfully. This phase still has incomplete plans, so p
|
|
|
469
870
|
- this means the selected wave happened to be the last remaining work in the phase
|
|
470
871
|
</step>
|
|
471
872
|
|
|
873
|
+
<step name="code_review_gate" required="true">
|
|
874
|
+
**This step is REQUIRED and must not be skipped.** Auto-invoke code review on the phase's source changes. Advisory only — never blocks execution flow.
|
|
875
|
+
|
|
876
|
+
**Config gate:**
|
|
877
|
+
```bash
|
|
878
|
+
CODE_REVIEW_ENABLED=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.code_review 2>/dev/null || echo "true")
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
|
|
882
|
+
|
|
883
|
+
**Invoke review:**
|
|
884
|
+
```
|
|
885
|
+
Skill(skill="sdd:code-review", args="${PHASE_NUMBER}")
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
**Check results using deterministic path (not glob):**
|
|
889
|
+
```bash
|
|
890
|
+
PADDED=$(printf "%02d" "${PHASE_NUMBER}")
|
|
891
|
+
REVIEW_FILE="${PHASE_DIR}/${PADDED}-REVIEW.md"
|
|
892
|
+
REVIEW_STATUS=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^status:" | head -1 | cut -d: -f2 | tr -d ' ')
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
If REVIEW_STATUS is not "clean" and not "skipped" and not empty, display:
|
|
896
|
+
```
|
|
897
|
+
Code review found issues. Consider running:
|
|
898
|
+
/sdd-code-review-fix ${PHASE_NUMBER}
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
**Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to next step. Review failures must never block execution.
|
|
902
|
+
|
|
903
|
+
Regardless of review result, ALWAYS proceed to close_parent_artifacts → regression_gate → verify_phase_goal.
|
|
904
|
+
</step>
|
|
905
|
+
|
|
472
906
|
<step name="close_parent_artifacts">
|
|
473
907
|
**For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
|
|
474
908
|
|
|
@@ -544,10 +978,11 @@ Collect all unique test file paths into `REGRESSION_FILES`.
|
|
|
544
978
|
```bash
|
|
545
979
|
# Detect test runner and run prior phase tests
|
|
546
980
|
if [ -f "package.json" ]; then
|
|
547
|
-
|
|
548
|
-
npx jest ${REGRESSION_FILES} --passWithNoTests --no-coverage -q 2>&1 || npx vitest run ${REGRESSION_FILES} 2>&1
|
|
981
|
+
npm test 2>&1
|
|
549
982
|
elif [ -f "Cargo.toml" ]; then
|
|
550
983
|
cargo test 2>&1
|
|
984
|
+
elif [ -f "go.mod" ]; then
|
|
985
|
+
go test ./... 2>&1
|
|
551
986
|
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
|
|
552
987
|
python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
|
|
553
988
|
fi
|
|
@@ -580,6 +1015,72 @@ Options:
|
|
|
580
1015
|
Use AskUserQuestion to present the options.
|
|
581
1016
|
</step>
|
|
582
1017
|
|
|
1018
|
+
<step name="schema_drift_gate">
|
|
1019
|
+
Post-execution schema drift detection. Catches false-positive verification where
|
|
1020
|
+
build/types pass because TypeScript types come from config, not the live database.
|
|
1021
|
+
|
|
1022
|
+
**Run after execution completes but BEFORE verification marks success.**
|
|
1023
|
+
|
|
1024
|
+
```bash
|
|
1025
|
+
SCHEMA_DRIFT=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
|
|
1026
|
+
```
|
|
1027
|
+
|
|
1028
|
+
Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
|
|
1029
|
+
|
|
1030
|
+
**If `drift_detected` is false:** Skip to verify_phase_goal.
|
|
1031
|
+
|
|
1032
|
+
**If `drift_detected` is true AND `blocking` is true:**
|
|
1033
|
+
|
|
1034
|
+
Check for override:
|
|
1035
|
+
```bash
|
|
1036
|
+
SKIP_SCHEMA=$(echo "${SDD_SKIP_SCHEMA_CHECK:-false}")
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
**If `SKIP_SCHEMA` is `true`:**
|
|
1040
|
+
|
|
1041
|
+
Display:
|
|
1042
|
+
```
|
|
1043
|
+
⚠ Schema drift detected but SDD_SKIP_SCHEMA_CHECK=true — bypassing gate.
|
|
1044
|
+
|
|
1045
|
+
Schema files changed: {schema_files}
|
|
1046
|
+
ORMs requiring push: {unpushed_orms}
|
|
1047
|
+
|
|
1048
|
+
Proceeding to verification (database may be out of sync).
|
|
1049
|
+
```
|
|
1050
|
+
→ Continue to verify_phase_goal.
|
|
1051
|
+
|
|
1052
|
+
**If `SKIP_SCHEMA` is not `true`:**
|
|
1053
|
+
|
|
1054
|
+
BLOCK verification. Display:
|
|
1055
|
+
|
|
1056
|
+
```
|
|
1057
|
+
## BLOCKED: Schema Drift Detected
|
|
1058
|
+
|
|
1059
|
+
Schema-relevant files changed during this phase but no database push command
|
|
1060
|
+
was executed. Build and type checks pass because TypeScript types come from
|
|
1061
|
+
config, not the live database — verification would produce a false positive.
|
|
1062
|
+
|
|
1063
|
+
Schema files changed: {schema_files}
|
|
1064
|
+
ORMs requiring push: {unpushed_orms}
|
|
1065
|
+
|
|
1066
|
+
Required push commands:
|
|
1067
|
+
{For each unpushed ORM, show the push command from the message}
|
|
1068
|
+
|
|
1069
|
+
Options:
|
|
1070
|
+
1. Run push command now (recommended) — execute the push, then re-verify
|
|
1071
|
+
2. Skip schema check (SDD_SKIP_SCHEMA_CHECK=true) — bypass this gate
|
|
1072
|
+
3. Abort — stop execution and investigate
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
|
|
1076
|
+
|
|
1077
|
+
**If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
|
|
1078
|
+
|
|
1079
|
+
**If user selects option 2:** Set override and continue to verify_phase_goal.
|
|
1080
|
+
|
|
1081
|
+
**If user selects option 3:** Stop execution. Report partial completion.
|
|
1082
|
+
</step>
|
|
1083
|
+
|
|
583
1084
|
<step name="verify_phase_goal">
|
|
584
1085
|
Verify phase achieved its GOAL, not just completed tasks.
|
|
585
1086
|
|
|
@@ -589,6 +1090,7 @@ VERIFIER_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-ve
|
|
|
589
1090
|
|
|
590
1091
|
```
|
|
591
1092
|
Task(
|
|
1093
|
+
description="Verify phase {phase_number} goal achievement",
|
|
592
1094
|
prompt="Verify phase {phase_number} goal achievement.
|
|
593
1095
|
Phase directory: {phase_dir}
|
|
594
1096
|
Phase goal: {goal from ROADMAP.md}
|
|
@@ -596,6 +1098,18 @@ Phase requirement IDs: {phase_req_ids}
|
|
|
596
1098
|
Check must_haves against actual codebase.
|
|
597
1099
|
Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
|
|
598
1100
|
Create VERIFICATION.md.
|
|
1101
|
+
|
|
1102
|
+
<files_to_read>
|
|
1103
|
+
Read these files before verification:
|
|
1104
|
+
- {phase_dir}/*-PLAN.md (All plans — understand intent, check must_haves)
|
|
1105
|
+
- {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
|
|
1106
|
+
- .planning/REQUIREMENTS.md (Requirement traceability)
|
|
1107
|
+
${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
|
|
1108
|
+
- {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
|
|
1109
|
+
- Prior VERIFICATION.md files from earlier phases (regression check)
|
|
1110
|
+
` : ''}
|
|
1111
|
+
</files_to_read>
|
|
1112
|
+
|
|
599
1113
|
${VERIFIER_SKILLS}",
|
|
600
1114
|
subagent_type="sdd-verifier",
|
|
601
1115
|
model="{verifier_model}"
|
|
@@ -611,7 +1125,7 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
|
|
|
611
1125
|
|--------|--------|
|
|
612
1126
|
| `passed` | → update_roadmap |
|
|
613
1127
|
| `human_needed` | Present items for human testing, get approval or feedback |
|
|
614
|
-
| `gaps_found` | Present gap summary, offer `/sdd
|
|
1128
|
+
| `gaps_found` | Present gap summary, offer `/sdd-plan-phase {phase} --gaps ${SDD_WS}` |
|
|
615
1129
|
|
|
616
1130
|
**If human_needed:**
|
|
617
1131
|
|
|
@@ -666,12 +1180,12 @@ All automated checks passed. {N} items need human testing:
|
|
|
666
1180
|
|
|
667
1181
|
{From VERIFICATION.md human_verification section}
|
|
668
1182
|
|
|
669
|
-
Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd
|
|
1183
|
+
Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd-progress` and `/sdd-audit-uat`.
|
|
670
1184
|
|
|
671
1185
|
"approved" → continue | Report issues → gap closure
|
|
672
1186
|
```
|
|
673
1187
|
|
|
674
|
-
**If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/sdd
|
|
1188
|
+
**If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/sdd-verify-work` on it.
|
|
675
1189
|
|
|
676
1190
|
**If user reports issues:** Proceed to gap closure as currently implemented.
|
|
677
1191
|
|
|
@@ -688,15 +1202,15 @@ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd:progress
|
|
|
688
1202
|
---
|
|
689
1203
|
## ▶ Next Up
|
|
690
1204
|
|
|
691
|
-
`/
|
|
1205
|
+
`/clear` then:
|
|
692
1206
|
|
|
693
|
-
|
|
1207
|
+
`/sdd-plan-phase {X} --gaps ${SDD_WS}`
|
|
694
1208
|
|
|
695
1209
|
Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
|
|
696
|
-
Also: `/sdd
|
|
1210
|
+
Also: `/sdd-verify-work {X} ${SDD_WS}` — manual testing first
|
|
697
1211
|
```
|
|
698
1212
|
|
|
699
|
-
Gap closure cycle: `/sdd
|
|
1213
|
+
Gap closure cycle: `/sdd-plan-phase {X} --gaps ${SDD_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/sdd-execute-phase {X} --gaps-only ${SDD_WS}` → verifier re-runs.
|
|
700
1214
|
</step>
|
|
701
1215
|
|
|
702
1216
|
<step name="update_roadmap">
|
|
@@ -722,7 +1236,7 @@ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `warnings
|
|
|
722
1236
|
|
|
723
1237
|
{list each warning}
|
|
724
1238
|
|
|
725
|
-
These items are tracked and will appear in `/sdd
|
|
1239
|
+
These items are tracked and will appear in `/sdd-progress` and `/sdd-audit-uat`.
|
|
726
1240
|
```
|
|
727
1241
|
|
|
728
1242
|
```bash
|
|
@@ -730,6 +1244,29 @@ node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): complete pha
|
|
|
730
1244
|
```
|
|
731
1245
|
</step>
|
|
732
1246
|
|
|
1247
|
+
<step name="auto_copy_learnings">
|
|
1248
|
+
**Auto-copy phase learnings to global store (when enabled).**
|
|
1249
|
+
|
|
1250
|
+
This step runs AFTER phase completion and SUMMARY.md is written. It copies any LEARNINGS.md
|
|
1251
|
+
entries from the completed phase to the global learnings store at `~/.sdd/knowledge/`.
|
|
1252
|
+
|
|
1253
|
+
**Check config gate:**
|
|
1254
|
+
```bash
|
|
1255
|
+
GL_ENABLED=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get features.global_learnings --raw 2>/dev/null || echo "false")
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
**If `GL_ENABLED` is not `true`:** Skip this step entirely (feature disabled by default).
|
|
1259
|
+
|
|
1260
|
+
**If enabled:**
|
|
1261
|
+
|
|
1262
|
+
1. Check if LEARNINGS.md exists in the phase directory (use the `phase_dir` value from init context)
|
|
1263
|
+
2. If found, copy to global store:
|
|
1264
|
+
```bash
|
|
1265
|
+
node "$HOME/.claude/sdd/bin/sdd-tools.cjs" learnings copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
|
|
1266
|
+
```
|
|
1267
|
+
Copy failure must NOT block phase completion.
|
|
1268
|
+
</step>
|
|
1269
|
+
|
|
733
1270
|
<step name="update_project_md">
|
|
734
1271
|
**Evolve PROJECT.md to reflect phase completion (prevents planning document drift — #956):**
|
|
735
1272
|
|
|
@@ -754,7 +1291,7 @@ node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): evolve PROJE
|
|
|
754
1291
|
|
|
755
1292
|
<step name="offer_next">
|
|
756
1293
|
|
|
757
|
-
**Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/sdd
|
|
1294
|
+
**Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/sdd-plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
|
|
758
1295
|
|
|
759
1296
|
**No-transition check (spawned by auto-advance chain):**
|
|
760
1297
|
|
|
@@ -805,15 +1342,34 @@ Read and follow `~/.claude/sdd/workflows/transition.md`, passing through the `--
|
|
|
805
1342
|
|
|
806
1343
|
**STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
|
|
807
1344
|
|
|
808
|
-
**IMPORTANT: There is NO `/sdd
|
|
1345
|
+
**IMPORTANT: There is NO `/sdd-transition` command. Never suggest it. The transition workflow is internal only.**
|
|
1346
|
+
|
|
1347
|
+
Check whether CONTEXT.md already exists for the next phase:
|
|
1348
|
+
|
|
1349
|
+
```bash
|
|
1350
|
+
ls .planning/phases/*{next}*/{next}-CONTEXT.md 2>/dev/null || echo "no-context"
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
If CONTEXT.md does **not** exist for the next phase, present:
|
|
1354
|
+
|
|
1355
|
+
```
|
|
1356
|
+
## ✓ Phase {X}: {Name} Complete
|
|
1357
|
+
|
|
1358
|
+
/sdd-progress ${SDD_WS} — see updated roadmap
|
|
1359
|
+
/sdd-discuss-phase {next} ${SDD_WS} — start here: discuss next phase before planning ← recommended
|
|
1360
|
+
/sdd-plan-phase {next} ${SDD_WS} — plan next phase (skip discuss)
|
|
1361
|
+
/sdd-execute-phase {next} ${SDD_WS} — execute next phase (skip discuss and plan)
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
If CONTEXT.md **exists** for the next phase, present:
|
|
809
1365
|
|
|
810
1366
|
```
|
|
811
1367
|
## ✓ Phase {X}: {Name} Complete
|
|
812
1368
|
|
|
813
|
-
/sdd
|
|
814
|
-
/sdd
|
|
815
|
-
/sdd
|
|
816
|
-
/sdd
|
|
1369
|
+
/sdd-progress ${SDD_WS} — see updated roadmap
|
|
1370
|
+
/sdd-plan-phase {next} ${SDD_WS} — start here: plan next phase (CONTEXT.md already present) ← recommended
|
|
1371
|
+
/sdd-discuss-phase {next} ${SDD_WS} — re-discuss next phase
|
|
1372
|
+
/sdd-execute-phase {next} ${SDD_WS} — execute next phase (skip planning)
|
|
817
1373
|
```
|
|
818
1374
|
|
|
819
1375
|
Only suggest the commands listed above. Do not invent or hallucinate command names.
|
|
@@ -840,7 +1396,7 @@ For 1M+ context models, consider:
|
|
|
840
1396
|
</failure_handling>
|
|
841
1397
|
|
|
842
1398
|
<resumption>
|
|
843
|
-
Re-run `/sdd
|
|
1399
|
+
Re-run `/sdd-execute-phase {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
|
|
844
1400
|
|
|
845
1401
|
STATE.md tracks: last completed plan, current wave, pending checkpoints.
|
|
846
1402
|
</resumption>
|