@ktpartners/dgs-platform 2.6.2

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 (256) hide show
  1. package/LICENSE +38 -0
  2. package/README.md +851 -0
  3. package/agents/dgs-codebase-cross-analyzer.md +183 -0
  4. package/agents/dgs-codebase-mapper.md +782 -0
  5. package/agents/dgs-codebase-synthesizer.md +156 -0
  6. package/agents/dgs-debugger.md +1256 -0
  7. package/agents/dgs-executor.md +550 -0
  8. package/agents/dgs-integration-checker.md +481 -0
  9. package/agents/dgs-nyquist-auditor.md +178 -0
  10. package/agents/dgs-phase-researcher.md +563 -0
  11. package/agents/dgs-phase-verifier.md +450 -0
  12. package/agents/dgs-plan-checker.md +708 -0
  13. package/agents/dgs-planner.md +1324 -0
  14. package/agents/dgs-project-researcher.md +631 -0
  15. package/agents/dgs-research-synthesizer.md +249 -0
  16. package/agents/dgs-roadmapper.md +652 -0
  17. package/agents/dgs-verifier.md +607 -0
  18. package/bin/install.js +2073 -0
  19. package/commands/dgs/add-doc.md +45 -0
  20. package/commands/dgs/add-idea.md +38 -0
  21. package/commands/dgs/add-phase.md +43 -0
  22. package/commands/dgs/add-repo.md +54 -0
  23. package/commands/dgs/add-tests.md +41 -0
  24. package/commands/dgs/add-todo.md +47 -0
  25. package/commands/dgs/approve-spec.md +38 -0
  26. package/commands/dgs/audit-milestone.md +36 -0
  27. package/commands/dgs/audit-phase.md +37 -0
  28. package/commands/dgs/cancel-job.md +23 -0
  29. package/commands/dgs/capture-principle.md +143 -0
  30. package/commands/dgs/check-todos.md +45 -0
  31. package/commands/dgs/cleanup.md +18 -0
  32. package/commands/dgs/complete-milestone.md +136 -0
  33. package/commands/dgs/complete-project.md +70 -0
  34. package/commands/dgs/consolidate-ideas.md +50 -0
  35. package/commands/dgs/create-milestone-job.md +37 -0
  36. package/commands/dgs/debug.md +164 -0
  37. package/commands/dgs/develop-idea.md +53 -0
  38. package/commands/dgs/discuss-idea.md +41 -0
  39. package/commands/dgs/discuss-phase.md +83 -0
  40. package/commands/dgs/execute-phase.md +41 -0
  41. package/commands/dgs/fast.md +38 -0
  42. package/commands/dgs/find-related-ideas.md +43 -0
  43. package/commands/dgs/health.md +28 -0
  44. package/commands/dgs/help.md +22 -0
  45. package/commands/dgs/import-spec.md +36 -0
  46. package/commands/dgs/init-product.md +28 -0
  47. package/commands/dgs/insert-phase.md +32 -0
  48. package/commands/dgs/join-discord.md +18 -0
  49. package/commands/dgs/list-docs.md +40 -0
  50. package/commands/dgs/list-ideas.md +42 -0
  51. package/commands/dgs/list-jobs.md +22 -0
  52. package/commands/dgs/list-phase-assumptions.md +46 -0
  53. package/commands/dgs/list-projects.md +57 -0
  54. package/commands/dgs/list-specs.md +40 -0
  55. package/commands/dgs/map-codebase.md +92 -0
  56. package/commands/dgs/new-milestone.md +44 -0
  57. package/commands/dgs/new-project.md +42 -0
  58. package/commands/dgs/node-repair.md +26 -0
  59. package/commands/dgs/overlap-check.md +20 -0
  60. package/commands/dgs/pause-work.md +38 -0
  61. package/commands/dgs/plan-milestone-gaps.md +34 -0
  62. package/commands/dgs/plan-phase.md +44 -0
  63. package/commands/dgs/progress.md +24 -0
  64. package/commands/dgs/quick.md +41 -0
  65. package/commands/dgs/reactivate-project.md +70 -0
  66. package/commands/dgs/reapply-patches.md +110 -0
  67. package/commands/dgs/refine-spec.md +38 -0
  68. package/commands/dgs/reject-idea.md +43 -0
  69. package/commands/dgs/remove-doc.md +44 -0
  70. package/commands/dgs/remove-phase.md +31 -0
  71. package/commands/dgs/remove-repo.md +69 -0
  72. package/commands/dgs/research-idea.md +43 -0
  73. package/commands/dgs/research-phase.md +189 -0
  74. package/commands/dgs/restore-idea.md +45 -0
  75. package/commands/dgs/resume-work.md +40 -0
  76. package/commands/dgs/rollback-job.md +24 -0
  77. package/commands/dgs/run-job.md +35 -0
  78. package/commands/dgs/search.md +40 -0
  79. package/commands/dgs/set-profile.md +34 -0
  80. package/commands/dgs/settings.md +38 -0
  81. package/commands/dgs/switch-project.md +58 -0
  82. package/commands/dgs/undo-consolidation.md +42 -0
  83. package/commands/dgs/update-idea.md +44 -0
  84. package/commands/dgs/update.md +37 -0
  85. package/commands/dgs/validate-phase.md +35 -0
  86. package/commands/dgs/verify-work.md +39 -0
  87. package/commands/dgs/write-spec.md +49 -0
  88. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-01-SUMMARY.md +84 -0
  89. package/deliver-great-systems/.planning/phases/09-backend-wiring-and-error-handling/09-02-SUMMARY.md +86 -0
  90. package/deliver-great-systems/.planning/phases/10-v1-to-v2-migration-flow/10-01-SUMMARY.md +85 -0
  91. package/deliver-great-systems/bin/dgs-tools.cjs +1444 -0
  92. package/deliver-great-systems/bin/lib/auto-test.cjs +1365 -0
  93. package/deliver-great-systems/bin/lib/commands.cjs +570 -0
  94. package/deliver-great-systems/bin/lib/config.cjs +417 -0
  95. package/deliver-great-systems/bin/lib/conflict-agent.cjs +1063 -0
  96. package/deliver-great-systems/bin/lib/conflict-agent.test.cjs +554 -0
  97. package/deliver-great-systems/bin/lib/context.cjs +929 -0
  98. package/deliver-great-systems/bin/lib/context.test.cjs +693 -0
  99. package/deliver-great-systems/bin/lib/core.cjs +744 -0
  100. package/deliver-great-systems/bin/lib/core.test.cjs +822 -0
  101. package/deliver-great-systems/bin/lib/docs.cjs +919 -0
  102. package/deliver-great-systems/bin/lib/docs.test.cjs +211 -0
  103. package/deliver-great-systems/bin/lib/execution.cjs +705 -0
  104. package/deliver-great-systems/bin/lib/execution.test.cjs +1472 -0
  105. package/deliver-great-systems/bin/lib/frontmatter.cjs +324 -0
  106. package/deliver-great-systems/bin/lib/ideas.cjs +1406 -0
  107. package/deliver-great-systems/bin/lib/ideas.test.cjs +1417 -0
  108. package/deliver-great-systems/bin/lib/identity.cjs +125 -0
  109. package/deliver-great-systems/bin/lib/init.cjs +1114 -0
  110. package/deliver-great-systems/bin/lib/init.test.cjs +1271 -0
  111. package/deliver-great-systems/bin/lib/jobs.cjs +2015 -0
  112. package/deliver-great-systems/bin/lib/jobs.test.cjs +2619 -0
  113. package/deliver-great-systems/bin/lib/merge-conflicts.cjs +654 -0
  114. package/deliver-great-systems/bin/lib/merge-conflicts.test.cjs +370 -0
  115. package/deliver-great-systems/bin/lib/migration.cjs +352 -0
  116. package/deliver-great-systems/bin/lib/migration.test.cjs +582 -0
  117. package/deliver-great-systems/bin/lib/milestone.cjs +243 -0
  118. package/deliver-great-systems/bin/lib/overlap.cjs +437 -0
  119. package/deliver-great-systems/bin/lib/overlap.test.cjs +747 -0
  120. package/deliver-great-systems/bin/lib/path-audit.test.cjs +384 -0
  121. package/deliver-great-systems/bin/lib/paths.cjs +144 -0
  122. package/deliver-great-systems/bin/lib/paths.test.cjs +486 -0
  123. package/deliver-great-systems/bin/lib/phase.cjs +910 -0
  124. package/deliver-great-systems/bin/lib/projects.cjs +691 -0
  125. package/deliver-great-systems/bin/lib/projects.test.cjs +871 -0
  126. package/deliver-great-systems/bin/lib/repos.cjs +1432 -0
  127. package/deliver-great-systems/bin/lib/repos.test.cjs +1882 -0
  128. package/deliver-great-systems/bin/lib/roadmap.cjs +305 -0
  129. package/deliver-great-systems/bin/lib/search.cjs +570 -0
  130. package/deliver-great-systems/bin/lib/specs.cjs +1303 -0
  131. package/deliver-great-systems/bin/lib/state.cjs +893 -0
  132. package/deliver-great-systems/bin/lib/template.cjs +228 -0
  133. package/deliver-great-systems/bin/lib/test-helpers.cjs +291 -0
  134. package/deliver-great-systems/bin/lib/verify.cjs +796 -0
  135. package/deliver-great-systems/references/checkpoints.md +776 -0
  136. package/deliver-great-systems/references/conflict-resolution.md +66 -0
  137. package/deliver-great-systems/references/context-tiers.md +166 -0
  138. package/deliver-great-systems/references/continuation-format.md +249 -0
  139. package/deliver-great-systems/references/decimal-phase-calculation.md +67 -0
  140. package/deliver-great-systems/references/git-integration.md +250 -0
  141. package/deliver-great-systems/references/git-planning-commit.md +40 -0
  142. package/deliver-great-systems/references/model-profile-resolution.md +36 -0
  143. package/deliver-great-systems/references/model-profiles.md +95 -0
  144. package/deliver-great-systems/references/phase-argument-parsing.md +61 -0
  145. package/deliver-great-systems/references/planning-config.md +224 -0
  146. package/deliver-great-systems/references/questioning.md +162 -0
  147. package/deliver-great-systems/references/spec-review-loop.md +177 -0
  148. package/deliver-great-systems/references/tdd.md +265 -0
  149. package/deliver-great-systems/references/ui-brand.md +160 -0
  150. package/deliver-great-systems/references/verification-patterns.md +612 -0
  151. package/deliver-great-systems/templates/DEBUG.md +166 -0
  152. package/deliver-great-systems/templates/UAT.md +251 -0
  153. package/deliver-great-systems/templates/VALIDATION.md +95 -0
  154. package/deliver-great-systems/templates/claude-md.md +74 -0
  155. package/deliver-great-systems/templates/codebase/architecture.md +257 -0
  156. package/deliver-great-systems/templates/codebase/concerns.md +312 -0
  157. package/deliver-great-systems/templates/codebase/conventions.md +309 -0
  158. package/deliver-great-systems/templates/codebase/integrations.md +282 -0
  159. package/deliver-great-systems/templates/codebase/stack.md +188 -0
  160. package/deliver-great-systems/templates/codebase/structure.md +287 -0
  161. package/deliver-great-systems/templates/codebase/testing.md +482 -0
  162. package/deliver-great-systems/templates/config.json +38 -0
  163. package/deliver-great-systems/templates/context.md +354 -0
  164. package/deliver-great-systems/templates/continue-here.md +80 -0
  165. package/deliver-great-systems/templates/debug-subagent-prompt.md +93 -0
  166. package/deliver-great-systems/templates/discovery.md +148 -0
  167. package/deliver-great-systems/templates/milestone-archive.md +125 -0
  168. package/deliver-great-systems/templates/milestone.md +117 -0
  169. package/deliver-great-systems/templates/phase-prompt.md +615 -0
  170. package/deliver-great-systems/templates/planner-subagent-prompt.md +119 -0
  171. package/deliver-great-systems/templates/project.md +186 -0
  172. package/deliver-great-systems/templates/requirements.md +233 -0
  173. package/deliver-great-systems/templates/research-project/ARCHITECTURE.md +206 -0
  174. package/deliver-great-systems/templates/research-project/FEATURES.md +149 -0
  175. package/deliver-great-systems/templates/research-project/PITFALLS.md +202 -0
  176. package/deliver-great-systems/templates/research-project/STACK.md +122 -0
  177. package/deliver-great-systems/templates/research-project/SUMMARY.md +172 -0
  178. package/deliver-great-systems/templates/research.md +554 -0
  179. package/deliver-great-systems/templates/retrospective.md +54 -0
  180. package/deliver-great-systems/templates/roadmap.md +204 -0
  181. package/deliver-great-systems/templates/state.md +178 -0
  182. package/deliver-great-systems/templates/summary-complex.md +59 -0
  183. package/deliver-great-systems/templates/summary-minimal.md +41 -0
  184. package/deliver-great-systems/templates/summary-standard.md +48 -0
  185. package/deliver-great-systems/templates/summary.md +253 -0
  186. package/deliver-great-systems/templates/user-setup.md +313 -0
  187. package/deliver-great-systems/templates/verification-report.md +324 -0
  188. package/deliver-great-systems/workflows/add-doc.md +151 -0
  189. package/deliver-great-systems/workflows/add-idea.md +96 -0
  190. package/deliver-great-systems/workflows/add-phase.md +120 -0
  191. package/deliver-great-systems/workflows/add-tests.md +359 -0
  192. package/deliver-great-systems/workflows/add-todo.md +162 -0
  193. package/deliver-great-systems/workflows/approve-spec.md +194 -0
  194. package/deliver-great-systems/workflows/audit-milestone.md +364 -0
  195. package/deliver-great-systems/workflows/audit-phase.md +462 -0
  196. package/deliver-great-systems/workflows/cancel-job.md +108 -0
  197. package/deliver-great-systems/workflows/check-todos.md +181 -0
  198. package/deliver-great-systems/workflows/cleanup.md +247 -0
  199. package/deliver-great-systems/workflows/codereview.md +526 -0
  200. package/deliver-great-systems/workflows/complete-milestone.md +1298 -0
  201. package/deliver-great-systems/workflows/consolidate-ideas.md +365 -0
  202. package/deliver-great-systems/workflows/create-milestone-job.md +177 -0
  203. package/deliver-great-systems/workflows/develop-idea.md +544 -0
  204. package/deliver-great-systems/workflows/diagnose-issues.md +231 -0
  205. package/deliver-great-systems/workflows/discovery-phase.md +301 -0
  206. package/deliver-great-systems/workflows/discuss-idea.md +263 -0
  207. package/deliver-great-systems/workflows/discuss-phase.md +733 -0
  208. package/deliver-great-systems/workflows/execute-phase.md +571 -0
  209. package/deliver-great-systems/workflows/execute-plan.md +592 -0
  210. package/deliver-great-systems/workflows/find-related-ideas.md +271 -0
  211. package/deliver-great-systems/workflows/health.md +173 -0
  212. package/deliver-great-systems/workflows/help.md +997 -0
  213. package/deliver-great-systems/workflows/import-spec.md +381 -0
  214. package/deliver-great-systems/workflows/init-product.md +767 -0
  215. package/deliver-great-systems/workflows/insert-phase.md +138 -0
  216. package/deliver-great-systems/workflows/list-docs.md +119 -0
  217. package/deliver-great-systems/workflows/list-ideas.md +154 -0
  218. package/deliver-great-systems/workflows/list-jobs.md +89 -0
  219. package/deliver-great-systems/workflows/list-phase-assumptions.md +192 -0
  220. package/deliver-great-systems/workflows/list-specs.md +101 -0
  221. package/deliver-great-systems/workflows/map-codebase.md +621 -0
  222. package/deliver-great-systems/workflows/new-milestone.md +591 -0
  223. package/deliver-great-systems/workflows/new-project.md +1113 -0
  224. package/deliver-great-systems/workflows/node-repair.md +94 -0
  225. package/deliver-great-systems/workflows/overlap-check.md +86 -0
  226. package/deliver-great-systems/workflows/pause-work.md +134 -0
  227. package/deliver-great-systems/workflows/plan-milestone-gaps.md +306 -0
  228. package/deliver-great-systems/workflows/plan-phase.md +698 -0
  229. package/deliver-great-systems/workflows/progress.md +386 -0
  230. package/deliver-great-systems/workflows/quick.md +845 -0
  231. package/deliver-great-systems/workflows/refine-spec.md +275 -0
  232. package/deliver-great-systems/workflows/reject-idea.md +109 -0
  233. package/deliver-great-systems/workflows/remove-doc.md +117 -0
  234. package/deliver-great-systems/workflows/remove-phase.md +163 -0
  235. package/deliver-great-systems/workflows/research-idea.md +325 -0
  236. package/deliver-great-systems/workflows/research-phase.md +81 -0
  237. package/deliver-great-systems/workflows/restore-idea.md +101 -0
  238. package/deliver-great-systems/workflows/resume-project.md +311 -0
  239. package/deliver-great-systems/workflows/rollback-job.md +130 -0
  240. package/deliver-great-systems/workflows/run-job.md +498 -0
  241. package/deliver-great-systems/workflows/search.md +130 -0
  242. package/deliver-great-systems/workflows/set-profile.md +83 -0
  243. package/deliver-great-systems/workflows/settings.md +470 -0
  244. package/deliver-great-systems/workflows/transition.md +563 -0
  245. package/deliver-great-systems/workflows/undo-consolidation.md +155 -0
  246. package/deliver-great-systems/workflows/update-idea.md +157 -0
  247. package/deliver-great-systems/workflows/update.md +242 -0
  248. package/deliver-great-systems/workflows/validate-phase.md +177 -0
  249. package/deliver-great-systems/workflows/verify-phase.md +253 -0
  250. package/deliver-great-systems/workflows/verify-work.md +671 -0
  251. package/deliver-great-systems/workflows/write-spec.md +450 -0
  252. package/hooks/dist/dgs-check-update.js +62 -0
  253. package/hooks/dist/dgs-context-monitor.js +141 -0
  254. package/hooks/dist/dgs-statusline.js +115 -0
  255. package/package.json +60 -0
  256. package/scripts/build-hooks.js +43 -0
@@ -0,0 +1,733 @@
1
+ <purpose>
2
+ Extract implementation decisions that downstream agents need. Analyze the phase to identify gray areas, let the user choose what to discuss, then deep-dive each selected area until satisfied.
3
+
4
+ You are a thinking partner, not an interviewer. The user is the visionary — you are the builder. Your job is to capture decisions that will guide research and planning, not to figure out implementation yourself.
5
+ </purpose>
6
+
7
+ <context_tier>planning</context_tier>
8
+
9
+ <downstream_awareness>
10
+ **CONTEXT.md feeds into:**
11
+
12
+ 1. **dgs-phase-researcher** — Reads CONTEXT.md to know WHAT to research
13
+ - "User wants card-based layout" → researcher investigates card component patterns
14
+ - "Infinite scroll decided" → researcher looks into virtualization libraries
15
+
16
+ 2. **dgs-planner** — Reads CONTEXT.md to know WHAT decisions are locked
17
+ - "Pull-to-refresh on mobile" → planner includes that in task specs
18
+ - "Claude's Discretion: loading skeleton" → planner can decide approach
19
+
20
+ **Your job:** Capture decisions clearly enough that downstream agents can act on them without asking the user again.
21
+
22
+ **Not your job:** Figure out HOW to implement. That's what research and planning do with the decisions you capture.
23
+ </downstream_awareness>
24
+
25
+ <philosophy>
26
+ **User = founder/visionary. Claude = builder.**
27
+
28
+ The user knows:
29
+ - How they imagine it working
30
+ - What it should look/feel like
31
+ - What's essential vs nice-to-have
32
+ - Specific behaviors or references they have in mind
33
+
34
+ The user doesn't know (and shouldn't be asked):
35
+ - Codebase patterns (researcher reads the code)
36
+ - Technical risks (researcher identifies these)
37
+ - Implementation approach (planner figures this out)
38
+ - Success metrics (inferred from the work)
39
+
40
+ Ask about vision and implementation choices. Capture decisions for downstream agents.
41
+ </philosophy>
42
+
43
+ <scope_guardrail>
44
+ **CRITICAL: No scope creep.**
45
+
46
+ The phase boundary comes from ROADMAP.md and is FIXED. Discussion clarifies HOW to implement what's scoped, never WHETHER to add new capabilities.
47
+
48
+ **Allowed (clarifying ambiguity):**
49
+ - "How should posts be displayed?" (layout, density, info shown)
50
+ - "What happens on empty state?" (within the feature)
51
+ - "Pull to refresh or manual?" (behavior choice)
52
+
53
+ **Not allowed (scope creep):**
54
+ - "Should we also add comments?" (new capability)
55
+ - "What about search/filtering?" (new capability)
56
+ - "Maybe include bookmarking?" (new capability)
57
+
58
+ **The heuristic:** Does this clarify how we implement what's already in the phase, or does it add a new capability that could be its own phase?
59
+
60
+ **When user suggests scope creep:**
61
+ ```
62
+ "[Feature X] would be a new capability — that's its own phase.
63
+ Want me to note it for the roadmap backlog?
64
+
65
+ For now, let's focus on [phase domain]."
66
+ ```
67
+
68
+ Capture the idea in a "Deferred Ideas" section. Don't lose it, don't act on it.
69
+ </scope_guardrail>
70
+
71
+ <gray_area_identification>
72
+ Gray areas are **implementation decisions the user cares about** — things that could go multiple ways and would change the result.
73
+
74
+ **How to identify gray areas:**
75
+
76
+ 1. **Read the phase goal** from ROADMAP.md
77
+ 2. **Understand the domain** — What kind of thing is being built?
78
+ - Something users SEE → visual presentation, interactions, states matter
79
+ - Something users CALL → interface contracts, responses, errors matter
80
+ - Something users RUN → invocation, output, behavior modes matter
81
+ - Something users READ → structure, tone, depth, flow matter
82
+ - Something being ORGANIZED → criteria, grouping, handling exceptions matter
83
+ 3. **Generate phase-specific gray areas** — Not generic categories, but concrete decisions for THIS phase
84
+
85
+ **Don't use generic category labels** (UI, UX, Behavior). Generate specific gray areas:
86
+
87
+ ```
88
+ Phase: "User authentication"
89
+ → Session handling, Error responses, Multi-device policy, Recovery flow
90
+
91
+ Phase: "Organize photo library"
92
+ → Grouping criteria, Duplicate handling, Naming convention, Folder structure
93
+
94
+ Phase: "CLI for database backups"
95
+ → Output format, Flag design, Progress reporting, Error recovery
96
+
97
+ Phase: "API documentation"
98
+ → Structure/navigation, Code examples depth, Versioning approach, Interactive elements
99
+ ```
100
+
101
+ **The key question:** What decisions would change the outcome that the user should weigh in on?
102
+
103
+ **Claude handles these (don't ask):**
104
+ - Technical implementation details
105
+ - Architecture patterns
106
+ - Performance optimization
107
+ - Scope (roadmap defines this)
108
+ </gray_area_identification>
109
+
110
+ <process>
111
+
112
+ **Express path available:** If you already have a PRD or acceptance criteria document, use `/dgs:plan-phase {phase} --prd path/to/prd.md` to skip this discussion and go straight to planning.
113
+
114
+ <step name="initialize" priority="first">
115
+ Phase number from argument (required).
116
+
117
+ ```bash
118
+ INIT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" init phase-op "${PHASE}")
119
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
120
+ ```
121
+
122
+ Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `has_verification`, `plan_count`, `roadmap_exists`, `planning_exists`.
123
+
124
+ Load planning-tier context files:
125
+
126
+ ```bash
127
+ TIER_FILES=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" context load-tier planning --raw 2>/dev/null)
128
+ ```
129
+
130
+ **If `phase_found` is false:**
131
+ ```
132
+ Phase [X] not found in roadmap.
133
+
134
+ Use /dgs:progress to see available phases.
135
+ ```
136
+ Exit workflow.
137
+
138
+ **If `phase_found` is true:** Continue to check_existing.
139
+ </step>
140
+
141
+ <step name="check_existing">
142
+ Check if CONTEXT.md already exists using `has_context` from init.
143
+
144
+ ```bash
145
+ ls ${phase_dir}/*-CONTEXT.md 2>/dev/null
146
+ ```
147
+
148
+ **If exists:**
149
+ Use AskUserQuestion:
150
+ - header: "Context"
151
+ - question: "Phase [X] already has context. What do you want to do?"
152
+ - options:
153
+ - "Update it" — Review and revise existing context
154
+ - "View it" — Show me what's there
155
+ - "Skip" — Use existing context as-is
156
+
157
+ If "Update": Load existing, continue to analyze_phase
158
+ If "View": Display CONTEXT.md, then offer update/skip
159
+ If "Skip": Exit workflow
160
+
161
+ **If doesn't exist:**
162
+
163
+ Check `has_plans` and `plan_count` from init. **If `has_plans` is true:**
164
+
165
+ Use AskUserQuestion:
166
+ - header: "Plans exist"
167
+ - question: "Phase [X] already has {plan_count} plan(s) created without user context. Your decisions here won't affect existing plans unless you replan."
168
+ - options:
169
+ - "Continue and replan after" — Capture context, then run /dgs:plan-phase {X} to replan
170
+ - "View existing plans" — Show plans before deciding
171
+ - "Cancel" — Skip discuss-phase
172
+
173
+ If "Continue and replan after": Continue to analyze_phase.
174
+ If "View existing plans": Display plan files, then offer "Continue" / "Cancel".
175
+ If "Cancel": Exit workflow.
176
+
177
+ **If `has_plans` is false:** Continue to load_prior_context.
178
+ </step>
179
+
180
+ <step name="load_prior_context">
181
+ Read prior phase context to avoid re-asking decided questions and maintain consistency.
182
+
183
+ **Step 1: Project-level files**
184
+
185
+ Project-level files (PROJECT.md, REQUIREMENTS.md, STATE.md, ROADMAP.md, REPOS.md, and codebase docs) are already loaded via the planning-tier `load-tier` call in the initialize step. Extract from those:
186
+ - **PROJECT.md** — Vision, principles, non-negotiables, user preferences
187
+ - **REQUIREMENTS.md** — Acceptance criteria, constraints, must-haves vs nice-to-haves
188
+ - **STATE.md** — Current progress, any flags or session notes
189
+
190
+ **Step 2: Read all prior CONTEXT.md files**
191
+ ```bash
192
+ # Find all CONTEXT.md files from phases before current
193
+ find .planning/phases -name "*-CONTEXT.md" 2>/dev/null | sort
194
+ ```
195
+
196
+ For each CONTEXT.md where phase number < current phase:
197
+ - Read the `<decisions>` section — these are locked preferences
198
+ - Read `<specifics>` — particular references or "I want it like X" moments
199
+ - Note any patterns (e.g., "user consistently prefers minimal UI", "user rejected single-key shortcuts")
200
+
201
+ **Step 3: Build internal `<prior_decisions>` context**
202
+
203
+ Structure the extracted information:
204
+ ```
205
+ <prior_decisions>
206
+ ## Project-Level
207
+ - [Key principle or constraint from PROJECT.md]
208
+ - [Requirement that affects this phase from REQUIREMENTS.md]
209
+
210
+ ## From Prior Phases
211
+ ### Phase N: [Name]
212
+ - [Decision that may be relevant to current phase]
213
+ - [Preference that establishes a pattern]
214
+
215
+ ### Phase M: [Name]
216
+ - [Another relevant decision]
217
+ </prior_decisions>
218
+ ```
219
+
220
+ **Usage in subsequent steps:**
221
+ - `analyze_phase`: Skip gray areas already decided in prior phases
222
+ - `present_gray_areas`: Annotate options with prior decisions ("You chose X in Phase 5")
223
+ - `discuss_areas`: Pre-fill answers or flag conflicts ("This contradicts Phase 3 — same here or different?")
224
+
225
+ **If no prior context exists:** Continue without — this is expected for early phases.
226
+ </step>
227
+
228
+ <step name="scout_codebase">
229
+ Lightweight scan of existing code to inform gray area identification and discussion. Uses ~10% context — acceptable for an interactive session.
230
+
231
+ **Step 1: Check for existing codebase maps**
232
+ ```bash
233
+ ls .planning/codebase/*.md 2>/dev/null
234
+ ```
235
+
236
+ **If codebase maps exist:** Read the most relevant ones (CONVENTIONS.md, STRUCTURE.md, STACK.md based on phase type). Extract:
237
+ - Reusable components/hooks/utilities
238
+ - Established patterns (state management, styling, data fetching)
239
+ - Integration points (where new code would connect)
240
+
241
+ Skip to Step 3 below.
242
+
243
+ **Step 2: If no codebase maps, do targeted grep**
244
+
245
+ Extract key terms from the phase goal (e.g., "feed" → "post", "card", "list"; "auth" → "login", "session", "token").
246
+
247
+ ```bash
248
+ # Find files related to phase goal terms
249
+ grep -rl "{term1}\|{term2}" src/ app/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" 2>/dev/null | head -10
250
+
251
+ # Find existing components/hooks
252
+ ls src/components/ 2>/dev/null
253
+ ls src/hooks/ 2>/dev/null
254
+ ls src/lib/ src/utils/ 2>/dev/null
255
+ ```
256
+
257
+ Read the 3-5 most relevant files to understand existing patterns.
258
+
259
+ **Step 3: Build internal codebase_context**
260
+
261
+ From the scan, identify:
262
+ - **Reusable assets** — existing components, hooks, utilities that could be used in this phase
263
+ - **Established patterns** — how the codebase does state management, styling, data fetching
264
+ - **Integration points** — where new code would connect (routes, nav, providers)
265
+ - **Creative options** — approaches the existing architecture enables or constrains
266
+
267
+ Store as internal `<codebase_context>` for use in analyze_phase and present_gray_areas. This is NOT written to a file — it's used within this session only.
268
+ </step>
269
+
270
+ <step name="analyze_phase">
271
+ Analyze the phase to identify gray areas worth discussing. **Use both `prior_decisions` and `codebase_context` to ground the analysis.**
272
+
273
+ **Read the phase description from ROADMAP.md and determine:**
274
+
275
+ 1. **Domain boundary** — What capability is this phase delivering? State it clearly.
276
+
277
+ 1b. **Initialize canonical refs accumulator** — Start building the `<canonical_refs>` list for CONTEXT.md. This accumulates throughout the entire discussion, not just this step.
278
+
279
+ **Source 1 (now):** Copy `Canonical refs:` from ROADMAP.md for this phase. Expand each to a full relative path.
280
+ **Source 2 (now):** Check REQUIREMENTS.md and PROJECT.md for any specs/ADRs referenced for this phase.
281
+ **Source 3 (scout_codebase):** If existing code references docs (e.g., comments citing ADRs), add those.
282
+ **Source 4 (discuss_areas):** When the user says "read X", "check Y", or references any doc/spec/ADR during discussion — add it immediately. These are often the MOST important refs because they represent docs the user specifically wants followed.
283
+
284
+ This list is MANDATORY in CONTEXT.md. Every ref must have a full relative path so downstream agents can read it directly. If no external docs exist, note that explicitly.
285
+
286
+ 2. **Check prior decisions** — Before generating gray areas, check if any were already decided:
287
+ - Scan `<prior_decisions>` for relevant choices (e.g., "Ctrl+C only, no single-key shortcuts")
288
+ - These are **pre-answered** — don't re-ask unless this phase has conflicting needs
289
+ - Note applicable prior decisions for use in presentation
290
+
291
+ 3. **Gray areas by category** — For each relevant category (UI, UX, Behavior, Empty States, Content), identify 1-2 specific ambiguities that would change implementation. **Annotate with code context where relevant** (e.g., "You already have a Card component" or "No existing pattern for this").
292
+
293
+ 4. **Always proceed** — Even for infrastructure or seemingly clear-cut phases, there are always implementation decisions worth discussing. Find them. The user explicitly ran this command to have a discussion.
294
+
295
+ **Output your analysis internally, then ALWAYS proceed to present_gray_areas.**
296
+
297
+ Example analysis for "Post Feed" phase (with code and prior context):
298
+ ```
299
+ Domain: Displaying posts from followed users
300
+ Existing: Card component (src/components/ui/Card.tsx), useInfiniteQuery hook, Tailwind CSS
301
+ Prior decisions: "Minimal UI preferred" (Phase 2), "No pagination — always infinite scroll" (Phase 4)
302
+ Gray areas:
303
+ - UI: Layout style (cards vs timeline vs grid) — Card component exists with shadow/rounded variants
304
+ - UI: Information density (full posts vs previews) — no existing density patterns
305
+ - Behavior: Loading pattern — ALREADY DECIDED: infinite scroll (Phase 4)
306
+ - Empty State: What shows when no posts exist — EmptyState component exists in ui/
307
+ - Content: What metadata displays (time, author, reactions count)
308
+ ```
309
+ </step>
310
+
311
+ <step name="present_gray_areas">
312
+ Present the domain boundary, prior decisions, and gray areas to user.
313
+
314
+ **First, state the boundary and any prior decisions that apply:**
315
+ ```
316
+ Phase [X]: [Name]
317
+ Domain: [What this phase delivers — from your analysis]
318
+
319
+ We'll clarify HOW to implement this.
320
+ (New capabilities belong in other phases.)
321
+
322
+ [If prior decisions apply:]
323
+ **Carrying forward from earlier phases:**
324
+ - [Decision from Phase N that applies here]
325
+ - [Decision from Phase M that applies here]
326
+ ```
327
+
328
+ **Then use AskUserQuestion (multiSelect: true):**
329
+ - header: "Discuss"
330
+ - question: "Which areas do you want to discuss for [phase name]?"
331
+ - options: Generate 3-4 phase-specific gray areas, each with:
332
+ - "[Specific area]" (label) — concrete, not generic
333
+ - [1-2 questions this covers + code context annotation] (description)
334
+ - **Highlight the recommended choice with brief explanation why**
335
+
336
+ **Prior decision annotations:** When a gray area was already decided in a prior phase, annotate it:
337
+ ```
338
+ ☐ Exit shortcuts — How should users quit?
339
+ (You decided "Ctrl+C only, no single-key shortcuts" in Phase 5 — revisit or keep?)
340
+ ```
341
+
342
+ **Code context annotations:** When the scout found relevant existing code, annotate the gray area description:
343
+ ```
344
+ ☐ Layout style — Cards vs list vs timeline?
345
+ (You already have a Card component with shadow/rounded variants. Reusing it keeps the app consistent.)
346
+ ```
347
+
348
+ **Combining both:** When both prior decisions and code context apply:
349
+ ```
350
+ ☐ Loading behavior — Infinite scroll or pagination?
351
+ (You chose infinite scroll in Phase 4. useInfiniteQuery hook already set up.)
352
+ ```
353
+
354
+ **Do NOT include a "skip" or "you decide" option.** User ran this command to discuss — give them real choices.
355
+
356
+ **Examples by domain (with code context):**
357
+
358
+ For "Post Feed" (visual feature):
359
+ ```
360
+ ☐ Layout style — Cards vs list vs timeline? (Card component exists with variants)
361
+ ☐ Loading behavior — Infinite scroll or pagination? (useInfiniteQuery hook available)
362
+ ☐ Content ordering — Chronological, algorithmic, or user choice?
363
+ ☐ Post metadata — What info per post? Timestamps, reactions, author?
364
+ ```
365
+
366
+ For "Database backup CLI" (command-line tool):
367
+ ```
368
+ ☐ Output format — JSON, table, or plain text? Verbosity levels?
369
+ ☐ Flag design — Short flags, long flags, or both? Required vs optional?
370
+ ☐ Progress reporting — Silent, progress bar, or verbose logging?
371
+ ☐ Error recovery — Fail fast, retry, or prompt for action?
372
+ ```
373
+
374
+ For "Organize photo library" (organization task):
375
+ ```
376
+ ☐ Grouping criteria — By date, location, faces, or events?
377
+ ☐ Duplicate handling — Keep best, keep all, or prompt each time?
378
+ ☐ Naming convention — Original names, dates, or descriptive?
379
+ ☐ Folder structure — Flat, nested by year, or by category?
380
+ ```
381
+
382
+ Continue to discuss_areas with selected areas.
383
+ </step>
384
+
385
+ <step name="discuss_areas">
386
+ For each selected area, conduct a focused discussion loop.
387
+
388
+ **Batch mode support:** Parse optional `--batch` from `$ARGUMENTS`.
389
+ - Accept `--batch`, `--batch=N`, or `--batch N`
390
+ - Default to 4 questions per batch when no number is provided
391
+ - Clamp explicit sizes to 2-5 so a batch stays answerable
392
+ - If `--batch` is absent, keep the existing one-question-at-a-time flow
393
+
394
+ **Philosophy:** stay adaptive, but let the user choose the pacing.
395
+ - Default mode: 4 single-question turns, then check whether to continue
396
+ - `--batch` mode: 1 grouped turn with 2-5 numbered questions, then check whether to continue
397
+
398
+ Each answer (or answer set, in batch mode) should reveal the next question or next batch.
399
+
400
+ **For each area:**
401
+
402
+ 1. **Announce the area:**
403
+ ```
404
+ Let's talk about [Area].
405
+ ```
406
+
407
+ 2. **Ask questions using the selected pacing:**
408
+
409
+ **Default (no `--batch`): Ask 4 questions using AskUserQuestion**
410
+ - header: "[Area]" (max 12 chars — abbreviate if needed)
411
+ - question: Specific decision for this area
412
+ - options: 2-3 concrete choices (AskUserQuestion adds "Other" automatically), with the recommended choice highlighted and brief explanation why
413
+ - **Annotate options with code context** when relevant:
414
+ ```
415
+ "How should posts be displayed?"
416
+ - Cards (reuses existing Card component — consistent with Messages)
417
+ - List (simpler, would be a new pattern)
418
+ - Timeline (needs new Timeline component — none exists yet)
419
+ ```
420
+ - Include "You decide" as an option when reasonable — captures Claude discretion
421
+
422
+ **Batch mode (`--batch`): Ask 2-5 numbered questions in one plain-text turn**
423
+ - Group closely related questions for the current area into a single message
424
+ - Keep each question concrete and answerable in one reply
425
+ - When options are helpful, include short inline choices per question rather than a separate AskUserQuestion for every item
426
+ - After the user replies, reflect back the captured decisions, note any unanswered items, and ask only the minimum follow-up needed before moving on
427
+ - Preserve adaptiveness between batches: use the full set of answers to decide the next batch or whether the area is sufficiently clear
428
+
429
+ 3. **After the current set of questions, check:**
430
+ - header: "[Area]" (max 12 chars)
431
+ - question: "More questions about [area], or move to next?"
432
+ - options: "More questions" / "Next area"
433
+
434
+ If "More questions" → ask another 4 single questions, or another 2-5 question batch when `--batch` is active, then check again
435
+ If "Next area" → proceed to next selected area
436
+ If "Other" (free text) → interpret intent: continuation phrases ("chat more", "keep going", "yes", "more") map to "More questions"; advancement phrases ("done", "move on", "next", "skip") map to "Next area". If ambiguous, ask: "Continue with more questions about [area], or move to the next area?"
437
+
438
+ 4. **After all initially-selected areas complete:**
439
+ - Summarize what was captured from the discussion so far
440
+ - AskUserQuestion:
441
+ - header: "Done"
442
+ - question: "We've discussed [list areas]. Which gray areas remain unclear?"
443
+ - options: "Explore more gray areas" / "I'm ready for context"
444
+ - If "Explore more gray areas":
445
+ - Identify 2-4 additional gray areas based on what was learned
446
+ - Return to present_gray_areas logic with these new areas
447
+ - Loop: discuss new areas, then prompt again
448
+ - If "I'm ready for context": Proceed to write_context
449
+
450
+ **Canonical ref accumulation during discussion:**
451
+ When the user references a doc, spec, or ADR during any answer — e.g., "read adr-014", "check the MCP spec", "per browse-spec.md" — immediately:
452
+ 1. Read the referenced doc (or confirm it exists)
453
+ 2. Add it to the canonical refs accumulator with full relative path
454
+ 3. Use what you learned from the doc to inform subsequent questions
455
+
456
+ These user-referenced docs are often MORE important than ROADMAP.md refs because they represent docs the user specifically wants downstream agents to follow. Never drop them.
457
+
458
+ **Question design:**
459
+ - Options should be concrete, not abstract ("Cards" not "Option A")
460
+ - Each answer should inform the next question or next batch
461
+ - If user picks "Other" to provide freeform input (e.g., "let me describe it", "something else", or an open-ended reply), ask your follow-up as plain text — NOT another AskUserQuestion. Wait for them to type at the normal prompt, then reflect their input back and confirm before resuming AskUserQuestion or the next numbered batch.
462
+
463
+ **Scope creep handling:**
464
+ If user mentions something outside the phase domain:
465
+ ```
466
+ "[Feature] sounds like a new capability — that belongs in its own phase.
467
+ I'll note it as a deferred idea.
468
+
469
+ Back to [current area]: [return to current question]"
470
+ ```
471
+
472
+ Track deferred ideas internally.
473
+ </step>
474
+
475
+ <step name="write_context">
476
+ Create CONTEXT.md capturing decisions made.
477
+
478
+ **Find or create phase directory:**
479
+
480
+ Use values from init: `phase_dir`, `phase_slug`, `padded_phase`.
481
+
482
+ If `phase_dir` is null (phase exists in roadmap but no directory). Use `project_root` from init:
483
+ ```bash
484
+ mkdir -p "${project_root}/phases/${padded_phase}-${phase_slug}"
485
+ ```
486
+
487
+ **File location:** `${phase_dir}/${padded_phase}-CONTEXT.md`
488
+
489
+ **Structure the content by what was discussed:**
490
+
491
+ ```markdown
492
+ # Phase [X]: [Name] - Context
493
+
494
+ **Gathered:** [date]
495
+ **Status:** Ready for planning
496
+
497
+ <domain>
498
+ ## Phase Boundary
499
+
500
+ [Clear statement of what this phase delivers — the scope anchor]
501
+
502
+ </domain>
503
+
504
+ <decisions>
505
+ ## Implementation Decisions
506
+
507
+ ### [Category 1 that was discussed]
508
+ - [Decision or preference captured]
509
+ - [Another decision if applicable]
510
+
511
+ ### [Category 2 that was discussed]
512
+ - [Decision or preference captured]
513
+
514
+ ### Claude's Discretion
515
+ [Areas where user said "you decide" — note that Claude has flexibility here]
516
+
517
+ </decisions>
518
+
519
+ <canonical_refs>
520
+ ## Canonical References
521
+
522
+ **Downstream agents MUST read these before planning or implementing.**
523
+
524
+ [MANDATORY section. Write the FULL accumulated canonical refs list here.
525
+ Sources: ROADMAP.md refs + REQUIREMENTS.md refs + user-referenced docs during
526
+ discussion + any docs discovered during codebase scout. Group by topic area.
527
+ Every entry needs a full relative path — not just a name.]
528
+
529
+ ### [Topic area 1]
530
+ - `path/to/adr-or-spec.md` — [What it decides/defines that's relevant]
531
+ - `path/to/doc.md` §N — [Specific section reference]
532
+
533
+ ### [Topic area 2]
534
+ - `path/to/feature-doc.md` — [What this doc defines]
535
+
536
+ [If no external specs: "No external specs — requirements fully captured in decisions above"]
537
+
538
+ </canonical_refs>
539
+
540
+ <code_context>
541
+ ## Existing Code Insights
542
+
543
+ ### Reusable Assets
544
+ - [Component/hook/utility]: [How it could be used in this phase]
545
+
546
+ ### Established Patterns
547
+ - [Pattern]: [How it constrains/enables this phase]
548
+
549
+ ### Integration Points
550
+ - [Where new code connects to existing system]
551
+
552
+ </code_context>
553
+
554
+ <specifics>
555
+ ## Specific Ideas
556
+
557
+ [Any particular references, examples, or "I want it like X" moments from discussion]
558
+
559
+ [If none: "No specific requirements — open to standard approaches"]
560
+
561
+ </specifics>
562
+
563
+ <deferred>
564
+ ## Deferred Ideas
565
+
566
+ [Ideas that came up but belong in other phases. Don't lose them.]
567
+
568
+ [If none: "None — discussion stayed within phase scope"]
569
+
570
+ </deferred>
571
+
572
+ ---
573
+
574
+ *Phase: XX-name*
575
+ *Context gathered: [date]*
576
+ ```
577
+
578
+ Write file.
579
+ </step>
580
+
581
+ <step name="confirm_creation">
582
+ Present summary and next steps:
583
+
584
+ ```
585
+ Created: ${phase_dir}/${PADDED_PHASE}-CONTEXT.md
586
+
587
+ ## Decisions Captured
588
+
589
+ ### [Category]
590
+ - [Key decision]
591
+
592
+ ### [Category]
593
+ - [Key decision]
594
+
595
+ [If deferred ideas exist:]
596
+ ## Noted for Later
597
+ - [Deferred idea] — future phase
598
+
599
+ ---
600
+
601
+ ## ▶ Next Up
602
+
603
+ **Phase ${PHASE}: [Name]** — [Goal from ROADMAP.md]
604
+
605
+ `/dgs:plan-phase ${PHASE}`
606
+
607
+ <sub>`/clear` first → fresh context window</sub>
608
+
609
+ ---
610
+
611
+ **Also available:**
612
+ - `/dgs:plan-phase ${PHASE} --skip-research` — plan without research
613
+ - Review/edit CONTEXT.md before continuing
614
+
615
+ ---
616
+ ```
617
+ </step>
618
+
619
+ <step name="git_commit">
620
+ Commit phase context (uses `commit_docs` from init internally):
621
+
622
+ ```bash
623
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(${padded_phase}): capture phase context" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
624
+ ```
625
+
626
+ Confirm: "Committed: docs(${padded_phase}): capture phase context"
627
+ </step>
628
+
629
+ <step name="update_state">
630
+ Update STATE.md with session info:
631
+
632
+ ```bash
633
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" state record-session \
634
+ --stopped-at "Phase ${PHASE} context gathered" \
635
+ --resume-file "${phase_dir}/${padded_phase}-CONTEXT.md"
636
+ ```
637
+
638
+ Commit STATE.md:
639
+
640
+ ```bash
641
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs(state): record phase ${PHASE} context session" --files ${state_path}
642
+ ```
643
+ </step>
644
+
645
+ <step name="auto_advance">
646
+ Check for auto-advance trigger:
647
+
648
+ 1. Parse `--auto` flag from $ARGUMENTS
649
+ 2. **Sync chain flag with intent** — if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
650
+ ```bash
651
+ if [[ ! "$ARGUMENTS" =~ --auto ]]; then
652
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
653
+ fi
654
+ ```
655
+ 3. Read both the chain flag and user preference:
656
+ ```bash
657
+ AUTO_CHAIN=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
658
+ AUTO_CFG=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
659
+ ```
660
+
661
+ **If `--auto` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct `--auto` usage without new-project):
662
+ ```bash
663
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" config-set workflow._auto_chain_active true
664
+ ```
665
+
666
+ **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
667
+
668
+ Display banner:
669
+ ```
670
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
671
+ DGS ► AUTO-ADVANCING TO PLAN
672
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
673
+
674
+ Context captured. Launching plan-phase...
675
+ ```
676
+
677
+ Launch plan-phase using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting):
678
+ ```
679
+ Skill(skill="dgs:plan-phase", args="${PHASE} --auto")
680
+ ```
681
+
682
+ This keeps the auto-advance chain flat — discuss, plan, and execute all run at the same nesting level rather than spawning increasingly deep Task agents.
683
+
684
+ **Handle plan-phase return:**
685
+ - **PHASE COMPLETE** → Full chain succeeded. Display:
686
+ ```
687
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
688
+ DGS ► PHASE ${PHASE} COMPLETE
689
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
690
+
691
+ Auto-advance pipeline finished: discuss → plan → execute
692
+
693
+ Next: /dgs:discuss-phase ${NEXT_PHASE} --auto
694
+ <sub>/clear first → fresh context window</sub>
695
+ ```
696
+ - **PLANNING COMPLETE** → Planning done, execution didn't complete:
697
+ ```
698
+ Auto-advance partial: Planning complete, execution did not finish.
699
+ Continue: /dgs:execute-phase ${PHASE}
700
+ ```
701
+ - **PLANNING INCONCLUSIVE / CHECKPOINT** → Stop chain:
702
+ ```
703
+ Auto-advance stopped: Planning needs input.
704
+ Continue: /dgs:plan-phase ${PHASE}
705
+ ```
706
+ - **GAPS FOUND** → Stop chain:
707
+ ```
708
+ Auto-advance stopped: Gaps found during execution.
709
+ Continue: /dgs:plan-phase ${PHASE} --gaps
710
+ ```
711
+
712
+ **If neither `--auto` nor config enabled:**
713
+ Route to `confirm_creation` step (existing behavior — show manual next steps).
714
+ </step>
715
+
716
+ </process>
717
+
718
+ <success_criteria>
719
+ - Phase validated against roadmap
720
+ - Prior context loaded (PROJECT.md, REQUIREMENTS.md, STATE.md, prior CONTEXT.md files)
721
+ - Already-decided questions not re-asked (carried forward from prior phases)
722
+ - Codebase scouted for reusable assets, patterns, and integration points
723
+ - Gray areas identified through intelligent analysis with code and prior decision annotations
724
+ - User selected which areas to discuss
725
+ - Each selected area explored until user satisfied (with code-informed and prior-decision-informed options)
726
+ - Scope creep redirected to deferred ideas
727
+ - CONTEXT.md captures actual decisions, not vague vision
728
+ - CONTEXT.md includes canonical_refs section with full file paths to every spec/ADR/doc downstream agents need (MANDATORY — never omit)
729
+ - CONTEXT.md includes code_context section with reusable assets and patterns
730
+ - Deferred ideas preserved for future phases
731
+ - STATE.md updated with session info
732
+ - User knows next steps
733
+ </success_criteria>