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,1677 @@
1
+ <purpose>
2
+ Execute all plans in a phase using wave-based parallel execution. Orchestrator stays lean — delegates plan execution to subagents.
3
+ </purpose>
4
+
5
+ <core_principle>
6
+ Orchestrator coordinates, not executes. Each subagent loads the full execute-plan context. Orchestrator: discover plans → analyze deps → group waves → spawn agents → handle checkpoints → collect results.
7
+ </core_principle>
8
+
9
+ <runtime_compatibility>
10
+ **Subagent spawning is runtime-specific:**
11
+ - **Claude Code:** Uses `Task(subagent_type="gsd-executor", ...)` — blocks until complete, returns result
12
+ - **Copilot:** Subagent spawning does not reliably return completion signals. **Default to
13
+ sequential inline execution**: read and follow execute-plan.md directly for each plan
14
+ instead of spawning parallel agents. Only attempt parallel spawning if the user
15
+ explicitly requests it — and in that case, rely on the spot-check fallback in step 3
16
+ to detect completion.
17
+ - **Other runtimes:** If `Task`/`task` tool is unavailable, use sequential inline execution as the
18
+ fallback. Check for tool availability at runtime rather than assuming based on runtime name.
19
+
20
+ **Fallback rule:** If a spawned agent completes its work (commits visible, SUMMARY.md exists) but
21
+ the orchestrator never receives the completion signal, treat it as successful based on spot-checks
22
+ and continue to the next wave/plan. Never block indefinitely waiting for a signal — always verify
23
+ via filesystem and git state.
24
+ </runtime_compatibility>
25
+
26
+ <required_reading>
27
+ Read STATE.md before any operation to load project context.
28
+
29
+ @~/.claude/get-shit-done/references/agent-contracts.md
30
+ @~/.claude/get-shit-done/references/context-budget.md
31
+ @~/.claude/get-shit-done/references/gates.md
32
+ </required_reading>
33
+
34
+ <available_agent_types>
35
+ These are the valid GSD subagent types registered in .claude/agents/ (or equivalent for your runtime).
36
+ Always use the exact name from this list — do not fall back to 'general-purpose' or other built-in types:
37
+
38
+ - gsd-executor — Executes plan tasks, commits, creates SUMMARY.md
39
+ - gsd-verifier — Verifies phase completion, checks quality gates
40
+ - gsd-planner — Creates detailed plans from phase scope
41
+ - gsd-phase-researcher — Researches technical approaches for a phase
42
+ - gsd-plan-checker — Reviews plan quality before execution
43
+ - gsd-debugger — Diagnoses and fixes issues
44
+ - gsd-codebase-mapper — Maps project structure and dependencies
45
+ - gsd-integration-checker — Checks cross-phase integration
46
+ - gsd-nyquist-auditor — Validates verification coverage
47
+ - gsd-ui-researcher — Researches UI/UX approaches
48
+ - gsd-ui-checker — Reviews UI implementation quality
49
+ - gsd-ui-auditor — Audits UI against design requirements
50
+ </available_agent_types>
51
+
52
+ <process>
53
+
54
+ <step name="parse_args" priority="first">
55
+ Parse `$ARGUMENTS` before loading any context:
56
+
57
+ - First positional token → `PHASE_ARG`
58
+ - Optional `--wave N` → `WAVE_FILTER`
59
+ - Optional `--gaps-only` keeps its current meaning
60
+ - Optional `--cross-ai` → `CROSS_AI_FORCE=true` (force all plans through cross-AI execution)
61
+ - Optional `--no-cross-ai` → `CROSS_AI_DISABLED=true` (disable cross-AI for this run, overrides config and frontmatter)
62
+
63
+ If `--wave` is absent, preserve the current behavior of executing all incomplete waves in the phase.
64
+ </step>
65
+
66
+ <step name="runtime_health_preflight" priority="first">
67
+ **MANDATORY — Check runtime health before any GSD SDK query.**
68
+
69
+ ```bash
70
+ if ! command -v gsd-remix-sdk &>/dev/null; then
71
+ echo "⚠ gsd-remix-sdk not found in PATH — /gsd-execute-phase requires it."
72
+ echo ""
73
+ echo "Repair the bundled SDK:"
74
+ echo " /gsd-health --runtime --repair"
75
+ echo ""
76
+ echo "Or refresh all runtime assets:"
77
+ echo " /gsd-update"
78
+ exit 1
79
+ fi
80
+
81
+ 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":[]}')
82
+ ```
83
+
84
+ 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`.
85
+
86
+ Rules:
87
+ - If `blockers[]` is non-empty: stop immediately, show each blocker and fix, and do not continue to `initialize`.
88
+ - If `warnings[]` is non-empty: show them once as runtime advisories, then continue.
89
+ - This step is deterministic. Do not infer extra runtime problems beyond the query result.
90
+ </step>
91
+
92
+ <step name="initialize" priority="first">
93
+ Load all context in one call:
94
+
95
+ ```bash
96
+ INIT=$(gsd-remix-sdk query init.execute-phase "${PHASE_ARG}")
97
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
98
+ AGENT_SKILLS=$(gsd-remix-sdk query agent-skills gsd-executor 2>/dev/null)
99
+ ```
100
+
101
+ Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
102
+
103
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
104
+
105
+ Read worktree config:
106
+
107
+ ```bash
108
+ USE_WORKTREES=$(gsd-remix-sdk query config-get workflow.use_worktrees 2>/dev/null || echo "true")
109
+ ```
110
+
111
+ If the project uses git submodules, worktree isolation is skipped regardless of the `workflow.use_worktrees` config — the executor commit protocol cannot correctly handle submodule commits inside isolated worktrees. Sequential execution handles submodules transparently.
112
+
113
+ ```bash
114
+ if [ -f .gitmodules ]; then
115
+ echo "[worktree] Submodule project detected (.gitmodules exists) — falling back to sequential execution"
116
+ USE_WORKTREES=false
117
+ fi
118
+ ```
119
+
120
+ When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees.
121
+
122
+ Read context window size for adaptive prompt enrichment:
123
+
124
+ ```bash
125
+ CONTEXT_WINDOW=$(gsd-remix-sdk query config-get context_window 2>/dev/null || echo "200000")
126
+ ```
127
+
128
+ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
129
+ - Executor agents receive prior wave SUMMARY.md files and the phase CONTEXT.md/RESEARCH.md
130
+ - Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
131
+ - This enables cross-phase awareness and history-aware verification
132
+
133
+ When `CONTEXT_WINDOW < 200000` (sub-200K models), subagent prompts are thinned to reduce static overhead:
134
+ - Executor agents omit extended deviation rule examples and checkpoint examples from inline prompt — load on-demand via @~/.claude/get-shit-done/references/executor-examples.md
135
+ - Planner agents omit extended anti-pattern lists and specificity examples from inline prompt — load on-demand via @~/.claude/get-shit-done/references/planner-antipatterns.md
136
+ - Core rules and decision logic remain inline; only verbose examples and edge-case lists are extracted
137
+ - This reduces executor static overhead by ~40% while preserving behavioral correctness
138
+
139
+ **If `phase_found` is false:** Error — phase directory not found.
140
+ **If `plan_count` is 0:** Error — no plans found in phase.
141
+ **If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
142
+
143
+ When `parallelization` is false, plans within a wave execute sequentially.
144
+
145
+ **Runtime detection for Copilot:**
146
+ Check if the current runtime is Copilot by testing for the `@gsd-executor` agent pattern
147
+ or absence of the `Task()` subagent API. If running under Copilot, force sequential inline
148
+ execution regardless of the `parallelization` setting — Copilot's subagent completion
149
+ signals are unreliable (see `<runtime_compatibility>`). Set `COPILOT_SEQUENTIAL=true`
150
+ internally and skip the `execute_waves` step in favor of `check_interactive_mode`'s
151
+ inline path for each plan.
152
+
153
+ **REQUIRED — Sync chain flag with intent.** If user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This prevents stale `_auto_chain_active: true` from causing unwanted auto-advance. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference). You MUST execute this bash block before any config reads:
154
+ ```bash
155
+ # REQUIRED: prevents stale auto-chain from previous --auto runs
156
+ if [[ ! "$ARGUMENTS" =~ --auto ]]; then
157
+ gsd-remix-sdk query config-set workflow._auto_chain_active false 2>/dev/null
158
+ fi
159
+ ```
160
+ </step>
161
+
162
+ <step name="check_blocking_antipatterns" priority="first">
163
+ **MANDATORY — Check for blocking anti-patterns before any other work.**
164
+
165
+ Look for a `.continue-here.md` in the current phase directory:
166
+
167
+ ```bash
168
+ ls ${phase_dir}/.continue-here.md 2>/dev/null || true
169
+ ```
170
+
171
+ If `.continue-here.md` exists, parse its "Critical Anti-Patterns" table for rows with `severity` = `blocking`.
172
+
173
+ **If one or more `blocking` anti-patterns are found:**
174
+
175
+ This step cannot be skipped. Before proceeding to `check_interactive_mode` or any other step, the agent must demonstrate understanding of each blocking anti-pattern by answering all three questions for each one:
176
+
177
+ 1. **What is this anti-pattern?** — Describe it in your own words, not by quoting the handoff.
178
+ 2. **How did it manifest?** — Explain the specific failure that caused it to be recorded.
179
+ 3. **What structural mechanism (not acknowledgment) prevents it?** — Name the concrete step, checklist item, or enforcement mechanism that stops recurrence.
180
+
181
+ Write these answers inline before continuing. If a blocking anti-pattern cannot be answered from the context in `.continue-here.md`, stop and ask the user for clarification.
182
+
183
+ **If no `.continue-here.md` exists, or no `blocking` rows are found:** Proceed directly to `check_interactive_mode`.
184
+ </step>
185
+
186
+ <step name="check_interactive_mode">
187
+ **Parse `--interactive` flag from $ARGUMENTS.**
188
+
189
+ **If `--interactive` flag present:** Switch to interactive execution mode.
190
+
191
+ Interactive mode executes plans sequentially **inline** (no subagent spawning) with user
192
+ checkpoints between tasks. The user can review, modify, or redirect work at any point.
193
+
194
+ **Interactive execution flow:**
195
+
196
+ 1. Load plan inventory as normal (discover_and_group_plans)
197
+ 2. For each plan (sequentially, ignoring wave grouping):
198
+
199
+ a. **Present the plan to the user:**
200
+ ```
201
+ ## Plan {plan_id}: {plan_name}
202
+
203
+ Objective: {from plan file}
204
+ Tasks: {task_count}
205
+
206
+ Options:
207
+ - Execute (proceed with all tasks)
208
+ - Review first (show task breakdown before starting)
209
+ - Skip (move to next plan)
210
+ - Stop (end execution, save progress)
211
+ ```
212
+
213
+ b. **If "Review first":** Read and display the full plan file. Ask again: Execute, Modify, Skip.
214
+
215
+ c. **If "Execute":** Read and follow `~/.claude/get-shit-done/workflows/execute-plan.md` **inline**
216
+ (do NOT spawn a subagent). Execute tasks one at a time.
217
+
218
+ d. **After each task:** Pause briefly. If the user intervenes (types anything), stop and address
219
+ their feedback before continuing. Otherwise proceed to next task.
220
+
221
+ e. **After plan complete:** Show results, commit, create SUMMARY.md, then present next plan.
222
+
223
+ 3. After all plans: proceed to verification (same as normal mode).
224
+
225
+ **Benefits of interactive mode:**
226
+ - No subagent overhead — dramatically lower token usage
227
+ - User catches mistakes early — saves costly verification cycles
228
+ - Maintains GSD's planning/tracking structure
229
+ - Best for: small phases, bug fixes, verification gaps, learning GSD
230
+
231
+ **Skip to handle_branching step** (interactive plans execute inline after grouping).
232
+ </step>
233
+
234
+ <step name="handle_branching">
235
+ Check `branching_strategy` from init:
236
+
237
+ **"none":** Skip, continue on current branch.
238
+
239
+ **"phase" or "milestone":** Use pre-computed `branch_name` from init:
240
+ ```bash
241
+ git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
242
+ ```
243
+
244
+ All subsequent commits go to this branch. User handles merging.
245
+ </step>
246
+
247
+ <step name="validate_phase">
248
+ From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
249
+
250
+ Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
251
+
252
+ **Update STATE.md for phase start:**
253
+ ```bash
254
+ gsd-remix-sdk query state.begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
255
+ ```
256
+ This updates Status, Last Activity, Current focus, Current Position, and plan counts in STATE.md so frontmatter and body text reflect the active phase immediately.
257
+ </step>
258
+
259
+ <step name="discover_and_group_plans">
260
+ Load plan inventory with wave grouping in one call:
261
+
262
+ ```bash
263
+ PLAN_INDEX=$(gsd-remix-sdk query phase-plan-index "${PHASE_NUMBER}")
264
+ ```
265
+
266
+ Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
267
+
268
+ **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If `WAVE_FILTER` is set: also skip plans whose `wave` does not equal `WAVE_FILTER`.
269
+
270
+ **Wave safety check:** If `WAVE_FILTER` is set and there are still incomplete plans in any lower wave that match the current execution mode, STOP and tell the user to finish earlier waves first. Do not let Wave 2+ execute while prerequisite earlier-wave plans remain incomplete.
271
+
272
+ If all filtered: "No matching incomplete plans" → exit.
273
+
274
+ Report:
275
+ ```
276
+ ## Execution Plan
277
+
278
+ **Phase {X}: {Name}** — {total_plans} matching plans across {wave_count} wave(s)
279
+
280
+ {If WAVE_FILTER is set: `Wave filter active: executing only Wave {WAVE_FILTER}`.}
281
+
282
+ | Wave | Plans | What it builds |
283
+ |------|-------|----------------|
284
+ | 1 | 01-01, 01-02 | {from plan objectives, 3-8 words} |
285
+ | 2 | 01-03 | ... |
286
+ ```
287
+ </step>
288
+
289
+ <step name="cross_ai_delegation">
290
+ **Optional step 2.5 — Delegate plans to an external AI runtime.**
291
+
292
+ This step runs after plan discovery and before normal wave execution. It identifies plans
293
+ that should be delegated to an external AI command and executes them via stdin-based prompt
294
+ delivery. Plans handled here are removed from the execute_waves plan list so the normal
295
+ executor skips them.
296
+
297
+ **Activation logic:**
298
+
299
+ 1. If `CROSS_AI_DISABLED` is true (`--no-cross-ai` flag): skip this step entirely.
300
+ 2. If `CROSS_AI_FORCE` is true (`--cross-ai` flag): mark ALL incomplete plans for cross-AI execution.
301
+ 3. Otherwise: check each plan's frontmatter for `cross_ai: true` AND verify config
302
+ `workflow.cross_ai_execution` is `true`. Plans matching both conditions are marked for cross-AI.
303
+
304
+ ```bash
305
+ CROSS_AI_ENABLED=$(gsd-remix-sdk query config-get workflow.cross_ai_execution 2>/dev/null || echo "false")
306
+ CROSS_AI_CMD=$(gsd-remix-sdk query config-get workflow.cross_ai_command 2>/dev/null || echo "")
307
+ CROSS_AI_TIMEOUT=$(gsd-remix-sdk query config-get workflow.cross_ai_timeout 2>/dev/null || echo "300")
308
+ ```
309
+
310
+ **If no plans are marked for cross-AI:** Skip to execute_waves.
311
+
312
+ **If plans are marked but `cross_ai_command` is empty:** Error — tell user to set
313
+ `workflow.cross_ai_command` via `gsd-remix-sdk query config-set workflow.cross_ai_command "<command>"`.
314
+
315
+ **For each cross-AI plan (sequentially):**
316
+
317
+ 1. **Construct the task prompt** from the plan file:
318
+ - Extract `<objective>` and `<tasks>` sections from the PLAN.md
319
+ - Append PROJECT.md context (project name, description, tech stack)
320
+ - Format as a self-contained execution prompt
321
+
322
+ 2. **Check for dirty working tree before execution:**
323
+ ```bash
324
+ if ! git diff --quiet HEAD 2>/dev/null; then
325
+ echo "WARNING: dirty working tree detected — the external AI command may produce uncommitted changes that conflict with existing modifications"
326
+ fi
327
+ ```
328
+
329
+ 3. **Run the external command** from the project root, writing the prompt to stdin.
330
+ Never shell-interpolate the prompt — always pipe via stdin to prevent injection:
331
+ ```bash
332
+ echo "$TASK_PROMPT" | timeout "${CROSS_AI_TIMEOUT}s" ${CROSS_AI_CMD} > "$CANDIDATE_SUMMARY" 2>"$ERROR_LOG"
333
+ EXIT_CODE=$?
334
+ ```
335
+
336
+ 4. **Evaluate the result:**
337
+
338
+ **Success (exit 0 + valid summary):**
339
+ - Read `$CANDIDATE_SUMMARY` and validate it contains meaningful content
340
+ (not empty, has at least a heading and description — a valid SUMMARY.md structure)
341
+ - Write it as the plan's SUMMARY.md file
342
+ - Update STATE.md plan status to complete
343
+ - Update ROADMAP.md progress
344
+ - Mark plan as handled — skip it in execute_waves
345
+
346
+ **Failure (non-zero exit or invalid summary):**
347
+ - Display the error output and exit code
348
+ - Warn: "The external command may have left uncommitted changes or partial edits
349
+ in the working tree. Review `git status` and `git diff` before proceeding."
350
+ - Offer three choices:
351
+ - **retry** — run the same plan through cross-AI again
352
+ - **skip** — fall back to normal executor for this plan (re-add to execute_waves list)
353
+ - **abort** — stop execution entirely, preserve state for resume
354
+
355
+ 5. **After all cross-AI plans processed:** Remove successfully handled plans from the
356
+ incomplete plan list so execute_waves skips them. Any skipped-to-fallback plans remain
357
+ in the list for normal executor processing.
358
+ </step>
359
+
360
+ <step name="execute_waves">
361
+ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
362
+
363
+ **For each wave:**
364
+
365
+ 1. **Intra-wave files_modified overlap check (BEFORE spawning):**
366
+
367
+ Before spawning any agents for this wave, inspect the `files_modified` list of all plans
368
+ in the wave. Check every pair of plans in the wave — if any two plans share even one file
369
+ in their `files_modified` lists, those plans have an implicit dependency and MUST NOT run
370
+ in parallel.
371
+
372
+ **Detection algorithm (pseudocode):**
373
+ ```
374
+ seen_files = {}
375
+ overlapping_plans = []
376
+ for each plan in wave_plans:
377
+ for each file in plan.files_modified:
378
+ if file in seen_files:
379
+ overlapping_plans.add(plan, seen_files[file]) # both plans overlap on this file
380
+ else:
381
+ seen_files[file] = plan
382
+ ```
383
+
384
+ **If overlap is detected:**
385
+ - Warn the user:
386
+ ```
387
+ ⚠ Intra-wave files_modified overlap detected in Wave {N}:
388
+ Plan {A} and Plan {B} both modify {file}
389
+ Running these plans sequentially to avoid parallel worktree conflicts.
390
+ ```
391
+ - Override `PARALLELIZATION` to `false` for this wave only — run all plans in the wave
392
+ sequentially regardless of the global parallelization setting.
393
+ - This is a safety net for plans that were incorrectly assigned to the same wave.
394
+ The planner should have caught this; flag it as a planning defect so the user can
395
+ replan the phase if desired.
396
+
397
+ **If no overlap:** proceed normally (parallel if `PARALLELIZATION=true`).
398
+
399
+ 2. **Describe what's being built (BEFORE spawning):**
400
+
401
+ Read each plan's `<objective>`. Extract what's being built and why.
402
+
403
+ ```
404
+ ---
405
+ ## Wave {N}
406
+
407
+ **{Plan ID}: {Plan Name}**
408
+ {2-3 sentences: what this builds, technical approach, why it matters}
409
+
410
+ Spawning {count} agent(s)...
411
+ ---
412
+ ```
413
+
414
+ - Bad: "Executing terrain generation plan"
415
+ - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
416
+
417
+ 3. **Spawn executor agents:**
418
+
419
+ Pass paths only — executors read files themselves with their fresh context window.
420
+ For 200k models, this keeps orchestrator context lean (~10-15%).
421
+ For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
422
+
423
+ **Worktree mode** (`USE_WORKTREES` is not `false`):
424
+
425
+ Before spawning, capture the current HEAD:
426
+ ```bash
427
+ EXPECTED_BASE=$(git rev-parse HEAD)
428
+ ```
429
+
430
+ **Sequential dispatch for parallel execution (waves with 2+ agents):**
431
+ When spawning multiple agents in a wave, dispatch each `Task()` call **one at a time
432
+ with `run_in_background: true`** — do NOT send all Task calls in a single message.
433
+ `git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
434
+ calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
435
+ creation before the next begins (the round-trip latency of each tool call provides
436
+ natural spacing), while all agents still **run in parallel** once created.
437
+
438
+ ```
439
+ # CORRECT: dispatch one Task() per message, each with run_in_background: true
440
+ # → worktrees created sequentially, agents execute in parallel
441
+ #
442
+ # WRONG: multiple Task() calls in a single message
443
+ # → simultaneous git worktree add → .git/config.lock contention → failures
444
+ ```
445
+
446
+ ```
447
+ Task(
448
+ subagent_type="gsd-executor",
449
+ description="Execute plan {plan_number} of phase {phase_number}",
450
+ model="{executor_model}",
451
+ isolation="worktree",
452
+ prompt="
453
+ <objective>
454
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
455
+ Commit each task atomically. Create SUMMARY.md.
456
+ Do NOT update STATE.md or ROADMAP.md — the orchestrator owns those writes after all worktree agents in the wave complete.
457
+ </objective>
458
+
459
+ <worktree_branch_check>
460
+ FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
461
+
462
+ Run:
463
+ ```bash
464
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
465
+ ```
466
+
467
+ If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
468
+ base such as `main` instead of the feature branch HEAD), hard-reset to the correct base:
469
+ ```bash
470
+ # Safe: this runs before any agent work, so no uncommitted changes to lose
471
+ git reset --hard {EXPECTED_BASE}
472
+ # Verify correction succeeded
473
+ if [ "$(git rev-parse HEAD)" != "{EXPECTED_BASE}" ]; then
474
+ echo "ERROR: Could not correct worktree base — aborting to prevent data loss"
475
+ exit 1
476
+ fi
477
+ ```
478
+
479
+ `reset --hard` is safe here because this is a fresh worktree with no user changes. It
480
+ resets both the HEAD pointer AND the working tree to the correct base commit (#2015).
481
+
482
+ If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
483
+
484
+ This check fixes a known issue where `EnterWorktree` creates branches from
485
+ `main` instead of the current feature branch HEAD (affects all platforms).
486
+ </worktree_branch_check>
487
+
488
+ <parallel_execution>
489
+ You are running as a PARALLEL executor agent in a git worktree.
490
+ Use --no-verify on all git commits to avoid pre-commit hook contention
491
+ with other agents. The orchestrator validates hooks once after all agents complete.
492
+ For `gsd-remix-sdk query commit` (or legacy `gsd-tools.cjs` commit): add --no-verify flag when needed.
493
+ For direct git commits: use git commit --no-verify -m "..."
494
+
495
+ IMPORTANT: Do NOT modify STATE.md or ROADMAP.md. execute-plan.md
496
+ auto-detects worktree mode (`.git` is a file, not a directory) and skips
497
+ shared file updates automatically. The orchestrator updates them centrally
498
+ after merge.
499
+
500
+ REQUIRED: SUMMARY.md MUST be committed before you return. In worktree mode the
501
+ git_commit_metadata step in execute-plan.md commits SUMMARY.md and REQUIREMENTS.md
502
+ only (STATE.md and ROADMAP.md are excluded automatically). Do NOT skip or defer
503
+ this commit — the orchestrator force-removes the worktree after you return, and
504
+ any uncommitted SUMMARY.md will be permanently lost (#2070).
505
+ </parallel_execution>
506
+
507
+ <execution_context>
508
+ @~/.claude/get-shit-done/workflows/execute-plan.md
509
+ @~/.claude/get-shit-done/templates/summary.md
510
+ @~/.claude/get-shit-done/references/checkpoints.md
511
+ @~/.claude/get-shit-done/references/tdd.md
512
+ ${CONTEXT_WINDOW < 200000 ? '' : '@~/.claude/get-shit-done/references/executor-examples.md'}
513
+ </execution_context>
514
+
515
+ <files_to_read>
516
+ Read these files at execution start using the Read tool:
517
+ - {phase_dir}/{plan_file} (Plan)
518
+ - .planning/PROJECT.md (Project context — core value, requirements, evolution rules)
519
+ - .planning/STATE.md (State)
520
+ - .planning/config.json (Config, if exists)
521
+ ${CONTEXT_WINDOW >= 500000 ? `
522
+ - ${phase_dir}/*-CONTEXT.md (User decisions from discuss-phase — honors locked choices)
523
+ - ${phase_dir}/*-RESEARCH.md (Technical research — pitfalls and patterns to follow)
524
+ - ${prior_wave_summaries} (SUMMARY.md files from earlier waves in this phase — what was already built)
525
+ ` : ''}
526
+ - ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
527
+ - .claude/skills/ or .agents/skills/ (Project skills, if either exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
528
+ </files_to_read>
529
+
530
+ ${AGENT_SKILLS}
531
+
532
+ <mcp_tools>
533
+ If CLAUDE.md or project instructions reference MCP tools (e.g. jCodeMunch, context7,
534
+ or other MCP servers), prefer those tools over Grep/Glob for code navigation when available.
535
+ MCP tools often save significant tokens by providing structured code indexes.
536
+ Check tool availability first — if MCP tools are not accessible, fall back to Grep/Glob.
537
+ </mcp_tools>
538
+
539
+ <success_criteria>
540
+ - [ ] All tasks executed
541
+ - [ ] Each task committed individually
542
+ - [ ] SUMMARY.md created in plan directory
543
+ - [ ] No modifications to shared orchestrator artifacts (the orchestrator handles all post-wave shared-file writes)
544
+ </success_criteria>
545
+ "
546
+ )
547
+ ```
548
+
549
+ **Sequential mode** (`USE_WORKTREES` is `false`):
550
+
551
+ Omit `isolation="worktree"` from the Task call. Replace the `<parallel_execution>` block with:
552
+
553
+ ```
554
+ <sequential_execution>
555
+ You are running as a SEQUENTIAL executor agent on the main working tree.
556
+ Use normal git commits (with hooks). Do NOT use --no-verify.
557
+ </sequential_execution>
558
+ ```
559
+
560
+ The sequential mode Task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
561
+
562
+ ```
563
+ <success_criteria>
564
+ - [ ] All tasks executed
565
+ - [ ] Each task committed individually
566
+ - [ ] SUMMARY.md created in plan directory
567
+ - [ ] STATE.md updated with position and decisions
568
+ - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
569
+ </success_criteria>
570
+ ```
571
+
572
+ When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting — multiple agents writing to the same working tree concurrently would cause conflicts.
573
+
574
+ 4. **Wait for all agents in wave to complete.**
575
+
576
+ **Completion signal fallback (Copilot and runtimes where Task() may not return):**
577
+
578
+ If a spawned agent does not return a completion signal but appears to have finished
579
+ its work, do NOT block indefinitely. Instead, verify completion via spot-checks:
580
+
581
+ ```bash
582
+ # For each plan in this wave, check if the executor finished:
583
+ SUMMARY_EXISTS=$(test -f "{phase_dir}/{plan_number}-{plan_padded}-SUMMARY.md" && echo "true" || echo "false")
584
+ COMMITS_FOUND=$(git log --oneline --all --grep="{phase_number}-{plan_padded}" --since="1 hour ago" | head -1)
585
+ ```
586
+
587
+ **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
588
+ treat as done and proceed to step 5. Log: `"✓ {Plan ID} completed (verified via spot-check — completion signal not received)"`
589
+
590
+ **If SUMMARY.md does NOT exist after a reasonable wait:** The agent may still be
591
+ running or may have failed silently. Check `git log --oneline -5` for recent
592
+ activity. If commits are still appearing, wait longer. If no activity, report
593
+ the plan as failed and route to the failure handler in step 6.
594
+
595
+ **This fallback applies automatically to all runtimes.** Claude Code's Task() normally
596
+ returns synchronously, but the fallback ensures resilience if it doesn't.
597
+
598
+ 5. **Post-wave hook validation (parallel mode only):**
599
+
600
+ When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
601
+ ```bash
602
+ # Run project's pre-commit hooks on the current state
603
+ git diff --cached --quiet || git stash # stash any unstaged changes
604
+ git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed — review before continuing"
605
+ ```
606
+ If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
607
+
608
+ 5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
609
+
610
+ When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
611
+
612
+ ```bash
613
+ # List worktrees created by this wave's agents
614
+ WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
615
+
616
+ for WT in $WORKTREES; do
617
+ # Get the branch name for this worktree
618
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
619
+ if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
620
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
621
+
622
+ # --- Orchestrator file protection (#1756) ---
623
+ # Snapshot orchestrator-owned files BEFORE merge. If the worktree
624
+ # branch outlived a milestone transition, its versions of STATE.md
625
+ # and ROADMAP.md are stale. Main always wins for these files.
626
+ STATE_BACKUP=$(mktemp)
627
+ ROADMAP_BACKUP=$(mktemp)
628
+ [ -f .planning/STATE.md ] && cp .planning/STATE.md "$STATE_BACKUP" || true
629
+ [ -f .planning/ROADMAP.md ] && cp .planning/ROADMAP.md "$ROADMAP_BACKUP" || true
630
+
631
+ # Snapshot list of files on main BEFORE merge to detect resurrections
632
+ PRE_MERGE_FILES=$(git ls-files .planning/)
633
+
634
+ # Pre-merge deletion check: warn if the worktree branch deletes tracked files
635
+ DELETIONS=$(git diff --diff-filter=D --name-only HEAD..."$WT_BRANCH" 2>/dev/null || true)
636
+ if [ -n "$DELETIONS" ]; then
637
+ echo "BLOCKED: Worktree branch $WT_BRANCH contains file deletions: $DELETIONS"
638
+ echo "Review these deletions before merging. If intentional, remove this guard and re-run."
639
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
640
+ continue
641
+ fi
642
+
643
+ # Merge the worktree branch into the current branch (--no-ff ensures a merge commit so HEAD~1 is reliable)
644
+ git merge "$WT_BRANCH" --no-ff --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
645
+ echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
646
+ echo " STATE.md backup: $STATE_BACKUP"
647
+ echo " ROADMAP.md backup: $ROADMAP_BACKUP"
648
+ echo " Restore with: cp \$STATE_BACKUP .planning/STATE.md && cp \$ROADMAP_BACKUP .planning/ROADMAP.md"
649
+ break
650
+ }
651
+
652
+ # Post-merge deletion audit: detect bulk file deletions in merge commit (#2384)
653
+ # --diff-filter=D HEAD~1 HEAD shows files deleted by the merge commit itself.
654
+ # Exclude .planning/ — orchestrator-owned deletions there are expected (resurrections
655
+ # are handled below). Require ALLOW_BULK_DELETE=1 to bypass for intentional large refactors.
656
+ MERGE_DEL_COUNT=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -vc '^\.planning/' || true)
657
+ if [ "$MERGE_DEL_COUNT" -gt 5 ] && [ "${ALLOW_BULK_DELETE:-0}" != "1" ]; then
658
+ MERGE_DELETIONS=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -v '^\.planning/' || true)
659
+ echo "⚠ BLOCKED: Merge of $WT_BRANCH deleted $MERGE_DEL_COUNT files outside .planning/ — reverting to protect repository integrity (#2384)"
660
+ echo "$MERGE_DELETIONS"
661
+ echo " If these deletions are intentional, re-run with ALLOW_BULK_DELETE=1"
662
+ git reset --hard HEAD~1 2>/dev/null || true
663
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
664
+ continue
665
+ fi
666
+
667
+ # Restore orchestrator-owned files (main always wins)
668
+ if [ -s "$STATE_BACKUP" ]; then
669
+ cp "$STATE_BACKUP" .planning/STATE.md
670
+ fi
671
+ if [ -s "$ROADMAP_BACKUP" ]; then
672
+ cp "$ROADMAP_BACKUP" .planning/ROADMAP.md
673
+ fi
674
+ rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
675
+
676
+ # Detect files deleted on main but re-added by worktree merge
677
+ # (e.g., archived phase directories that were intentionally removed)
678
+ DELETED_FILES=$(git diff --diff-filter=A --name-only HEAD~1 -- .planning/ 2>/dev/null || true)
679
+ for RESURRECTED in $DELETED_FILES; do
680
+ # Check if this file was NOT in main's pre-merge tree
681
+ if ! echo "$PRE_MERGE_FILES" | grep -qxF "$RESURRECTED"; then
682
+ git rm -f "$RESURRECTED" 2>/dev/null || true
683
+ fi
684
+ done
685
+
686
+ # Amend merge commit with restored files if any changed
687
+ if ! git diff --quiet .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || \
688
+ [ -n "$DELETED_FILES" ]; then
689
+ # Only amend the commit with .planning/ files if commit_docs is enabled (#1783)
690
+ COMMIT_DOCS=$(gsd-remix-sdk query config-get commit_docs 2>/dev/null || echo "true")
691
+ if [ "$COMMIT_DOCS" != "false" ]; then
692
+ git add .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || true
693
+ git commit --amend --no-edit 2>/dev/null || true
694
+ fi
695
+ fi
696
+
697
+ # Safety net: commit any uncommitted SUMMARY.md before force-removing the worktree.
698
+ # This guards against executors that skipped the git_commit_metadata step (#2070).
699
+ UNCOMMITTED_SUMMARY=$(git -C "$WT" ls-files --modified --others --exclude-standard -- "*SUMMARY.md" 2>/dev/null || true)
700
+ if [ -n "$UNCOMMITTED_SUMMARY" ]; then
701
+ echo "⚠ SUMMARY.md was not committed by executor — committing now to prevent data loss"
702
+ git -C "$WT" add -- "*SUMMARY.md" 2>/dev/null || true
703
+ git -C "$WT" commit --no-verify -m "docs(recovery): rescue uncommitted SUMMARY.md before worktree removal (#2070)" 2>/dev/null || true
704
+ # Re-merge the recovery commit
705
+ git merge "$WT_BRANCH" --no-edit -m "chore: merge rescued SUMMARY.md from executor worktree ($WT_BRANCH)" 2>/dev/null || true
706
+ fi
707
+
708
+ # Remove the worktree
709
+ if ! git worktree remove "$WT" --force; then
710
+ WT_NAME=$(basename "$WT")
711
+ if [ -f ".git/worktrees/${WT_NAME}/locked" ]; then
712
+ echo "⚠ Worktree $WT is locked — attempting to unlock and retry"
713
+ git worktree unlock "$WT" 2>/dev/null || true
714
+ if ! git worktree remove "$WT" --force; then
715
+ echo "⚠ Residual worktree at $WT — manual cleanup required after session exits:"
716
+ echo " git worktree unlock \"$WT\" && git worktree remove \"$WT\" --force && git branch -D \"$WT_BRANCH\""
717
+ fi
718
+ else
719
+ echo "⚠ Residual worktree at $WT (remove failed) — investigate manually"
720
+ fi
721
+ fi
722
+
723
+ # Delete the temporary branch
724
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
725
+ fi
726
+ done
727
+ ```
728
+
729
+ **If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
730
+
731
+ **If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
732
+
733
+ 5.6. **Post-merge test gate (parallel mode only):**
734
+
735
+ After merging all worktrees in a wave, run the project's test suite to catch
736
+ cross-plan integration issues that individual worktree self-checks cannot detect
737
+ (e.g., conflicting type definitions, removed exports, import changes).
738
+
739
+ This addresses the Generator self-evaluation blind spot identified in Anthropic's
740
+ harness engineering research: agents reliably report Self-Check: PASSED even when
741
+ merging their work creates failures.
742
+
743
+ ```bash
744
+ # Resolve test command: project config > Makefile > language sniff
745
+ TEST_CMD=$(gsd-remix-sdk query config-get workflow.test_command --default "" 2>/dev/null || true)
746
+ if [ -z "$TEST_CMD" ]; then
747
+ if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
748
+ TEST_CMD="make test"
749
+ elif [ -f "Justfile" ] || [ -f "justfile" ]; then
750
+ TEST_CMD="just test"
751
+ elif [ -f "package.json" ]; then
752
+ TEST_CMD="npm test"
753
+ elif [ -f "Cargo.toml" ]; then
754
+ TEST_CMD="cargo test"
755
+ elif [ -f "go.mod" ]; then
756
+ TEST_CMD="go test ./..."
757
+ elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
758
+ TEST_CMD="python -m pytest -x -q --tb=short 2>&1 || uv run python -m pytest -x -q --tb=short"
759
+ else
760
+ TEST_CMD="true"
761
+ echo "⚠ No test runner detected — skipping post-merge test gate"
762
+ fi
763
+ fi
764
+ # Detect test runner and run quick smoke test (timeout: 5 minutes)
765
+ TEST_EXIT=0
766
+ timeout 300 bash -c "$TEST_CMD" 2>&1
767
+ TEST_EXIT=$?
768
+ if [ "${TEST_EXIT}" -eq 0 ]; then
769
+ echo "✓ Post-merge test gate passed — no cross-plan conflicts"
770
+ elif [ "${TEST_EXIT}" -eq 124 ]; then
771
+ echo "⚠ Post-merge test gate timed out after 5 minutes"
772
+ else
773
+ echo "✗ Post-merge test gate failed (exit code ${TEST_EXIT})"
774
+ WAVE_FAILURE_COUNT=$((WAVE_FAILURE_COUNT + 1))
775
+ fi
776
+ ```
777
+
778
+ **If `TEST_EXIT` is 0 (pass):** `✓ Post-merge test gate: {N} tests passed — no cross-plan conflicts` → continue to orchestrator tracking update.
779
+
780
+ **If `TEST_EXIT` is 124 (timeout):** Log warning, treat as non-blocking, continue. Tests may need a longer budget or manual run.
781
+
782
+ **If `TEST_EXIT` is non-zero (test failure):** Increment `WAVE_FAILURE_COUNT` to track
783
+ cumulative failures across waves. Subsequent waves should report:
784
+ `⚠ Note: ${WAVE_FAILURE_COUNT} prior wave(s) had test failures`
785
+
786
+ 5.7. **Post-wave shared artifact update (worktree mode only, skip if tests failed):**
787
+
788
+ When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once.
789
+
790
+ **Only update tracking when tests passed (TEST_EXIT=0).**
791
+ If tests failed or timed out, skip the tracking update — plans should
792
+ not be marked as complete when integration tests are failing or inconclusive.
793
+
794
+ ```bash
795
+ # Guard: only update tracking if post-merge tests passed
796
+ # Timeout (124) is treated as inconclusive — do NOT mark plans complete
797
+ if [ "${TEST_EXIT}" -eq 0 ]; then
798
+ # Update ROADMAP plan progress for each completed plan in this wave
799
+ for plan_id in {completed_plan_ids}; do
800
+ gsd-remix-sdk query roadmap.update-plan-progress "${PHASE_NUMBER}" "${plan_id}" "complete"
801
+ done
802
+
803
+ # Only commit tracking files if they actually changed
804
+ if ! git diff --quiet .planning/ROADMAP.md .planning/STATE.md 2>/dev/null; then
805
+ gsd-remix-sdk query commit "docs(phase-${PHASE_NUMBER}): update tracking after wave ${N}" .planning/ROADMAP.md .planning/STATE.md
806
+ fi
807
+ elif [ "${TEST_EXIT}" -eq 124 ]; then
808
+ echo "⚠ Skipping tracking update — test suite timed out. Plans remain in-progress. Run tests manually to confirm."
809
+ else
810
+ echo "⚠ Skipping tracking update — post-merge tests failed (exit ${TEST_EXIT}). Plans remain in-progress until tests pass."
811
+ fi
812
+ ```
813
+
814
+ Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
815
+
816
+ **If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
817
+
818
+ 5.8. **Handle test gate failures (when `WAVE_FAILURE_COUNT > 0`):**
819
+
820
+ ```
821
+ ## ⚠ Post-Merge Test Failure (cumulative failures: ${WAVE_FAILURE_COUNT})
822
+
823
+ Wave {N} worktrees merged successfully, but {M} tests fail after merge.
824
+ This typically indicates conflicting changes across parallel plans
825
+ (e.g., type definitions, shared imports, API contracts).
826
+
827
+ Failed tests:
828
+ {first 10 lines of failure output}
829
+
830
+ Options:
831
+ 1. Fix now (recommended) — resolve conflicts before next wave
832
+ 2. Continue — failures may compound in subsequent waves
833
+ ```
834
+
835
+ Note: If `WAVE_FAILURE_COUNT > 1`, strongly recommend "Fix now" — compounding
836
+ failures across multiple waves become exponentially harder to diagnose.
837
+
838
+ If "Fix now": diagnose failures (typically import conflicts, missing types,
839
+ or changed function signatures from parallel plans modifying the same module).
840
+ Fix, commit as `fix: resolve post-merge conflicts from wave {N}`, re-run tests.
841
+
842
+ **Why this matters:** Worktree isolation means each agent's Self-Check passes
843
+ in isolation. But when merged, add/add conflicts in shared files (models, registries,
844
+ CLI entry points) can silently drop code. The post-merge gate catches this before
845
+ the next wave builds on a broken foundation.
846
+
847
+ 6. **Report completion — spot-check claims first:**
848
+
849
+ For each SUMMARY.md:
850
+ - Verify first 2 files from `key-files.created` exist on disk
851
+ - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
852
+ - Check for `## Self-Check: FAILED` marker
853
+
854
+ If ANY spot-check fails: report which plan failed, route to failure handler — ask "Retry plan?" or "Continue with remaining waves?"
855
+
856
+ If pass:
857
+ ```
858
+ ---
859
+ ## Wave {N} Complete
860
+
861
+ **{Plan ID}: {Plan Name}**
862
+ {What was built — from SUMMARY.md}
863
+ {Notable deviations, if any}
864
+
865
+ {If more waves: what this enables for next wave}
866
+ ---
867
+ ```
868
+
869
+ - Bad: "Wave 2 complete. Proceeding to Wave 3."
870
+ - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
871
+
872
+ 7. **Handle failures:**
873
+
874
+ **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a GSD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
875
+
876
+ For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
877
+
878
+ 7b. **Pre-wave dependency check (waves 2+ only):**
879
+
880
+ Before spawning wave N+1, for each plan in the upcoming wave:
881
+ ```bash
882
+ gsd-remix-sdk query verify.key-links {phase_dir}/{plan}-PLAN.md
883
+ ```
884
+
885
+ If any key-link from a PRIOR wave's artifact fails verification:
886
+
887
+ ## Cross-Plan Wiring Gap
888
+
889
+ | Plan | Link | From | Expected Pattern | Status |
890
+ |------|------|------|-----------------|--------|
891
+ | {plan} | {via} | {from} | {pattern} | NOT FOUND |
892
+
893
+ Wave {N} artifacts may not be properly wired. Options:
894
+ 1. Investigate and fix before continuing
895
+ 2. Continue (may cause cascading failures in wave {N+1})
896
+
897
+ Key-links referencing files in the CURRENT (upcoming) wave are skipped.
898
+
899
+ 8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
900
+
901
+ 9. **Proceed to next wave.**
902
+ </step>
903
+
904
+ <step name="checkpoint_handling">
905
+ Plans with `autonomous: false` require user interaction.
906
+
907
+ **Auto-mode checkpoint handling:**
908
+
909
+ Read auto-advance config (chain flag OR user preference — same boolean as `check.auto-mode`):
910
+ ```bash
911
+ AUTO_MODE=$(gsd-remix-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
912
+ ```
913
+
914
+ When executor returns a checkpoint AND `AUTO_MODE` is `true`:
915
+ - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
916
+ - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
917
+ - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
918
+
919
+ **Standard flow (not auto-mode, or human-action type):**
920
+
921
+ 1. Spawn agent for checkpoint plan
922
+ 2. Agent runs until checkpoint task or auth gate → returns structured state
923
+ 3. Agent return includes: completed tasks table, current task + blocker, checkpoint type/details, what's awaited
924
+ 4. **Present to user:**
925
+ ```
926
+ ## Checkpoint: [Type]
927
+
928
+ **Plan:** 03-03 Dashboard Layout
929
+ **Progress:** 2/3 tasks complete
930
+
931
+ [Checkpoint Details from agent return]
932
+ [Awaiting section from agent return]
933
+ ```
934
+ 5. User responds: "approved"/"done" | issue description | decision selection
935
+ 6. **Spawn continuation agent (NOT resume)** using continuation-prompt.md template:
936
+ - `{completed_tasks_table}`: From checkpoint return
937
+ - `{resume_task_number}` + `{resume_task_name}`: Current task
938
+ - `{user_response}`: What user provided
939
+ - `{resume_instructions}`: Based on checkpoint type
940
+ 7. Continuation agent verifies previous commits, continues from resume point
941
+ 8. Repeat until plan completes or user stops
942
+
943
+ **Why fresh agent, not resume:** Resume relies on internal serialization that breaks with parallel tool calls. Fresh agents with explicit state are more reliable.
944
+
945
+ **Checkpoints in parallel waves:** Agent pauses and returns while other parallel agents may complete. Present checkpoint, spawn continuation, wait for all before next wave.
946
+ </step>
947
+
948
+ <step name="aggregate_results">
949
+ After all waves:
950
+
951
+ ```markdown
952
+ ## Phase {X}: {Name} Execution Complete
953
+
954
+ **Waves:** {N} | **Plans:** {M}/{total} complete
955
+
956
+ | Wave | Plans | Status |
957
+ |------|-------|--------|
958
+ | 1 | plan-01, plan-02 | ✓ Complete |
959
+ | CP | plan-03 | ✓ Verified |
960
+ | 2 | plan-04 | ✓ Complete |
961
+
962
+ ### Plan Details
963
+ 1. **03-01**: [one-liner from SUMMARY.md]
964
+ 2. **03-02**: [one-liner from SUMMARY.md]
965
+
966
+ ### Issues Encountered
967
+ [Aggregate from SUMMARYs, or "None"]
968
+ ```
969
+
970
+ **Security gate check:**
971
+ ```bash
972
+ SECURITY_CFG=$(gsd-remix-sdk query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
973
+ SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
974
+ ```
975
+
976
+ If `SECURITY_CFG` is `false`: skip.
977
+
978
+ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
979
+ Include in the next-steps routing output:
980
+ ```
981
+ ⚠ Security enforcement enabled — run before advancing:
982
+ /gsd-secure-phase {PHASE} ${GSD_WS}
983
+ ```
984
+
985
+ If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
986
+ ```
987
+ ⚠ Security gate: {threats_open} threats open
988
+ /gsd-secure-phase {PHASE} — resolve before advancing
989
+ ```
990
+ </step>
991
+
992
+ <step name="tdd_review_checkpoint">
993
+ **Optional step — TDD collaborative review.**
994
+
995
+ ```bash
996
+ TDD_MODE=$(gsd-remix-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
997
+ ```
998
+
999
+ **Skip if `TDD_MODE` is `false`.**
1000
+
1001
+ When `TDD_MODE` is `true`, check whether any completed plans in this phase have `type: tdd` in their frontmatter:
1002
+
1003
+ ```bash
1004
+ TDD_PLANS=$(grep -rl "^type: tdd" "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1005
+ ```
1006
+
1007
+ **If `TDD_PLANS` > 0:** Insert end-of-phase collaborative review checkpoint.
1008
+
1009
+ 1. Collect all SUMMARY.md files for TDD plans
1010
+ 2. For each TDD plan summary, verify the RED/GREEN/REFACTOR gate sequence:
1011
+ - RED gate: A failing test commit exists (`test(...)` commit with MUST-fail evidence)
1012
+ - GREEN gate: An implementation commit exists (`feat(...)` commit making tests pass)
1013
+ - REFACTOR gate: Optional cleanup commit (`refactor(...)` commit, tests still pass)
1014
+ 3. If any TDD plan is missing the RED or GREEN gate commits, flag it:
1015
+ ```
1016
+ ⚠ TDD gate violation: Plan {plan_id} missing {RED|GREEN} phase commit.
1017
+ Expected commit pattern: test({phase}-{plan}): ... → feat({phase}-{plan}): ...
1018
+ ```
1019
+ 4. Present collaborative review summary:
1020
+ ```
1021
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1022
+ TDD REVIEW — Phase {X}
1023
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1024
+
1025
+ TDD Plans: {TDD_PLANS} | Gate violations: {count}
1026
+
1027
+ | Plan | RED | GREEN | REFACTOR | Status |
1028
+ |------|-----|-------|----------|--------|
1029
+ | {id} | ✓ | ✓ | ✓ | Pass |
1030
+ | {id} | ✓ | ✗ | — | FAIL |
1031
+ ```
1032
+
1033
+ **Gate violations are advisory** — they do not block execution but are surfaced to the user for review. The verifier agent (step `verify_phase_goal`) will also check TDD discipline as part of its quality assessment.
1034
+ </step>
1035
+
1036
+ <step name="handle_partial_wave_execution">
1037
+ If `WAVE_FILTER` was used, re-run plan discovery after execution:
1038
+
1039
+ ```bash
1040
+ POST_PLAN_INDEX=$(gsd-remix-sdk query phase-plan-index "${PHASE_NUMBER}")
1041
+ ```
1042
+
1043
+ Apply the same "incomplete" filtering rules as earlier:
1044
+ - ignore plans with `has_summary: true`
1045
+ - if `--gaps-only`, only consider `gap_closure: true` plans
1046
+
1047
+ **If incomplete plans still remain anywhere in the phase:**
1048
+ - STOP here
1049
+ - Do NOT run phase verification
1050
+ - Do NOT mark the phase complete in ROADMAP/STATE
1051
+ - Present:
1052
+
1053
+ ```markdown
1054
+ ## Wave {WAVE_FILTER} Complete
1055
+
1056
+ Selected wave finished successfully. This phase still has incomplete plans, so phase-level verification and completion were intentionally skipped.
1057
+
1058
+ /gsd-execute-phase {phase} ${GSD_WS} # Continue remaining waves
1059
+ /gsd-execute-phase {phase} --wave {next} ${GSD_WS} # Run the next wave explicitly
1060
+ ```
1061
+
1062
+ **If no incomplete plans remain after the selected wave finishes:**
1063
+ - continue with the normal phase-level verification and completion flow below
1064
+ - this means the selected wave happened to be the last remaining work in the phase
1065
+ </step>
1066
+
1067
+ <step name="code_review_gate" required="true">
1068
+ **This step is REQUIRED and must not be skipped.** Auto-invoke code review on the phase's source changes. Advisory only — never blocks execution flow.
1069
+
1070
+ **Config gate:**
1071
+ ```bash
1072
+ CODE_REVIEW_ENABLED=$(gsd-remix-sdk query config-get workflow.code_review 2>/dev/null || echo "true")
1073
+ ```
1074
+
1075
+ If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
1076
+
1077
+ **Invoke review:**
1078
+ ```
1079
+ Skill(skill="gsd:code-review", args="${PHASE_NUMBER}")
1080
+ ```
1081
+
1082
+ **Check results using deterministic path (not glob):**
1083
+ ```bash
1084
+ PADDED=$(printf "%02d" "${PHASE_NUMBER}")
1085
+ REVIEW_FILE="${PHASE_DIR}/${PADDED}-REVIEW.md"
1086
+ REVIEW_STATUS=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^status:" | head -1 | cut -d: -f2 | tr -d ' ')
1087
+ ```
1088
+
1089
+ If REVIEW_STATUS is not "clean" and not "skipped" and not empty, display:
1090
+ ```
1091
+ Code review found issues. Consider running:
1092
+ /gsd-code-review-fix ${PHASE_NUMBER}
1093
+ ```
1094
+
1095
+ **Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to next step. Review failures must never block execution.
1096
+
1097
+ Regardless of review result, ALWAYS proceed to close_parent_artifacts → regression_gate → verify_phase_goal.
1098
+ </step>
1099
+
1100
+ <step name="close_parent_artifacts">
1101
+ **For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
1102
+
1103
+ **Skip if** phase number has no decimal (e.g., `3`, `04`) — only applies to gap-closure phases like `4.1`, `03.1`.
1104
+
1105
+ **1. Detect decimal phase and derive parent:**
1106
+ ```bash
1107
+ # Check if phase_number contains a decimal
1108
+ if [[ "$PHASE_NUMBER" == *.* ]]; then
1109
+ PARENT_PHASE="${PHASE_NUMBER%%.*}"
1110
+ fi
1111
+ ```
1112
+
1113
+ **2. Find parent UAT file:**
1114
+ ```bash
1115
+ PARENT_INFO=$(gsd-remix-sdk query find-phase "${PARENT_PHASE}" --raw)
1116
+ # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
1117
+ ```
1118
+
1119
+ **If no parent UAT found:** Skip this step (gap-closure may have been triggered by VERIFICATION.md instead).
1120
+
1121
+ **3. Update UAT gap statuses:**
1122
+
1123
+ Read the parent UAT file's `## Gaps` section. For each gap entry with `status: failed`:
1124
+ - Update to `status: resolved`
1125
+
1126
+ **4. Update UAT frontmatter:**
1127
+
1128
+ If all gaps now have `status: resolved`:
1129
+ - Update frontmatter `status: diagnosed` → `status: resolved`
1130
+ - Update frontmatter `updated:` timestamp
1131
+
1132
+ **5. Resolve referenced debug sessions:**
1133
+
1134
+ For each gap that has a `debug_session:` field:
1135
+ - Read the debug session file
1136
+ - Update frontmatter `status:` → `resolved`
1137
+ - Update frontmatter `updated:` timestamp
1138
+ - Move to resolved directory:
1139
+ ```bash
1140
+ mkdir -p .planning/debug/resolved
1141
+ mv .planning/debug/{slug}.md .planning/debug/resolved/
1142
+ ```
1143
+
1144
+ **6. Commit updated artifacts:**
1145
+ ```bash
1146
+ gsd-remix-sdk query commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
1147
+ ```
1148
+ </step>
1149
+
1150
+ <step name="regression_gate">
1151
+ Run prior phases' test suites to catch cross-phase regressions BEFORE verification.
1152
+
1153
+ **Skip if:** This is the first phase (no prior phases), or no prior VERIFICATION.md files exist.
1154
+
1155
+ **Step 1: Discover prior phases' test files**
1156
+ ```bash
1157
+ # Find all VERIFICATION.md files from prior phases in current milestone
1158
+ PRIOR_VERIFICATIONS=$(find .planning/phases/ -name "*-VERIFICATION.md" ! -path "*${PHASE_NUMBER}*" 2>/dev/null)
1159
+ ```
1160
+
1161
+ **Step 2: Extract test file lists from prior verifications**
1162
+
1163
+ For each VERIFICATION.md found, look for test file references:
1164
+ - Lines containing `test`, `spec`, or `__tests__` paths
1165
+ - The "Test Suite" or "Automated Checks" section
1166
+ - File patterns from `key-files.created` in corresponding SUMMARY.md files that match `*.test.*` or `*.spec.*`
1167
+
1168
+ Collect all unique test file paths into `REGRESSION_FILES`.
1169
+
1170
+ **Step 3: Run regression tests (if any found)**
1171
+
1172
+ ```bash
1173
+ # Resolve test command: project config > Makefile > language sniff
1174
+ REG_TEST_CMD=$(gsd-remix-sdk query config-get workflow.test_command --default "" 2>/dev/null || true)
1175
+ if [ -z "$REG_TEST_CMD" ]; then
1176
+ if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
1177
+ REG_TEST_CMD="make test"
1178
+ elif [ -f "Justfile" ] || [ -f "justfile" ]; then
1179
+ REG_TEST_CMD="just test"
1180
+ elif [ -f "package.json" ]; then
1181
+ REG_TEST_CMD="npm test"
1182
+ elif [ -f "Cargo.toml" ]; then
1183
+ REG_TEST_CMD="cargo test"
1184
+ elif [ -f "go.mod" ]; then
1185
+ REG_TEST_CMD="go test ./..."
1186
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
1187
+ REG_TEST_CMD="python -m pytest ${REGRESSION_FILES} -q --tb=short"
1188
+ else
1189
+ REG_TEST_CMD="true"
1190
+ fi
1191
+ fi
1192
+ # Detect test runner and run prior phase tests
1193
+ eval "$REG_TEST_CMD" 2>&1
1194
+ ```
1195
+
1196
+ **Step 4: Report results**
1197
+
1198
+ If all tests pass:
1199
+ ```
1200
+ ✓ Regression gate: {N} prior-phase test files passed — no regressions detected
1201
+ ```
1202
+ → Proceed to verify_phase_goal
1203
+
1204
+ If any tests fail:
1205
+ ```
1206
+ ## ⚠ Cross-Phase Regression Detected
1207
+
1208
+ Phase {X} execution may have broken functionality from prior phases.
1209
+
1210
+ | Test File | Phase | Status | Detail |
1211
+ |-----------|-------|--------|--------|
1212
+ | {file} | {origin_phase} | FAILED | {first_failure_line} |
1213
+
1214
+ Options:
1215
+ 1. Fix regressions before verification (recommended)
1216
+ 2. Continue to verification anyway (regressions will compound)
1217
+ 3. Abort phase — roll back and re-plan
1218
+ ```
1219
+
1220
+ Use AskUserQuestion to present the options.
1221
+ </step>
1222
+
1223
+ <step name="schema_drift_gate">
1224
+ Post-execution schema drift detection. Catches false-positive verification where
1225
+ build/types pass because TypeScript types come from config, not the live database.
1226
+
1227
+ **Run after execution completes but BEFORE verification marks success.**
1228
+
1229
+ ```bash
1230
+ SCHEMA_DRIFT=$(gsd-remix-sdk query verify.schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1231
+ ```
1232
+
1233
+ Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
1234
+
1235
+ **If `drift_detected` is false:** Skip to verify_phase_goal.
1236
+
1237
+ **If `drift_detected` is true AND `blocking` is true:**
1238
+
1239
+ Check for override:
1240
+ ```bash
1241
+ SKIP_SCHEMA=$(echo "${GSD_SKIP_SCHEMA_CHECK:-false}")
1242
+ ```
1243
+
1244
+ **If `SKIP_SCHEMA` is `true`:**
1245
+
1246
+ Display:
1247
+ ```
1248
+ ⚠ Schema drift detected but GSD_SKIP_SCHEMA_CHECK=true — bypassing gate.
1249
+
1250
+ Schema files changed: {schema_files}
1251
+ ORMs requiring push: {unpushed_orms}
1252
+
1253
+ Proceeding to verification (database may be out of sync).
1254
+ ```
1255
+ → Continue to verify_phase_goal.
1256
+
1257
+ **If `SKIP_SCHEMA` is not `true`:**
1258
+
1259
+ BLOCK verification. Display:
1260
+
1261
+ ```
1262
+ ## BLOCKED: Schema Drift Detected
1263
+
1264
+ Schema-relevant files changed during this phase but no database push command
1265
+ was executed. Build and type checks pass because TypeScript types come from
1266
+ config, not the live database — verification would produce a false positive.
1267
+
1268
+ Schema files changed: {schema_files}
1269
+ ORMs requiring push: {unpushed_orms}
1270
+
1271
+ Required push commands:
1272
+ {For each unpushed ORM, show the push command from the message}
1273
+
1274
+ Options:
1275
+ 1. Run push command now (recommended) — execute the push, then re-verify
1276
+ 2. Skip schema check (GSD_SKIP_SCHEMA_CHECK=true) — bypass this gate
1277
+ 3. Abort — stop execution and investigate
1278
+ ```
1279
+
1280
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
1281
+
1282
+ **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
1283
+
1284
+ **If user selects option 2:** Set override and continue to verify_phase_goal.
1285
+
1286
+ **If user selects option 3:** Stop execution. Report partial completion.
1287
+ </step>
1288
+
1289
+ <step name="verify_phase_goal">
1290
+ Verify phase achieved its GOAL, not just completed tasks.
1291
+
1292
+ ```bash
1293
+ VERIFIER_SKILLS=$(gsd-remix-sdk query agent-skills gsd-verifier 2>/dev/null)
1294
+ ```
1295
+
1296
+ ```
1297
+ Task(
1298
+ description="Verify phase {phase_number} goal achievement",
1299
+ prompt="Verify phase {phase_number} goal achievement.
1300
+ Phase directory: {phase_dir}
1301
+ Phase goal: {goal from ROADMAP.md}
1302
+ Phase requirement IDs: {phase_req_ids}
1303
+ Check must_haves against actual codebase.
1304
+ Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
1305
+ Create VERIFICATION.md.
1306
+
1307
+ <files_to_read>
1308
+ Read these files before verification:
1309
+ - {phase_dir}/*-PLAN.md (All plans — understand intent, check must_haves)
1310
+ - {phase_dir}/*-SUMMARY.md (All summaries — cross-reference claimed vs actual)
1311
+ - .planning/REQUIREMENTS.md (Requirement traceability)
1312
+ ${CONTEXT_WINDOW >= 500000 ? `- {phase_dir}/*-CONTEXT.md (User decisions — verify they were honored)
1313
+ - {phase_dir}/*-RESEARCH.md (Known pitfalls — check for traps)
1314
+ - Prior VERIFICATION.md files from earlier phases (regression check)
1315
+ ` : ''}
1316
+ </files_to_read>
1317
+
1318
+ ${VERIFIER_SKILLS}",
1319
+ subagent_type="gsd-verifier",
1320
+ model="{verifier_model}"
1321
+ )
1322
+ ```
1323
+
1324
+ Read status:
1325
+ ```bash
1326
+ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
1327
+ ```
1328
+
1329
+ | Status | Action |
1330
+ |--------|--------|
1331
+ | `passed` | → update_roadmap |
1332
+ | `human_needed` | Present items for human testing, get approval or feedback |
1333
+ | `gaps_found` | Present gap summary, offer `/gsd-plan-phase {phase} --gaps ${GSD_WS}` |
1334
+
1335
+ **If human_needed:**
1336
+
1337
+ **Step A: Persist human verification items as UAT file.**
1338
+
1339
+ Create `{phase_dir}/{phase_num}-HUMAN-UAT.md` using UAT template format:
1340
+
1341
+ ```markdown
1342
+ ---
1343
+ status: partial
1344
+ phase: {phase_num}-{phase_name}
1345
+ source: [{phase_num}-VERIFICATION.md]
1346
+ started: [now ISO]
1347
+ updated: [now ISO]
1348
+ ---
1349
+
1350
+ ## Current Test
1351
+
1352
+ [awaiting human testing]
1353
+
1354
+ ## Tests
1355
+
1356
+ {For each human_verification item from VERIFICATION.md:}
1357
+
1358
+ ### {N}. {item description}
1359
+ expected: {expected behavior from VERIFICATION.md}
1360
+ result: [pending]
1361
+
1362
+ ## Summary
1363
+
1364
+ total: {count}
1365
+ passed: 0
1366
+ issues: 0
1367
+ pending: {count}
1368
+ skipped: 0
1369
+ blocked: 0
1370
+
1371
+ ## Gaps
1372
+ ```
1373
+
1374
+ Commit the file:
1375
+ ```bash
1376
+ gsd-remix-sdk query commit "test({phase_num}): persist human verification items as UAT" "{phase_dir}/{phase_num}-HUMAN-UAT.md"
1377
+ ```
1378
+
1379
+ **Step B: Present to user:**
1380
+
1381
+ ```
1382
+ ## ✓ Phase {X}: {Name} — Human Verification Required
1383
+
1384
+ All automated checks passed. {N} items need human testing:
1385
+
1386
+ {From VERIFICATION.md human_verification section}
1387
+
1388
+ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/gsd-progress` and `/gsd-audit-uat`.
1389
+
1390
+ "approved" → continue | Report issues → gap closure
1391
+ ```
1392
+
1393
+ **If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/gsd-verify-work` on it.
1394
+
1395
+ **If user reports issues:** Proceed to gap closure as currently implemented.
1396
+
1397
+ **If gaps_found:**
1398
+ ```
1399
+ ## ⚠ Phase {X}: {Name} — Gaps Found
1400
+
1401
+ **Score:** {N}/{M} must-haves verified
1402
+ **Report:** {phase_dir}/{phase_num}-VERIFICATION.md
1403
+
1404
+ ### What's Missing
1405
+ {Gap summaries from VERIFICATION.md}
1406
+
1407
+ ---
1408
+ ## ▶ Next Up — [${PROJECT_CODE}] ${PROJECT_TITLE}
1409
+
1410
+ `/clear` then:
1411
+
1412
+ `/gsd-plan-phase {X} --gaps ${GSD_WS}`
1413
+
1414
+ Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
1415
+ Also: `/gsd-verify-work {X} ${GSD_WS}` — manual testing first
1416
+ ```
1417
+
1418
+ Gap closure cycle: `/gsd-plan-phase {X} --gaps ${GSD_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/gsd-execute-phase {X} --gaps-only ${GSD_WS}` → verifier re-runs.
1419
+ </step>
1420
+
1421
+ <step name="capture_failure_memory">
1422
+ **Persist failure signals for future self-evolution memory.**
1423
+
1424
+ This step is non-blocking and should run immediately after verification writes its artifacts.
1425
+
1426
+ ```bash
1427
+ gsd-remix-sdk query failure.capture-phase "${PHASE_NUMBER}" 2>/dev/null || echo '{"captured":0}'
1428
+ ```
1429
+
1430
+ This captures:
1431
+ - `SUMMARY.md` execution issues
1432
+ - `SUMMARY.md` self-check failures
1433
+ - `VERIFICATION.md` non-passed outcomes
1434
+ - `.continue-here.md` blocking anti-patterns
1435
+
1436
+ **If capture fails:** Ignore the error and continue. Failure-memory logging must never block phase execution.
1437
+ </step>
1438
+
1439
+ <step name="promote_failure_memory">
1440
+ **Compile captured failure events into longer-lived memory artifacts.**
1441
+
1442
+ This step is also non-blocking and should run after `capture_failure_memory`.
1443
+
1444
+ ```bash
1445
+ gsd-remix-sdk query failure.promote-phase "${PHASE_NUMBER}" 2>/dev/null || echo '{"entries":0}'
1446
+ ```
1447
+
1448
+ This rebuilds:
1449
+ - `.planning/failure-memory/index.json`
1450
+ - `.planning/FAILURE-MEMORY.md`
1451
+ - `.planning/failure-memory/FM-xxx.md` detail files
1452
+
1453
+ Promotion is conservative:
1454
+ - blocking anti-patterns promote immediately
1455
+ - other failures promote only after repeated matching evidence
1456
+
1457
+ **If promotion fails:** Ignore the error and continue. Self-evolution indexing must never block phase execution.
1458
+ </step>
1459
+
1460
+ <step name="update_roadmap">
1461
+ **Mark phase complete and update all tracking files:**
1462
+
1463
+ ```bash
1464
+ COMPLETION=$(gsd-remix-sdk query phase.complete "${PHASE_NUMBER}")
1465
+ ```
1466
+
1467
+ The CLI handles:
1468
+ - Marking phase checkbox `[x]` with completion date
1469
+ - Updating Progress table (Status → Complete, date)
1470
+ - Updating plan count to final
1471
+ - Advancing STATE.md to next phase
1472
+ - Updating REQUIREMENTS.md traceability
1473
+ - Scanning for verification debt (returns `warnings` array)
1474
+
1475
+ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `warnings`, `has_warnings`.
1476
+
1477
+ **If has_warnings is true:**
1478
+ ```
1479
+ ## Phase {X} marked complete with {N} warnings:
1480
+
1481
+ {list each warning}
1482
+
1483
+ These items are tracked and will appear in `/gsd-progress` and `/gsd-audit-uat`.
1484
+ ```
1485
+
1486
+ ```bash
1487
+ gsd-remix-sdk query commit "docs(phase-{X}): complete phase execution" .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1488
+ ```
1489
+ </step>
1490
+
1491
+ <step name="auto_copy_learnings">
1492
+ **Auto-copy phase learnings to global store (when enabled).**
1493
+
1494
+ This step runs AFTER phase completion and SUMMARY.md is written. It copies any LEARNINGS.md
1495
+ entries from the completed phase to the global learnings store at `~/.gsd/knowledge/`.
1496
+
1497
+ **Check config gate:**
1498
+ ```bash
1499
+ GL_ENABLED=$(gsd-remix-sdk query config-get features.global_learnings --raw 2>/dev/null || echo "false")
1500
+ ```
1501
+
1502
+ **If `GL_ENABLED` is not `true`:** Skip this step entirely (feature disabled by default).
1503
+
1504
+ **If enabled:**
1505
+
1506
+ 1. Check if LEARNINGS.md exists in the phase directory (use the `phase_dir` value from init context)
1507
+ 2. If found, copy to global store:
1508
+ ```bash
1509
+ gsd-remix-sdk query learnings.copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
1510
+ ```
1511
+ Copy failure must NOT block phase completion.
1512
+ </step>
1513
+
1514
+ <step name="close_phase_todos">
1515
+ **Auto-close pending todos tagged for this phase (#2433).**
1516
+
1517
+ This step runs AFTER `update_roadmap` marks the phase complete. It moves any pending todos that carry `resolves_phase: <current-phase-number>` to the completed directory.
1518
+
1519
+ ```bash
1520
+ PHASE_NUM="${PHASE_NUMBER}"
1521
+ PENDING_DIR=".planning/todos/pending"
1522
+ COMPLETED_DIR=".planning/todos/completed"
1523
+ mkdir -p "$COMPLETED_DIR"
1524
+
1525
+ CLOSED=()
1526
+ for TODO_FILE in "$PENDING_DIR"/*.md; do
1527
+ [ -f "$TODO_FILE" ] || continue
1528
+ # Extract resolves_phase from YAML frontmatter (first --- block only)
1529
+ RP=$(awk '/^---/{c++;next} c==1 && /^resolves_phase:/{print $2;exit} c==2{exit}' "$TODO_FILE" 2>/dev/null || true)
1530
+ if [ "$RP" = "$PHASE_NUM" ] || [ "$RP" = "\"$PHASE_NUM\"" ]; then
1531
+ mv "$TODO_FILE" "$COMPLETED_DIR/"
1532
+ CLOSED+=("$(basename "$TODO_FILE")")
1533
+ fi
1534
+ done
1535
+
1536
+ if [ ${#CLOSED[@]} -gt 0 ]; then
1537
+ gsd-remix-sdk query commit "docs(phase-${PHASE_NUMBER}): auto-close ${#CLOSED[@]} todo(s) resolved by this phase" .planning/todos/completed/ .planning/STATE.md || true
1538
+ echo "◆ Closed ${#CLOSED[@]} todo(s) resolved by Phase ${PHASE_NUMBER}:"
1539
+ for f in "${CLOSED[@]}"; do echo " ✓ $f"; done
1540
+ fi
1541
+ ```
1542
+
1543
+ **If no todos have `resolves_phase: <this-phase>`:** Skip silently — this step is always additive and never blocks phase completion.
1544
+ </step>
1545
+
1546
+ <step name="update_project_md">
1547
+ **Evolve PROJECT.md to reflect phase completion (prevents planning document drift — #956):**
1548
+
1549
+ PROJECT.md tracks validated requirements, decisions, and current state. Without this step,
1550
+ PROJECT.md falls behind silently over multiple phases.
1551
+
1552
+ 1. Read `.planning/PROJECT.md`
1553
+ 2. If the file exists and has a `## Validated Requirements` or `## Requirements` section:
1554
+ - Move any requirements validated by this phase from Active → Validated
1555
+ - Add a brief note: `Validated in Phase {X}: {Name}`
1556
+ 3. If the file has a `## Current State` or similar section:
1557
+ - Update it to reflect this phase's completion (e.g., "Phase {X} complete — {one-liner}")
1558
+ 4. Update the `Last updated:` footer to today's date
1559
+ 5. Commit the change:
1560
+
1561
+ ```bash
1562
+ gsd-remix-sdk query commit "docs(phase-{X}): evolve PROJECT.md after phase completion" .planning/PROJECT.md
1563
+ ```
1564
+
1565
+ **Skip this step if** `.planning/PROJECT.md` does not exist.
1566
+ </step>
1567
+
1568
+ <step name="offer_next">
1569
+
1570
+ **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/gsd-plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
1571
+
1572
+ **No-transition check (spawned by auto-advance chain):**
1573
+
1574
+ Parse `--no-transition` flag from $ARGUMENTS.
1575
+
1576
+ **If `--no-transition` flag present:**
1577
+
1578
+ Execute-phase was spawned by plan-phase's auto-advance. Do NOT run transition.md.
1579
+ After verification passes and roadmap is updated, return completion status to parent:
1580
+
1581
+ ```
1582
+ ## PHASE COMPLETE
1583
+
1584
+ Phase: ${PHASE_NUMBER} - ${PHASE_NAME}
1585
+ Plans: ${completed_count}/${total_count}
1586
+ Verification: {Passed | Gaps Found}
1587
+
1588
+ [Include aggregate_results output]
1589
+ ```
1590
+
1591
+ STOP. Do not proceed to auto-advance or transition.
1592
+
1593
+ **If `--no-transition` flag is NOT present:**
1594
+
1595
+ **Auto-advance detection:**
1596
+
1597
+ 1. Parse `--auto` flag from $ARGUMENTS
1598
+ 2. Read consolidated auto-mode (`active` = chain flag OR user preference; chain flag already synced in init step):
1599
+ ```bash
1600
+ AUTO_MODE=$(gsd-remix-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
1601
+ ```
1602
+
1603
+ **If `--auto` flag present OR `AUTO_MODE` is true (AND verification passed with no gaps):**
1604
+
1605
+ ```
1606
+ ╔══════════════════════════════════════════╗
1607
+ ║ AUTO-ADVANCING → TRANSITION ║
1608
+ ║ Phase {X} verified, continuing chain ║
1609
+ ╚══════════════════════════════════════════╝
1610
+ ```
1611
+
1612
+ Execute the transition workflow inline (do NOT use Task — orchestrator context is ~10-15%, transition needs phase completion data already in context):
1613
+
1614
+ Read and follow `~/.claude/get-shit-done/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
1615
+
1616
+ **If neither `--auto` nor `AUTO_MODE` is true:**
1617
+
1618
+ **STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
1619
+
1620
+ **IMPORTANT: There is NO `/gsd-transition` command. Never suggest it. The transition workflow is internal only.**
1621
+
1622
+ Check whether CONTEXT.md already exists for the next phase:
1623
+
1624
+ ```bash
1625
+ ls .planning/phases/*{next}*/{next}-CONTEXT.md 2>/dev/null || echo "no-context"
1626
+ ```
1627
+
1628
+ If CONTEXT.md does **not** exist for the next phase, present:
1629
+
1630
+ ```
1631
+ ## ✓ Phase {X}: {Name} Complete
1632
+
1633
+ /gsd-progress ${GSD_WS} — see updated roadmap
1634
+ /gsd-discuss-phase {next} ${GSD_WS} — start here: discuss next phase before planning ← recommended
1635
+ /gsd-plan-phase {next} ${GSD_WS} — plan next phase (skip discuss)
1636
+ /gsd-execute-phase {next} ${GSD_WS} — execute next phase (skip discuss and plan)
1637
+ ```
1638
+
1639
+ If CONTEXT.md **exists** for the next phase, present:
1640
+
1641
+ ```
1642
+ ## ✓ Phase {X}: {Name} Complete
1643
+
1644
+ /gsd-progress ${GSD_WS} — see updated roadmap
1645
+ /gsd-plan-phase {next} ${GSD_WS} — start here: plan next phase (CONTEXT.md already present) ← recommended
1646
+ /gsd-discuss-phase {next} ${GSD_WS} — re-discuss next phase
1647
+ /gsd-execute-phase {next} ${GSD_WS} — execute next phase (skip planning)
1648
+ ```
1649
+
1650
+ Only suggest the commands listed above. Do not invent or hallucinate command names.
1651
+ </step>
1652
+
1653
+ </process>
1654
+
1655
+ <context_efficiency>
1656
+ Orchestrator: ~10-15% context for 200k windows, can use more for 1M+ windows.
1657
+ Subagents: fresh context each (200k-1M depending on model). No polling (Task blocks). No context bleed.
1658
+
1659
+ For 1M+ context models, consider:
1660
+ - Passing richer context (code snippets, dependency outputs) directly to executors instead of just file paths
1661
+ - Running small phases (≤3 plans, no dependencies) inline without subagent spawning overhead
1662
+ - Relaxing /clear recommendations — context rot onset is much further out with 5x window
1663
+ </context_efficiency>
1664
+
1665
+ <failure_handling>
1666
+ - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not GSD. Spot-check (SUMMARY exists, commits present) → if pass, treat as success
1667
+ - **Agent fails mid-plan:** Missing SUMMARY.md → report, ask user how to proceed
1668
+ - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip
1669
+ - **All agents in wave fail:** Systemic issue → stop, report for investigation
1670
+ - **Checkpoint unresolvable:** "Skip this plan?" or "Abort phase execution?" → record partial progress in STATE.md
1671
+ </failure_handling>
1672
+
1673
+ <resumption>
1674
+ Re-run `/gsd-execute-phase {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
1675
+
1676
+ STATE.md tracks: last completed plan, current wave, pending checkpoints.
1677
+ </resumption>