gsd-remix 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 (554) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +939 -0
  3. package/README.zh-CN.md +876 -0
  4. package/agents/gsd-advisor-researcher.md +127 -0
  5. package/agents/gsd-ai-researcher.md +133 -0
  6. package/agents/gsd-assumptions-analyzer.md +105 -0
  7. package/agents/gsd-code-fixer.md +517 -0
  8. package/agents/gsd-code-reviewer.md +371 -0
  9. package/agents/gsd-codebase-mapper.md +781 -0
  10. package/agents/gsd-debug-session-manager.md +314 -0
  11. package/agents/gsd-debugger.md +1452 -0
  12. package/agents/gsd-doc-classifier.md +168 -0
  13. package/agents/gsd-doc-synthesizer.md +204 -0
  14. package/agents/gsd-doc-verifier.md +217 -0
  15. package/agents/gsd-doc-writer.md +615 -0
  16. package/agents/gsd-domain-researcher.md +153 -0
  17. package/agents/gsd-eval-auditor.md +191 -0
  18. package/agents/gsd-eval-planner.md +154 -0
  19. package/agents/gsd-executor.md +603 -0
  20. package/agents/gsd-framework-selector.md +160 -0
  21. package/agents/gsd-integration-checker.md +470 -0
  22. package/agents/gsd-intel-updater.md +334 -0
  23. package/agents/gsd-nyquist-auditor.md +203 -0
  24. package/agents/gsd-pattern-mapper.md +335 -0
  25. package/agents/gsd-phase-researcher.md +841 -0
  26. package/agents/gsd-plan-checker.md +978 -0
  27. package/agents/gsd-planner.md +1251 -0
  28. package/agents/gsd-project-researcher.md +677 -0
  29. package/agents/gsd-research-synthesizer.md +247 -0
  30. package/agents/gsd-roadmapper.md +688 -0
  31. package/agents/gsd-security-auditor.md +155 -0
  32. package/agents/gsd-ui-auditor.md +495 -0
  33. package/agents/gsd-ui-checker.md +309 -0
  34. package/agents/gsd-ui-researcher.md +380 -0
  35. package/agents/gsd-user-profiler.md +171 -0
  36. package/agents/gsd-verifier.md +830 -0
  37. package/bin/install.js +7062 -0
  38. package/commands/gsd/add-backlog.md +79 -0
  39. package/commands/gsd/add-phase.md +43 -0
  40. package/commands/gsd/add-tests.md +41 -0
  41. package/commands/gsd/add-todo.md +47 -0
  42. package/commands/gsd/ai-integration-phase.md +36 -0
  43. package/commands/gsd/analyze-dependencies.md +34 -0
  44. package/commands/gsd/audit-fix.md +33 -0
  45. package/commands/gsd/audit-milestone.md +36 -0
  46. package/commands/gsd/audit-uat.md +24 -0
  47. package/commands/gsd/autonomous.md +46 -0
  48. package/commands/gsd/check-todos.md +45 -0
  49. package/commands/gsd/cleanup.md +23 -0
  50. package/commands/gsd/code-review-fix.md +52 -0
  51. package/commands/gsd/code-review.md +55 -0
  52. package/commands/gsd/complete-milestone.md +136 -0
  53. package/commands/gsd/debug.md +263 -0
  54. package/commands/gsd/discuss-phase.md +69 -0
  55. package/commands/gsd/do.md +30 -0
  56. package/commands/gsd/docs-update.md +48 -0
  57. package/commands/gsd/eval-review.md +32 -0
  58. package/commands/gsd/execute-phase.md +63 -0
  59. package/commands/gsd/explore.md +27 -0
  60. package/commands/gsd/extract_learnings.md +22 -0
  61. package/commands/gsd/fast.md +30 -0
  62. package/commands/gsd/forensics.md +56 -0
  63. package/commands/gsd/from-gsd2.md +47 -0
  64. package/commands/gsd/graphify.md +201 -0
  65. package/commands/gsd/health.md +22 -0
  66. package/commands/gsd/help.md +24 -0
  67. package/commands/gsd/import.md +37 -0
  68. package/commands/gsd/inbox.md +38 -0
  69. package/commands/gsd/ingest-docs.md +42 -0
  70. package/commands/gsd/insert-phase.md +32 -0
  71. package/commands/gsd/intel.md +179 -0
  72. package/commands/gsd/join-discord.md +19 -0
  73. package/commands/gsd/list-phase-assumptions.md +46 -0
  74. package/commands/gsd/list-workspaces.md +19 -0
  75. package/commands/gsd/manager.md +40 -0
  76. package/commands/gsd/map-codebase.md +71 -0
  77. package/commands/gsd/milestone-summary.md +51 -0
  78. package/commands/gsd/new-milestone.md +44 -0
  79. package/commands/gsd/new-project.md +46 -0
  80. package/commands/gsd/new-workspace.md +44 -0
  81. package/commands/gsd/next.md +28 -0
  82. package/commands/gsd/note.md +34 -0
  83. package/commands/gsd/pause-work.md +38 -0
  84. package/commands/gsd/plan-milestone-gaps.md +34 -0
  85. package/commands/gsd/plan-phase.md +52 -0
  86. package/commands/gsd/plan-review-convergence.md +52 -0
  87. package/commands/gsd/plant-seed.md +28 -0
  88. package/commands/gsd/pr-branch.md +25 -0
  89. package/commands/gsd/profile-user.md +46 -0
  90. package/commands/gsd/progress.md +25 -0
  91. package/commands/gsd/quick.md +173 -0
  92. package/commands/gsd/reapply-patches.md +331 -0
  93. package/commands/gsd/remove-phase.md +31 -0
  94. package/commands/gsd/remove-workspace.md +26 -0
  95. package/commands/gsd/research-phase.md +195 -0
  96. package/commands/gsd/resume-work.md +40 -0
  97. package/commands/gsd/review-backlog.md +62 -0
  98. package/commands/gsd/review.md +40 -0
  99. package/commands/gsd/scan.md +26 -0
  100. package/commands/gsd/secure-phase.md +35 -0
  101. package/commands/gsd/session-report.md +19 -0
  102. package/commands/gsd/set-profile.md +12 -0
  103. package/commands/gsd/settings.md +36 -0
  104. package/commands/gsd/ship.md +23 -0
  105. package/commands/gsd/sketch-wrap-up.md +31 -0
  106. package/commands/gsd/sketch.md +49 -0
  107. package/commands/gsd/spec-phase.md +62 -0
  108. package/commands/gsd/spike-wrap-up.md +31 -0
  109. package/commands/gsd/spike.md +46 -0
  110. package/commands/gsd/stats.md +18 -0
  111. package/commands/gsd/sync-skills.md +19 -0
  112. package/commands/gsd/thread.md +227 -0
  113. package/commands/gsd/ui-phase.md +34 -0
  114. package/commands/gsd/ui-review.md +32 -0
  115. package/commands/gsd/ultraplan-phase.md +33 -0
  116. package/commands/gsd/undo.md +34 -0
  117. package/commands/gsd/update.md +37 -0
  118. package/commands/gsd/validate-phase.md +35 -0
  119. package/commands/gsd/verify-work.md +38 -0
  120. package/commands/gsd/workstreams.md +69 -0
  121. package/get-shit-done/bin/gsd-tools.cjs +1263 -0
  122. package/get-shit-done/bin/lib/artifacts.cjs +52 -0
  123. package/get-shit-done/bin/lib/audit.cjs +757 -0
  124. package/get-shit-done/bin/lib/commands.cjs +1023 -0
  125. package/get-shit-done/bin/lib/config-schema.cjs +79 -0
  126. package/get-shit-done/bin/lib/config.cjs +463 -0
  127. package/get-shit-done/bin/lib/core.cjs +1794 -0
  128. package/get-shit-done/bin/lib/docs.cjs +267 -0
  129. package/get-shit-done/bin/lib/frontmatter.cjs +379 -0
  130. package/get-shit-done/bin/lib/graphify.cjs +494 -0
  131. package/get-shit-done/bin/lib/gsd2-import.cjs +511 -0
  132. package/get-shit-done/bin/lib/init.cjs +1878 -0
  133. package/get-shit-done/bin/lib/intel.cjs +639 -0
  134. package/get-shit-done/bin/lib/learnings.cjs +378 -0
  135. package/get-shit-done/bin/lib/milestone.cjs +283 -0
  136. package/get-shit-done/bin/lib/model-profiles.cjs +71 -0
  137. package/get-shit-done/bin/lib/phase.cjs +1058 -0
  138. package/get-shit-done/bin/lib/profile-output.cjs +1080 -0
  139. package/get-shit-done/bin/lib/profile-pipeline.cjs +539 -0
  140. package/get-shit-done/bin/lib/roadmap.cjs +523 -0
  141. package/get-shit-done/bin/lib/schema-detect.cjs +238 -0
  142. package/get-shit-done/bin/lib/security.cjs +504 -0
  143. package/get-shit-done/bin/lib/state.cjs +1649 -0
  144. package/get-shit-done/bin/lib/template.cjs +226 -0
  145. package/get-shit-done/bin/lib/uat.cjs +288 -0
  146. package/get-shit-done/bin/lib/verify.cjs +1184 -0
  147. package/get-shit-done/bin/lib/workstream.cjs +495 -0
  148. package/get-shit-done/bin/repair-sdk.cjs +177 -0
  149. package/get-shit-done/contexts/dev.md +21 -0
  150. package/get-shit-done/contexts/research.md +22 -0
  151. package/get-shit-done/contexts/review.md +22 -0
  152. package/get-shit-done/references/agent-contracts.md +79 -0
  153. package/get-shit-done/references/ai-evals.md +156 -0
  154. package/get-shit-done/references/ai-frameworks.md +186 -0
  155. package/get-shit-done/references/artifact-types.md +131 -0
  156. package/get-shit-done/references/autonomous-smart-discuss.md +277 -0
  157. package/get-shit-done/references/checkpoints.md +808 -0
  158. package/get-shit-done/references/common-bug-patterns.md +114 -0
  159. package/get-shit-done/references/context-budget.md +49 -0
  160. package/get-shit-done/references/continuation-format.md +253 -0
  161. package/get-shit-done/references/debugger-philosophy.md +76 -0
  162. package/get-shit-done/references/decimal-phase-calculation.md +64 -0
  163. package/get-shit-done/references/doc-conflict-engine.md +91 -0
  164. package/get-shit-done/references/domain-probes.md +125 -0
  165. package/get-shit-done/references/executor-examples.md +110 -0
  166. package/get-shit-done/references/few-shot-examples/plan-checker.md +73 -0
  167. package/get-shit-done/references/few-shot-examples/verifier.md +109 -0
  168. package/get-shit-done/references/gate-prompts.md +100 -0
  169. package/get-shit-done/references/gates.md +70 -0
  170. package/get-shit-done/references/git-integration.md +295 -0
  171. package/get-shit-done/references/git-planning-commit.md +40 -0
  172. package/get-shit-done/references/ios-scaffold.md +123 -0
  173. package/get-shit-done/references/mandatory-initial-read.md +2 -0
  174. package/get-shit-done/references/model-profile-resolution.md +38 -0
  175. package/get-shit-done/references/model-profiles.md +145 -0
  176. package/get-shit-done/references/phase-argument-parsing.md +61 -0
  177. package/get-shit-done/references/planner-antipatterns.md +89 -0
  178. package/get-shit-done/references/planner-gap-closure.md +62 -0
  179. package/get-shit-done/references/planner-reviews.md +39 -0
  180. package/get-shit-done/references/planner-revision.md +87 -0
  181. package/get-shit-done/references/planner-source-audit.md +73 -0
  182. package/get-shit-done/references/planning-config.md +460 -0
  183. package/get-shit-done/references/project-skills-discovery.md +19 -0
  184. package/get-shit-done/references/questioning.md +162 -0
  185. package/get-shit-done/references/revision-loop.md +97 -0
  186. package/get-shit-done/references/sketch-interactivity.md +41 -0
  187. package/get-shit-done/references/sketch-theme-system.md +94 -0
  188. package/get-shit-done/references/sketch-tooling.md +45 -0
  189. package/get-shit-done/references/sketch-variant-patterns.md +81 -0
  190. package/get-shit-done/references/tdd.md +330 -0
  191. package/get-shit-done/references/thinking-models-debug.md +44 -0
  192. package/get-shit-done/references/thinking-models-execution.md +50 -0
  193. package/get-shit-done/references/thinking-models-planning.md +62 -0
  194. package/get-shit-done/references/thinking-models-research.md +50 -0
  195. package/get-shit-done/references/thinking-models-verification.md +55 -0
  196. package/get-shit-done/references/thinking-partner.md +96 -0
  197. package/get-shit-done/references/ui-brand.md +160 -0
  198. package/get-shit-done/references/universal-anti-patterns.md +63 -0
  199. package/get-shit-done/references/user-profiling.md +681 -0
  200. package/get-shit-done/references/verification-overrides.md +227 -0
  201. package/get-shit-done/references/verification-patterns.md +612 -0
  202. package/get-shit-done/references/workstream-flag.md +111 -0
  203. package/get-shit-done/templates/AI-SPEC.md +246 -0
  204. package/get-shit-done/templates/DEBUG.md +169 -0
  205. package/get-shit-done/templates/README.md +76 -0
  206. package/get-shit-done/templates/SECURITY.md +61 -0
  207. package/get-shit-done/templates/UAT.md +265 -0
  208. package/get-shit-done/templates/UI-SPEC.md +100 -0
  209. package/get-shit-done/templates/VALIDATION.md +76 -0
  210. package/get-shit-done/templates/claude-md.md +145 -0
  211. package/get-shit-done/templates/codebase/architecture.md +255 -0
  212. package/get-shit-done/templates/codebase/concerns.md +310 -0
  213. package/get-shit-done/templates/codebase/conventions.md +307 -0
  214. package/get-shit-done/templates/codebase/integrations.md +280 -0
  215. package/get-shit-done/templates/codebase/stack.md +186 -0
  216. package/get-shit-done/templates/codebase/structure.md +285 -0
  217. package/get-shit-done/templates/codebase/testing.md +480 -0
  218. package/get-shit-done/templates/config.json +56 -0
  219. package/get-shit-done/templates/context.md +352 -0
  220. package/get-shit-done/templates/continue-here.md +78 -0
  221. package/get-shit-done/templates/copilot-instructions.md +7 -0
  222. package/get-shit-done/templates/debug-subagent-prompt.md +91 -0
  223. package/get-shit-done/templates/dev-preferences.md +21 -0
  224. package/get-shit-done/templates/discovery.md +146 -0
  225. package/get-shit-done/templates/discussion-log.md +63 -0
  226. package/get-shit-done/templates/milestone-archive.md +123 -0
  227. package/get-shit-done/templates/milestone.md +115 -0
  228. package/get-shit-done/templates/phase-prompt.md +610 -0
  229. package/get-shit-done/templates/planner-subagent-prompt.md +117 -0
  230. package/get-shit-done/templates/project.md +186 -0
  231. package/get-shit-done/templates/requirements.md +231 -0
  232. package/get-shit-done/templates/research-project/ARCHITECTURE.md +204 -0
  233. package/get-shit-done/templates/research-project/FEATURES.md +147 -0
  234. package/get-shit-done/templates/research-project/PITFALLS.md +200 -0
  235. package/get-shit-done/templates/research-project/STACK.md +120 -0
  236. package/get-shit-done/templates/research-project/SUMMARY.md +170 -0
  237. package/get-shit-done/templates/research.md +592 -0
  238. package/get-shit-done/templates/retrospective.md +54 -0
  239. package/get-shit-done/templates/roadmap.md +202 -0
  240. package/get-shit-done/templates/spec.md +307 -0
  241. package/get-shit-done/templates/state.md +184 -0
  242. package/get-shit-done/templates/summary-complex.md +59 -0
  243. package/get-shit-done/templates/summary-minimal.md +41 -0
  244. package/get-shit-done/templates/summary-standard.md +48 -0
  245. package/get-shit-done/templates/summary.md +248 -0
  246. package/get-shit-done/templates/user-profile.md +146 -0
  247. package/get-shit-done/templates/user-setup.md +311 -0
  248. package/get-shit-done/templates/verification-report.md +322 -0
  249. package/get-shit-done/workflows/add-phase.md +112 -0
  250. package/get-shit-done/workflows/add-tests.md +354 -0
  251. package/get-shit-done/workflows/add-todo.md +160 -0
  252. package/get-shit-done/workflows/ai-integration-phase.md +284 -0
  253. package/get-shit-done/workflows/analyze-dependencies.md +96 -0
  254. package/get-shit-done/workflows/audit-fix.md +175 -0
  255. package/get-shit-done/workflows/audit-milestone.md +340 -0
  256. package/get-shit-done/workflows/audit-uat.md +109 -0
  257. package/get-shit-done/workflows/autonomous.md +789 -0
  258. package/get-shit-done/workflows/check-todos.md +179 -0
  259. package/get-shit-done/workflows/cleanup.md +154 -0
  260. package/get-shit-done/workflows/code-review-fix.md +497 -0
  261. package/get-shit-done/workflows/code-review.md +515 -0
  262. package/get-shit-done/workflows/complete-milestone.md +847 -0
  263. package/get-shit-done/workflows/diagnose-issues.md +238 -0
  264. package/get-shit-done/workflows/discovery-phase.md +291 -0
  265. package/get-shit-done/workflows/discuss-phase-assumptions.md +670 -0
  266. package/get-shit-done/workflows/discuss-phase-power.md +308 -0
  267. package/get-shit-done/workflows/discuss-phase.md +1378 -0
  268. package/get-shit-done/workflows/do.md +110 -0
  269. package/get-shit-done/workflows/docs-update.md +1155 -0
  270. package/get-shit-done/workflows/eval-review.md +155 -0
  271. package/get-shit-done/workflows/execute-phase.md +1677 -0
  272. package/get-shit-done/workflows/execute-plan.md +533 -0
  273. package/get-shit-done/workflows/explore.md +141 -0
  274. package/get-shit-done/workflows/extract_learnings.md +242 -0
  275. package/get-shit-done/workflows/fast.md +105 -0
  276. package/get-shit-done/workflows/forensics.md +265 -0
  277. package/get-shit-done/workflows/graduation.md +195 -0
  278. package/get-shit-done/workflows/health.md +314 -0
  279. package/get-shit-done/workflows/help.md +667 -0
  280. package/get-shit-done/workflows/import.md +246 -0
  281. package/get-shit-done/workflows/inbox.md +387 -0
  282. package/get-shit-done/workflows/ingest-docs.md +328 -0
  283. package/get-shit-done/workflows/insert-phase.md +130 -0
  284. package/get-shit-done/workflows/list-phase-assumptions.md +178 -0
  285. package/get-shit-done/workflows/list-workspaces.md +56 -0
  286. package/get-shit-done/workflows/manager.md +365 -0
  287. package/get-shit-done/workflows/map-codebase.md +393 -0
  288. package/get-shit-done/workflows/milestone-summary.md +223 -0
  289. package/get-shit-done/workflows/new-milestone.md +611 -0
  290. package/get-shit-done/workflows/new-project.md +1391 -0
  291. package/get-shit-done/workflows/new-workspace.md +239 -0
  292. package/get-shit-done/workflows/next.md +220 -0
  293. package/get-shit-done/workflows/node-repair.md +92 -0
  294. package/get-shit-done/workflows/note.md +158 -0
  295. package/get-shit-done/workflows/pause-work.md +243 -0
  296. package/get-shit-done/workflows/plan-milestone-gaps.md +273 -0
  297. package/get-shit-done/workflows/plan-phase.md +1349 -0
  298. package/get-shit-done/workflows/plan-review-convergence.md +254 -0
  299. package/get-shit-done/workflows/plant-seed.md +172 -0
  300. package/get-shit-done/workflows/pr-branch.md +157 -0
  301. package/get-shit-done/workflows/profile-user.md +452 -0
  302. package/get-shit-done/workflows/progress.md +619 -0
  303. package/get-shit-done/workflows/quick.md +970 -0
  304. package/get-shit-done/workflows/remove-phase.md +155 -0
  305. package/get-shit-done/workflows/remove-workspace.md +92 -0
  306. package/get-shit-done/workflows/research-phase.md +89 -0
  307. package/get-shit-done/workflows/resume-project.md +326 -0
  308. package/get-shit-done/workflows/review.md +344 -0
  309. package/get-shit-done/workflows/scan.md +102 -0
  310. package/get-shit-done/workflows/secure-phase.md +166 -0
  311. package/get-shit-done/workflows/session-report.md +146 -0
  312. package/get-shit-done/workflows/settings.md +319 -0
  313. package/get-shit-done/workflows/ship.md +302 -0
  314. package/get-shit-done/workflows/sketch-wrap-up.md +283 -0
  315. package/get-shit-done/workflows/sketch.md +286 -0
  316. package/get-shit-done/workflows/spec-phase.md +262 -0
  317. package/get-shit-done/workflows/spike-wrap-up.md +281 -0
  318. package/get-shit-done/workflows/spike.md +362 -0
  319. package/get-shit-done/workflows/stats.md +60 -0
  320. package/get-shit-done/workflows/sync-skills.md +182 -0
  321. package/get-shit-done/workflows/transition.md +693 -0
  322. package/get-shit-done/workflows/ui-phase.md +323 -0
  323. package/get-shit-done/workflows/ui-review.md +190 -0
  324. package/get-shit-done/workflows/ultraplan-phase.md +189 -0
  325. package/get-shit-done/workflows/undo.md +314 -0
  326. package/get-shit-done/workflows/update.md +587 -0
  327. package/get-shit-done/workflows/validate-phase.md +176 -0
  328. package/get-shit-done/workflows/verify-phase.md +465 -0
  329. package/get-shit-done/workflows/verify-work.md +740 -0
  330. package/hooks/dist/gsd-check-update-worker.js +108 -0
  331. package/hooks/dist/gsd-check-update.js +64 -0
  332. package/hooks/dist/gsd-context-monitor.js +192 -0
  333. package/hooks/dist/gsd-phase-boundary.sh +28 -0
  334. package/hooks/dist/gsd-prompt-guard.js +97 -0
  335. package/hooks/dist/gsd-read-guard.js +82 -0
  336. package/hooks/dist/gsd-read-injection-scanner.js +152 -0
  337. package/hooks/dist/gsd-session-state.sh +34 -0
  338. package/hooks/dist/gsd-statusline.js +293 -0
  339. package/hooks/dist/gsd-validate-commit.sh +48 -0
  340. package/hooks/dist/gsd-workflow-guard.js +94 -0
  341. package/hooks/gsd-check-update-worker.js +108 -0
  342. package/hooks/gsd-check-update.js +64 -0
  343. package/hooks/gsd-context-monitor.js +192 -0
  344. package/hooks/gsd-phase-boundary.sh +28 -0
  345. package/hooks/gsd-prompt-guard.js +97 -0
  346. package/hooks/gsd-read-guard.js +82 -0
  347. package/hooks/gsd-read-injection-scanner.js +152 -0
  348. package/hooks/gsd-session-state.sh +34 -0
  349. package/hooks/gsd-statusline.js +293 -0
  350. package/hooks/gsd-validate-commit.sh +48 -0
  351. package/hooks/gsd-workflow-guard.js +94 -0
  352. package/package.json +59 -0
  353. package/scripts/base64-scan.sh +262 -0
  354. package/scripts/build-hooks.js +95 -0
  355. package/scripts/gen-inventory-manifest.cjs +109 -0
  356. package/scripts/prompt-injection-scan.sh +201 -0
  357. package/scripts/run-tests.cjs +33 -0
  358. package/scripts/secret-scan.sh +227 -0
  359. package/sdk/package-lock.json +1998 -0
  360. package/sdk/package.json +52 -0
  361. package/sdk/prompts/agents/gsd-executor.md +110 -0
  362. package/sdk/prompts/agents/gsd-phase-researcher.md +158 -0
  363. package/sdk/prompts/agents/gsd-plan-checker.md +160 -0
  364. package/sdk/prompts/agents/gsd-planner.md +214 -0
  365. package/sdk/prompts/agents/gsd-project-researcher.md +323 -0
  366. package/sdk/prompts/agents/gsd-research-synthesizer.md +237 -0
  367. package/sdk/prompts/agents/gsd-roadmapper.md +670 -0
  368. package/sdk/prompts/agents/gsd-verifier.md +159 -0
  369. package/sdk/prompts/templates/project.md +186 -0
  370. package/sdk/prompts/templates/requirements.md +231 -0
  371. package/sdk/prompts/templates/research-project/ARCHITECTURE.md +204 -0
  372. package/sdk/prompts/templates/research-project/FEATURES.md +147 -0
  373. package/sdk/prompts/templates/research-project/PITFALLS.md +200 -0
  374. package/sdk/prompts/templates/research-project/STACK.md +120 -0
  375. package/sdk/prompts/templates/research-project/SUMMARY.md +170 -0
  376. package/sdk/prompts/templates/roadmap.md +202 -0
  377. package/sdk/prompts/templates/state.md +175 -0
  378. package/sdk/prompts/workflows/discuss-phase.md +126 -0
  379. package/sdk/prompts/workflows/execute-plan.md +106 -0
  380. package/sdk/prompts/workflows/plan-phase.md +84 -0
  381. package/sdk/prompts/workflows/research-phase.md +45 -0
  382. package/sdk/prompts/workflows/verify-phase.md +142 -0
  383. package/sdk/src/assembled-prompts.test.ts +349 -0
  384. package/sdk/src/cli-transport.test.ts +388 -0
  385. package/sdk/src/cli-transport.ts +130 -0
  386. package/sdk/src/cli.test.ts +383 -0
  387. package/sdk/src/cli.ts +670 -0
  388. package/sdk/src/config.test.ts +168 -0
  389. package/sdk/src/config.ts +177 -0
  390. package/sdk/src/context-engine.test.ts +295 -0
  391. package/sdk/src/context-engine.ts +170 -0
  392. package/sdk/src/context-truncation.test.ts +163 -0
  393. package/sdk/src/context-truncation.ts +233 -0
  394. package/sdk/src/e2e.integration.test.ts +178 -0
  395. package/sdk/src/errors.ts +72 -0
  396. package/sdk/src/event-stream.test.ts +661 -0
  397. package/sdk/src/event-stream.ts +441 -0
  398. package/sdk/src/failure-memory.test.ts +457 -0
  399. package/sdk/src/failure-memory.ts +1324 -0
  400. package/sdk/src/golden/capture.ts +95 -0
  401. package/sdk/src/golden/fixtures/generate-slug.golden.json +1 -0
  402. package/sdk/src/golden/fixtures/profile-sample-sessions/demo-project/sample.jsonl +3 -0
  403. package/sdk/src/golden/fixtures/summary-extract-sample.md +26 -0
  404. package/sdk/src/golden/fixtures/uat-render-checkpoint-sample.md +15 -0
  405. package/sdk/src/golden/golden-integration-covered.ts +30 -0
  406. package/sdk/src/golden/golden-mutation-covered.ts +7 -0
  407. package/sdk/src/golden/golden-policy.test.ts +8 -0
  408. package/sdk/src/golden/golden-policy.ts +112 -0
  409. package/sdk/src/golden/golden.integration.test.ts +373 -0
  410. package/sdk/src/golden/init-golden-normalize.ts +15 -0
  411. package/sdk/src/golden/read-only-golden-rows.ts +77 -0
  412. package/sdk/src/golden/read-only-parity.integration.test.ts +125 -0
  413. package/sdk/src/golden/registry-canonical-commands.ts +31 -0
  414. package/sdk/src/gsd-tools.test.ts +409 -0
  415. package/sdk/src/gsd-tools.ts +595 -0
  416. package/sdk/src/headless-prompts.test.ts +159 -0
  417. package/sdk/src/index.ts +333 -0
  418. package/sdk/src/init-e2e.integration.test.ts +136 -0
  419. package/sdk/src/init-runner.test.ts +783 -0
  420. package/sdk/src/init-runner.ts +735 -0
  421. package/sdk/src/lifecycle-e2e.integration.test.ts +258 -0
  422. package/sdk/src/logger.test.ts +149 -0
  423. package/sdk/src/logger.ts +113 -0
  424. package/sdk/src/milestone-runner.test.ts +421 -0
  425. package/sdk/src/phase-prompt.test.ts +538 -0
  426. package/sdk/src/phase-prompt.ts +264 -0
  427. package/sdk/src/phase-runner-types.test.ts +421 -0
  428. package/sdk/src/phase-runner.integration.test.ts +377 -0
  429. package/sdk/src/phase-runner.test.ts +2333 -0
  430. package/sdk/src/phase-runner.ts +1203 -0
  431. package/sdk/src/plan-parser.test.ts +528 -0
  432. package/sdk/src/plan-parser.ts +427 -0
  433. package/sdk/src/prompt-builder.test.ts +306 -0
  434. package/sdk/src/prompt-builder.ts +193 -0
  435. package/sdk/src/prompt-sanitizer.test.ts +260 -0
  436. package/sdk/src/prompt-sanitizer.ts +71 -0
  437. package/sdk/src/query/QUERY-HANDLERS.md +317 -0
  438. package/sdk/src/query/audit-open.ts +722 -0
  439. package/sdk/src/query/check-auto-mode.test.ts +77 -0
  440. package/sdk/src/query/check-auto-mode.ts +50 -0
  441. package/sdk/src/query/check-completion.test.ts +113 -0
  442. package/sdk/src/query/check-completion.ts +182 -0
  443. package/sdk/src/query/check-gates.test.ts +103 -0
  444. package/sdk/src/query/check-gates.ts +112 -0
  445. package/sdk/src/query/check-ship-ready.test.ts +77 -0
  446. package/sdk/src/query/check-ship-ready.ts +103 -0
  447. package/sdk/src/query/check-verification-status.test.ts +143 -0
  448. package/sdk/src/query/check-verification-status.ts +160 -0
  449. package/sdk/src/query/commit.test.ts +202 -0
  450. package/sdk/src/query/commit.ts +301 -0
  451. package/sdk/src/query/config-gates.test.ts +89 -0
  452. package/sdk/src/query/config-gates.ts +69 -0
  453. package/sdk/src/query/config-mutation.test.ts +365 -0
  454. package/sdk/src/query/config-mutation.ts +497 -0
  455. package/sdk/src/query/config-query.test.ts +161 -0
  456. package/sdk/src/query/config-query.ts +190 -0
  457. package/sdk/src/query/context-history.test.ts +165 -0
  458. package/sdk/src/query/context-history.ts +467 -0
  459. package/sdk/src/query/decomposed-handlers.test.ts +365 -0
  460. package/sdk/src/query/detect-custom-files.ts +97 -0
  461. package/sdk/src/query/detect-phase-type.test.ts +105 -0
  462. package/sdk/src/query/detect-phase-type.ts +141 -0
  463. package/sdk/src/query/docs-init.ts +257 -0
  464. package/sdk/src/query/failure-capture.ts +58 -0
  465. package/sdk/src/query/frontmatter-array.test.ts +14 -0
  466. package/sdk/src/query/frontmatter-mutation.test.ts +259 -0
  467. package/sdk/src/query/frontmatter-mutation.ts +343 -0
  468. package/sdk/src/query/frontmatter.test.ts +281 -0
  469. package/sdk/src/query/frontmatter.ts +397 -0
  470. package/sdk/src/query/helpers.test.ts +426 -0
  471. package/sdk/src/query/helpers.ts +482 -0
  472. package/sdk/src/query/index.ts +586 -0
  473. package/sdk/src/query/init-complex.test.ts +232 -0
  474. package/sdk/src/query/init-complex.ts +578 -0
  475. package/sdk/src/query/init.test.ts +522 -0
  476. package/sdk/src/query/init.ts +1046 -0
  477. package/sdk/src/query/intel.test.ts +90 -0
  478. package/sdk/src/query/intel.ts +404 -0
  479. package/sdk/src/query/normalize-query-command.test.ts +50 -0
  480. package/sdk/src/query/normalize-query-command.ts +56 -0
  481. package/sdk/src/query/phase-lifecycle.test.ts +1126 -0
  482. package/sdk/src/query/phase-lifecycle.ts +1799 -0
  483. package/sdk/src/query/phase-list-queries.test.ts +88 -0
  484. package/sdk/src/query/phase-list-queries.ts +152 -0
  485. package/sdk/src/query/phase-ready.test.ts +65 -0
  486. package/sdk/src/query/phase-ready.ts +158 -0
  487. package/sdk/src/query/phase.test.ts +307 -0
  488. package/sdk/src/query/phase.ts +340 -0
  489. package/sdk/src/query/pipeline.test.ts +169 -0
  490. package/sdk/src/query/pipeline.ts +243 -0
  491. package/sdk/src/query/plan-execution-route.test.ts +166 -0
  492. package/sdk/src/query/plan-execution-route.ts +209 -0
  493. package/sdk/src/query/plan-task-structure.test.ts +65 -0
  494. package/sdk/src/query/plan-task-structure.ts +63 -0
  495. package/sdk/src/query/profile-extract-messages.ts +247 -0
  496. package/sdk/src/query/profile-output.ts +908 -0
  497. package/sdk/src/query/profile-questionnaire-data.ts +181 -0
  498. package/sdk/src/query/profile-sample.ts +184 -0
  499. package/sdk/src/query/profile-scan-sessions.ts +174 -0
  500. package/sdk/src/query/profile.test.ts +74 -0
  501. package/sdk/src/query/profile.ts +337 -0
  502. package/sdk/src/query/progress.test.ts +156 -0
  503. package/sdk/src/query/progress.ts +566 -0
  504. package/sdk/src/query/registry.test.ts +216 -0
  505. package/sdk/src/query/registry.ts +174 -0
  506. package/sdk/src/query/requirements-extract-from-plans.test.ts +58 -0
  507. package/sdk/src/query/requirements-extract-from-plans.ts +86 -0
  508. package/sdk/src/query/roadmap-update-plan-progress.ts +132 -0
  509. package/sdk/src/query/roadmap.test.ts +359 -0
  510. package/sdk/src/query/roadmap.ts +591 -0
  511. package/sdk/src/query/route-next-action.test.ts +61 -0
  512. package/sdk/src/query/route-next-action.ts +345 -0
  513. package/sdk/src/query/runtime-health.ts +7 -0
  514. package/sdk/src/query/schema-detect.ts +189 -0
  515. package/sdk/src/query/skill-manifest.ts +214 -0
  516. package/sdk/src/query/skills.test.ts +80 -0
  517. package/sdk/src/query/skills.ts +62 -0
  518. package/sdk/src/query/state-mutation.test.ts +450 -0
  519. package/sdk/src/query/state-mutation.ts +1444 -0
  520. package/sdk/src/query/state-project-load.ts +109 -0
  521. package/sdk/src/query/state.test.ts +347 -0
  522. package/sdk/src/query/state.ts +397 -0
  523. package/sdk/src/query/summary.test.ts +95 -0
  524. package/sdk/src/query/summary.ts +296 -0
  525. package/sdk/src/query/template.test.ts +180 -0
  526. package/sdk/src/query/template.ts +242 -0
  527. package/sdk/src/query/uat.test.ts +77 -0
  528. package/sdk/src/query/uat.ts +314 -0
  529. package/sdk/src/query/utils.test.ts +82 -0
  530. package/sdk/src/query/utils.ts +92 -0
  531. package/sdk/src/query/validate.test.ts +656 -0
  532. package/sdk/src/query/validate.ts +807 -0
  533. package/sdk/src/query/verify.test.ts +414 -0
  534. package/sdk/src/query/verify.ts +645 -0
  535. package/sdk/src/query/websearch.test.ts +31 -0
  536. package/sdk/src/query/websearch.ts +82 -0
  537. package/sdk/src/query/workspace.test.ts +119 -0
  538. package/sdk/src/query/workspace.ts +131 -0
  539. package/sdk/src/query/workstream.test.ts +51 -0
  540. package/sdk/src/query/workstream.ts +434 -0
  541. package/sdk/src/research-gate.test.ts +190 -0
  542. package/sdk/src/research-gate.ts +94 -0
  543. package/sdk/src/runtime-health.test.ts +176 -0
  544. package/sdk/src/runtime-health.ts +387 -0
  545. package/sdk/src/session-runner.test.ts +98 -0
  546. package/sdk/src/session-runner.ts +299 -0
  547. package/sdk/src/tool-scoping.test.ts +160 -0
  548. package/sdk/src/tool-scoping.ts +61 -0
  549. package/sdk/src/types.ts +917 -0
  550. package/sdk/src/workstream-utils.ts +33 -0
  551. package/sdk/src/ws-flag.test.ts +285 -0
  552. package/sdk/src/ws-transport.test.ts +161 -0
  553. package/sdk/src/ws-transport.ts +93 -0
  554. package/sdk/tsconfig.json +20 -0
@@ -0,0 +1,1349 @@
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
+
8
+ @~/.claude/get-shit-done/references/ui-brand.md
9
+ @~/.claude/get-shit-done/references/revision-loop.md
10
+ @~/.claude/get-shit-done/references/gate-prompts.md
11
+ @~/.claude/get-shit-done/references/agent-contracts.md
12
+ @~/.claude/get-shit-done/references/gates.md
13
+ </required_reading>
14
+
15
+ <available_agent_types>
16
+ Valid GSD subagent types (use exact names — do not fall back to 'general-purpose'):
17
+ - gsd-phase-researcher — Researches technical approaches for a phase
18
+ - gsd-pattern-mapper — Analyzes codebase for existing patterns, produces PATTERNS.md
19
+ - gsd-planner — Creates detailed plans from phase scope
20
+ - gsd-plan-checker — Reviews plan quality before execution
21
+ </available_agent_types>
22
+
23
+ <process>
24
+
25
+ ## 0. Git Branch Invariant
26
+
27
+ **Do not create, rename, or switch git branches during plan-phase.** Branch identity is established at discuss-phase and is owned by the user's git workflow. A phase rename in ROADMAP.md is a plan-level change only — it does not mutate git branch names. If `phase_slug` in the init JSON differs from the current branch name, that is expected and correct; leave the branch unchanged.
28
+
29
+ ## 0.5. Runtime Health Preflight
30
+
31
+ **MANDATORY — Check runtime health before any GSD SDK query.**
32
+
33
+ ```bash
34
+ if ! command -v gsd-remix-sdk &>/dev/null; then
35
+ echo "⚠ gsd-remix-sdk not found in PATH — /gsd-plan-phase requires it."
36
+ echo ""
37
+ echo "Repair the bundled SDK:"
38
+ echo " /gsd-health --runtime --repair"
39
+ echo ""
40
+ echo "Or refresh all runtime assets:"
41
+ echo " /gsd-update"
42
+ exit 1
43
+ fi
44
+
45
+ RUNTIME_HEALTH=$(gsd-remix-sdk query runtime.health 2>/dev/null || echo '{"passed":false,"blockers":[{"code":"runtime_health_unavailable","level":"block","message":"Installed gsd-remix-sdk does not expose runtime.health.","fix":"Run /gsd-health --runtime --repair to rebuild the bundled SDK."}],"warnings":[],"checks":[]}')
46
+ ```
47
+
48
+ Parse JSON for: `passed`, `blockers[]`, `warnings[]`, `checks[]`, `node_version`, `required_node_range`, `runtime_identity`, `runtime_identity_path`, `gsd_tools_source`, `gsd_tools_path`, `legacy_bridge_available`.
49
+
50
+ Rules:
51
+ - If `blockers[]` is non-empty: stop immediately, show each blocker and fix, and do not continue to `Initialize`.
52
+ - If `warnings[]` is non-empty: show them once as runtime advisories, then continue.
53
+ - This step is deterministic. Do not infer extra runtime problems beyond the query result.
54
+
55
+ ## 1. Initialize
56
+
57
+ Load all context in one call (paths only to minimize orchestrator context):
58
+
59
+ ```bash
60
+ INIT=$(gsd-remix-sdk query init.plan-phase "$PHASE")
61
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
62
+ AGENT_SKILLS_RESEARCHER=$(gsd-remix-sdk query agent-skills gsd-researcher 2>/dev/null)
63
+ AGENT_SKILLS_PLANNER=$(gsd-remix-sdk query agent-skills gsd-planner 2>/dev/null)
64
+ AGENT_SKILLS_CHECKER=$(gsd-remix-sdk query agent-skills gsd-checker 2>/dev/null)
65
+ CONTEXT_WINDOW=$(gsd-remix-sdk query config-get context_window 2>/dev/null || echo "200000")
66
+ TDD_MODE=$(gsd-remix-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
67
+ ```
68
+
69
+ When `TDD_MODE` is `true`, the planner agent is instructed to apply `type: tdd` to eligible tasks using heuristics from `references/tdd.md`. The planner's `<required_reading>` is extended to include `@~/.claude/get-shit-done/references/tdd.md` so gate enforcement rules are available during planning.
70
+
71
+ When `CONTEXT_WINDOW >= 500000`, the planner prompt includes the 3 most recent prior phase CONTEXT.md and SUMMARY.md files PLUS any phases explicitly listed in the current phase's `Depends on:` field in ROADMAP.md. Explicit dependencies always load regardless of recency (e.g., Phase 7 declaring `Depends on: Phase 2` always sees Phase 2's context). Bounded recency keeps the planner's context budget focused on recent work.
72
+
73
+ 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`, `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
+ **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.
78
+
79
+ **If `planning_exists` is false:** Error — run `/gsd-new-project` first.
80
+
81
+ ## 2. Parse and Normalize Arguments
82
+
83
+ Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--skip-ui`, `--prd <filepath>`, `--reviews`, `--text`, `--bounce`, `--skip-bounce`).
84
+
85
+ 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.
86
+
87
+ Extract `--prd <filepath>` from $ARGUMENTS. If present, set PRD_FILE to the filepath.
88
+
89
+ **If no phase number:** Detect next unplanned phase from roadmap.
90
+
91
+ **If `phase_found` is false:** Validate phase exists in ROADMAP.md. If valid, create the directory using `phase_slug` and `padded_phase` from init:
92
+ ```bash
93
+ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
94
+ ```
95
+
96
+ **Existing artifacts from init:** `has_research`, `has_plans`, `plan_count`.
97
+
98
+ ## 2.5. Validate `--reviews` Prerequisite
99
+
100
+ **Skip if:** No `--reviews` flag.
101
+
102
+ **If `--reviews` AND `--gaps`:** Error — cannot combine `--reviews` with `--gaps`. These are conflicting modes.
103
+
104
+ **If `--reviews` AND `has_reviews` is false (no REVIEWS.md in phase dir):**
105
+
106
+ Error:
107
+ ```
108
+ No REVIEWS.md found for Phase {N}. Run reviews first:
109
+
110
+ /gsd-review --phase {N}
111
+
112
+ Then re-run /gsd-plan-phase {N} --reviews
113
+ ```
114
+ Exit workflow.
115
+
116
+ ## 3. Validate Phase
117
+
118
+ ```bash
119
+ PHASE_INFO=$(gsd-remix-sdk query roadmap.get-phase "${PHASE}")
120
+ ```
121
+
122
+ **If `found` is false:** Error with available phases. **If `found` is true:** Extract `phase_number`, `phase_name`, `goal` from JSON.
123
+
124
+ ## 3.5. Handle PRD Express Path
125
+
126
+ **Skip if:** No `--prd` flag in arguments.
127
+
128
+ **If `--prd <filepath>` provided:**
129
+
130
+ 1. Read the PRD file:
131
+ ```bash
132
+ PRD_CONTENT=$(cat "$PRD_FILE" 2>/dev/null)
133
+ if [ -z "$PRD_CONTENT" ]; then
134
+ echo "Error: PRD file not found: $PRD_FILE"
135
+ exit 1
136
+ fi
137
+ ```
138
+
139
+ 2. Display banner:
140
+ ```
141
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
142
+ GSD ► PRD EXPRESS PATH
143
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+
145
+ Using PRD: {PRD_FILE}
146
+ Generating CONTEXT.md from requirements...
147
+ ```
148
+
149
+ 3. Parse the PRD content and generate CONTEXT.md. The orchestrator should:
150
+ - Extract all requirements, user stories, acceptance criteria, and constraints from the PRD
151
+ - Map each to a locked decision (everything in the PRD is treated as a locked decision)
152
+ - Identify any areas the PRD doesn't cover and mark as "Claude's Discretion"
153
+ - **Extract canonical refs** from ROADMAP.md for this phase, plus any specs/ADRs referenced in the PRD — expand to full file paths (MANDATORY)
154
+ - Create CONTEXT.md in the phase directory
155
+
156
+ 4. Write CONTEXT.md:
157
+ ```markdown
158
+ # Phase [X]: [Name] - Context
159
+
160
+ **Gathered:** [date]
161
+ **Status:** Ready for planning
162
+ **Source:** PRD Express Path ({PRD_FILE})
163
+
164
+ <domain>
165
+ ## Phase Boundary
166
+
167
+ [Extracted from PRD — what this phase delivers]
168
+
169
+ </domain>
170
+
171
+ <decisions>
172
+ ## Implementation Decisions
173
+
174
+ {For each requirement/story/criterion in the PRD:}
175
+ ### [Category derived from content]
176
+ - [Requirement as locked decision]
177
+
178
+ ### Claude's Discretion
179
+ [Areas not covered by PRD — implementation details, technical choices]
180
+
181
+ </decisions>
182
+
183
+ <canonical_refs>
184
+ ## Canonical References
185
+
186
+ **Downstream agents MUST read these before planning or implementing.**
187
+
188
+ [MANDATORY. Extract from ROADMAP.md and any docs referenced in the PRD.
189
+ Use full relative paths. Group by topic area.]
190
+
191
+ ### [Topic area]
192
+ - `path/to/spec-or-adr.md` — [What it decides/defines]
193
+
194
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
195
+
196
+ </canonical_refs>
197
+
198
+ <specifics>
199
+ ## Specific Ideas
200
+
201
+ [Any specific references, examples, or concrete requirements from PRD]
202
+
203
+ </specifics>
204
+
205
+ <deferred>
206
+ ## Deferred Ideas
207
+
208
+ [Items in PRD explicitly marked as future/v2/out-of-scope]
209
+ [If none: "None — PRD covers phase scope"]
210
+
211
+ </deferred>
212
+
213
+ ---
214
+
215
+ *Phase: XX-name*
216
+ *Context gathered: [date] via PRD Express Path*
217
+ ```
218
+
219
+ 5. Commit:
220
+ ```bash
221
+ gsd-remix-sdk query commit "docs(${padded_phase}): generate context from PRD" "${phase_dir}/${padded_phase}-CONTEXT.md"
222
+ ```
223
+
224
+ 6. Set `context_content` to the generated CONTEXT.md content and continue to step 5 (Handle Research).
225
+
226
+ **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.
227
+
228
+ ## 4. Load CONTEXT.md
229
+
230
+ **Skip if:** PRD express path was used (CONTEXT.md already created in step 3.5).
231
+
232
+ Check `context_path` from init JSON.
233
+
234
+ If `context_path` is not null, display: `Using phase context from: ${context_path}`
235
+
236
+ **If `context_path` is null (no CONTEXT.md exists):**
237
+
238
+ Read discuss mode for context gate label:
239
+ ```bash
240
+ DISCUSS_MODE=$(gsd-remix-sdk query config-get workflow.discuss_mode 2>/dev/null || echo "discuss")
241
+ ```
242
+
243
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
244
+ ```
245
+ No CONTEXT.md found for Phase {X}. Plans will use research and requirements only — your design preferences won't be included.
246
+
247
+ 1. Continue without context — Plan using research + requirements only
248
+ [If DISCUSS_MODE is "assumptions":]
249
+ 2. Gather context (assumptions mode) — Analyze codebase and surface assumptions before planning
250
+ [If DISCUSS_MODE is "discuss" or unset:]
251
+ 2. Run discuss-phase first — Capture design decisions before planning
252
+
253
+ Enter number:
254
+ ```
255
+
256
+ Otherwise use AskUserQuestion:
257
+ - header: "No context"
258
+ - 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?"
259
+ - options:
260
+ - "Continue without context" — Plan using research + requirements only
261
+ If `DISCUSS_MODE` is `"assumptions"`:
262
+ - "Gather context (assumptions mode)" — Analyze codebase and surface assumptions before planning
263
+ If `DISCUSS_MODE` is `"discuss"` (or unset):
264
+ - "Run discuss-phase first" — Capture design decisions before planning
265
+
266
+ If "Continue without context": Proceed to step 5.
267
+ If "Run discuss-phase first":
268
+ **IMPORTANT:** Do NOT invoke discuss-phase as a nested Skill/Task call — AskUserQuestion
269
+ does not work correctly in nested subcontexts (#1009). Instead, display the command
270
+ and exit so the user runs it as a top-level command:
271
+ ```
272
+ Run this command first, then re-run /gsd-plan-phase {X} ${GSD_WS}:
273
+
274
+ /gsd-discuss-phase {X} ${GSD_WS}
275
+ ```
276
+ **Exit the plan-phase workflow. Do not continue.**
277
+
278
+ ## 4.5. Check AI-SPEC
279
+
280
+ **Skip if:** `ai_integration_phase_enabled` from config is false, or `--skip-ai-spec` flag provided.
281
+
282
+ ```bash
283
+ AI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-AI-SPEC.md 2>/dev/null | head -1)
284
+ AI_PHASE_CFG=$(gsd-remix-sdk query config-get workflow.ai_integration_phase 2>/dev/null || echo "true")
285
+ ```
286
+
287
+ **Skip if `AI_PHASE_CFG` is `false`.**
288
+
289
+ **If `AI_SPEC_FILE` is empty:** Check phase goal for AI keywords:
290
+ ```bash
291
+ echo "${phase_goal}" | grep -qi "agent\|llm\|rag\|chatbot\|embedding\|langchain\|llamaindex\|crewai\|langgraph\|openai\|anthropic\|vector\|eval\|ai system"
292
+ ```
293
+
294
+ **If AI keywords detected AND no AI-SPEC.md:**
295
+ ```
296
+ ◆ Note: This phase appears to involve AI system development.
297
+ Consider running /gsd-ai-integration-phase {N} before planning to:
298
+ - Select the right framework for your use case
299
+ - Research its docs and best practices
300
+ - Design an evaluation strategy
301
+
302
+ Continue planning without AI-SPEC? (non-blocking — /gsd-ai-integration-phase can be run after)
303
+ ```
304
+
305
+ Use AskUserQuestion with options:
306
+ - "Continue — plan without AI-SPEC"
307
+ - "Stop — I'll run /gsd-ai-integration-phase {N} first"
308
+
309
+ If "Stop": Exit with `/gsd-ai-integration-phase {N}` reminder.
310
+ If "Continue": Proceed. (Non-blocking — planner will note AI-SPEC is absent.)
311
+
312
+ **If `AI_SPEC_FILE` is non-empty:** Extract framework for planner context:
313
+ ```bash
314
+ FRAMEWORK_LINE=$(grep "Selected Framework:" "${AI_SPEC_FILE}" | head -1)
315
+ ```
316
+ Pass `ai_spec_path` and `framework_line` to planner in step 7 so it can reference the AI design contract.
317
+
318
+ ## 5. Handle Research
319
+
320
+ **Skip if:** `--gaps` flag or `--skip-research` flag or `--reviews` flag.
321
+
322
+ **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
323
+
324
+ **If RESEARCH.md missing OR `--research` flag:**
325
+
326
+ **If no explicit flag (`--research` or `--skip-research`) and not `--auto`:**
327
+ Ask the user whether to research, with a contextual recommendation based on the phase:
328
+
329
+ If `TEXT_MODE` is true, present as a plain-text numbered list:
330
+ ```
331
+ Research before planning Phase {X}: {phase_name}?
332
+
333
+ 1. Research first (Recommended) — Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes.
334
+ 2. Skip research — Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks.
335
+
336
+ Enter number:
337
+ ```
338
+
339
+ Otherwise use AskUserQuestion:
340
+ ```
341
+ AskUserQuestion([
342
+ {
343
+ question: "Research before planning Phase {X}: {phase_name}?",
344
+ header: "Research",
345
+ multiSelect: false,
346
+ options: [
347
+ { label: "Research first (Recommended)", description: "Investigate domain, patterns, and dependencies before planning. Best for new features, unfamiliar integrations, or architectural changes." },
348
+ { label: "Skip research", description: "Plan directly from context and requirements. Best for bug fixes, simple refactors, or well-understood tasks." }
349
+ ]
350
+ }
351
+ ])
352
+ ```
353
+
354
+ If user selects "Skip research": skip to step 6.
355
+
356
+ **If `--auto` and `research_enabled` is false:** Skip research silently (preserves automated behavior).
357
+
358
+ Display banner:
359
+ ```
360
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
361
+ GSD ► RESEARCHING PHASE {X}
362
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
363
+
364
+ ◆ Spawning researcher...
365
+ ```
366
+
367
+ ### Spawn gsd-phase-researcher
368
+
369
+ ```bash
370
+ PHASE_DESC=$(gsd-remix-sdk query roadmap.get-phase "${PHASE}" --pick section)
371
+ ```
372
+
373
+ Research prompt:
374
+
375
+ ```markdown
376
+ <objective>
377
+ Research how to implement Phase {phase_number}: {phase_name}
378
+ Answer: "What do I need to know to PLAN this phase well?"
379
+ </objective>
380
+
381
+ <files_to_read>
382
+ - {context_path} (USER DECISIONS from /gsd-discuss-phase)
383
+ - {requirements_path} (Project requirements)
384
+ - {state_path} (Project decisions and history)
385
+ </files_to_read>
386
+
387
+ ${AGENT_SKILLS_RESEARCHER}
388
+
389
+ <additional_context>
390
+ **Phase description:** {phase_description}
391
+ **Phase requirement IDs (MUST address):** {phase_req_ids}
392
+
393
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
394
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, research should account for project skill patterns
395
+ </additional_context>
396
+
397
+ <output>
398
+ Write to: {phase_dir}/{phase_num}-RESEARCH.md
399
+ </output>
400
+ ```
401
+
402
+ ```
403
+ Task(
404
+ prompt=research_prompt,
405
+ subagent_type="gsd-phase-researcher",
406
+ model="{researcher_model}",
407
+ description="Research Phase {phase}"
408
+ )
409
+ ```
410
+
411
+ ### Handle Researcher Return
412
+
413
+ - **`## RESEARCH COMPLETE`:** Display confirmation, continue to step 6
414
+ - **`## RESEARCH BLOCKED`:** Display blocker, offer: 1) Provide context, 2) Skip research, 3) Abort
415
+
416
+ ## 5.5. Create Validation Strategy
417
+
418
+ Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
419
+
420
+ 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.
421
+
422
+ **But Nyquist is not applicable for this run** when all of the following are true:
423
+ - `research_enabled` is false
424
+ - `has_research` is false
425
+ - no `--research` flag was provided
426
+
427
+ In that case: **skip validation-strategy creation entirely**. Do **not** expect `RESEARCH.md` or `VALIDATION.md` for this run, and continue to Step 6.
428
+
429
+ ```bash
430
+ grep -l "## Validation Architecture" "${PHASE_DIR}"/*-RESEARCH.md 2>/dev/null || true
431
+ ```
432
+
433
+ **If found:**
434
+ 1. Read template: `~/.claude/get-shit-done/templates/VALIDATION.md`
435
+ 2. Write to `${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md` (use Write tool)
436
+ 3. Fill frontmatter: `{N}` → phase number, `{phase-slug}` → slug, `{date}` → current date
437
+ 4. Verify:
438
+ ```bash
439
+ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED=true" || echo "VALIDATION_CREATED=false"
440
+ ```
441
+ 5. If `VALIDATION_CREATED=false`: STOP — do not proceed to Step 6
442
+ 6. If `commit_docs`: `commit "docs(phase-${PHASE}): add validation strategy"`
443
+
444
+ **If not found:** Warn and continue — plans may fail Dimension 8.
445
+
446
+ ## 5.55. Security Threat Model Gate
447
+
448
+ > Skip if `workflow.security_enforcement` is explicitly `false`. Absent = enabled.
449
+
450
+ ```bash
451
+ SECURITY_CFG=$(gsd-remix-sdk query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
452
+ SECURITY_ASVS=$(gsd-remix-sdk query config-get workflow.security_asvs_level --raw 2>/dev/null || echo "1")
453
+ SECURITY_BLOCK=$(gsd-remix-sdk query config-get workflow.security_block_on --raw 2>/dev/null || echo "high")
454
+ ```
455
+
456
+ **If `SECURITY_CFG` is `false`:** Skip to step 5.6.
457
+
458
+ **If `SECURITY_CFG` is `true`:** Display banner:
459
+
460
+ ```
461
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
462
+ GSD ► SECURITY THREAT MODEL REQUIRED (ASVS L{SECURITY_ASVS})
463
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
464
+
465
+ Each PLAN.md must include a <threat_model> block.
466
+ Block on: {SECURITY_BLOCK} severity threats.
467
+ Opt out: set security_enforcement: false in .planning/config.json
468
+ ```
469
+
470
+ Continue to step 5.6. Security config is passed to the planner in step 8.
471
+
472
+ ## 5.6. UI Design Contract Gate
473
+
474
+ > 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.
475
+
476
+ ```bash
477
+ UI_PHASE_CFG=$(gsd-remix-sdk query config-get workflow.ui_phase 2>/dev/null || echo "true")
478
+ UI_GATE_CFG=$(gsd-remix-sdk query config-get workflow.ui_safety_gate 2>/dev/null || echo "true")
479
+ ```
480
+
481
+ **If both are `false`:** Skip to step 6.
482
+
483
+ Check if phase has frontend indicators:
484
+
485
+ ```bash
486
+ PHASE_SECTION=$(gsd-remix-sdk query roadmap.get-phase "${PHASE}" 2>/dev/null)
487
+ echo "$PHASE_SECTION" | grep -iE "UI|interface|frontend|component|layout|page|screen|view|form|dashboard|widget" > /dev/null 2>&1
488
+ HAS_UI=$?
489
+ ```
490
+
491
+ **If `HAS_UI` is 0 (frontend indicators found):**
492
+
493
+ Check for existing UI-SPEC:
494
+ ```bash
495
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
496
+ ```
497
+
498
+ **If UI-SPEC.md found:** Set `UI_SPEC_PATH=$UI_SPEC_FILE`. Display: `Using UI design contract: ${UI_SPEC_PATH}`
499
+
500
+ **If UI-SPEC.md missing AND `--skip-ui` flag is present in $ARGUMENTS:** Skip silently to step 6.
501
+
502
+ **If UI-SPEC.md missing AND `UI_GATE_CFG` is `true`:**
503
+
504
+ Read ephemeral chain flag (same field as `check.auto-mode` → `auto_chain_active`):
505
+ ```bash
506
+ AUTO_CHAIN=$(gsd-remix-sdk query check auto-mode --pick auto_chain_active 2>/dev/null || echo "false")
507
+ ```
508
+
509
+ **If `AUTO_CHAIN` is `true` (running inside a `--chain` or `--auto` pipeline):**
510
+
511
+ Auto-generate UI-SPEC without prompting:
512
+ ```
513
+ Skill(skill="gsd-ui-phase", args="${PHASE} --auto ${GSD_WS}")
514
+ ```
515
+ After `gsd-ui-phase` returns, re-read:
516
+ ```bash
517
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
518
+ UI_SPEC_PATH="${UI_SPEC_FILE}"
519
+ ```
520
+ Continue to step 6.
521
+
522
+ **If `AUTO_CHAIN` is `false` (manual invocation):**
523
+
524
+ Output this markdown directly (not as a code block):
525
+
526
+ ```
527
+ ## ⚠ UI-SPEC.md missing for Phase {N}
528
+ ▶ Recommended next step:
529
+ `/gsd-ui-phase {N} ${GSD_WS}` — generate UI design contract before planning
530
+ ───────────────────────────────────────────────
531
+ Also available:
532
+ - `/gsd-plan-phase {N} --skip-ui ${GSD_WS}` — plan without UI-SPEC (not recommended for frontend phases)
533
+ ```
534
+
535
+ **Exit the plan-phase workflow. Do not continue.**
536
+
537
+ **If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 5.7.
538
+
539
+ ## 5.7. Schema Push Detection Gate
540
+
541
+ > Detects schema-relevant files in the phase scope and injects a mandatory `[BLOCKING]` schema push task into the plan. Prevents false-positive verification where build/types pass because TypeScript types come from config, not the live database.
542
+
543
+ Check if any files in the phase scope match schema patterns:
544
+
545
+ ```bash
546
+ PHASE_SECTION=$(gsd-remix-sdk query roadmap.get-phase "${PHASE}" --pick section 2>/dev/null)
547
+ ```
548
+
549
+ Scan `PHASE_SECTION`, `CONTEXT.md` (if loaded), and `RESEARCH.md` (if exists) for file paths matching these ORM patterns:
550
+
551
+ | ORM | File Patterns |
552
+ |-----|--------------|
553
+ | Payload CMS | `src/collections/**/*.ts`, `src/globals/**/*.ts` |
554
+ | Prisma | `prisma/schema.prisma`, `prisma/schema/*.prisma` |
555
+ | Drizzle | `drizzle/schema.ts`, `src/db/schema.ts`, `drizzle/*.ts` |
556
+ | Supabase | `supabase/migrations/*.sql` |
557
+ | TypeORM | `src/entities/**/*.ts`, `src/migrations/**/*.ts` |
558
+
559
+ Also check if any existing PLAN.md files for this phase already reference these file patterns in `files_modified`.
560
+
561
+ **If schema-relevant files detected:**
562
+
563
+ Set `SCHEMA_PUSH_REQUIRED=true` and `SCHEMA_ORM={detected_orm}`.
564
+
565
+ Determine the push command for the detected ORM:
566
+
567
+ | ORM | Push Command | Non-TTY Workaround |
568
+ |-----|-------------|-------------------|
569
+ | Payload CMS | `npx payload migrate` | `CI=true PAYLOAD_MIGRATING=true npx payload migrate` |
570
+ | Prisma | `npx prisma db push` | `npx prisma db push --accept-data-loss` (if destructive) |
571
+ | Drizzle | `npx drizzle-kit push` | `npx drizzle-kit push` |
572
+ | Supabase | `supabase db push` | Set `SUPABASE_ACCESS_TOKEN` env var |
573
+ | TypeORM | `npx typeorm migration:run` | `npx typeorm migration:run -d src/data-source.ts` |
574
+
575
+ Inject the following into the planner prompt (step 8) as an additional constraint:
576
+
577
+ ```markdown
578
+ <schema_push_requirement>
579
+ **[BLOCKING] Schema Push Required**
580
+
581
+ This phase modifies schema-relevant files ({detected_files}). The planner MUST include
582
+ a `[BLOCKING]` task that runs the database schema push command AFTER all schema file
583
+ modifications are complete but BEFORE verification.
584
+
585
+ - ORM detected: {SCHEMA_ORM}
586
+ - Push command: {push_command}
587
+ - Non-TTY workaround: {env_hint}
588
+ - If push requires interactive prompts that cannot be suppressed, flag the task for
589
+ manual intervention with `autonomous: false`
590
+
591
+ This task is mandatory — the phase CANNOT pass verification without it. Build and
592
+ type checks will pass without the push (types come from config, not the live database),
593
+ creating a false-positive verification state.
594
+ </schema_push_requirement>
595
+ ```
596
+
597
+ Display: `Schema files detected ({SCHEMA_ORM}) — [BLOCKING] push task will be injected into plans`
598
+
599
+ **If no schema-relevant files detected:** Skip silently to step 6.
600
+
601
+ ## 6. Check Existing Plans
602
+
603
+ ```bash
604
+ ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null || true
605
+ ```
606
+
607
+ **If exists AND `--reviews` flag:** Skip prompt — go straight to replanning (the purpose of `--reviews` is to replan with review feedback).
608
+
609
+ **If exists AND no `--reviews` flag:** Offer: 1) Add more plans, 2) View existing, 3) Replan from scratch.
610
+
611
+ ## 7. Use Context Paths from INIT
612
+
613
+ Extract from INIT JSON:
614
+
615
+ ```bash
616
+ _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"; }
617
+ STATE_PATH=$(_gsd_field "$INIT" state_path)
618
+ ROADMAP_PATH=$(_gsd_field "$INIT" roadmap_path)
619
+ REQUIREMENTS_PATH=$(_gsd_field "$INIT" requirements_path)
620
+ RESEARCH_PATH=$(_gsd_field "$INIT" research_path)
621
+ VERIFICATION_PATH=$(_gsd_field "$INIT" verification_path)
622
+ UAT_PATH=$(_gsd_field "$INIT" uat_path)
623
+ CONTEXT_PATH=$(_gsd_field "$INIT" context_path)
624
+ REVIEWS_PATH=$(_gsd_field "$INIT" reviews_path)
625
+ PATTERNS_PATH=$(_gsd_field "$INIT" patterns_path)
626
+
627
+ # Detect spike/sketch findings skills (project-local)
628
+ SPIKE_FINDINGS_PATH=$(ls ./.claude/skills/spike-findings-*/SKILL.md 2>/dev/null | head -1)
629
+ SKETCH_FINDINGS_PATH=$(ls ./.claude/skills/sketch-findings-*/SKILL.md 2>/dev/null | head -1)
630
+ ```
631
+
632
+ ## 7.5. Verify Nyquist Artifacts
633
+
634
+ Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
635
+
636
+ Also skip if all of the following are true:
637
+ - `research_enabled` is false
638
+ - `has_research` is false
639
+ - no `--research` flag was provided
640
+
641
+ In that no-research path, Nyquist artifacts are **not required** for this run.
642
+
643
+ ```bash
644
+ VALIDATION_EXISTS=$(ls "${PHASE_DIR}"/*-VALIDATION.md 2>/dev/null | head -1)
645
+ ```
646
+
647
+ If missing and Nyquist is still enabled/applicable — ask user:
648
+ 1. Re-run: `/gsd-plan-phase {PHASE} --research ${GSD_WS}`
649
+ 2. Disable Nyquist with the exact command:
650
+ `gsd-remix-sdk query config-set workflow.nyquist_validation false`
651
+ 3. Continue anyway (plans fail Dimension 8)
652
+
653
+ Proceed to Step 7.8 (or Step 8 if pattern mapper is disabled) only if user selects 2 or 3.
654
+
655
+ ## 7.8. Spawn gsd-pattern-mapper Agent (Optional)
656
+
657
+ **Skip if** `workflow.pattern_mapper` is explicitly set to `false` in config.json (absent key = enabled). Also skip if no CONTEXT.md and no RESEARCH.md exist for this phase (nothing to extract file lists from).
658
+
659
+ Check config:
660
+ ```bash
661
+ PATTERN_MAPPER_CFG=$(gsd-remix-sdk query config-get workflow.pattern_mapper 2>/dev/null || echo "true")
662
+ ```
663
+
664
+ **If `PATTERN_MAPPER_CFG` is `false`:** Skip to step 8.
665
+
666
+ **If PATTERNS.md already exists** (`PATTERNS_PATH` is non-empty from step 7): Skip to step 8 (use existing).
667
+
668
+ Display banner:
669
+ ```
670
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
671
+ GSD ► PATTERN MAPPING PHASE {X}
672
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
673
+
674
+ ◆ Spawning pattern mapper...
675
+ ```
676
+
677
+ Pattern mapper prompt:
678
+
679
+ ```markdown
680
+ <pattern_mapping_context>
681
+ **Phase:** {phase_number} - {phase_name}
682
+ **Phase directory:** {phase_dir}
683
+ **Padded phase:** {padded_phase}
684
+
685
+ <files_to_read>
686
+ - {context_path} (USER DECISIONS from /gsd-discuss-phase)
687
+ - {research_path} (Technical Research)
688
+ </files_to_read>
689
+
690
+ **Output file:** {phase_dir}/{padded_phase}-PATTERNS.md
691
+
692
+ Extract the list of files to be created/modified from CONTEXT.md and RESEARCH.md. For each file, classify by role and data flow, find the closest existing analog in the codebase, extract concrete code excerpts, and produce PATTERNS.md.
693
+ </pattern_mapping_context>
694
+ ```
695
+
696
+ Spawn with:
697
+ ```
698
+ Task(
699
+ prompt="{above}",
700
+ subagent_type="gsd-pattern-mapper",
701
+ model="{researcher_model}",
702
+ )
703
+ ```
704
+
705
+ **Handle return:**
706
+ - **`## PATTERN MAPPING COMPLETE`:** Update `PATTERNS_PATH` to the created file path, continue to step 8.
707
+ - **Any error or empty return:** Log warning, continue to step 8 without patterns (non-blocking).
708
+
709
+ After pattern mapper completes, update the path variable:
710
+ ```bash
711
+ PATTERNS_PATH="${PHASE_DIR}/${PADDED_PHASE}-PATTERNS.md"
712
+ ```
713
+
714
+ ## 8. Spawn gsd-planner Agent
715
+
716
+ Display banner:
717
+ ```
718
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
719
+ GSD ► PLANNING PHASE {X}
720
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
721
+
722
+ ◆ Spawning planner...
723
+ ```
724
+
725
+ Planner prompt:
726
+
727
+ ```markdown
728
+ <planning_context>
729
+ **Phase:** {phase_number}
730
+ **Mode:** {standard | gap_closure | reviews}
731
+
732
+ <files_to_read>
733
+ - {state_path} (Project State)
734
+ - {roadmap_path} (Roadmap)
735
+ - {requirements_path} (Requirements)
736
+ - {context_path} (USER DECISIONS from /gsd-discuss-phase)
737
+ - {research_path} (Technical Research)
738
+ - {PATTERNS_PATH} (Pattern Map — analog files and code excerpts, if exists)
739
+ - {verification_path} (Verification Gaps - if --gaps)
740
+ - {uat_path} (UAT Gaps - if --gaps)
741
+ - {reviews_path} (Cross-AI Review Feedback - if --reviews)
742
+ - {UI_SPEC_PATH} (UI Design Contract — visual/interaction specs, if exists)
743
+ - {SPIKE_FINDINGS_PATH} (Spike Findings — validated patterns, constraints, landmines from experiments, if exists)
744
+ - {SKETCH_FINDINGS_PATH} (Sketch Findings — validated design decisions, CSS patterns, visual direction, if exists)
745
+ ${CONTEXT_WINDOW >= 500000 ? `
746
+ **Cross-phase context (1M model enrichment):**
747
+ - CONTEXT.md files from the 3 most recent completed phases (locked decisions — maintain consistency)
748
+ - SUMMARY.md files from the 3 most recent completed phases (what was built — reuse patterns, avoid duplication)
749
+ - LEARNINGS.md files from the 3 most recent completed phases (structured decisions, patterns, lessons, surprises — skip silently if a phase has no LEARNINGS.md; prefix each block with \`[from Phase N LEARNINGS]\` for source attribution; if total size exceeds 15% of context budget, drop oldest first)
750
+ - CONTEXT.md, SUMMARY.md, and LEARNINGS.md from any phases listed in the current phase's "Depends on:" field in ROADMAP.md (regardless of recency — explicit dependencies always load, deduplicated against the 3 most recent)
751
+ - Skip all other prior phases to stay within context budget
752
+ ` : ''}
753
+ </files_to_read>
754
+
755
+ ${AGENT_SKILLS_PLANNER}
756
+
757
+ **Phase requirement IDs (every ID MUST appear in a plan's `requirements` field):** {phase_req_ids}
758
+
759
+ **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
760
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, plans should account for project skill rules
761
+
762
+ ${TDD_MODE === 'true' ? `
763
+ <tdd_mode_active>
764
+ **TDD Mode is ENABLED.** Apply TDD heuristics from @~/.claude/get-shit-done/references/tdd.md to all eligible tasks:
765
+ - Business logic with defined I/O → type: tdd
766
+ - API endpoints with request/response contracts → type: tdd
767
+ - Data transformations, validation, algorithms → type: tdd
768
+ - UI, config, glue code, CRUD → standard plan (type: execute)
769
+ Each TDD plan gets one feature with RED/GREEN/REFACTOR gate sequence.
770
+ </tdd_mode_active>
771
+ ` : ''}
772
+ </planning_context>
773
+
774
+ <downstream_consumer>
775
+ Output consumed by /gsd-execute-phase. Plans need:
776
+ - Frontmatter (wave, depends_on, files_modified, autonomous)
777
+ - Tasks in XML format with read_first and acceptance_criteria fields (MANDATORY on every task)
778
+ - Verification criteria
779
+ - must_haves for goal-backward verification
780
+ </downstream_consumer>
781
+
782
+ <deep_work_rules>
783
+ ## Anti-Shallow Execution Rules (MANDATORY)
784
+
785
+ Every task MUST include these fields — they are NOT optional:
786
+
787
+ 1. **`<read_first>`** — Files the executor MUST read before touching anything. Always include:
788
+ - The file being modified (so executor sees current state, not assumptions)
789
+ - Any "source of truth" file referenced in CONTEXT.md (reference implementations, existing patterns, config files, schemas)
790
+ - Any file whose patterns, signatures, types, or conventions must be replicated or respected
791
+
792
+ 2. **`<acceptance_criteria>`** — Verifiable conditions that prove the task was done correctly. Rules:
793
+ - Every criterion must be checkable with grep, file read, test command, or CLI output
794
+ - NEVER use subjective language ("looks correct", "properly configured", "consistent with")
795
+ - ALWAYS include exact strings, patterns, values, or command outputs that must be present
796
+ - Examples:
797
+ - Code: `auth.py contains def verify_token(` / `test_auth.py exits 0`
798
+ - Config: `.env.example contains DATABASE_URL=` / `Dockerfile contains HEALTHCHECK`
799
+ - Docs: `README.md contains '## Installation'` / `API.md lists all endpoints`
800
+ - Infra: `deploy.yml has rollback step` / `docker-compose.yml has healthcheck for db`
801
+
802
+ 3. **`<action>`** — Must include CONCRETE values, not references. Rules:
803
+ - NEVER say "align X with Y", "match X to Y", "update to be consistent" without specifying the exact target state
804
+ - ALWAYS include the actual values: config keys, function signatures, SQL statements, class names, import paths, env vars, etc.
805
+ - If CONTEXT.md has a comparison table or expected values, copy them into the action verbatim
806
+ - 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)
807
+
808
+ **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 DATABASE_URL=postgresql://... , set POOL_SIZE=20, add REDIS_URL=redis://..." produce complete work. The cost of verbose plans is far less than the cost of re-doing shallow execution.
809
+ </deep_work_rules>
810
+
811
+ <quality_gate>
812
+ - [ ] PLAN.md files created in phase directory
813
+ - [ ] Each plan has valid frontmatter
814
+ - [ ] Tasks are specific and actionable
815
+ - [ ] Every task has `<read_first>` with at least the file being modified
816
+ - [ ] Every task has `<acceptance_criteria>` with grep-verifiable conditions
817
+ - [ ] Every `<action>` contains concrete values (no "align X with Y" without specifying what)
818
+ - [ ] Dependencies correctly identified
819
+ - [ ] Waves assigned for parallel execution
820
+ - [ ] must_haves derived from phase goal
821
+ </quality_gate>
822
+ ```
823
+
824
+ ```
825
+ Task(
826
+ prompt=filled_prompt,
827
+ subagent_type="gsd-planner",
828
+ model="{planner_model}",
829
+ description="Plan Phase {phase}"
830
+ )
831
+ ```
832
+
833
+ ## 9. Handle Planner Return
834
+
835
+ - **`## PLANNING COMPLETE`:** Display plan count. If `--skip-verify` or `plan_checker_enabled` is false (from init): skip to step 13. Otherwise: step 10.
836
+ - **`## PHASE SPLIT RECOMMENDED`:** The planner determined the phase exceeds the context budget for full-fidelity implementation of all source items. Handle in step 9b.
837
+ - **`## ⚠ Source Audit: Unplanned Items Found`:** The planner's multi-source coverage audit found items from REQUIREMENTS.md, RESEARCH.md, ROADMAP goal, or CONTEXT.md decisions that are not covered by any plan. Handle in step 9c.
838
+ - **`## CHECKPOINT REACHED`:** Present to user, get response, spawn continuation (step 12)
839
+ - **`## PLANNING INCONCLUSIVE`:** Show attempts, offer: Add context / Retry / Manual
840
+
841
+ ## 9b. Handle Phase Split Recommendation
842
+
843
+ When the planner returns `## PHASE SPLIT RECOMMENDED`, it means the phase's source items exceed the context budget for full-fidelity implementation. The planner proposes groupings.
844
+
845
+ **Extract from planner return:**
846
+ - Proposed sub-phases (e.g., "17a: processing core (D-01 to D-19)", "17b: billing + config UX (D-20 to D-27)")
847
+ - Which source items (REQ-IDs, D-XX decisions, RESEARCH items) go in each sub-phase
848
+ - Why the split is necessary (context cost estimate, file count)
849
+
850
+ **Present to user:**
851
+ ```
852
+ ## Phase {X} exceeds context budget for full-fidelity implementation
853
+
854
+ The planner found {N} source items that exceed the context budget when
855
+ planned at full fidelity. Instead of reducing scope, we recommend splitting:
856
+
857
+ **Option 1: Split into sub-phases**
858
+ - Phase {X}a: {name} — {items} ({N} source items, ~{P}% context)
859
+ - Phase {X}b: {name} — {items} ({M} source items, ~{Q}% context)
860
+
861
+ **Option 2: Proceed anyway** (planner will attempt all, quality may degrade past 50% context)
862
+
863
+ **Option 3: Prioritize** — you choose which items to implement now,
864
+ rest become a follow-up phase
865
+ ```
866
+
867
+ Use AskUserQuestion with these 3 options.
868
+
869
+ **If "Split":** Use `/gsd-insert-phase` to create the sub-phases, then replan each.
870
+ **If "Proceed":** Return to planner with instruction to attempt all items at full fidelity, accepting more plans/tasks.
871
+ **If "Prioritize":** Use AskUserQuestion (multiSelect) to let user pick which items are "now" vs "later". Create CONTEXT.md for each sub-phase with the selected items.
872
+
873
+ ## 9c. Handle Source Audit Gaps
874
+
875
+ When the planner returns `## ⚠ Source Audit: Unplanned Items Found`, it means items from REQUIREMENTS.md, RESEARCH.md, ROADMAP goal, or CONTEXT.md decisions have no corresponding plan.
876
+
877
+ **Extract from planner return:**
878
+ - Each unplanned item with its source artifact and section
879
+ - The planner's suggested options (A: add plan, B: split phase, C: defer with confirmation)
880
+
881
+ **Present each gap to user.** For each unplanned item:
882
+
883
+ ```
884
+ ## ⚠ Unplanned: {item description}
885
+
886
+ Source: {RESEARCH.md / REQUIREMENTS.md / ROADMAP goal / CONTEXT.md}
887
+ Details: {why the planner flagged this}
888
+
889
+ Options:
890
+ 1. Add a plan to cover this item (recommended)
891
+ 2. Split phase — move to a sub-phase with related items
892
+ 3. Defer — add to backlog (developer confirms this is intentional)
893
+ ```
894
+
895
+ Use AskUserQuestion for each gap (or batch if multiple gaps).
896
+
897
+ **If "Add plan":** Return to planner (step 8) with instruction to add plans covering the missing items, preserving existing plans.
898
+ **If "Split":** Use `/gsd-insert-phase` for overflow items, then replan.
899
+ **If "Defer":** Record in CONTEXT.md `## Deferred Ideas` with developer's confirmation. Proceed to step 10.
900
+
901
+ ## 10. Spawn gsd-plan-checker Agent
902
+
903
+ Display banner:
904
+ ```
905
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
906
+ GSD ► VERIFYING PLANS
907
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
908
+
909
+ ◆ Spawning plan checker...
910
+ ```
911
+
912
+ Checker prompt:
913
+
914
+ ```markdown
915
+ <verification_context>
916
+ **Phase:** {phase_number}
917
+ **Phase Goal:** {goal from ROADMAP}
918
+
919
+ <files_to_read>
920
+ - {PHASE_DIR}/*-PLAN.md (Plans to verify)
921
+ - {roadmap_path} (Roadmap)
922
+ - {requirements_path} (Requirements)
923
+ - {context_path} (USER DECISIONS from /gsd-discuss-phase)
924
+ - {research_path} (Technical Research — includes Validation Architecture)
925
+ </files_to_read>
926
+
927
+ ${AGENT_SKILLS_CHECKER}
928
+
929
+ **Phase requirement IDs (MUST ALL be covered):** {phase_req_ids}
930
+
931
+ **Project instructions:** Read ./CLAUDE.md if exists — verify plans honor project guidelines
932
+ **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — verify plans account for project skill rules
933
+ </verification_context>
934
+
935
+ <expected_output>
936
+ - ## VERIFICATION PASSED — all checks pass
937
+ - ## ISSUES FOUND — structured issue list
938
+ </expected_output>
939
+ ```
940
+
941
+ ```
942
+ Task(
943
+ prompt=checker_prompt,
944
+ subagent_type="gsd-plan-checker",
945
+ model="{checker_model}",
946
+ description="Verify Phase {phase} plans"
947
+ )
948
+ ```
949
+
950
+ ## 11. Handle Checker Return
951
+
952
+ - **`## VERIFICATION PASSED`:** Display confirmation, proceed to step 13.
953
+ - **`## ISSUES FOUND`:** Display issues, check iteration count, proceed to step 12.
954
+
955
+ **Thinking partner for architectural tradeoffs (conditional):**
956
+ If `features.thinking_partner` is enabled, scan the checker's issues for architectural tradeoff keywords
957
+ ("architecture", "approach", "strategy", "pattern", "vs", "alternative"). If found:
958
+
959
+ ```
960
+ The plan-checker flagged an architectural decision point:
961
+ {issue description}
962
+
963
+ Brief analysis:
964
+ - Option A: {approach_from_plan} — {pros/cons}
965
+ - Option B: {alternative_approach} — {pros/cons}
966
+ - Recommendation: {choice} aligned with {phase_goal}
967
+
968
+ Apply this to the revision? [Yes] / [No, I'll decide]
969
+ ```
970
+
971
+ If yes: include the recommendation in the revision prompt. If no: proceed to revision loop as normal.
972
+ If thinking_partner disabled: skip this block entirely.
973
+
974
+ ## 12. Revision Loop (Max 3 Iterations)
975
+
976
+ Track `iteration_count` (starts at 1 after initial plan + check).
977
+ Track `prev_issue_count` (initialized to `Infinity` before the loop begins).
978
+ Track `stall_reentry_count` (starts at 0; incremented each time "Adjust approach" re-enters step 8).
979
+
980
+ **If iteration_count < 3:**
981
+
982
+ Parse issue count from checker return: count BLOCKER + WARNING entries in the YAML issues block (structured output from gsd-plan-checker). If the checker's return contains no YAML issues block (i.e., the plan was approved with no issues), treat `issue_count` as 0 and skip the stall check — the plan passed. Proceed to step 13.
983
+
984
+ Display: `Revision iteration {N}/3 -- {blocker_count} blockers, {warning_count} warnings`
985
+
986
+ **Stall detection:** If `issue_count >= prev_issue_count`:
987
+ Display: `Revision loop stalled — issue count not decreasing ({issue_count} issues remain after {N} iterations)`
988
+
989
+ **If `stall_reentry_count < 2`:**
990
+ Ask user:
991
+ Question: "Issues remain after {N} revision attempts with no progress. Proceed with current output?"
992
+ Options: "Proceed anyway" | "Adjust approach"
993
+ If "Proceed anyway": accept current plans and continue to step 13.
994
+ If "Adjust approach": increment `stall_reentry_count`, open freeform discussion, then re-enter step 8 (full replanning). Note: re-entry resets `iteration_count` and `prev_issue_count` but `stall_reentry_count` persists across re-entries and is capped at 2.
995
+
996
+ **If `stall_reentry_count >= 2`:**
997
+ Display: `Stall persists after 2 re-planning attempts. The following issues could not be resolved automatically:`
998
+ List the remaining issues from the checker.
999
+ Suggest: "Consider resolving these issues manually or running `/gsd-debug` to investigate root causes."
1000
+ Options: "Proceed anyway" | "Abandon"
1001
+ If "Proceed anyway": accept current plans and continue to step 13.
1002
+ If "Abandon": stop workflow.
1003
+
1004
+ Set `prev_issue_count = issue_count`.
1005
+
1006
+ Revision prompt:
1007
+
1008
+ ```markdown
1009
+ <revision_context>
1010
+ **Phase:** {phase_number}
1011
+ **Mode:** revision
1012
+
1013
+ <files_to_read>
1014
+ - {PHASE_DIR}/*-PLAN.md (Existing plans)
1015
+ - {context_path} (USER DECISIONS from /gsd-discuss-phase)
1016
+ </files_to_read>
1017
+
1018
+ ${AGENT_SKILLS_PLANNER}
1019
+
1020
+ **Checker issues:** {structured_issues_from_checker}
1021
+ </revision_context>
1022
+
1023
+ <instructions>
1024
+ Make targeted updates to address checker issues.
1025
+ Do NOT replan from scratch unless issues are fundamental.
1026
+ Return what changed.
1027
+ </instructions>
1028
+ ```
1029
+
1030
+ ```
1031
+ Task(
1032
+ prompt=revision_prompt,
1033
+ subagent_type="gsd-planner",
1034
+ model="{planner_model}",
1035
+ description="Revise Phase {phase} plans"
1036
+ )
1037
+ ```
1038
+
1039
+ After planner returns -> spawn checker again (step 10), increment iteration_count.
1040
+
1041
+ **If iteration_count >= 3:**
1042
+
1043
+ Display: `Max iterations reached. {N} issues remain:` + issue list
1044
+
1045
+ Offer: 1) Force proceed, 2) Provide guidance and retry, 3) Abandon
1046
+
1047
+ ## 12.5. Plan Bounce (Optional External Refinement)
1048
+
1049
+ **Skip if:** `--skip-bounce` flag, `--gaps` flag, or bounce is not activated.
1050
+
1051
+ **Activation:** Bounce runs when `--bounce` flag is present OR `workflow.plan_bounce` config is `true`. The `--skip-bounce` flag always wins (disables bounce even if config enables it). The `--gaps` flag also disables bounce (gap-closure mode should not modify plans externally).
1052
+
1053
+ **Prerequisites:** `workflow.plan_bounce_script` must be set to a valid script path. If bounce is activated but no script is configured, display warning and skip:
1054
+ ```
1055
+ ⚠ Plan bounce activated but no script configured.
1056
+ Set workflow.plan_bounce_script to the path of your refinement script.
1057
+ Skipping bounce step.
1058
+ ```
1059
+
1060
+ **Read pass count:**
1061
+ ```bash
1062
+ BOUNCE_PASSES=$(gsd-remix-sdk query config-get workflow.plan_bounce_passes 2>/dev/null || echo "2")
1063
+ BOUNCE_SCRIPT=$(gsd-remix-sdk query config-get workflow.plan_bounce_script 2>/dev/null | jq -r '.' 2>/dev/null || true)
1064
+ ```
1065
+
1066
+ Display banner:
1067
+ ```
1068
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1069
+ GSD ► BOUNCING PLANS (External Refinement)
1070
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1071
+
1072
+ Script: ${BOUNCE_SCRIPT}
1073
+ Max passes: ${BOUNCE_PASSES}
1074
+ ```
1075
+
1076
+ **For each PLAN.md file in the phase directory:**
1077
+
1078
+ 1. **Backup:** Copy `*-PLAN.md` to `*-PLAN.pre-bounce.md`
1079
+ ```bash
1080
+ cp "${PLAN_FILE}" "${PLAN_FILE%.md}.pre-bounce.md"
1081
+ ```
1082
+
1083
+ 2. **Invoke bounce script:**
1084
+ ```bash
1085
+ "${BOUNCE_SCRIPT}" "${PLAN_FILE}" "${BOUNCE_PASSES}"
1086
+ ```
1087
+
1088
+ 3. **Validate bounced plan — YAML frontmatter integrity:**
1089
+ After the script returns, check that the bounced file still has valid YAML frontmatter (opening and closing `---` delimiters with parseable content between them). If the bounced plan breaks YAML frontmatter validation, restore the original from the pre-bounce.md backup and continue to the next plan:
1090
+ ```
1091
+ ⚠ Bounced plan ${PLAN_FILE} has broken YAML frontmatter — restoring original from pre-bounce backup.
1092
+ ```
1093
+
1094
+ 4. **Handle script failure:** If the bounce script exits non-zero, restore the original plan from the pre-bounce.md backup and continue to the next plan:
1095
+ ```
1096
+ ⚠ Bounce script failed for ${PLAN_FILE} (exit code ${EXIT_CODE}) — restoring original from pre-bounce backup.
1097
+ ```
1098
+
1099
+ **After all plans are bounced:**
1100
+
1101
+ 5. **Re-run plan checker on bounced plans:** Spawn gsd-plan-checker (same as step 10) on all modified plans. If a bounced plan fails the checker, restore original from its pre-bounce.md backup:
1102
+ ```
1103
+ ⚠ Bounced plan ${PLAN_FILE} failed checker validation — restoring original from pre-bounce backup.
1104
+ ```
1105
+
1106
+ 6. **Commit surviving bounced plans:** If at least one plan survived both the frontmatter validation and the checker re-run, commit the changes:
1107
+ ```bash
1108
+ gsd-remix-sdk query commit "refactor(${padded_phase}): bounce plans through external refinement" "${PHASE_DIR}/*-PLAN.md"
1109
+ ```
1110
+
1111
+ Display summary:
1112
+ ```
1113
+ Plan bounce complete: {survived}/{total} plans refined
1114
+ ```
1115
+
1116
+ **Clean up:** Remove all `*-PLAN.pre-bounce.md` backup files after the bounce step completes (whether plans survived or were restored).
1117
+
1118
+ ## 13. Requirements Coverage Gate
1119
+
1120
+ After plans pass the checker (or checker is skipped), verify that all phase requirements are covered by at least one plan.
1121
+
1122
+ **Skip if:** `phase_req_ids` is null or TBD (no requirements mapped to this phase).
1123
+
1124
+ **Step 1: Extract requirement IDs claimed by plans**
1125
+ ```bash
1126
+ # Collect all requirement IDs from plan frontmatter
1127
+ PLAN_REQS=$(grep -h "requirements_addressed\|requirements:" ${PHASE_DIR}/*-PLAN.md 2>/dev/null | tr -d '[]' | tr ',' '\n' | sed 's/^[[:space:]]*//' | sort -u)
1128
+ ```
1129
+
1130
+ **Step 2: Compare against phase requirements from ROADMAP**
1131
+
1132
+ For each REQ-ID in `phase_req_ids`:
1133
+ - If REQ-ID appears in `PLAN_REQS` → covered ✓
1134
+ - If REQ-ID does NOT appear in any plan → uncovered ✗
1135
+
1136
+ **Step 3: Check CONTEXT.md features against plan objectives**
1137
+
1138
+ Read CONTEXT.md `<decisions>` section. Extract feature/capability names. Check each against plan `<objective>` blocks. Features not mentioned in any plan objective → potentially dropped.
1139
+
1140
+ **Step 4: Report**
1141
+
1142
+ If all requirements covered and no dropped features:
1143
+ ```
1144
+ ✓ Requirements coverage: {N}/{N} REQ-IDs covered by plans
1145
+ ```
1146
+ → Proceed to step 14.
1147
+
1148
+ If gaps found:
1149
+ ```
1150
+ ## ⚠ Requirements Coverage Gap
1151
+
1152
+ {M} of {N} phase requirements are not assigned to any plan:
1153
+
1154
+ | REQ-ID | Description | Plans |
1155
+ |--------|-------------|-------|
1156
+ | {id} | {from REQUIREMENTS.md} | None |
1157
+
1158
+ {K} CONTEXT.md features not found in plan objectives:
1159
+ - {feature_name} — described in CONTEXT.md but no plan covers it
1160
+
1161
+ Options:
1162
+ 1. Re-plan to include missing requirements (recommended)
1163
+ 2. Move uncovered requirements to next phase
1164
+ 3. Proceed anyway — accept coverage gaps
1165
+ ```
1166
+
1167
+ 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.
1168
+
1169
+ ## 13b. Record Planning Completion in STATE.md
1170
+
1171
+ After plans pass all gates, record that planning is complete so STATE.md reflects the new phase status:
1172
+
1173
+ ```bash
1174
+ gsd-remix-sdk query state.planned-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
1175
+ ```
1176
+
1177
+ This updates STATUS to "Ready to execute", sets the correct plan count, and timestamps Last Activity.
1178
+
1179
+ ## 13c. Annotate ROADMAP with Wave Dependencies and Cross-cutting Constraints
1180
+
1181
+ After plans are finalized, annotate the ROADMAP.md plan list for this phase with:
1182
+ - **Wave dependency notes** — a bold header before each wave group ("Wave 2 *(blocked on Wave 1 completion)*")
1183
+ - **Cross-cutting constraints** — a "Cross-cutting constraints:" subsection listing `must_haves.truths` entries that appear in 2 or more plans
1184
+
1185
+ This step is derived entirely from existing PLAN frontmatter — no extra LLM pass is required.
1186
+
1187
+ ```bash
1188
+ gsd-remix-sdk query roadmap.annotate-dependencies "${PHASE_NUMBER}"
1189
+ ```
1190
+
1191
+ This operation is idempotent: if wave headers or cross-cutting constraints already exist in the ROADMAP phase section, the command returns without modifying the file. Skip this step if `plan_count` is 0.
1192
+
1193
+ ## 13d. Commit Plans if commit_docs is true
1194
+
1195
+ If `commit_docs` is true (from the init JSON parsed in step 1), commit the generated plan artifacts (including any ROADMAP.md annotations from step 13c):
1196
+
1197
+ ```bash
1198
+ gsd-remix-sdk query commit "docs(${PADDED_PHASE}): create phase plan" --files "${PHASE_DIR}"/*-PLAN.md .planning/STATE.md .planning/ROADMAP.md
1199
+ ```
1200
+
1201
+ This commits all PLAN.md files for the phase plus the updated STATE.md and ROADMAP.md to version-control the planning artifacts. Skip this step if `commit_docs` is false.
1202
+
1203
+ ## 14. Present Final Status
1204
+
1205
+ Route to `<offer_next>` OR `auto_advance` depending on flags/config.
1206
+
1207
+ ## 15. Auto-Advance Check
1208
+
1209
+ Check for auto-advance trigger using values already loaded in step 1:
1210
+
1211
+ 1. Parse `--auto` and `--chain` flags from $ARGUMENTS
1212
+ 2. Use `auto_chain_active` and `auto_advance` from the INIT JSON parsed in step 1 — **do not issue additional `config-get` calls for these values** (they are already present in the init output). Issuing redundant `config-get` calls for values already in INIT can cause infinite read loops on some runtimes.
1213
+ 3. **Sync chain flag with intent** — if user invoked manually (no `--auto` and no `--chain`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
1214
+ ```bash
1215
+ if [[ ! "$ARGUMENTS" =~ --auto ]] && [[ ! "$ARGUMENTS" =~ --chain ]]; then
1216
+ gsd-remix-sdk query config-set workflow._auto_chain_active false 2>/dev/null
1217
+ fi
1218
+ ```
1219
+
1220
+ Set local variables from INIT (parsed once in step 1):
1221
+ - `AUTO_CHAIN` = `auto_chain_active` from INIT JSON (boolean, default false)
1222
+ - `AUTO_CFG` = `auto_advance` from INIT JSON (boolean, default false)
1223
+
1224
+ **If `--auto` or `--chain` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct invocation without prior discuss-phase):
1225
+ ```bash
1226
+ if ([[ "$ARGUMENTS" =~ --auto ]] || [[ "$ARGUMENTS" =~ --chain ]]) && [[ "$AUTO_CHAIN" != "true" ]]; then
1227
+ gsd-remix-sdk query config-set workflow._auto_chain_active true
1228
+ fi
1229
+ ```
1230
+
1231
+ **If `--auto` or `--chain` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
1232
+
1233
+ Display banner:
1234
+ ```
1235
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1236
+ GSD ► AUTO-ADVANCING TO EXECUTE
1237
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1238
+
1239
+ Plans ready. Launching execute-phase...
1240
+ ```
1241
+
1242
+ Launch execute-phase using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting):
1243
+ ```
1244
+ Skill(skill="gsd-execute-phase", args="${PHASE} --auto --no-transition ${GSD_WS}")
1245
+ ```
1246
+
1247
+ 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.
1248
+
1249
+ **Handle execute-phase return:**
1250
+ - **PHASE COMPLETE** → Display final summary:
1251
+ ```
1252
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1253
+ GSD ► PHASE ${PHASE} COMPLETE ✓
1254
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1255
+
1256
+ Auto-advance pipeline finished.
1257
+
1258
+ Next: /gsd-discuss-phase ${NEXT_PHASE} --auto ${GSD_WS}
1259
+ ```
1260
+ - **GAPS FOUND / VERIFICATION FAILED** → Display result, stop chain:
1261
+ ```
1262
+ Auto-advance stopped: Execution needs review.
1263
+
1264
+ Review the output above and continue manually:
1265
+ /gsd-execute-phase ${PHASE} ${GSD_WS}
1266
+ ```
1267
+
1268
+ **If neither `--auto` nor config enabled:**
1269
+ Route to `<offer_next>` (existing behavior).
1270
+
1271
+ </process>
1272
+
1273
+ <offer_next>
1274
+ Output this markdown directly (not as a code block):
1275
+
1276
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1277
+ GSD ► PHASE {X} PLANNED ✓
1278
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1279
+
1280
+ **Phase {X}: {Name}** — {N} plan(s) in {M} wave(s)
1281
+
1282
+ | Wave | Plans | What it builds |
1283
+ |------|-------|----------------|
1284
+ | 1 | 01, 02 | [objectives] |
1285
+ | 2 | 03 | [objective] |
1286
+
1287
+ Research: {Completed | Used existing | Skipped}
1288
+ Verification: {Passed | Passed with override | Skipped}
1289
+
1290
+ ───────────────────────────────────────────────────────────────
1291
+
1292
+ ## ▶ Next Up — [${PROJECT_CODE}] ${PROJECT_TITLE}
1293
+
1294
+ **Execute Phase {X}** — run all {N} plans
1295
+
1296
+ /clear then:
1297
+
1298
+ /gsd-execute-phase {X} ${GSD_WS}
1299
+
1300
+ ───────────────────────────────────────────────────────────────
1301
+
1302
+ **Also available:**
1303
+ - cat .planning/phases/{phase-dir}/*-PLAN.md — review plans
1304
+ - /gsd-plan-phase {X} --research — re-research first
1305
+ - /gsd-review --phase {X} --all — peer review plans with external AIs
1306
+ - /gsd-plan-phase {X} --reviews — replan incorporating review feedback
1307
+
1308
+ ───────────────────────────────────────────────────────────────
1309
+ </offer_next>
1310
+
1311
+ <windows_troubleshooting>
1312
+ **Windows users:** If plan-phase freezes during agent spawning (common on Windows due to
1313
+ stdio deadlocks with MCP servers — see Claude Code issue anthropics/claude-code#28126):
1314
+
1315
+ 1. **Force-kill:** Close the terminal (Ctrl+C may not work)
1316
+ 2. **Clean up orphaned processes:**
1317
+ ```powershell
1318
+ # Kill orphaned node processes from stale MCP servers
1319
+ Get-Process node -ErrorAction SilentlyContinue | Where-Object {$_.StartTime -lt (Get-Date).AddHours(-1)} | Stop-Process -Force
1320
+ ```
1321
+ 3. **Clean up stale task directories:**
1322
+ ```powershell
1323
+ # Remove stale subagent task dirs (Claude Code never cleans these on crash)
1324
+ Remove-Item -Recurse -Force "$env:USERPROFILE\.claude\tasks\*" -ErrorAction SilentlyContinue
1325
+ ```
1326
+ 4. **Reduce MCP server count:** Temporarily disable non-essential MCP servers in settings.json
1327
+ 5. **Retry:** Restart Claude Code and run `/gsd-plan-phase` again
1328
+
1329
+ If freezes persist, try `--skip-research` to reduce the agent chain from 3 to 2 agents:
1330
+ ```
1331
+ /gsd-plan-phase N --skip-research
1332
+ ```
1333
+ </windows_troubleshooting>
1334
+
1335
+ <success_criteria>
1336
+ - [ ] .planning/ directory validated
1337
+ - [ ] Phase validated against roadmap
1338
+ - [ ] Phase directory created if needed
1339
+ - [ ] CONTEXT.md loaded early (step 4) and passed to ALL agents
1340
+ - [ ] Research completed (unless --skip-research or --gaps or exists)
1341
+ - [ ] gsd-phase-researcher spawned with CONTEXT.md
1342
+ - [ ] Existing plans checked
1343
+ - [ ] gsd-planner spawned with CONTEXT.md + RESEARCH.md
1344
+ - [ ] Plans created (PLANNING COMPLETE or CHECKPOINT handled)
1345
+ - [ ] gsd-plan-checker spawned with CONTEXT.md
1346
+ - [ ] Verification passed OR user override OR max iterations with user decision
1347
+ - [ ] User sees status between agent spawns
1348
+ - [ ] User knows next steps
1349
+ </success_criteria>