cap-pro 1.0.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.
Files changed (275) hide show
  1. package/.claude-plugin/README.md +26 -0
  2. package/.claude-plugin/marketplace.json +24 -0
  3. package/.claude-plugin/plugin.json +24 -0
  4. package/LICENSE +21 -0
  5. package/README.ja-JP.md +834 -0
  6. package/README.ko-KR.md +823 -0
  7. package/README.md +806 -0
  8. package/README.pt-BR.md +452 -0
  9. package/README.zh-CN.md +800 -0
  10. package/agents/cap-architect.md +269 -0
  11. package/agents/cap-brainstormer.md +207 -0
  12. package/agents/cap-curator.md +276 -0
  13. package/agents/cap-debugger.md +365 -0
  14. package/agents/cap-designer.md +246 -0
  15. package/agents/cap-historian.md +464 -0
  16. package/agents/cap-migrator.md +291 -0
  17. package/agents/cap-prototyper.md +197 -0
  18. package/agents/cap-validator.md +308 -0
  19. package/bin/install.js +5433 -0
  20. package/cap/bin/cap-tools.cjs +853 -0
  21. package/cap/bin/lib/arc-scanner.cjs +344 -0
  22. package/cap/bin/lib/cap-affinity-engine.cjs +862 -0
  23. package/cap/bin/lib/cap-anchor.cjs +228 -0
  24. package/cap/bin/lib/cap-annotation-writer.cjs +340 -0
  25. package/cap/bin/lib/cap-checkpoint.cjs +434 -0
  26. package/cap/bin/lib/cap-cluster-detect.cjs +945 -0
  27. package/cap/bin/lib/cap-cluster-display.cjs +52 -0
  28. package/cap/bin/lib/cap-cluster-format.cjs +245 -0
  29. package/cap/bin/lib/cap-cluster-helpers.cjs +295 -0
  30. package/cap/bin/lib/cap-cluster-io.cjs +212 -0
  31. package/cap/bin/lib/cap-completeness.cjs +540 -0
  32. package/cap/bin/lib/cap-deps.cjs +583 -0
  33. package/cap/bin/lib/cap-design-families.cjs +332 -0
  34. package/cap/bin/lib/cap-design.cjs +966 -0
  35. package/cap/bin/lib/cap-divergence-detector.cjs +400 -0
  36. package/cap/bin/lib/cap-doctor.cjs +752 -0
  37. package/cap/bin/lib/cap-feature-map-internals.cjs +19 -0
  38. package/cap/bin/lib/cap-feature-map-migrate.cjs +335 -0
  39. package/cap/bin/lib/cap-feature-map-monorepo.cjs +885 -0
  40. package/cap/bin/lib/cap-feature-map-shard.cjs +315 -0
  41. package/cap/bin/lib/cap-feature-map.cjs +1943 -0
  42. package/cap/bin/lib/cap-fitness-score.cjs +1075 -0
  43. package/cap/bin/lib/cap-impact-analysis.cjs +652 -0
  44. package/cap/bin/lib/cap-learn-review.cjs +1072 -0
  45. package/cap/bin/lib/cap-learning-signals.cjs +627 -0
  46. package/cap/bin/lib/cap-loader.cjs +227 -0
  47. package/cap/bin/lib/cap-logger.cjs +57 -0
  48. package/cap/bin/lib/cap-memory-bridge.cjs +764 -0
  49. package/cap/bin/lib/cap-memory-confidence.cjs +452 -0
  50. package/cap/bin/lib/cap-memory-dir.cjs +987 -0
  51. package/cap/bin/lib/cap-memory-engine.cjs +698 -0
  52. package/cap/bin/lib/cap-memory-extends.cjs +398 -0
  53. package/cap/bin/lib/cap-memory-graph.cjs +790 -0
  54. package/cap/bin/lib/cap-memory-migrate.cjs +2015 -0
  55. package/cap/bin/lib/cap-memory-pin.cjs +183 -0
  56. package/cap/bin/lib/cap-memory-platform.cjs +490 -0
  57. package/cap/bin/lib/cap-memory-prune.cjs +707 -0
  58. package/cap/bin/lib/cap-memory-schema.cjs +812 -0
  59. package/cap/bin/lib/cap-migrate-tags.cjs +309 -0
  60. package/cap/bin/lib/cap-migrate.cjs +540 -0
  61. package/cap/bin/lib/cap-pattern-apply.cjs +1203 -0
  62. package/cap/bin/lib/cap-pattern-pipeline.cjs +1034 -0
  63. package/cap/bin/lib/cap-plugin-manifest.cjs +80 -0
  64. package/cap/bin/lib/cap-realtime-affinity.cjs +399 -0
  65. package/cap/bin/lib/cap-reconcile.cjs +570 -0
  66. package/cap/bin/lib/cap-research-gate.cjs +218 -0
  67. package/cap/bin/lib/cap-scope-filter.cjs +402 -0
  68. package/cap/bin/lib/cap-semantic-pipeline.cjs +1038 -0
  69. package/cap/bin/lib/cap-session-extract.cjs +987 -0
  70. package/cap/bin/lib/cap-session.cjs +445 -0
  71. package/cap/bin/lib/cap-snapshot-linkage.cjs +963 -0
  72. package/cap/bin/lib/cap-stack-docs.cjs +646 -0
  73. package/cap/bin/lib/cap-tag-observer.cjs +371 -0
  74. package/cap/bin/lib/cap-tag-scanner.cjs +1766 -0
  75. package/cap/bin/lib/cap-telemetry.cjs +466 -0
  76. package/cap/bin/lib/cap-test-audit.cjs +1438 -0
  77. package/cap/bin/lib/cap-thread-migrator.cjs +307 -0
  78. package/cap/bin/lib/cap-thread-synthesis.cjs +545 -0
  79. package/cap/bin/lib/cap-thread-tracker.cjs +519 -0
  80. package/cap/bin/lib/cap-trace.cjs +399 -0
  81. package/cap/bin/lib/cap-trust-mode.cjs +336 -0
  82. package/cap/bin/lib/cap-ui-design-editor.cjs +642 -0
  83. package/cap/bin/lib/cap-ui-mind-map.cjs +712 -0
  84. package/cap/bin/lib/cap-ui-thread-nav.cjs +693 -0
  85. package/cap/bin/lib/cap-ui.cjs +1245 -0
  86. package/cap/bin/lib/cap-upgrade.cjs +1028 -0
  87. package/cap/bin/lib/cli/arg-helpers.cjs +49 -0
  88. package/cap/bin/lib/cli/frontmatter-router.cjs +31 -0
  89. package/cap/bin/lib/cli/init-router.cjs +68 -0
  90. package/cap/bin/lib/cli/phase-router.cjs +102 -0
  91. package/cap/bin/lib/cli/state-router.cjs +61 -0
  92. package/cap/bin/lib/cli/template-router.cjs +37 -0
  93. package/cap/bin/lib/cli/uat-router.cjs +29 -0
  94. package/cap/bin/lib/cli/validation-router.cjs +26 -0
  95. package/cap/bin/lib/cli/verification-router.cjs +31 -0
  96. package/cap/bin/lib/cli/workstream-router.cjs +39 -0
  97. package/cap/bin/lib/commands.cjs +961 -0
  98. package/cap/bin/lib/config.cjs +467 -0
  99. package/cap/bin/lib/convention-reader.cjs +258 -0
  100. package/cap/bin/lib/core.cjs +1241 -0
  101. package/cap/bin/lib/feature-aggregator.cjs +423 -0
  102. package/cap/bin/lib/frontmatter.cjs +337 -0
  103. package/cap/bin/lib/init.cjs +1443 -0
  104. package/cap/bin/lib/manifest-generator.cjs +383 -0
  105. package/cap/bin/lib/milestone.cjs +253 -0
  106. package/cap/bin/lib/model-profiles.cjs +69 -0
  107. package/cap/bin/lib/monorepo-context.cjs +226 -0
  108. package/cap/bin/lib/monorepo-migrator.cjs +509 -0
  109. package/cap/bin/lib/phase.cjs +889 -0
  110. package/cap/bin/lib/profile-output.cjs +989 -0
  111. package/cap/bin/lib/profile-pipeline.cjs +540 -0
  112. package/cap/bin/lib/roadmap.cjs +330 -0
  113. package/cap/bin/lib/security.cjs +394 -0
  114. package/cap/bin/lib/session-manager.cjs +292 -0
  115. package/cap/bin/lib/skeleton-generator.cjs +179 -0
  116. package/cap/bin/lib/state.cjs +1032 -0
  117. package/cap/bin/lib/template.cjs +231 -0
  118. package/cap/bin/lib/test-detector.cjs +62 -0
  119. package/cap/bin/lib/uat.cjs +283 -0
  120. package/cap/bin/lib/verify.cjs +889 -0
  121. package/cap/bin/lib/workspace-detector.cjs +371 -0
  122. package/cap/bin/lib/workstream.cjs +492 -0
  123. package/cap/commands/gsd/workstreams.md +63 -0
  124. package/cap/references/arc-standard.md +315 -0
  125. package/cap/references/cap-agent-architecture.md +101 -0
  126. package/cap/references/cap-gitignore-template +9 -0
  127. package/cap/references/cap-zero-deps.md +158 -0
  128. package/cap/references/checkpoints.md +778 -0
  129. package/cap/references/continuation-format.md +249 -0
  130. package/cap/references/contract-test-templates.md +312 -0
  131. package/cap/references/feature-map-template.md +25 -0
  132. package/cap/references/git-integration.md +295 -0
  133. package/cap/references/git-planning-commit.md +38 -0
  134. package/cap/references/model-profiles.md +174 -0
  135. package/cap/references/phase-numbering.md +126 -0
  136. package/cap/references/planning-config.md +202 -0
  137. package/cap/references/property-test-templates.md +316 -0
  138. package/cap/references/security-test-templates.md +347 -0
  139. package/cap/references/session-template.json +8 -0
  140. package/cap/references/tdd.md +263 -0
  141. package/cap/references/user-profiling.md +681 -0
  142. package/cap/references/verification-patterns.md +612 -0
  143. package/cap/templates/UAT.md +265 -0
  144. package/cap/templates/claude-md.md +175 -0
  145. package/cap/templates/codebase/architecture.md +255 -0
  146. package/cap/templates/codebase/concerns.md +310 -0
  147. package/cap/templates/codebase/conventions.md +307 -0
  148. package/cap/templates/codebase/integrations.md +280 -0
  149. package/cap/templates/codebase/stack.md +186 -0
  150. package/cap/templates/codebase/structure.md +285 -0
  151. package/cap/templates/codebase/testing.md +480 -0
  152. package/cap/templates/config.json +44 -0
  153. package/cap/templates/context.md +352 -0
  154. package/cap/templates/continue-here.md +78 -0
  155. package/cap/templates/copilot-instructions.md +7 -0
  156. package/cap/templates/debug-subagent-prompt.md +91 -0
  157. package/cap/templates/discussion-log.md +63 -0
  158. package/cap/templates/milestone-archive.md +123 -0
  159. package/cap/templates/milestone.md +115 -0
  160. package/cap/templates/phase-prompt.md +610 -0
  161. package/cap/templates/planner-subagent-prompt.md +117 -0
  162. package/cap/templates/project.md +186 -0
  163. package/cap/templates/requirements.md +231 -0
  164. package/cap/templates/research-project/ARCHITECTURE.md +204 -0
  165. package/cap/templates/research-project/FEATURES.md +147 -0
  166. package/cap/templates/research-project/PITFALLS.md +200 -0
  167. package/cap/templates/research-project/STACK.md +120 -0
  168. package/cap/templates/research-project/SUMMARY.md +170 -0
  169. package/cap/templates/research.md +552 -0
  170. package/cap/templates/roadmap.md +202 -0
  171. package/cap/templates/state.md +176 -0
  172. package/cap/templates/summary.md +364 -0
  173. package/cap/templates/user-preferences.md +498 -0
  174. package/cap/templates/verification-report.md +322 -0
  175. package/cap/workflows/add-phase.md +112 -0
  176. package/cap/workflows/add-tests.md +351 -0
  177. package/cap/workflows/add-todo.md +158 -0
  178. package/cap/workflows/audit-milestone.md +340 -0
  179. package/cap/workflows/audit-uat.md +109 -0
  180. package/cap/workflows/autonomous.md +891 -0
  181. package/cap/workflows/check-todos.md +177 -0
  182. package/cap/workflows/cleanup.md +152 -0
  183. package/cap/workflows/complete-milestone.md +767 -0
  184. package/cap/workflows/diagnose-issues.md +231 -0
  185. package/cap/workflows/discovery-phase.md +289 -0
  186. package/cap/workflows/discuss-phase-assumptions.md +653 -0
  187. package/cap/workflows/discuss-phase.md +1049 -0
  188. package/cap/workflows/do.md +104 -0
  189. package/cap/workflows/execute-phase.md +846 -0
  190. package/cap/workflows/execute-plan.md +514 -0
  191. package/cap/workflows/fast.md +105 -0
  192. package/cap/workflows/forensics.md +265 -0
  193. package/cap/workflows/health.md +181 -0
  194. package/cap/workflows/help.md +660 -0
  195. package/cap/workflows/insert-phase.md +130 -0
  196. package/cap/workflows/list-phase-assumptions.md +178 -0
  197. package/cap/workflows/list-workspaces.md +56 -0
  198. package/cap/workflows/manager.md +362 -0
  199. package/cap/workflows/map-codebase.md +377 -0
  200. package/cap/workflows/milestone-summary.md +223 -0
  201. package/cap/workflows/new-milestone.md +486 -0
  202. package/cap/workflows/new-project.md +1250 -0
  203. package/cap/workflows/new-workspace.md +237 -0
  204. package/cap/workflows/next.md +97 -0
  205. package/cap/workflows/node-repair.md +92 -0
  206. package/cap/workflows/note.md +156 -0
  207. package/cap/workflows/pause-work.md +176 -0
  208. package/cap/workflows/plan-milestone-gaps.md +273 -0
  209. package/cap/workflows/plan-phase.md +857 -0
  210. package/cap/workflows/plant-seed.md +169 -0
  211. package/cap/workflows/pr-branch.md +129 -0
  212. package/cap/workflows/profile-user.md +449 -0
  213. package/cap/workflows/progress.md +507 -0
  214. package/cap/workflows/quick.md +757 -0
  215. package/cap/workflows/remove-phase.md +155 -0
  216. package/cap/workflows/remove-workspace.md +90 -0
  217. package/cap/workflows/research-phase.md +82 -0
  218. package/cap/workflows/resume-project.md +326 -0
  219. package/cap/workflows/review.md +228 -0
  220. package/cap/workflows/session-report.md +146 -0
  221. package/cap/workflows/settings.md +283 -0
  222. package/cap/workflows/ship.md +228 -0
  223. package/cap/workflows/stats.md +60 -0
  224. package/cap/workflows/transition.md +671 -0
  225. package/cap/workflows/ui-phase.md +298 -0
  226. package/cap/workflows/ui-review.md +161 -0
  227. package/cap/workflows/update.md +323 -0
  228. package/cap/workflows/validate-phase.md +170 -0
  229. package/cap/workflows/verify-phase.md +254 -0
  230. package/cap/workflows/verify-work.md +637 -0
  231. package/commands/cap/annotate.md +165 -0
  232. package/commands/cap/brainstorm.md +393 -0
  233. package/commands/cap/checkpoint.md +106 -0
  234. package/commands/cap/completeness.md +94 -0
  235. package/commands/cap/continue.md +72 -0
  236. package/commands/cap/debug.md +588 -0
  237. package/commands/cap/deps.md +169 -0
  238. package/commands/cap/design.md +479 -0
  239. package/commands/cap/init.md +354 -0
  240. package/commands/cap/iterate.md +249 -0
  241. package/commands/cap/learn.md +459 -0
  242. package/commands/cap/memory.md +275 -0
  243. package/commands/cap/migrate-feature-map.md +91 -0
  244. package/commands/cap/migrate-memory.md +108 -0
  245. package/commands/cap/migrate-tags.md +91 -0
  246. package/commands/cap/migrate.md +131 -0
  247. package/commands/cap/prototype.md +510 -0
  248. package/commands/cap/reconcile.md +121 -0
  249. package/commands/cap/review.md +360 -0
  250. package/commands/cap/save.md +72 -0
  251. package/commands/cap/scan.md +404 -0
  252. package/commands/cap/start.md +356 -0
  253. package/commands/cap/status.md +118 -0
  254. package/commands/cap/test-audit.md +262 -0
  255. package/commands/cap/test.md +394 -0
  256. package/commands/cap/trace.md +133 -0
  257. package/commands/cap/ui.md +167 -0
  258. package/hooks/dist/cap-check-update.js +115 -0
  259. package/hooks/dist/cap-context-monitor.js +185 -0
  260. package/hooks/dist/cap-learn-review-hook.js +114 -0
  261. package/hooks/dist/cap-learning-hook.js +192 -0
  262. package/hooks/dist/cap-memory.js +299 -0
  263. package/hooks/dist/cap-prompt-guard.js +97 -0
  264. package/hooks/dist/cap-statusline.js +157 -0
  265. package/hooks/dist/cap-tag-observer.js +115 -0
  266. package/hooks/dist/cap-version-check.js +112 -0
  267. package/hooks/dist/cap-workflow-guard.js +175 -0
  268. package/hooks/hooks.json +55 -0
  269. package/package.json +58 -0
  270. package/scripts/base64-scan.sh +262 -0
  271. package/scripts/build-hooks.js +93 -0
  272. package/scripts/cap-removal-checklist.md +202 -0
  273. package/scripts/prompt-injection-scan.sh +199 -0
  274. package/scripts/run-tests.cjs +181 -0
  275. package/scripts/secret-scan.sh +227 -0
@@ -0,0 +1,857 @@
1
+ <purpose>
2
+ Create executable phase prompts (PLAN.md files) for a roadmap phase with integrated research and verification. Default flow: Research (if needed) -> Plan -> Verify -> Done. Orchestrates gsd-phase-researcher, gsd-planner, and gsd-plan-checker agents with a revision loop (max 3 iterations).
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ Read all files referenced by the invoking prompt's execution_context before starting.
7
+ </required_reading>
8
+
9
+ <available_agent_types>
10
+ Valid GSD subagent types (use exact names — do not fall back to 'general-purpose'):
11
+ - gsd-phase-researcher — Researches technical approaches for a phase
12
+ - gsd-planner — Creates detailed plans from phase scope
13
+ - gsd-plan-checker — Reviews plan quality before execution
14
+ </available_agent_types>
15
+
16
+ <process>
17
+
18
+ ## 1. Initialize
19
+
20
+ Load all context in one call (paths only to minimize orchestrator context):
21
+
22
+ ```bash
23
+ INIT=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" init plan-phase "$PHASE")
24
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
25
+ AGENT_SKILLS_RESEARCHER=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" agent-skills gsd-researcher 2>/dev/null)
26
+ AGENT_SKILLS_PLANNER=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" agent-skills gsd-planner 2>/dev/null)
27
+ AGENT_SKILLS_CHECKER=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" agent-skills gsd-checker 2>/dev/null)
28
+ ```
29
+
30
+ Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_enabled`, `plan_checker_enabled`, `nyquist_validation_enabled`, `commit_docs`, `text_mode`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_reviews`, `has_plans`, `plan_count`, `planning_exists`, `roadmap_exists`, `phase_req_ids`.
31
+
32
+ **File paths (for <files_to_read> blocks):** `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`, `verification_path`, `uat_path`, `reviews_path`. These are null if files don't exist.
33
+
34
+ **If `planning_exists` is false:** Error — run `/gsd:new-project` first.
35
+
36
+ ## 2. Parse and Normalize Arguments
37
+
38
+ Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--prd <filepath>`, `--reviews`, `--text`).
39
+
40
+ Set `TEXT_MODE=true` if `--text` is present in $ARGUMENTS OR `text_mode` from init JSON is `true`. When `TEXT_MODE` is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number. This is required for Claude Code remote sessions (`/rc` mode) where TUI menus don't work through the Claude App.
41
+
42
+ Extract `--prd <filepath>` from $ARGUMENTS. If present, set PRD_FILE to the filepath.
43
+
44
+ **If no phase number:** Detect next unplanned phase from roadmap.
45
+
46
+ **If `phase_found` is false:** Validate phase exists in ROADMAP.md. If valid, create the directory using `phase_slug` and `padded_phase` from init:
47
+ ```bash
48
+ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
49
+ ```
50
+
51
+ **Existing artifacts from init:** `has_research`, `has_plans`, `plan_count`.
52
+
53
+ ## 2.5. Validate `--reviews` Prerequisite
54
+
55
+ **Skip if:** No `--reviews` flag.
56
+
57
+ **If `--reviews` AND `--gaps`:** Error — cannot combine `--reviews` with `--gaps`. These are conflicting modes.
58
+
59
+ **If `--reviews` AND `has_reviews` is false (no REVIEWS.md in phase dir):**
60
+
61
+ Error:
62
+ ```
63
+ No REVIEWS.md found for Phase {N}. Run reviews first:
64
+
65
+ /gsd:review --phase {N}
66
+
67
+ Then re-run /gsd:plan-phase {N} --reviews
68
+ ```
69
+ Exit workflow.
70
+
71
+ ## 3. Validate Phase
72
+
73
+ ```bash
74
+ PHASE_INFO=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" roadmap get-phase "${PHASE}")
75
+ ```
76
+
77
+ **If `found` is false:** Error with available phases. **If `found` is true:** Extract `phase_number`, `phase_name`, `goal` from JSON.
78
+
79
+ ## 3.5. Handle PRD Express Path
80
+
81
+ **Skip if:** No `--prd` flag in arguments.
82
+
83
+ **If `--prd <filepath>` provided:**
84
+
85
+ 1. Read the PRD file:
86
+ ```bash
87
+ PRD_CONTENT=$(cat "$PRD_FILE" 2>/dev/null)
88
+ if [ -z "$PRD_CONTENT" ]; then
89
+ echo "Error: PRD file not found: $PRD_FILE"
90
+ exit 1
91
+ fi
92
+ ```
93
+
94
+ 2. Display banner:
95
+ ```
96
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
97
+ GSD ► PRD EXPRESS PATH
98
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
99
+
100
+ Using PRD: {PRD_FILE}
101
+ Generating CONTEXT.md from requirements...
102
+ ```
103
+
104
+ 3. Parse the PRD content and generate CONTEXT.md. The orchestrator should:
105
+ - Extract all requirements, user stories, acceptance criteria, and constraints from the PRD
106
+ - Map each to a locked decision (everything in the PRD is treated as a locked decision)
107
+ - Identify any areas the PRD doesn't cover and mark as "Claude's Discretion"
108
+ - **Extract canonical refs** from ROADMAP.md for this phase, plus any specs/ADRs referenced in the PRD — expand to full file paths (MANDATORY)
109
+ - Create CONTEXT.md in the phase directory
110
+
111
+ 4. Write CONTEXT.md:
112
+ ```markdown
113
+ # Phase [X]: [Name] - Context
114
+
115
+ **Gathered:** [date]
116
+ **Status:** Ready for planning
117
+ **Source:** PRD Express Path ({PRD_FILE})
118
+
119
+ <domain>
120
+ ## Phase Boundary
121
+
122
+ [Extracted from PRD — what this phase delivers]
123
+
124
+ </domain>
125
+
126
+ <decisions>
127
+ ## Implementation Decisions
128
+
129
+ {For each requirement/story/criterion in the PRD:}
130
+ ### [Category derived from content]
131
+ - [Requirement as locked decision]
132
+
133
+ ### Claude's Discretion
134
+ [Areas not covered by PRD — implementation details, technical choices]
135
+
136
+ </decisions>
137
+
138
+ <canonical_refs>
139
+ ## Canonical References
140
+
141
+ **Downstream agents MUST read these before planning or implementing.**
142
+
143
+ [MANDATORY. Extract from ROADMAP.md and any docs referenced in the PRD.
144
+ Use full relative paths. Group by topic area.]
145
+
146
+ ### [Topic area]
147
+ - `path/to/spec-or-adr.md` — [What it decides/defines]
148
+
149
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
150
+
151
+ </canonical_refs>
152
+
153
+ <specifics>
154
+ ## Specific Ideas
155
+
156
+ [Any specific references, examples, or concrete requirements from PRD]
157
+
158
+ </specifics>
159
+
160
+ <deferred>
161
+ ## Deferred Ideas
162
+
163
+ [Items in PRD explicitly marked as future/v2/out-of-scope]
164
+ [If none: "None — PRD covers phase scope"]
165
+
166
+ </deferred>
167
+
168
+ ---
169
+
170
+ *Phase: XX-name*
171
+ *Context gathered: [date] via PRD Express Path*
172
+ ```
173
+
174
+ 5. Commit:
175
+ ```bash
176
+ node "$HOME/.claude/cap/bin/cap-tools.cjs" commit "docs(${padded_phase}): generate context from PRD" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
177
+ ```
178
+
179
+ 6. Set `context_content` to the generated CONTEXT.md content and continue to step 5 (Handle Research).
180
+
181
+ **Effect:** This completely bypasses step 4 (Load CONTEXT.md) since we just created it. The rest of the workflow (research, planning, verification) proceeds normally with the PRD-derived context.
182
+
183
+ ## 4. Load CONTEXT.md
184
+
185
+ **Skip if:** PRD express path was used (CONTEXT.md already created in step 3.5).
186
+
187
+ Check `context_path` from init JSON.
188
+
189
+ If `context_path` is not null, display: `Using phase context from: ${context_path}`
190
+
191
+ **If `context_path` is null (no CONTEXT.md exists):**
192
+
193
+ Read discuss mode for context gate label:
194
+ ```bash
195
+ DISCUSS_MODE=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" config-get workflow.discuss_mode 2>/dev/null || echo "discuss")
196
+ ```
197
+
198
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
199
+ ```
200
+ No CONTEXT.md found for Phase {X}. Plans will use research and requirements only — your design preferences won't be included.
201
+
202
+ 1. Continue without context — Plan using research + requirements only
203
+ [If DISCUSS_MODE is "assumptions":]
204
+ 2. Gather context (assumptions mode) — Analyze codebase and surface assumptions before planning
205
+ [If DISCUSS_MODE is "discuss" or unset:]
206
+ 2. Run discuss-phase first — Capture design decisions before planning
207
+
208
+ Enter number:
209
+ ```
210
+
211
+ Otherwise use AskUserQuestion:
212
+ - header: "No context"
213
+ - question: "No CONTEXT.md found for Phase {X}. Plans will use research and requirements only — your design preferences won't be included. Continue or capture context first?"
214
+ - options:
215
+ - "Continue without context" — Plan using research + requirements only
216
+ If `DISCUSS_MODE` is `"assumptions"`:
217
+ - "Gather context (assumptions mode)" — Analyze codebase and surface assumptions before planning
218
+ If `DISCUSS_MODE` is `"discuss"` (or unset):
219
+ - "Run discuss-phase first" — Capture design decisions before planning
220
+
221
+ If "Continue without context": Proceed to step 5.
222
+ If "Run discuss-phase first":
223
+ **IMPORTANT:** Do NOT invoke discuss-phase as a nested Skill/Task call — AskUserQuestion
224
+ does not work correctly in nested subcontexts (#1009). Instead, display the command
225
+ and exit so the user runs it as a top-level command:
226
+ ```
227
+ Run this command first, then re-run /gsd:plan-phase {X} ${GSD_WS}:
228
+
229
+ /gsd:discuss-phase {X} ${GSD_WS}
230
+ ```
231
+ **Exit the plan-phase workflow. Do not continue.**
232
+
233
+ ## 5. Handle Research
234
+
235
+ **Skip if:** `--gaps` flag or `--skip-research` flag or `--reviews` flag.
236
+
237
+ **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
238
+
239
+ **If RESEARCH.md missing OR `--research` flag:**
240
+
241
+ **If no explicit flag (`--research` or `--skip-research`) and not `--auto`:**
242
+ Ask the user whether to research, with a contextual recommendation based on the phase:
243
+
244
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
245
+ ```
246
+ Research before planning Phase {X}: {phase_name}?
247
+
248
+ 1. Research first (Recommended) — Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes.
249
+ 2. Skip research — Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks.
250
+
251
+ Enter number:
252
+ ```
253
+
254
+ Otherwise use AskUserQuestion:
255
+ ```
256
+ AskUserQuestion([
257
+ {
258
+ question: "Research before planning Phase {X}: {phase_name}?",
259
+ header: "Research",
260
+ multiSelect: false,
261
+ options: [
262
+ { label: "Research first (Recommended)", description: "Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes." },
263
+ { label: "Skip research", description: "Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks." }
264
+ ]
265
+ }
266
+ ])
267
+ ```
268
+
269
+ If user selects "Skip research": skip to step 6.
270
+
271
+ **If `--auto` and `research_enabled` is false:** Skip research silently (preserves automated behavior).
272
+
273
+ Display banner:
274
+ ```
275
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
276
+ GSD ► RESEARCHING PHASE {X}
277
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
278
+
279
+ ◆ Spawning researcher...
280
+ ```
281
+
282
+ ### Spawn gsd-phase-researcher
283
+
284
+ ```bash
285
+ PHASE_DESC=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" roadmap get-phase "${PHASE}" --pick section)
286
+ ```
287
+
288
+ Research prompt:
289
+
290
+ ```markdown
291
+ <objective>
292
+ Research how to implement Phase {phase_number}: {phase_name}
293
+ Answer: "What do I need to know to PLAN this phase well?"
294
+ </objective>
295
+
296
+ <files_to_read>
297
+ - {context_path} (USER DECISIONS from /gsd:discuss-phase)
298
+ - {requirements_path} (Project requirements)
299
+ - {state_path} (Project decisions and history)
300
+ </files_to_read>
301
+
302
+ ${AGENT_SKILLS_RESEARCHER}
303
+
304
+ <additional_context>
305
+ **Phase description:** {phase_description}
306
+ **Phase requirement IDs (MUST address):** {phase_req_ids}
307
+
308
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
309
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, research should account for project skill patterns
310
+ </additional_context>
311
+
312
+ <output>
313
+ Write to: {phase_dir}/{phase_num}-RESEARCH.md
314
+ </output>
315
+ ```
316
+
317
+ ```
318
+ Task(
319
+ prompt=research_prompt,
320
+ subagent_type="gsd-phase-researcher",
321
+ model="{researcher_model}",
322
+ description="Research Phase {phase}"
323
+ )
324
+ ```
325
+
326
+ ### Handle Researcher Return
327
+
328
+ - **`## RESEARCH COMPLETE`:** Display confirmation, continue to step 6
329
+ - **`## RESEARCH BLOCKED`:** Display blocker, offer: 1) Provide context, 2) Skip research, 3) Abort
330
+
331
+ ## 5.5. Create Validation Strategy
332
+
333
+ Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
334
+
335
+ If `research_enabled` is false and `nyquist_validation_enabled` is true: warn "Nyquist validation enabled but research disabled — VALIDATION.md cannot be created without RESEARCH.md. Plans will lack validation requirements (Dimension 8)." Continue to step 6.
336
+
337
+ **But Nyquist is not applicable for this run** when all of the following are true:
338
+ - `research_enabled` is false
339
+ - `has_research` is false
340
+ - no `--research` flag was provided
341
+
342
+ In that case: **skip validation-strategy creation entirely**. Do **not** expect `RESEARCH.md` or `VALIDATION.md` for this run, and continue to Step 6.
343
+
344
+ ```bash
345
+ grep -l "## Validation Architecture" "${PHASE_DIR}"/*-RESEARCH.md 2>/dev/null || true
346
+ ```
347
+
348
+ **If found:**
349
+ 1. Read template: `~/.claude/cap/templates/VALIDATION.md`
350
+ 2. Write to `${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md` (use Write tool)
351
+ 3. Fill frontmatter: `{N}` → phase number, `{phase-slug}` → slug, `{date}` → current date
352
+ 4. Verify:
353
+ ```bash
354
+ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED=true" || echo "VALIDATION_CREATED=false"
355
+ ```
356
+ 5. If `VALIDATION_CREATED=false`: STOP — do not proceed to Step 6
357
+ 6. If `commit_docs`: `commit "docs(phase-${PHASE}): add validation strategy"`
358
+
359
+ **If not found:** Warn and continue — plans may fail Dimension 8.
360
+
361
+ ## 5.6. UI Design Contract Gate
362
+
363
+ > Skip if `workflow.ui_phase` is explicitly `false` AND `workflow.ui_safety_gate` is explicitly `false` in `.planning/config.json`. If keys are absent, treat as enabled.
364
+
365
+ ```bash
366
+ UI_PHASE_CFG=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" config-get workflow.ui_phase 2>/dev/null || echo "true")
367
+ UI_GATE_CFG=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" config-get workflow.ui_safety_gate 2>/dev/null || echo "true")
368
+ ```
369
+
370
+ **If both are `false`:** Skip to step 6.
371
+
372
+ Check if phase has frontend indicators:
373
+
374
+ ```bash
375
+ PHASE_SECTION=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" roadmap get-phase "${PHASE}" 2>/dev/null)
376
+ echo "$PHASE_SECTION" | grep -iE "UI|interface|frontend|component|layout|page|screen|view|form|dashboard|widget" > /dev/null 2>&1
377
+ HAS_UI=$?
378
+ ```
379
+
380
+ **If `HAS_UI` is 0 (frontend indicators found):**
381
+
382
+ Check for existing UI-SPEC:
383
+ ```bash
384
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
385
+ ```
386
+
387
+ **If UI-SPEC.md found:** Set `UI_SPEC_PATH=$UI_SPEC_FILE`. Display: `Using UI design contract: ${UI_SPEC_PATH}`
388
+
389
+ **If UI-SPEC.md missing AND `UI_GATE_CFG` is `true`:**
390
+
391
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
392
+ ```
393
+ Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?
394
+
395
+ 1. Generate UI-SPEC first — Run /gsd:ui-phase {N} then re-run /gsd:plan-phase {N}
396
+ 2. Continue without UI-SPEC
397
+ 3. Not a frontend phase
398
+
399
+ Enter number:
400
+ ```
401
+
402
+ Otherwise use AskUserQuestion:
403
+ - header: "UI Design Contract"
404
+ - question: "Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?"
405
+ - options:
406
+ - "Generate UI-SPEC first" → Display: "Run `/gsd:ui-phase {N} ${GSD_WS}` then re-run `/gsd:plan-phase {N} ${GSD_WS}`". Exit workflow.
407
+ - "Continue without UI-SPEC" → Continue to step 6.
408
+ - "Not a frontend phase" → Continue to step 6.
409
+
410
+ **If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 6.
411
+
412
+ ## 6. Check Existing Plans
413
+
414
+ ```bash
415
+ ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null || true
416
+ ```
417
+
418
+ **If exists AND `--reviews` flag:** Skip prompt — go straight to replanning (the purpose of `--reviews` is to replan with review feedback).
419
+
420
+ **If exists AND no `--reviews` flag:** Offer: 1) Add more plans, 2) View existing, 3) Replan from scratch.
421
+
422
+ ## 7. Use Context Paths from INIT
423
+
424
+ Extract from INIT JSON:
425
+
426
+ ```bash
427
+ _gsd_field() { node -e "const o=JSON.parse(process.argv[1]); const v=o[process.argv[2]]; process.stdout.write(v==null?'':String(v))" "$1" "$2"; }
428
+ STATE_PATH=$(_gsd_field "$INIT" state_path)
429
+ ROADMAP_PATH=$(_gsd_field "$INIT" roadmap_path)
430
+ REQUIREMENTS_PATH=$(_gsd_field "$INIT" requirements_path)
431
+ RESEARCH_PATH=$(_gsd_field "$INIT" research_path)
432
+ VERIFICATION_PATH=$(_gsd_field "$INIT" verification_path)
433
+ UAT_PATH=$(_gsd_field "$INIT" uat_path)
434
+ CONTEXT_PATH=$(_gsd_field "$INIT" context_path)
435
+ REVIEWS_PATH=$(_gsd_field "$INIT" reviews_path)
436
+ ```
437
+
438
+ ## 7.5. Verify Nyquist Artifacts
439
+
440
+ Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
441
+
442
+ Also skip if all of the following are true:
443
+ - `research_enabled` is false
444
+ - `has_research` is false
445
+ - no `--research` flag was provided
446
+
447
+ In that no-research path, Nyquist artifacts are **not required** for this run.
448
+
449
+ ```bash
450
+ VALIDATION_EXISTS=$(ls "${PHASE_DIR}"/*-VALIDATION.md 2>/dev/null | head -1)
451
+ ```
452
+
453
+ If missing and Nyquist is still enabled/applicable — ask user:
454
+ 1. Re-run: `/gsd:plan-phase {PHASE} --research ${GSD_WS}`
455
+ 2. Disable Nyquist with the exact command:
456
+ `node "$HOME/.claude/cap/bin/cap-tools.cjs" config-set workflow.nyquist_validation false`
457
+ 3. Continue anyway (plans fail Dimension 8)
458
+
459
+ Proceed to Step 8 only if user selects 2 or 3.
460
+
461
+ ## 8. Spawn gsd-planner Agent
462
+
463
+ Display banner:
464
+ ```
465
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
466
+ GSD ► PLANNING PHASE {X}
467
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
468
+
469
+ ◆ Spawning planner...
470
+ ```
471
+
472
+ Planner prompt:
473
+
474
+ ```markdown
475
+ <planning_context>
476
+ **Phase:** {phase_number}
477
+ **Mode:** {standard | gap_closure | reviews}
478
+
479
+ <files_to_read>
480
+ - {state_path} (Project State)
481
+ - {roadmap_path} (Roadmap)
482
+ - {requirements_path} (Requirements)
483
+ - {context_path} (USER DECISIONS from /gsd:discuss-phase)
484
+ - {research_path} (Technical Research)
485
+ - {verification_path} (Verification Gaps - if --gaps)
486
+ - {uat_path} (UAT Gaps - if --gaps)
487
+ - {reviews_path} (Cross-AI Review Feedback - if --reviews)
488
+ - {UI_SPEC_PATH} (UI Design Contract — visual/interaction specs, if exists)
489
+ </files_to_read>
490
+
491
+ ${AGENT_SKILLS_PLANNER}
492
+
493
+ **Phase requirement IDs (every ID MUST appear in a plan's `requirements` field):** {phase_req_ids}
494
+
495
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
496
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, plans should account for project skill rules
497
+ </planning_context>
498
+
499
+ <downstream_consumer>
500
+ Output consumed by /gsd:execute-phase. Plans need:
501
+ - Frontmatter (wave, depends_on, files_modified, autonomous)
502
+ - Tasks in XML format with read_first and acceptance_criteria fields (MANDATORY on every task)
503
+ - Verification criteria
504
+ - must_haves for goal-backward verification
505
+ </downstream_consumer>
506
+
507
+ <deep_work_rules>
508
+ ## Anti-Shallow Execution Rules (MANDATORY)
509
+
510
+ Every task MUST include these fields — they are NOT optional:
511
+
512
+ 1. **`<read_first>`** — Files the executor MUST read before touching anything. Always include:
513
+ - The file being modified (so executor sees current state, not assumptions)
514
+ - Any "source of truth" file referenced in CONTEXT.md (reference implementations, existing patterns, config files, schemas)
515
+ - Any file whose patterns, signatures, types, or conventions must be replicated or respected
516
+
517
+ 2. **`<acceptance_criteria>`** — Verifiable conditions that prove the task was done correctly. Rules:
518
+ - Every criterion must be checkable with grep, file read, test command, or CLI output
519
+ - NEVER use subjective language ("looks correct", "properly configured", "consistent with")
520
+ - ALWAYS include exact strings, patterns, values, or command outputs that must be present
521
+ - Examples:
522
+ - Code: `auth.py contains def verify_token(` / `test_auth.py exits 0`
523
+ - Config: `.env.example contains DATABASE_URL=` / `Dockerfile contains HEALTHCHECK`
524
+ - Docs: `README.md contains '## Installation'` / `API.md lists all endpoints`
525
+ - Infra: `deploy.yml has rollback step` / `docker-compose.yml has healthcheck for db`
526
+
527
+ 3. **`<action>`** — Must include CONCRETE values, not references. Rules:
528
+ - NEVER say "align X with Y", "match X to Y", "update to be consistent" without specifying the exact target state
529
+ - ALWAYS include the actual values: config keys, function signatures, SQL statements, class names, import paths, env vars, etc.
530
+ - If CONTEXT.md has a comparison table or expected values, copy them into the action verbatim
531
+ - The executor should be able to complete the task from the action text alone, without needing to read CONTEXT.md or reference files (read_first is for verification, not discovery)
532
+
533
+ **Why this matters:** Executor agents work from the plan text. Vague instructions like "update the config to match production" produce shallow one-line changes. Concrete instructions like "add env vars: CACHE_TTL=300, LOG_LEVEL=debug, FEATURE_FLAG_X=true" or "modify config.json: set servers.db.pool_size=20, servers.cache.enabled=true" produce complete work. The cost of verbose plans is far less than the cost of re-doing shallow execution.
534
+ </deep_work_rules>
535
+
536
+ <quality_gate>
537
+ - [ ] PLAN.md files created in phase directory
538
+ - [ ] Each plan has valid frontmatter
539
+ - [ ] Tasks are specific and actionable
540
+ - [ ] Every task has `<read_first>` with at least the file being modified
541
+ - [ ] Every task has `<acceptance_criteria>` with grep-verifiable conditions
542
+ - [ ] Every `<action>` contains concrete values (no "align X with Y" without specifying what)
543
+ - [ ] Dependencies correctly identified
544
+ - [ ] Waves assigned for parallel execution
545
+ - [ ] must_haves derived from phase goal
546
+ </quality_gate>
547
+ ```
548
+
549
+ ```
550
+ Task(
551
+ prompt=filled_prompt,
552
+ subagent_type="gsd-planner",
553
+ model="{planner_model}",
554
+ description="Plan Phase {phase}"
555
+ )
556
+ ```
557
+
558
+ ## 9. Handle Planner Return
559
+
560
+ - **`## PLANNING COMPLETE`:** Display plan count. If `--skip-verify` or `plan_checker_enabled` is false (from init): skip to step 13. Otherwise: step 10.
561
+ - **`## CHECKPOINT REACHED`:** Present to user, get response, spawn continuation (step 12)
562
+ - **`## PLANNING INCONCLUSIVE`:** Show attempts, offer: Add context / Retry / Manual
563
+
564
+ ## 10. Spawn gsd-plan-checker Agent
565
+
566
+ Display banner:
567
+ ```
568
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
569
+ GSD ► VERIFYING PLANS
570
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
571
+
572
+ ◆ Spawning plan checker...
573
+ ```
574
+
575
+ Checker prompt:
576
+
577
+ ```markdown
578
+ <verification_context>
579
+ **Phase:** {phase_number}
580
+ **Phase Goal:** {goal from ROADMAP}
581
+
582
+ <files_to_read>
583
+ - {PHASE_DIR}/*-PLAN.md (Plans to verify)
584
+ - {roadmap_path} (Roadmap)
585
+ - {requirements_path} (Requirements)
586
+ - {context_path} (USER DECISIONS from /gsd:discuss-phase)
587
+ - {research_path} (Technical Research — includes Validation Architecture)
588
+ </files_to_read>
589
+
590
+ ${AGENT_SKILLS_CHECKER}
591
+
592
+ **Phase requirement IDs (MUST ALL be covered):** {phase_req_ids}
593
+
594
+ **Project instructions:** Read ./CLAUDE.md if exists — verify plans honor project guidelines
595
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — verify plans account for project skill rules
596
+ </verification_context>
597
+
598
+ <expected_output>
599
+ - ## VERIFICATION PASSED — all checks pass
600
+ - ## ISSUES FOUND — structured issue list
601
+ </expected_output>
602
+ ```
603
+
604
+ ```
605
+ Task(
606
+ prompt=checker_prompt,
607
+ subagent_type="gsd-plan-checker",
608
+ model="{checker_model}",
609
+ description="Verify Phase {phase} plans"
610
+ )
611
+ ```
612
+
613
+ ## 11. Handle Checker Return
614
+
615
+ - **`## VERIFICATION PASSED`:** Display confirmation, proceed to step 13.
616
+ - **`## ISSUES FOUND`:** Display issues, check iteration count, proceed to step 12.
617
+
618
+ ## 12. Revision Loop (Max 3 Iterations)
619
+
620
+ Track `iteration_count` (starts at 1 after initial plan + check).
621
+
622
+ **If iteration_count < 3:**
623
+
624
+ Display: `Sending back to planner for revision... (iteration {N}/3)`
625
+
626
+ Revision prompt:
627
+
628
+ ```markdown
629
+ <revision_context>
630
+ **Phase:** {phase_number}
631
+ **Mode:** revision
632
+
633
+ <files_to_read>
634
+ - {PHASE_DIR}/*-PLAN.md (Existing plans)
635
+ - {context_path} (USER DECISIONS from /gsd:discuss-phase)
636
+ </files_to_read>
637
+
638
+ ${AGENT_SKILLS_PLANNER}
639
+
640
+ **Checker issues:** {structured_issues_from_checker}
641
+ </revision_context>
642
+
643
+ <instructions>
644
+ Make targeted updates to address checker issues.
645
+ Do NOT replan from scratch unless issues are fundamental.
646
+ Return what changed.
647
+ </instructions>
648
+ ```
649
+
650
+ ```
651
+ Task(
652
+ prompt=revision_prompt,
653
+ subagent_type="gsd-planner",
654
+ model="{planner_model}",
655
+ description="Revise Phase {phase} plans"
656
+ )
657
+ ```
658
+
659
+ After planner returns -> spawn checker again (step 10), increment iteration_count.
660
+
661
+ **If iteration_count >= 3:**
662
+
663
+ Display: `Max iterations reached. {N} issues remain:` + issue list
664
+
665
+ Offer: 1) Force proceed, 2) Provide guidance and retry, 3) Abandon
666
+
667
+ ## 13. Requirements Coverage Gate
668
+
669
+ After plans pass the checker (or checker is skipped), verify that all phase requirements are covered by at least one plan.
670
+
671
+ **Skip if:** `phase_req_ids` is null or TBD (no requirements mapped to this phase).
672
+
673
+ **Step 1: Extract requirement IDs claimed by plans**
674
+ ```bash
675
+ # Collect all requirement IDs from plan frontmatter
676
+ PLAN_REQS=$(grep -h "requirements_addressed\|requirements:" ${PHASE_DIR}/*-PLAN.md 2>/dev/null | tr -d '[]' | tr ',' '\n' | sed 's/^[[:space:]]*//' | sort -u)
677
+ ```
678
+
679
+ **Step 2: Compare against phase requirements from ROADMAP**
680
+
681
+ For each REQ-ID in `phase_req_ids`:
682
+ - If REQ-ID appears in `PLAN_REQS` → covered ✓
683
+ - If REQ-ID does NOT appear in any plan → uncovered ✗
684
+
685
+ **Step 3: Check CONTEXT.md features against plan objectives**
686
+
687
+ Read CONTEXT.md `<decisions>` section. Extract feature/capability names. Check each against plan `<objective>` blocks. Features not mentioned in any plan objective → potentially dropped.
688
+
689
+ **Step 4: Report**
690
+
691
+ If all requirements covered and no dropped features:
692
+ ```
693
+ ✓ Requirements coverage: {N}/{N} REQ-IDs covered by plans
694
+ ```
695
+ → Proceed to step 14.
696
+
697
+ If gaps found:
698
+ ```
699
+ ## ⚠ Requirements Coverage Gap
700
+
701
+ {M} of {N} phase requirements are not assigned to any plan:
702
+
703
+ | REQ-ID | Description | Plans |
704
+ |--------|-------------|-------|
705
+ | {id} | {from REQUIREMENTS.md} | None |
706
+
707
+ {K} CONTEXT.md features not found in plan objectives:
708
+ - {feature_name} — described in CONTEXT.md but no plan covers it
709
+
710
+ Options:
711
+ 1. Re-plan to include missing requirements (recommended)
712
+ 2. Move uncovered requirements to next phase
713
+ 3. Proceed anyway — accept coverage gaps
714
+ ```
715
+
716
+ If `TEXT_MODE` is true, present as a plain-text numbered list (options already shown in the block above). Otherwise use AskUserQuestion to present the options.
717
+
718
+ ## 14. Present Final Status
719
+
720
+ Route to `<offer_next>` OR `auto_advance` depending on flags/config.
721
+
722
+ ## 15. Auto-Advance Check
723
+
724
+ Check for auto-advance trigger:
725
+
726
+ 1. Parse `--auto` flag from $ARGUMENTS
727
+ 2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
728
+ ```bash
729
+ if [[ ! "$ARGUMENTS" =~ --auto ]]; then
730
+ node "$HOME/.claude/cap/bin/cap-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
731
+ fi
732
+ ```
733
+ 3. Read both the chain flag and user preference:
734
+ ```bash
735
+ AUTO_CHAIN=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
736
+ AUTO_CFG=$(node "$HOME/.claude/cap/bin/cap-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
737
+ ```
738
+
739
+ **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
740
+
741
+ Display banner:
742
+ ```
743
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
744
+ GSD ► AUTO-ADVANCING TO EXECUTE
745
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
746
+
747
+ Plans ready. Launching execute-phase...
748
+ ```
749
+
750
+ Launch execute-phase using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting):
751
+ ```
752
+ Skill(skill="gsd:execute-phase", args="${PHASE} --auto --no-transition ${GSD_WS}")
753
+ ```
754
+
755
+ The `--no-transition` flag tells execute-phase to return status after verification instead of chaining further. This keeps the auto-advance chain flat — each phase runs at the same nesting level rather than spawning deeper Task agents.
756
+
757
+ **Handle execute-phase return:**
758
+ - **PHASE COMPLETE** → Display final summary:
759
+ ```
760
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
761
+ GSD ► PHASE ${PHASE} COMPLETE ✓
762
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
763
+
764
+ Auto-advance pipeline finished.
765
+
766
+ Next: /gsd:discuss-phase ${NEXT_PHASE} --auto ${GSD_WS}
767
+ ```
768
+ - **GAPS FOUND / VERIFICATION FAILED** → Display result, stop chain:
769
+ ```
770
+ Auto-advance stopped: Execution needs review.
771
+
772
+ Review the output above and continue manually:
773
+ /gsd:execute-phase ${PHASE} ${GSD_WS}
774
+ ```
775
+
776
+ **If neither `--auto` nor config enabled:**
777
+ Route to `<offer_next>` (existing behavior).
778
+
779
+ </process>
780
+
781
+ <offer_next>
782
+ Output this markdown directly (not as a code block):
783
+
784
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
785
+ GSD ► PHASE {X} PLANNED ✓
786
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
787
+
788
+ **Phase {X}: {Name}** — {N} plan(s) in {M} wave(s)
789
+
790
+ | Wave | Plans | What it builds |
791
+ |------|-------|----------------|
792
+ | 1 | 01, 02 | [objectives] |
793
+ | 2 | 03 | [objective] |
794
+
795
+ Research: {Completed | Used existing | Skipped}
796
+ Verification: {Passed | Passed with override | Skipped}
797
+
798
+ ───────────────────────────────────────────────────────────────
799
+
800
+ ## ▶ Next Up
801
+
802
+ **Execute Phase {X}** — run all {N} plans
803
+
804
+ /gsd:execute-phase {X} ${GSD_WS}
805
+
806
+ <sub>/clear first → fresh context window</sub>
807
+
808
+ ───────────────────────────────────────────────────────────────
809
+
810
+ **Also available:**
811
+ - cat .planning/phases/{phase-dir}/*-PLAN.md — review plans
812
+ - /gsd:plan-phase {X} --research — re-research first
813
+ - /gsd:review --phase {X} --all — peer review plans with external AIs
814
+ - /gsd:plan-phase {X} --reviews — replan incorporating review feedback
815
+
816
+ ───────────────────────────────────────────────────────────────
817
+ </offer_next>
818
+
819
+ <windows_troubleshooting>
820
+ **Windows users:** If plan-phase freezes during agent spawning (common on Windows due to
821
+ stdio deadlocks with MCP servers — see Claude Code issue anthropics/claude-code#28126):
822
+
823
+ 1. **Force-kill:** Close the terminal (Ctrl+C may not work)
824
+ 2. **Clean up orphaned processes:**
825
+ ```powershell
826
+ # Kill orphaned node processes from stale MCP servers
827
+ Get-Process node -ErrorAction SilentlyContinue | Where-Object {$_.StartTime -lt (Get-Date).AddHours(-1)} | Stop-Process -Force
828
+ ```
829
+ 3. **Clean up stale task directories:**
830
+ ```powershell
831
+ # Remove stale subagent task dirs (Claude Code never cleans these on crash)
832
+ Remove-Item -Recurse -Force "$env:USERPROFILE\.claude\tasks\*" -ErrorAction SilentlyContinue
833
+ ```
834
+ 4. **Reduce MCP server count:** Temporarily disable non-essential MCP servers in settings.json
835
+ 5. **Retry:** Restart Claude Code and run `/gsd:plan-phase` again
836
+
837
+ If freezes persist, try `--skip-research` to reduce the agent chain from 3 to 2 agents:
838
+ ```
839
+ /gsd:plan-phase N --skip-research
840
+ ```
841
+ </windows_troubleshooting>
842
+
843
+ <success_criteria>
844
+ - [ ] .planning/ directory validated
845
+ - [ ] Phase validated against roadmap
846
+ - [ ] Phase directory created if needed
847
+ - [ ] CONTEXT.md loaded early (step 4) and passed to ALL agents
848
+ - [ ] Research completed (unless --skip-research or --gaps or exists)
849
+ - [ ] gsd-phase-researcher spawned with CONTEXT.md
850
+ - [ ] Existing plans checked
851
+ - [ ] gsd-planner spawned with CONTEXT.md + RESEARCH.md
852
+ - [ ] Plans created (PLANNING COMPLETE or CHECKPOINT handled)
853
+ - [ ] gsd-plan-checker spawned with CONTEXT.md
854
+ - [ ] Verification passed OR user override OR max iterations with user decision
855
+ - [ ] User sees status between agent spawns
856
+ - [ ] User knows next steps
857
+ </success_criteria>