get-research-done 1.1.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +560 -0
  3. package/agents/grd-architect.md +789 -0
  4. package/agents/grd-codebase-mapper.md +738 -0
  5. package/agents/grd-critic.md +1065 -0
  6. package/agents/grd-debugger.md +1203 -0
  7. package/agents/grd-evaluator.md +948 -0
  8. package/agents/grd-executor.md +784 -0
  9. package/agents/grd-explorer.md +2063 -0
  10. package/agents/grd-graduator.md +484 -0
  11. package/agents/grd-integration-checker.md +423 -0
  12. package/agents/grd-phase-researcher.md +641 -0
  13. package/agents/grd-plan-checker.md +745 -0
  14. package/agents/grd-planner.md +1386 -0
  15. package/agents/grd-project-researcher.md +865 -0
  16. package/agents/grd-research-synthesizer.md +256 -0
  17. package/agents/grd-researcher.md +2361 -0
  18. package/agents/grd-roadmapper.md +605 -0
  19. package/agents/grd-verifier.md +778 -0
  20. package/bin/install.js +1294 -0
  21. package/commands/grd/add-phase.md +207 -0
  22. package/commands/grd/add-todo.md +193 -0
  23. package/commands/grd/architect.md +283 -0
  24. package/commands/grd/audit-milestone.md +277 -0
  25. package/commands/grd/check-todos.md +228 -0
  26. package/commands/grd/complete-milestone.md +136 -0
  27. package/commands/grd/debug.md +169 -0
  28. package/commands/grd/discuss-phase.md +86 -0
  29. package/commands/grd/evaluate.md +1095 -0
  30. package/commands/grd/execute-phase.md +339 -0
  31. package/commands/grd/explore.md +258 -0
  32. package/commands/grd/graduate.md +323 -0
  33. package/commands/grd/help.md +482 -0
  34. package/commands/grd/insert-phase.md +227 -0
  35. package/commands/grd/insights.md +231 -0
  36. package/commands/grd/join-discord.md +18 -0
  37. package/commands/grd/list-phase-assumptions.md +50 -0
  38. package/commands/grd/map-codebase.md +71 -0
  39. package/commands/grd/new-milestone.md +721 -0
  40. package/commands/grd/new-project.md +1008 -0
  41. package/commands/grd/pause-work.md +134 -0
  42. package/commands/grd/plan-milestone-gaps.md +295 -0
  43. package/commands/grd/plan-phase.md +525 -0
  44. package/commands/grd/progress.md +364 -0
  45. package/commands/grd/quick-explore.md +236 -0
  46. package/commands/grd/quick.md +309 -0
  47. package/commands/grd/remove-phase.md +349 -0
  48. package/commands/grd/research-phase.md +200 -0
  49. package/commands/grd/research.md +681 -0
  50. package/commands/grd/resume-work.md +40 -0
  51. package/commands/grd/set-profile.md +106 -0
  52. package/commands/grd/settings.md +136 -0
  53. package/commands/grd/update.md +172 -0
  54. package/commands/grd/verify-work.md +219 -0
  55. package/get-research-done/config/default.json +15 -0
  56. package/get-research-done/references/checkpoints.md +1078 -0
  57. package/get-research-done/references/continuation-format.md +249 -0
  58. package/get-research-done/references/git-integration.md +254 -0
  59. package/get-research-done/references/model-profiles.md +73 -0
  60. package/get-research-done/references/planning-config.md +94 -0
  61. package/get-research-done/references/questioning.md +141 -0
  62. package/get-research-done/references/tdd.md +263 -0
  63. package/get-research-done/references/ui-brand.md +160 -0
  64. package/get-research-done/references/verification-patterns.md +612 -0
  65. package/get-research-done/templates/DEBUG.md +159 -0
  66. package/get-research-done/templates/UAT.md +247 -0
  67. package/get-research-done/templates/archive-reason.md +195 -0
  68. package/get-research-done/templates/codebase/architecture.md +255 -0
  69. package/get-research-done/templates/codebase/concerns.md +310 -0
  70. package/get-research-done/templates/codebase/conventions.md +307 -0
  71. package/get-research-done/templates/codebase/integrations.md +280 -0
  72. package/get-research-done/templates/codebase/stack.md +186 -0
  73. package/get-research-done/templates/codebase/structure.md +285 -0
  74. package/get-research-done/templates/codebase/testing.md +480 -0
  75. package/get-research-done/templates/config.json +35 -0
  76. package/get-research-done/templates/context.md +283 -0
  77. package/get-research-done/templates/continue-here.md +78 -0
  78. package/get-research-done/templates/critic-log.md +288 -0
  79. package/get-research-done/templates/data-report.md +173 -0
  80. package/get-research-done/templates/debug-subagent-prompt.md +91 -0
  81. package/get-research-done/templates/decision-log.md +58 -0
  82. package/get-research-done/templates/decision.md +138 -0
  83. package/get-research-done/templates/discovery.md +146 -0
  84. package/get-research-done/templates/experiment-readme.md +104 -0
  85. package/get-research-done/templates/graduated-script.md +180 -0
  86. package/get-research-done/templates/iteration-summary.md +234 -0
  87. package/get-research-done/templates/milestone-archive.md +123 -0
  88. package/get-research-done/templates/milestone.md +115 -0
  89. package/get-research-done/templates/objective.md +271 -0
  90. package/get-research-done/templates/phase-prompt.md +567 -0
  91. package/get-research-done/templates/planner-subagent-prompt.md +117 -0
  92. package/get-research-done/templates/project.md +184 -0
  93. package/get-research-done/templates/requirements.md +231 -0
  94. package/get-research-done/templates/research-project/ARCHITECTURE.md +204 -0
  95. package/get-research-done/templates/research-project/FEATURES.md +147 -0
  96. package/get-research-done/templates/research-project/PITFALLS.md +200 -0
  97. package/get-research-done/templates/research-project/STACK.md +120 -0
  98. package/get-research-done/templates/research-project/SUMMARY.md +170 -0
  99. package/get-research-done/templates/research.md +529 -0
  100. package/get-research-done/templates/roadmap.md +202 -0
  101. package/get-research-done/templates/scorecard.json +113 -0
  102. package/get-research-done/templates/state.md +287 -0
  103. package/get-research-done/templates/summary.md +246 -0
  104. package/get-research-done/templates/user-setup.md +311 -0
  105. package/get-research-done/templates/verification-report.md +322 -0
  106. package/get-research-done/workflows/complete-milestone.md +756 -0
  107. package/get-research-done/workflows/diagnose-issues.md +231 -0
  108. package/get-research-done/workflows/discovery-phase.md +289 -0
  109. package/get-research-done/workflows/discuss-phase.md +433 -0
  110. package/get-research-done/workflows/execute-phase.md +657 -0
  111. package/get-research-done/workflows/execute-plan.md +1844 -0
  112. package/get-research-done/workflows/list-phase-assumptions.md +178 -0
  113. package/get-research-done/workflows/map-codebase.md +322 -0
  114. package/get-research-done/workflows/resume-project.md +307 -0
  115. package/get-research-done/workflows/transition.md +556 -0
  116. package/get-research-done/workflows/verify-phase.md +628 -0
  117. package/get-research-done/workflows/verify-work.md +596 -0
  118. package/hooks/dist/grd-check-update.js +61 -0
  119. package/hooks/dist/grd-statusline.js +84 -0
  120. package/package.json +47 -0
  121. package/scripts/audit-help-commands.sh +115 -0
  122. package/scripts/build-hooks.js +42 -0
  123. package/scripts/verify-all-commands.sh +246 -0
  124. package/scripts/verify-architect-warning.sh +35 -0
  125. package/scripts/verify-insights-mode.sh +40 -0
  126. package/scripts/verify-quick-mode.sh +20 -0
  127. package/scripts/verify-revise-data-routing.sh +139 -0
@@ -0,0 +1,1844 @@
1
+ <purpose>
2
+ Execute a phase prompt (PLAN.md) and create the outcome summary (SUMMARY.md).
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ Read STATE.md before any operation to load project context.
7
+ Read config.json for planning behavior settings.
8
+
9
+ @~/.claude/get-research-done/references/git-integration.md
10
+ </required_reading>
11
+
12
+ <process>
13
+
14
+ <step name="resolve_model_profile" priority="first">
15
+ Read model profile for agent spawning:
16
+
17
+ ```bash
18
+ MODEL_PROFILE=$(cat .planning/config.json 2>/dev/null | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
19
+ ```
20
+
21
+ Default to "balanced" if not set.
22
+
23
+ **Model lookup table:**
24
+
25
+ | Agent | quality | balanced | budget |
26
+ |-------|---------|----------|--------|
27
+ | grd-executor | opus | sonnet | sonnet |
28
+
29
+ Store resolved model for use in Task calls below.
30
+ </step>
31
+
32
+ <step name="load_project_state">
33
+ Before any operation, read project state:
34
+
35
+ ```bash
36
+ cat .planning/STATE.md 2>/dev/null
37
+ ```
38
+
39
+ **If file exists:** Parse and internalize:
40
+
41
+ - Current position (phase, plan, status)
42
+ - Accumulated decisions (constraints on this execution)
43
+ - Blockers/concerns (things to watch for)
44
+ - Brief alignment status
45
+
46
+ **If file missing but .planning/ exists:**
47
+
48
+ ```
49
+ STATE.md missing but planning artifacts exist.
50
+ Options:
51
+ 1. Reconstruct from existing artifacts
52
+ 2. Continue without project state (may lose accumulated context)
53
+ ```
54
+
55
+ **If .planning/ doesn't exist:** Error - project not initialized.
56
+
57
+ This ensures every execution has full project context.
58
+
59
+ **Load planning config:**
60
+
61
+ ```bash
62
+ # Check if planning docs should be committed (default: true)
63
+ COMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
64
+ # Auto-detect gitignored (overrides config)
65
+ git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=false
66
+ ```
67
+
68
+ Store `COMMIT_PLANNING_DOCS` for use in git operations.
69
+ </step>
70
+
71
+ <step name="identify_plan">
72
+ Find the next plan to execute:
73
+ - Check roadmap for "In progress" phase
74
+ - Find plans in that phase directory
75
+ - Identify first plan without corresponding SUMMARY
76
+
77
+ ```bash
78
+ cat .planning/ROADMAP.md
79
+ # Look for phase with "In progress" status
80
+ # Then find plans in that phase
81
+ ls .planning/phases/XX-name/*-PLAN.md 2>/dev/null | sort
82
+ ls .planning/phases/XX-name/*-SUMMARY.md 2>/dev/null | sort
83
+ ```
84
+
85
+ **Logic:**
86
+
87
+ - If `01-01-PLAN.md` exists but `01-01-SUMMARY.md` doesn't → execute 01-01
88
+ - If `01-01-SUMMARY.md` exists but `01-02-SUMMARY.md` doesn't → execute 01-02
89
+ - Pattern: Find first PLAN file without matching SUMMARY file
90
+
91
+ **Decimal phase handling:**
92
+
93
+ Phase directories can be integer or decimal format:
94
+
95
+ - Integer: `.planning/phases/01-foundation/01-01-PLAN.md`
96
+ - Decimal: `.planning/phases/01.1-hotfix/01.1-01-PLAN.md`
97
+
98
+ Parse phase number from path (handles both formats):
99
+
100
+ ```bash
101
+ # Extract phase number (handles XX or XX.Y format)
102
+ PHASE=$(echo "$PLAN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
103
+ ```
104
+
105
+ SUMMARY naming follows same pattern:
106
+
107
+ - Integer: `01-01-SUMMARY.md`
108
+ - Decimal: `01.1-01-SUMMARY.md`
109
+
110
+ Confirm with user if ambiguous.
111
+
112
+ <config-check>
113
+ ```bash
114
+ cat .planning/config.json 2>/dev/null
115
+ ```
116
+ </config-check>
117
+
118
+ <if mode="yolo">
119
+ ```
120
+ ⚡ Auto-approved: Execute {phase}-{plan}-PLAN.md
121
+ [Plan X of Y for Phase Z]
122
+
123
+ Starting execution...
124
+ ```
125
+
126
+ Proceed directly to parse_segments step.
127
+ </if>
128
+
129
+ <if mode="interactive" OR="custom with gates.execute_next_plan true">
130
+ Present:
131
+
132
+ ```
133
+ Found plan to execute: {phase}-{plan}-PLAN.md
134
+ [Plan X of Y for Phase Z]
135
+
136
+ Proceed with execution?
137
+ ```
138
+
139
+ Wait for confirmation before proceeding.
140
+ </if>
141
+ </step>
142
+
143
+ <step name="record_start_time">
144
+ Record execution start time for performance tracking:
145
+
146
+ ```bash
147
+ PLAN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
148
+ PLAN_START_EPOCH=$(date +%s)
149
+ ```
150
+
151
+ Store in shell variables for duration calculation at completion.
152
+ </step>
153
+
154
+ <step name="parse_segments">
155
+ **Intelligent segmentation: Parse plan into execution segments.**
156
+
157
+ Plans are divided into segments by checkpoints. Each segment is routed to optimal execution context (subagent or main).
158
+
159
+ **1. Check for checkpoints:**
160
+
161
+ ```bash
162
+ # Find all checkpoints and their types
163
+ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
164
+ ```
165
+
166
+ **2. Analyze execution strategy:**
167
+
168
+ **If NO checkpoints found:**
169
+
170
+ - **Fully autonomous plan** - spawn single subagent for entire plan
171
+ - Subagent gets fresh 200k context, executes all tasks, creates SUMMARY, commits
172
+ - Main context: Just orchestration (~5% usage)
173
+
174
+ **If checkpoints found, parse into segments:**
175
+
176
+ Segment = tasks between checkpoints (or start→first checkpoint, or last checkpoint→end)
177
+
178
+ **For each segment, determine routing:**
179
+
180
+ ```
181
+ Segment routing rules:
182
+
183
+ IF segment has no prior checkpoint:
184
+ → SUBAGENT (first segment, nothing to depend on)
185
+
186
+ IF segment follows checkpoint:human-verify:
187
+ → SUBAGENT (verification is just confirmation, doesn't affect next work)
188
+
189
+ IF segment follows checkpoint:decision OR checkpoint:human-action:
190
+ → MAIN CONTEXT (next tasks need the decision/result)
191
+ ```
192
+
193
+ **3. Execution pattern:**
194
+
195
+ **Pattern A: Fully autonomous (no checkpoints)**
196
+
197
+ ```
198
+ Spawn subagent → execute all tasks → SUMMARY → commit → report back
199
+ ```
200
+
201
+ **Pattern B: Segmented with verify-only checkpoints**
202
+
203
+ ```
204
+ Segment 1 (tasks 1-3): Spawn subagent → execute → report back
205
+ Checkpoint 4 (human-verify): Main context → you verify → continue
206
+ Segment 2 (tasks 5-6): Spawn NEW subagent → execute → report back
207
+ Checkpoint 7 (human-verify): Main context → you verify → continue
208
+ Aggregate results → SUMMARY → commit
209
+ ```
210
+
211
+ **Pattern C: Decision-dependent (must stay in main)**
212
+
213
+ ```
214
+ Checkpoint 1 (decision): Main context → you decide → continue in main
215
+ Tasks 2-5: Main context (need decision from checkpoint 1)
216
+ No segmentation benefit - execute entirely in main
217
+ ```
218
+
219
+ **4. Why segment:** Fresh context per subagent preserves peak quality. Main context stays lean (~15% usage).
220
+
221
+ **5. Implementation:**
222
+
223
+ **For fully autonomous plans:**
224
+
225
+ ```
226
+ 1. Run init_agent_tracking step first (see step below)
227
+
228
+ 2. Use Task tool with subagent_type="grd-executor" and model="{executor_model}":
229
+
230
+ Prompt: "Execute plan at .planning/phases/{phase}-{plan}-PLAN.md
231
+
232
+ This is an autonomous plan (no checkpoints). Execute all tasks, create SUMMARY.md in phase directory, commit with message following plan's commit guidance.
233
+
234
+ Follow all deviation rules and authentication gate protocols from the plan.
235
+
236
+ When complete, report: plan name, tasks completed, SUMMARY path, commit hash."
237
+
238
+ 3. After Task tool returns with agent_id:
239
+
240
+ a. Write agent_id to current-agent-id.txt:
241
+ echo "[agent_id]" > .planning/current-agent-id.txt
242
+
243
+ b. Append spawn entry to agent-history.json:
244
+ {
245
+ "agent_id": "[agent_id from Task response]",
246
+ "task_description": "Execute full plan {phase}-{plan} (autonomous)",
247
+ "phase": "{phase}",
248
+ "plan": "{plan}",
249
+ "segment": null,
250
+ "timestamp": "[ISO timestamp]",
251
+ "status": "spawned",
252
+ "completion_timestamp": null
253
+ }
254
+
255
+ 4. Wait for subagent to complete
256
+
257
+ 5. After subagent completes successfully:
258
+
259
+ a. Update agent-history.json entry:
260
+ - Find entry with matching agent_id
261
+ - Set status: "completed"
262
+ - Set completion_timestamp: "[ISO timestamp]"
263
+
264
+ b. Clear current-agent-id.txt:
265
+ rm .planning/current-agent-id.txt
266
+
267
+ 6. Report completion to user
268
+ ```
269
+
270
+ **For segmented plans (has verify-only checkpoints):**
271
+
272
+ ```
273
+ Execute segment-by-segment:
274
+
275
+ For each autonomous segment:
276
+ Spawn subagent with prompt: "Execute tasks [X-Y] from plan at .planning/phases/{phase}-{plan}-PLAN.md. Read the plan for full context and deviation rules. Do NOT create SUMMARY or commit - just execute these tasks and report results."
277
+
278
+ Wait for subagent completion
279
+
280
+ For each checkpoint:
281
+ Execute in main context
282
+ Wait for user interaction
283
+ Continue to next segment
284
+
285
+ After all segments complete:
286
+ Aggregate all results
287
+ Create SUMMARY.md
288
+ Commit with all changes
289
+ ```
290
+
291
+ **For decision-dependent plans:**
292
+
293
+ ```
294
+ Execute in main context (standard flow below)
295
+ No subagent routing
296
+ Quality maintained through small scope (2-3 tasks per plan)
297
+ ```
298
+
299
+ See step name="segment_execution" for detailed segment execution loop.
300
+ </step>
301
+
302
+ <step name="init_agent_tracking">
303
+ **Initialize agent tracking for subagent resume capability.**
304
+
305
+ Before spawning any subagents, set up tracking infrastructure:
306
+
307
+ **1. Create/verify tracking files:**
308
+
309
+ ```bash
310
+ # Create agent history file if doesn't exist
311
+ if [ ! -f .planning/agent-history.json ]; then
312
+ echo '{"version":"1.0","max_entries":50,"entries":[]}' > .planning/agent-history.json
313
+ fi
314
+
315
+ # Clear any stale current-agent-id (from interrupted sessions)
316
+ # Will be populated when subagent spawns
317
+ rm -f .planning/current-agent-id.txt
318
+ ```
319
+
320
+ **2. Check for interrupted agents (resume detection):**
321
+
322
+ ```bash
323
+ # Check if current-agent-id.txt exists from previous interrupted session
324
+ if [ -f .planning/current-agent-id.txt ]; then
325
+ INTERRUPTED_ID=$(cat .planning/current-agent-id.txt)
326
+ echo "Found interrupted agent: $INTERRUPTED_ID"
327
+ fi
328
+ ```
329
+
330
+ **If interrupted agent found:**
331
+ - The agent ID file exists from a previous session that didn't complete
332
+ - This agent can potentially be resumed using Task tool's `resume` parameter
333
+ - Present to user: "Previous session was interrupted. Resume agent [ID] or start fresh?"
334
+ - If resume: Use Task tool with `resume` parameter set to the interrupted ID
335
+ - If fresh: Clear the file and proceed normally
336
+
337
+ **3. Prune old entries (housekeeping):**
338
+
339
+ If agent-history.json has more than `max_entries`:
340
+ - Remove oldest entries with status "completed"
341
+ - Never remove entries with status "spawned" (may need resume)
342
+ - Keep file under size limit for fast reads
343
+
344
+ **When to run this step:**
345
+ - Pattern A (fully autonomous): Before spawning the single subagent
346
+ - Pattern B (segmented): Before the segment execution loop
347
+ - Pattern C (main context): Skip - no subagents spawned
348
+ </step>
349
+
350
+ <step name="segment_execution">
351
+ **Detailed segment execution loop for segmented plans.**
352
+
353
+ **This step applies ONLY to segmented plans (Pattern B: has checkpoints, but they're verify-only).**
354
+
355
+ For Pattern A (fully autonomous) and Pattern C (decision-dependent), skip this step.
356
+
357
+ **Execution flow:**
358
+
359
+ ````
360
+ 1. Parse plan to identify segments:
361
+ - Read plan file
362
+ - Find checkpoint locations: grep -n "type=\"checkpoint" PLAN.md
363
+ - Identify checkpoint types: grep "type=\"checkpoint" PLAN.md | grep -o 'checkpoint:[^"]*'
364
+ - Build segment map:
365
+ * Segment 1: Start → first checkpoint (tasks 1-X)
366
+ * Checkpoint 1: Type and location
367
+ * Segment 2: After checkpoint 1 → next checkpoint (tasks X+1 to Y)
368
+ * Checkpoint 2: Type and location
369
+ * ... continue for all segments
370
+
371
+ 2. For each segment in order:
372
+
373
+ A. Determine routing (apply rules from parse_segments):
374
+ - No prior checkpoint? → Subagent
375
+ - Prior checkpoint was human-verify? → Subagent
376
+ - Prior checkpoint was decision/human-action? → Main context
377
+
378
+ B. If routing = Subagent:
379
+ ```
380
+ Spawn Task tool with subagent_type="grd-executor" and model="{executor_model}":
381
+
382
+ Prompt: "Execute tasks [task numbers/names] from plan at [plan path].
383
+
384
+ **Context:**
385
+ - Read the full plan for objective, context files, and deviation rules
386
+ - You are executing a SEGMENT of this plan (not the full plan)
387
+ - Other segments will be executed separately
388
+
389
+ **Your responsibilities:**
390
+ - Execute only the tasks assigned to you
391
+ - Follow all deviation rules and authentication gate protocols
392
+ - Track deviations for later Summary
393
+ - DO NOT create SUMMARY.md (will be created after all segments complete)
394
+ - DO NOT commit (will be done after all segments complete)
395
+
396
+ **Report back:**
397
+ - Tasks completed
398
+ - Files created/modified
399
+ - Deviations encountered
400
+ - Any issues or blockers"
401
+
402
+ **After Task tool returns with agent_id:**
403
+
404
+ 1. Write agent_id to current-agent-id.txt:
405
+ echo "[agent_id]" > .planning/current-agent-id.txt
406
+
407
+ 2. Append spawn entry to agent-history.json:
408
+ {
409
+ "agent_id": "[agent_id from Task response]",
410
+ "task_description": "Execute tasks [X-Y] from plan {phase}-{plan}",
411
+ "phase": "{phase}",
412
+ "plan": "{plan}",
413
+ "segment": [segment_number],
414
+ "timestamp": "[ISO timestamp]",
415
+ "status": "spawned",
416
+ "completion_timestamp": null
417
+ }
418
+
419
+ Wait for subagent to complete
420
+ Capture results (files changed, deviations, etc.)
421
+
422
+ **After subagent completes successfully:**
423
+
424
+ 1. Update agent-history.json entry:
425
+ - Find entry with matching agent_id
426
+ - Set status: "completed"
427
+ - Set completion_timestamp: "[ISO timestamp]"
428
+
429
+ 2. Clear current-agent-id.txt:
430
+ rm .planning/current-agent-id.txt
431
+
432
+ ```
433
+
434
+ C. If routing = Main context:
435
+ Execute tasks in main using standard execution flow (step name="execute")
436
+ Track results locally
437
+
438
+ D. After segment completes (whether subagent or main):
439
+ Continue to next checkpoint/segment
440
+
441
+ 3. After ALL segments complete:
442
+
443
+ A. Aggregate results from all segments:
444
+ - Collect files created/modified from all segments
445
+ - Collect deviations from all segments
446
+ - Collect decisions from all checkpoints
447
+ - Merge into complete picture
448
+
449
+ B. Create SUMMARY.md:
450
+ - Use aggregated results
451
+ - Document all work from all segments
452
+ - Include deviations from all segments
453
+ - Note which segments were subagented
454
+
455
+ C. Commit:
456
+ - Stage all files from all segments
457
+ - Stage SUMMARY.md
458
+ - Commit with message following plan guidance
459
+ - Include note about segmented execution if relevant
460
+
461
+ D. Report completion
462
+
463
+ **Example execution trace:**
464
+
465
+ ````
466
+
467
+ Plan: 01-02-PLAN.md (8 tasks, 2 verify checkpoints)
468
+
469
+ Parsing segments...
470
+
471
+ - Segment 1: Tasks 1-3 (autonomous)
472
+ - Checkpoint 4: human-verify
473
+ - Segment 2: Tasks 5-6 (autonomous)
474
+ - Checkpoint 7: human-verify
475
+ - Segment 3: Task 8 (autonomous)
476
+
477
+ Routing analysis:
478
+
479
+ - Segment 1: No prior checkpoint → SUBAGENT ✓
480
+ - Checkpoint 4: Verify only → MAIN (required)
481
+ - Segment 2: After verify → SUBAGENT ✓
482
+ - Checkpoint 7: Verify only → MAIN (required)
483
+ - Segment 3: After verify → SUBAGENT ✓
484
+
485
+ Execution:
486
+ [1] Spawning subagent for tasks 1-3...
487
+ → Subagent completes: 3 files modified, 0 deviations
488
+ [2] Executing checkpoint 4 (human-verify)...
489
+ ╔═══════════════════════════════════════════════════════╗
490
+ ║ CHECKPOINT: Verification Required ║
491
+ ╚═══════════════════════════════════════════════════════╝
492
+
493
+ Progress: 3/8 tasks complete
494
+ Task: Verify database schema
495
+
496
+ Built: User and Session tables with relations
497
+
498
+ How to verify:
499
+ 1. Check src/db/schema.ts for correct types
500
+
501
+ ────────────────────────────────────────────────────────
502
+ → YOUR ACTION: Type "approved" or describe issues
503
+ ────────────────────────────────────────────────────────
504
+ User: "approved"
505
+ [3] Spawning subagent for tasks 5-6...
506
+ → Subagent completes: 2 files modified, 1 deviation (added error handling)
507
+ [4] Executing checkpoint 7 (human-verify)...
508
+ User: "approved"
509
+ [5] Spawning subagent for task 8...
510
+ → Subagent completes: 1 file modified, 0 deviations
511
+
512
+ Aggregating results...
513
+
514
+ - Total files: 6 modified
515
+ - Total deviations: 1
516
+ - Segmented execution: 3 subagents, 2 checkpoints
517
+
518
+ Creating SUMMARY.md...
519
+ Committing...
520
+ ✓ Complete
521
+
522
+ ````
523
+
524
+ **Benefit:** Each subagent starts fresh (~20-30% context), enabling larger plans without quality degradation.
525
+ </step>
526
+
527
+ <step name="load_prompt">
528
+ Read the plan prompt:
529
+ ```bash
530
+ cat .planning/phases/XX-name/{phase}-{plan}-PLAN.md
531
+ ````
532
+
533
+ This IS the execution instructions. Follow it exactly.
534
+
535
+ **If plan references CONTEXT.md:**
536
+ The CONTEXT.md file provides the user's vision for this phase — how they imagine it working, what's essential, and what's out of scope. Honor this context throughout execution.
537
+ </step>
538
+
539
+ <step name="previous_phase_check">
540
+ Before executing, check if previous phase had issues:
541
+
542
+ ```bash
543
+ # Find previous phase summary
544
+ ls .planning/phases/*/SUMMARY.md 2>/dev/null | sort -r | head -2 | tail -1
545
+ ```
546
+
547
+ If previous phase SUMMARY.md has "Issues Encountered" != "None" or "Next Phase Readiness" mentions blockers:
548
+
549
+ Use AskUserQuestion:
550
+
551
+ - header: "Previous Issues"
552
+ - question: "Previous phase had unresolved items: [summary]. How to proceed?"
553
+ - options:
554
+ - "Proceed anyway" - Issues won't block this phase
555
+ - "Address first" - Let's resolve before continuing
556
+ - "Review previous" - Show me the full summary
557
+ </step>
558
+
559
+ <step name="execute">
560
+ Execute each task in the prompt. **Deviations are normal** - handle them automatically using embedded rules below.
561
+
562
+ 1. Read the @context files listed in the prompt
563
+
564
+ 2. For each task:
565
+
566
+ **If `type="auto"`:**
567
+
568
+ **Before executing:** Check if task has `tdd="true"` attribute:
569
+ - If yes: Follow TDD execution flow (see `<tdd_execution>`) - RED → GREEN → REFACTOR cycle with atomic commits per stage
570
+ - If no: Standard implementation
571
+
572
+ - Work toward task completion
573
+ - **If CLI/API returns authentication error:** Handle as authentication gate (see below)
574
+ - **When you discover additional work not in plan:** Apply deviation rules (see below) automatically
575
+ - Continue implementing, applying rules as needed
576
+ - Run the verification
577
+ - Confirm done criteria met
578
+ - **Commit the task** (see `<task_commit>` below)
579
+ - Track task completion and commit hash for Summary documentation
580
+ - Continue to next task
581
+
582
+ **If `type="checkpoint:*"`:**
583
+
584
+ - STOP immediately (do not continue to next task)
585
+ - Execute checkpoint_protocol (see below)
586
+ - Wait for user response
587
+ - Verify if possible (check files, env vars, etc.)
588
+ - Only after user confirmation: continue to next task
589
+
590
+ 3. Run overall verification checks from `<verification>` section
591
+ 4. Confirm all success criteria from `<success_criteria>` section met
592
+ 5. Document all deviations in Summary (automatic - see deviation_documentation below)
593
+ </step>
594
+
595
+ <authentication_gates>
596
+
597
+ ## Handling Authentication Errors During Execution
598
+
599
+ **When you encounter authentication errors during `type="auto"` task execution:**
600
+
601
+ This is NOT a failure. Authentication gates are expected and normal. Handle them dynamically:
602
+
603
+ **Authentication error indicators:**
604
+
605
+ - CLI returns: "Error: Not authenticated", "Not logged in", "Unauthorized", "401", "403"
606
+ - API returns: "Authentication required", "Invalid API key", "Missing credentials"
607
+ - Command fails with: "Please run {tool} login" or "Set {ENV_VAR} environment variable"
608
+
609
+ **Authentication gate protocol:**
610
+
611
+ 1. **Recognize it's an auth gate** - Not a bug, just needs credentials
612
+ 2. **STOP current task execution** - Don't retry repeatedly
613
+ 3. **Create dynamic checkpoint:human-action** - Present it to user immediately
614
+ 4. **Provide exact authentication steps** - CLI commands, where to get keys
615
+ 5. **Wait for user to authenticate** - Let them complete auth flow
616
+ 6. **Verify authentication works** - Test that credentials are valid
617
+ 7. **Retry the original task** - Resume automation where you left off
618
+ 8. **Continue normally** - Don't treat this as an error in Summary
619
+
620
+ **Example: Vercel deployment hits auth error**
621
+
622
+ ```
623
+ Task 3: Deploy to Vercel
624
+ Running: vercel --yes
625
+
626
+ Error: Not authenticated. Please run 'vercel login'
627
+
628
+ [Create checkpoint dynamically]
629
+
630
+ ╔═══════════════════════════════════════════════════════╗
631
+ ║ CHECKPOINT: Action Required ║
632
+ ╚═══════════════════════════════════════════════════════╝
633
+
634
+ Progress: 2/8 tasks complete
635
+ Task: Authenticate Vercel CLI
636
+
637
+ Attempted: vercel --yes
638
+ Error: Not authenticated
639
+
640
+ What you need to do:
641
+ 1. Run: vercel login
642
+ 2. Complete browser authentication
643
+
644
+ I'll verify: vercel whoami returns your account
645
+
646
+ ────────────────────────────────────────────────────────
647
+ → YOUR ACTION: Type "done" when authenticated
648
+ ────────────────────────────────────────────────────────
649
+
650
+ [Wait for user response]
651
+
652
+ [User types "done"]
653
+
654
+ Verifying authentication...
655
+ Running: vercel whoami
656
+ ✓ Authenticated as: user@example.com
657
+
658
+ Retrying deployment...
659
+ Running: vercel --yes
660
+ ✓ Deployed to: https://myapp-abc123.vercel.app
661
+
662
+ Task 3 complete. Continuing to task 4...
663
+ ```
664
+
665
+ **In Summary documentation:**
666
+
667
+ Document authentication gates as normal flow, not deviations:
668
+
669
+ ```markdown
670
+ ## Authentication Gates
671
+
672
+ During execution, I encountered authentication requirements:
673
+
674
+ 1. Task 3: Vercel CLI required authentication
675
+ - Paused for `vercel login`
676
+ - Resumed after authentication
677
+ - Deployed successfully
678
+
679
+ These are normal gates, not errors.
680
+ ```
681
+
682
+ **Key principles:**
683
+
684
+ - Authentication gates are NOT failures or bugs
685
+ - They're expected interaction points during first-time setup
686
+ - Handle them gracefully and continue automation after unblocked
687
+ - Don't mark tasks as "failed" or "incomplete" due to auth gates
688
+ - Document them as normal flow, separate from deviations
689
+ </authentication_gates>
690
+
691
+ <deviation_rules>
692
+
693
+ ## Automatic Deviation Handling
694
+
695
+ **While executing tasks, you WILL discover work not in the plan.** This is normal.
696
+
697
+ Apply these rules automatically. Track all deviations for Summary documentation.
698
+
699
+ ---
700
+
701
+ **RULE 1: Auto-fix bugs**
702
+
703
+ **Trigger:** Code doesn't work as intended (broken behavior, incorrect output, errors)
704
+
705
+ **Action:** Fix immediately, track for Summary
706
+
707
+ **Examples:**
708
+
709
+ - Wrong SQL query returning incorrect data
710
+ - Logic errors (inverted condition, off-by-one, infinite loop)
711
+ - Type errors, null pointer exceptions, undefined references
712
+ - Broken validation (accepts invalid input, rejects valid input)
713
+ - Security vulnerabilities (SQL injection, XSS, CSRF, insecure auth)
714
+ - Race conditions, deadlocks
715
+ - Memory leaks, resource leaks
716
+
717
+ **Process:**
718
+
719
+ 1. Fix the bug inline
720
+ 2. Add/update tests to prevent regression
721
+ 3. Verify fix works
722
+ 4. Continue task
723
+ 5. Track in deviations list: `[Rule 1 - Bug] [description]`
724
+
725
+ **No user permission needed.** Bugs must be fixed for correct operation.
726
+
727
+ ---
728
+
729
+ **RULE 2: Auto-add missing critical functionality**
730
+
731
+ **Trigger:** Code is missing essential features for correctness, security, or basic operation
732
+
733
+ **Action:** Add immediately, track for Summary
734
+
735
+ **Examples:**
736
+
737
+ - Missing error handling (no try/catch, unhandled promise rejections)
738
+ - No input validation (accepts malicious data, type coercion issues)
739
+ - Missing null/undefined checks (crashes on edge cases)
740
+ - No authentication on protected routes
741
+ - Missing authorization checks (users can access others' data)
742
+ - No CSRF protection, missing CORS configuration
743
+ - No rate limiting on public APIs
744
+ - Missing required database indexes (causes timeouts)
745
+ - No logging for errors (can't debug production)
746
+
747
+ **Process:**
748
+
749
+ 1. Add the missing functionality inline
750
+ 2. Add tests for the new functionality
751
+ 3. Verify it works
752
+ 4. Continue task
753
+ 5. Track in deviations list: `[Rule 2 - Missing Critical] [description]`
754
+
755
+ **Critical = required for correct/secure/performant operation**
756
+ **No user permission needed.** These are not "features" - they're requirements for basic correctness.
757
+
758
+ ---
759
+
760
+ **RULE 3: Auto-fix blocking issues**
761
+
762
+ **Trigger:** Something prevents you from completing current task
763
+
764
+ **Action:** Fix immediately to unblock, track for Summary
765
+
766
+ **Examples:**
767
+
768
+ - Missing dependency (package not installed, import fails)
769
+ - Wrong types blocking compilation
770
+ - Broken import paths (file moved, wrong relative path)
771
+ - Missing environment variable (app won't start)
772
+ - Database connection config error
773
+ - Build configuration error (webpack, tsconfig, etc.)
774
+ - Missing file referenced in code
775
+ - Circular dependency blocking module resolution
776
+
777
+ **Process:**
778
+
779
+ 1. Fix the blocking issue
780
+ 2. Verify task can now proceed
781
+ 3. Continue task
782
+ 4. Track in deviations list: `[Rule 3 - Blocking] [description]`
783
+
784
+ **No user permission needed.** Can't complete task without fixing blocker.
785
+
786
+ ---
787
+
788
+ **RULE 4: Ask about architectural changes**
789
+
790
+ **Trigger:** Fix/addition requires significant structural modification
791
+
792
+ **Action:** STOP, present to user, wait for decision
793
+
794
+ **Examples:**
795
+
796
+ - Adding new database table (not just column)
797
+ - Major schema changes (changing primary key, splitting tables)
798
+ - Introducing new service layer or architectural pattern
799
+ - Switching libraries/frameworks (React → Vue, REST → GraphQL)
800
+ - Changing authentication approach (sessions → JWT)
801
+ - Adding new infrastructure (message queue, cache layer, CDN)
802
+ - Changing API contracts (breaking changes to endpoints)
803
+ - Adding new deployment environment
804
+
805
+ **Process:**
806
+
807
+ 1. STOP current task
808
+ 2. Present clearly:
809
+
810
+ ```
811
+ ⚠️ Architectural Decision Needed
812
+
813
+ Current task: [task name]
814
+ Discovery: [what you found that prompted this]
815
+ Proposed change: [architectural modification]
816
+ Why needed: [rationale]
817
+ Impact: [what this affects - APIs, deployment, dependencies, etc.]
818
+ Alternatives: [other approaches, or "none apparent"]
819
+
820
+ Proceed with proposed change? (yes / different approach / defer)
821
+ ```
822
+
823
+ 3. WAIT for user response
824
+ 4. If approved: implement, track as `[Rule 4 - Architectural] [description]`
825
+ 5. If different approach: discuss and implement
826
+ 6. If deferred: note in Summary and continue without change
827
+
828
+ **User decision required.** These changes affect system design.
829
+
830
+ ---
831
+
832
+ **RULE PRIORITY (when multiple could apply):**
833
+
834
+ 1. **If Rule 4 applies** → STOP and ask (architectural decision)
835
+ 2. **If Rules 1-3 apply** → Fix automatically, track for Summary
836
+ 3. **If genuinely unsure which rule** → Apply Rule 4 (ask user)
837
+
838
+ **Edge case guidance:**
839
+
840
+ - "This validation is missing" → Rule 2 (critical for security)
841
+ - "This crashes on null" → Rule 1 (bug)
842
+ - "Need to add table" → Rule 4 (architectural)
843
+ - "Need to add column" → Rule 1 or 2 (depends: fixing bug or adding critical field)
844
+
845
+ **When in doubt:** Ask yourself "Does this affect correctness, security, or ability to complete task?"
846
+
847
+ - YES → Rules 1-3 (fix automatically)
848
+ - MAYBE → Rule 4 (ask user)
849
+
850
+ </deviation_rules>
851
+
852
+ <deviation_documentation>
853
+
854
+ ## Documenting Deviations in Summary
855
+
856
+ After all tasks complete, Summary MUST include deviations section.
857
+
858
+ **If no deviations:**
859
+
860
+ ```markdown
861
+ ## Deviations from Plan
862
+
863
+ None - plan executed exactly as written.
864
+ ```
865
+
866
+ **If deviations occurred:**
867
+
868
+ ```markdown
869
+ ## Deviations from Plan
870
+
871
+ ### Auto-fixed Issues
872
+
873
+ **1. [Rule 1 - Bug] Fixed case-sensitive email uniqueness constraint**
874
+
875
+ - **Found during:** Task 4 (Follow/unfollow API implementation)
876
+ - **Issue:** User.email unique constraint was case-sensitive - Test@example.com and test@example.com were both allowed, causing duplicate accounts
877
+ - **Fix:** Changed to `CREATE UNIQUE INDEX users_email_unique ON users (LOWER(email))`
878
+ - **Files modified:** src/models/User.ts, migrations/003_fix_email_unique.sql
879
+ - **Verification:** Unique constraint test passes - duplicate emails properly rejected
880
+ - **Commit:** abc123f
881
+
882
+ **2. [Rule 2 - Missing Critical] Added JWT expiry validation to auth middleware**
883
+
884
+ - **Found during:** Task 3 (Protected route implementation)
885
+ - **Issue:** Auth middleware wasn't checking token expiry - expired tokens were being accepted
886
+ - **Fix:** Added exp claim validation in middleware, reject with 401 if expired
887
+ - **Files modified:** src/middleware/auth.ts, src/middleware/auth.test.ts
888
+ - **Verification:** Expired token test passes - properly rejects with 401
889
+ - **Commit:** def456g
890
+
891
+ ---
892
+
893
+ **Total deviations:** 4 auto-fixed (1 bug, 1 missing critical, 1 blocking, 1 architectural with approval)
894
+ **Impact on plan:** All auto-fixes necessary for correctness/security/performance. No scope creep.
895
+ ```
896
+
897
+ **This provides complete transparency:**
898
+
899
+ - Every deviation documented
900
+ - Why it was needed
901
+ - What rule applied
902
+ - What was done
903
+ - User can see exactly what happened beyond the plan
904
+
905
+ </deviation_documentation>
906
+
907
+ <tdd_plan_execution>
908
+ ## TDD Plan Execution
909
+
910
+ When executing a plan with `type: tdd` in frontmatter, follow the RED-GREEN-REFACTOR cycle for the single feature defined in the plan.
911
+
912
+ **1. Check test infrastructure (if first TDD plan):**
913
+ If no test framework configured:
914
+ - Detect project type from package.json/requirements.txt/etc.
915
+ - Install minimal test framework (Jest, pytest, Go testing, etc.)
916
+ - Create test config file
917
+ - Verify: run empty test suite
918
+ - This is part of the RED phase, not a separate task
919
+
920
+ **2. RED - Write failing test:**
921
+ - Read `<behavior>` element for test specification
922
+ - Create test file if doesn't exist (follow project conventions)
923
+ - Write test(s) that describe expected behavior
924
+ - Run tests - MUST fail (if passes, test is wrong or feature exists)
925
+ - Commit: `test({phase}-{plan}): add failing test for [feature]`
926
+
927
+ **3. GREEN - Implement to pass:**
928
+ - Read `<implementation>` element for guidance
929
+ - Write minimal code to make test pass
930
+ - Run tests - MUST pass
931
+ - Commit: `feat({phase}-{plan}): implement [feature]`
932
+
933
+ **4. REFACTOR (if needed):**
934
+ - Clean up code if obvious improvements
935
+ - Run tests - MUST still pass
936
+ - Commit only if changes made: `refactor({phase}-{plan}): clean up [feature]`
937
+
938
+ **Commit pattern for TDD plans:**
939
+ Each TDD plan produces 2-3 atomic commits:
940
+ 1. `test({phase}-{plan}): add failing test for X`
941
+ 2. `feat({phase}-{plan}): implement X`
942
+ 3. `refactor({phase}-{plan}): clean up X` (optional)
943
+
944
+ **Error handling:**
945
+ - If test doesn't fail in RED phase: Test is wrong or feature already exists. Investigate before proceeding.
946
+ - If test doesn't pass in GREEN phase: Debug implementation, keep iterating until green.
947
+ - If tests fail in REFACTOR phase: Undo refactor, commit was premature.
948
+
949
+ **Verification:**
950
+ After TDD plan completion, ensure:
951
+ - All tests pass
952
+ - Test coverage for the new behavior exists
953
+ - No unrelated tests broken
954
+
955
+ **Why TDD uses dedicated plans:** TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This consumes 40-50% of context for a single feature. Dedicated plans ensure full quality throughout the cycle.
956
+
957
+ **Comparison:**
958
+ - Standard plans: Multiple tasks, 1 commit per task, 2-4 commits total
959
+ - TDD plans: Single feature, 2-3 commits for RED/GREEN/REFACTOR cycle
960
+
961
+ See `~/.claude/get-research-done/references/tdd.md` for TDD plan structure.
962
+ </tdd_plan_execution>
963
+
964
+ <task_commit>
965
+ ## Task Commit Protocol
966
+
967
+ After each task completes (verification passed, done criteria met), commit immediately:
968
+
969
+ **1. Identify modified files:**
970
+
971
+ Track files changed during this specific task (not the entire plan):
972
+
973
+ ```bash
974
+ git status --short
975
+ ```
976
+
977
+ **2. Stage only task-related files:**
978
+
979
+ Stage each file individually (NEVER use `git add .` or `git add -A`):
980
+
981
+ ```bash
982
+ # Example - adjust to actual files modified by this task
983
+ git add src/api/auth.ts
984
+ git add src/types/user.ts
985
+ ```
986
+
987
+ **3. Determine commit type:**
988
+
989
+ | Type | When to Use | Example |
990
+ |------|-------------|---------|
991
+ | `feat` | New feature, endpoint, component, functionality | feat(08-02): create user registration endpoint |
992
+ | `fix` | Bug fix, error correction | fix(08-02): correct email validation regex |
993
+ | `test` | Test-only changes (TDD RED phase) | test(08-02): add failing test for password hashing |
994
+ | `refactor` | Code cleanup, no behavior change (TDD REFACTOR phase) | refactor(08-02): extract validation to helper |
995
+ | `perf` | Performance improvement | perf(08-02): add database index for user lookups |
996
+ | `docs` | Documentation changes | docs(08-02): add API endpoint documentation |
997
+ | `style` | Formatting, linting fixes | style(08-02): format auth module |
998
+ | `chore` | Config, tooling, dependencies | chore(08-02): add bcrypt dependency |
999
+
1000
+ **4. Craft commit message:**
1001
+
1002
+ Format: `{type}({phase}-{plan}): {task-name-or-description}`
1003
+
1004
+ ```bash
1005
+ git commit -m "{type}({phase}-{plan}): {concise task description}
1006
+
1007
+ - {key change 1}
1008
+ - {key change 2}
1009
+ - {key change 3}
1010
+ "
1011
+ ```
1012
+
1013
+ **Examples:**
1014
+
1015
+ ```bash
1016
+ # Standard plan task
1017
+ git commit -m "feat(08-02): create user registration endpoint
1018
+
1019
+ - POST /auth/register validates email and password
1020
+ - Checks for duplicate users
1021
+ - Returns JWT token on success
1022
+ "
1023
+
1024
+ # Another standard task
1025
+ git commit -m "fix(08-02): correct email validation regex
1026
+
1027
+ - Fixed regex to accept plus-addressing
1028
+ - Added tests for edge cases
1029
+ "
1030
+ ```
1031
+
1032
+ **Note:** TDD plans have their own commit pattern (test/feat/refactor for RED/GREEN/REFACTOR phases). See `<tdd_plan_execution>` section above.
1033
+
1034
+ **5. Record commit hash:**
1035
+
1036
+ After committing, capture hash for SUMMARY.md:
1037
+
1038
+ ```bash
1039
+ TASK_COMMIT=$(git rev-parse --short HEAD)
1040
+ echo "Task ${TASK_NUM} committed: ${TASK_COMMIT}"
1041
+ ```
1042
+
1043
+ Store in array or list for SUMMARY generation:
1044
+ ```bash
1045
+ TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
1046
+ ```
1047
+
1048
+ </task_commit>
1049
+
1050
+ <step name="checkpoint_protocol">
1051
+ When encountering `type="checkpoint:*"`:
1052
+
1053
+ **Critical: Claude automates everything with CLI/API before checkpoints.** Checkpoints are for verification and decisions, not manual work.
1054
+
1055
+ **Display checkpoint clearly:**
1056
+
1057
+ ```
1058
+ ╔═══════════════════════════════════════════════════════╗
1059
+ ║ CHECKPOINT: [Type] ║
1060
+ ╚═══════════════════════════════════════════════════════╝
1061
+
1062
+ Progress: {X}/{Y} tasks complete
1063
+ Task: [task name]
1064
+
1065
+ [Display task-specific content based on type]
1066
+
1067
+ ────────────────────────────────────────────────────────
1068
+ → YOUR ACTION: [Resume signal instruction]
1069
+ ────────────────────────────────────────────────────────
1070
+ ```
1071
+
1072
+ **For checkpoint:human-verify (90% of checkpoints):**
1073
+
1074
+ ```
1075
+ Built: [what was automated - deployed, built, configured]
1076
+
1077
+ How to verify:
1078
+ 1. [Step 1 - exact command/URL]
1079
+ 2. [Step 2 - what to check]
1080
+ 3. [Step 3 - expected behavior]
1081
+
1082
+ ────────────────────────────────────────────────────────
1083
+ → YOUR ACTION: Type "approved" or describe issues
1084
+ ────────────────────────────────────────────────────────
1085
+ ```
1086
+
1087
+ **For checkpoint:decision (9% of checkpoints):**
1088
+
1089
+ ```
1090
+ Decision needed: [decision]
1091
+
1092
+ Context: [why this matters]
1093
+
1094
+ Options:
1095
+ 1. [option-id]: [name]
1096
+ Pros: [pros]
1097
+ Cons: [cons]
1098
+
1099
+ 2. [option-id]: [name]
1100
+ Pros: [pros]
1101
+ Cons: [cons]
1102
+
1103
+ [Resume signal - e.g., "Select: option-id"]
1104
+ ```
1105
+
1106
+ **For checkpoint:human-action (1% - rare, only for truly unavoidable manual steps):**
1107
+
1108
+ ```
1109
+ I automated: [what Claude already did via CLI/API]
1110
+
1111
+ Need your help with: [the ONE thing with no CLI/API - email link, 2FA code]
1112
+
1113
+ Instructions:
1114
+ [Single unavoidable step]
1115
+
1116
+ I'll verify after: [verification]
1117
+
1118
+ [Resume signal - e.g., "Type 'done' when complete"]
1119
+ ```
1120
+
1121
+ **After displaying:** WAIT for user response. Do NOT hallucinate completion. Do NOT continue to next task.
1122
+
1123
+ **After user responds:**
1124
+
1125
+ - Run verification if specified (file exists, env var set, tests pass, etc.)
1126
+ - If verification passes or N/A: continue to next task
1127
+ - If verification fails: inform user, wait for resolution
1128
+
1129
+ See ~/.claude/get-research-done/references/checkpoints.md for complete checkpoint guidance.
1130
+ </step>
1131
+
1132
+ <step name="checkpoint_return_for_orchestrator">
1133
+ **When spawned by an orchestrator (execute-phase or execute-plan command):**
1134
+
1135
+ If you were spawned via Task tool and hit a checkpoint, you cannot directly interact with the user. Instead, RETURN to the orchestrator with structured checkpoint state so it can present to the user and spawn a fresh continuation agent.
1136
+
1137
+ **Return format for checkpoints:**
1138
+
1139
+ **Required in your return:**
1140
+
1141
+ 1. **Completed Tasks table** - Tasks done so far with commit hashes and files created
1142
+ 2. **Current Task** - Which task you're on and what's blocking it
1143
+ 3. **Checkpoint Details** - User-facing content (verification steps, decision options, or action instructions)
1144
+ 4. **Awaiting** - What you need from the user
1145
+
1146
+ **Example return:**
1147
+
1148
+ ```
1149
+ ## CHECKPOINT REACHED
1150
+
1151
+ **Type:** human-action
1152
+ **Plan:** 01-01
1153
+ **Progress:** 1/3 tasks complete
1154
+
1155
+ ### Completed Tasks
1156
+
1157
+ | Task | Name | Commit | Files |
1158
+ |------|------|--------|-------|
1159
+ | 1 | Initialize Next.js 15 project | d6fe73f | package.json, tsconfig.json, app/ |
1160
+
1161
+ ### Current Task
1162
+
1163
+ **Task 2:** Initialize Convex backend
1164
+ **Status:** blocked
1165
+ **Blocked by:** Convex CLI authentication required
1166
+
1167
+ ### Checkpoint Details
1168
+
1169
+ **Automation attempted:**
1170
+ Ran `npx convex dev` to initialize Convex backend
1171
+
1172
+ **Error encountered:**
1173
+ "Error: Not authenticated. Run `npx convex login` first."
1174
+
1175
+ **What you need to do:**
1176
+ 1. Run: `npx convex login`
1177
+ 2. Complete browser authentication
1178
+ 3. Run: `npx convex dev`
1179
+ 4. Create project when prompted
1180
+
1181
+ **I'll verify after:**
1182
+ `cat .env.local | grep CONVEX` returns the Convex URL
1183
+
1184
+ ### Awaiting
1185
+
1186
+ Type "done" when Convex is authenticated and project created.
1187
+ ```
1188
+
1189
+ **After you return:**
1190
+
1191
+ The orchestrator will:
1192
+ 1. Parse your structured return
1193
+ 2. Present checkpoint details to the user
1194
+ 3. Collect user's response
1195
+ 4. Spawn a FRESH continuation agent with your completed tasks state
1196
+
1197
+ You will NOT be resumed. A new agent continues from where you stopped, using your Completed Tasks table to know what's done.
1198
+
1199
+ **How to know if you were spawned:**
1200
+
1201
+ If you're reading this workflow because an orchestrator spawned you (vs running directly), the orchestrator's prompt will include checkpoint return instructions. Follow those instructions when you hit a checkpoint.
1202
+
1203
+ **If running in main context (not spawned):**
1204
+
1205
+ Use the standard checkpoint_protocol - display checkpoint and wait for direct user response.
1206
+ </step>
1207
+
1208
+ <step name="verification_failure_gate">
1209
+ If any task verification fails:
1210
+
1211
+ STOP. Do not continue to next task.
1212
+
1213
+ Present inline:
1214
+ "Verification failed for Task [X]: [task name]
1215
+
1216
+ Expected: [verification criteria]
1217
+ Actual: [what happened]
1218
+
1219
+ How to proceed?
1220
+
1221
+ 1. Retry - Try the task again
1222
+ 2. Skip - Mark as incomplete, continue
1223
+ 3. Stop - Pause execution, investigate"
1224
+
1225
+ Wait for user decision.
1226
+
1227
+ If user chose "Skip", note it in SUMMARY.md under "Issues Encountered".
1228
+ </step>
1229
+
1230
+ <step name="record_completion_time">
1231
+ Record execution end time and calculate duration:
1232
+
1233
+ ```bash
1234
+ PLAN_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
1235
+ PLAN_END_EPOCH=$(date +%s)
1236
+
1237
+ DURATION_SEC=$(( PLAN_END_EPOCH - PLAN_START_EPOCH ))
1238
+ DURATION_MIN=$(( DURATION_SEC / 60 ))
1239
+
1240
+ if [[ $DURATION_MIN -ge 60 ]]; then
1241
+ HRS=$(( DURATION_MIN / 60 ))
1242
+ MIN=$(( DURATION_MIN % 60 ))
1243
+ DURATION="${HRS}h ${MIN}m"
1244
+ else
1245
+ DURATION="${DURATION_MIN} min"
1246
+ fi
1247
+ ```
1248
+
1249
+ Pass timing data to SUMMARY.md creation.
1250
+ </step>
1251
+
1252
+ <step name="generate_user_setup">
1253
+ **Generate USER-SETUP.md if plan has user_setup in frontmatter.**
1254
+
1255
+ Check PLAN.md frontmatter for `user_setup` field:
1256
+
1257
+ ```bash
1258
+ grep -A 50 "^user_setup:" .planning/phases/XX-name/{phase}-{plan}-PLAN.md | head -50
1259
+ ```
1260
+
1261
+ **If user_setup exists and is not empty:**
1262
+
1263
+ Create `.planning/phases/XX-name/{phase}-USER-SETUP.md` using template from `~/.claude/get-research-done/templates/user-setup.md`.
1264
+
1265
+ **Content generation:**
1266
+
1267
+ 1. Parse each service in `user_setup` array
1268
+ 2. For each service, generate sections:
1269
+ - Environment Variables table (from `env_vars`)
1270
+ - Account Setup checklist (from `account_setup`, if present)
1271
+ - Dashboard Configuration steps (from `dashboard_config`, if present)
1272
+ - Local Development notes (from `local_dev`, if present)
1273
+ 3. Add verification section with commands to confirm setup works
1274
+ 4. Set status to "Incomplete"
1275
+
1276
+ **Example output:**
1277
+
1278
+ ```markdown
1279
+ # Phase 10: User Setup Required
1280
+
1281
+ **Generated:** 2025-01-14
1282
+ **Phase:** 10-monetization
1283
+ **Status:** Incomplete
1284
+
1285
+ ## Environment Variables
1286
+
1287
+ | Status | Variable | Source | Add to |
1288
+ |--------|----------|--------|--------|
1289
+ | [ ] | `STRIPE_SECRET_KEY` | Stripe Dashboard → Developers → API keys → Secret key | `.env.local` |
1290
+ | [ ] | `STRIPE_WEBHOOK_SECRET` | Stripe Dashboard → Developers → Webhooks → Signing secret | `.env.local` |
1291
+
1292
+ ## Dashboard Configuration
1293
+
1294
+ - [ ] **Create webhook endpoint**
1295
+ - Location: Stripe Dashboard → Developers → Webhooks → Add endpoint
1296
+ - Details: URL: https://[your-domain]/api/webhooks/stripe, Events: checkout.session.completed
1297
+
1298
+ ## Local Development
1299
+
1300
+ For local testing:
1301
+ \`\`\`bash
1302
+ stripe listen --forward-to localhost:3000/api/webhooks/stripe
1303
+ \`\`\`
1304
+
1305
+ ## Verification
1306
+
1307
+ [Verification commands based on service]
1308
+
1309
+ ---
1310
+ **Once all items complete:** Mark status as "Complete"
1311
+ ```
1312
+
1313
+ **If user_setup is empty or missing:**
1314
+
1315
+ Skip this step - no USER-SETUP.md needed.
1316
+
1317
+ **Track for offer_next:**
1318
+
1319
+ Set `USER_SETUP_CREATED=true` if file was generated, for use in completion messaging.
1320
+ </step>
1321
+
1322
+ <step name="create_summary">
1323
+ Create `{phase}-{plan}-SUMMARY.md` as specified in the prompt's `<output>` section.
1324
+ Use ~/.claude/get-research-done/templates/summary.md for structure.
1325
+
1326
+ **File location:** `.planning/phases/XX-name/{phase}-{plan}-SUMMARY.md`
1327
+
1328
+ **Frontmatter population:**
1329
+
1330
+ Before writing summary content, populate frontmatter fields from execution context:
1331
+
1332
+ 1. **Basic identification:**
1333
+ - phase: From PLAN.md frontmatter
1334
+ - plan: From PLAN.md frontmatter
1335
+ - subsystem: Categorize based on phase focus (auth, payments, ui, api, database, infra, testing, etc.)
1336
+ - tags: Extract tech keywords (libraries, frameworks, tools used)
1337
+
1338
+ 2. **Dependency graph:**
1339
+ - requires: List prior phases this built upon (check PLAN.md context section for referenced prior summaries)
1340
+ - provides: Extract from accomplishments - what was delivered
1341
+ - affects: Infer from phase description/goal what future phases might need this
1342
+
1343
+ 3. **Tech tracking:**
1344
+ - tech-stack.added: New libraries from package.json changes or requirements
1345
+ - tech-stack.patterns: Architectural patterns established (from decisions/accomplishments)
1346
+
1347
+ 4. **File tracking:**
1348
+ - key-files.created: From "Files Created/Modified" section
1349
+ - key-files.modified: From "Files Created/Modified" section
1350
+
1351
+ 5. **Decisions:**
1352
+ - key-decisions: Extract from "Decisions Made" section
1353
+
1354
+ 6. **Metrics:**
1355
+ - duration: From $DURATION variable
1356
+ - completed: From $PLAN_END_TIME (date only, format YYYY-MM-DD)
1357
+
1358
+ Note: If subsystem/affects are unclear, use best judgment based on phase name and accomplishments. Can be refined later.
1359
+
1360
+ **Title format:** `# Phase [X] Plan [Y]: [Name] Summary`
1361
+
1362
+ The one-liner must be SUBSTANTIVE:
1363
+
1364
+ - Good: "JWT auth with refresh rotation using jose library"
1365
+ - Bad: "Authentication implemented"
1366
+
1367
+ **Include performance data:**
1368
+
1369
+ - Duration: `$DURATION`
1370
+ - Started: `$PLAN_START_TIME`
1371
+ - Completed: `$PLAN_END_TIME`
1372
+ - Tasks completed: (count from execution)
1373
+ - Files modified: (count from execution)
1374
+
1375
+ **Next Step section:**
1376
+
1377
+ - If more plans exist in this phase: "Ready for {phase}-{next-plan}-PLAN.md"
1378
+ - If this is the last plan: "Phase complete, ready for transition"
1379
+ </step>
1380
+
1381
+ <step name="update_current_position">
1382
+ Update Current Position section in STATE.md to reflect plan completion.
1383
+
1384
+ **Format:**
1385
+
1386
+ ```markdown
1387
+ Phase: [current] of [total] ([phase name])
1388
+ Plan: [just completed] of [total in phase]
1389
+ Status: [In progress / Phase complete]
1390
+ Last activity: [today] - Completed {phase}-{plan}-PLAN.md
1391
+
1392
+ Progress: [progress bar]
1393
+ ```
1394
+
1395
+ **Calculate progress bar:**
1396
+
1397
+ - Count total plans across all phases (from ROADMAP.md or ROADMAP.md)
1398
+ - Count completed plans (count SUMMARY.md files that exist)
1399
+ - Progress = (completed / total) × 100%
1400
+ - Render: ░ for incomplete, █ for complete
1401
+
1402
+ **Example - completing 02-01-PLAN.md (plan 5 of 10 total):**
1403
+
1404
+ Before:
1405
+
1406
+ ```markdown
1407
+ ## Current Position
1408
+
1409
+ Phase: 2 of 4 (Authentication)
1410
+ Plan: Not started
1411
+ Status: Ready to execute
1412
+ Last activity: 2025-01-18 - Phase 1 complete
1413
+
1414
+ Progress: ██████░░░░ 40%
1415
+ ```
1416
+
1417
+ After:
1418
+
1419
+ ```markdown
1420
+ ## Current Position
1421
+
1422
+ Phase: 2 of 4 (Authentication)
1423
+ Plan: 1 of 2 in current phase
1424
+ Status: In progress
1425
+ Last activity: 2025-01-19 - Completed 02-01-PLAN.md
1426
+
1427
+ Progress: ███████░░░ 50%
1428
+ ```
1429
+
1430
+ **Step complete when:**
1431
+
1432
+ - [ ] Phase number shows current phase (X of total)
1433
+ - [ ] Plan number shows plans complete in current phase (N of total-in-phase)
1434
+ - [ ] Status reflects current state (In progress / Phase complete)
1435
+ - [ ] Last activity shows today's date and the plan just completed
1436
+ - [ ] Progress bar calculated correctly from total completed plans
1437
+ </step>
1438
+
1439
+ <step name="extract_decisions_and_issues">
1440
+ Extract decisions, issues, and concerns from SUMMARY.md into STATE.md accumulated context.
1441
+
1442
+ **Decisions Made:**
1443
+
1444
+ - Read SUMMARY.md "## Decisions Made" section
1445
+ - If content exists (not "None"):
1446
+ - Add each decision to STATE.md Decisions table
1447
+ - Format: `| [phase number] | [decision summary] | [rationale] |`
1448
+
1449
+ **Blockers/Concerns:**
1450
+
1451
+ - Read SUMMARY.md "## Next Phase Readiness" section
1452
+ - If contains blockers or concerns:
1453
+ - Add to STATE.md "Blockers/Concerns Carried Forward"
1454
+ </step>
1455
+
1456
+ <step name="update_session_continuity">
1457
+ Update Session Continuity section in STATE.md to enable resumption in future sessions.
1458
+
1459
+ **Format:**
1460
+
1461
+ ```markdown
1462
+ Last session: [current date and time]
1463
+ Stopped at: Completed {phase}-{plan}-PLAN.md
1464
+ Resume file: [path to .continue-here if exists, else "None"]
1465
+ ```
1466
+
1467
+ **Size constraint note:** Keep STATE.md under 150 lines total.
1468
+ </step>
1469
+
1470
+ <step name="issues_review_gate">
1471
+ Before proceeding, check SUMMARY.md content.
1472
+
1473
+ If "Issues Encountered" is NOT "None":
1474
+
1475
+ <if mode="yolo">
1476
+ ```
1477
+ ⚡ Auto-approved: Issues acknowledgment
1478
+ ⚠️ Note: Issues were encountered during execution:
1479
+ - [Issue 1]
1480
+ - [Issue 2]
1481
+ (Logged - continuing in yolo mode)
1482
+ ```
1483
+
1484
+ Continue without waiting.
1485
+ </if>
1486
+
1487
+ <if mode="interactive" OR="custom with gates.issues_review true">
1488
+ Present issues and wait for acknowledgment before proceeding.
1489
+ </if>
1490
+ </step>
1491
+
1492
+ <step name="update_roadmap">
1493
+ Update the roadmap file:
1494
+
1495
+ ```bash
1496
+ ROADMAP_FILE=".planning/ROADMAP.md"
1497
+ ```
1498
+
1499
+ **If more plans remain in this phase:**
1500
+
1501
+ - Update plan count: "2/3 plans complete"
1502
+ - Keep phase status as "In progress"
1503
+
1504
+ **If this was the last plan in the phase:**
1505
+
1506
+ - Mark phase complete: status → "Complete"
1507
+ - Add completion date
1508
+ </step>
1509
+
1510
+ <step name="git_commit_metadata">
1511
+ Commit execution metadata (SUMMARY + STATE + ROADMAP):
1512
+
1513
+ **Note:** All task code has already been committed during execution (one commit per task).
1514
+ PLAN.md was already committed during plan-phase. This final commit captures execution results only.
1515
+
1516
+ **Check planning config:**
1517
+
1518
+ If `COMMIT_PLANNING_DOCS=false` (set in load_project_state):
1519
+ - Skip all git operations for .planning/ files
1520
+ - Planning docs exist locally but are gitignored
1521
+ - Log: "Skipping planning docs commit (commit_docs: false)"
1522
+ - Proceed to next step
1523
+
1524
+ If `COMMIT_PLANNING_DOCS=true` (default):
1525
+ - Continue with git operations below
1526
+
1527
+ **1. Stage execution artifacts:**
1528
+
1529
+ ```bash
1530
+ git add .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
1531
+ git add .planning/STATE.md
1532
+ ```
1533
+
1534
+ **2. Stage roadmap:**
1535
+
1536
+ ```bash
1537
+ git add .planning/ROADMAP.md
1538
+ ```
1539
+
1540
+ **3. Verify staging:**
1541
+
1542
+ ```bash
1543
+ git status
1544
+ # Should show only execution artifacts (SUMMARY, STATE, ROADMAP), no code files
1545
+ ```
1546
+
1547
+ **4. Commit metadata:**
1548
+
1549
+ ```bash
1550
+ git commit -m "$(cat <<'EOF'
1551
+ docs({phase}-{plan}): complete [plan-name] plan
1552
+
1553
+ Tasks completed: [N]/[N]
1554
+ - [Task 1 name]
1555
+ - [Task 2 name]
1556
+ - [Task 3 name]
1557
+
1558
+ SUMMARY: .planning/phases/XX-name/{phase}-{plan}-SUMMARY.md
1559
+ EOF
1560
+ )"
1561
+ ```
1562
+
1563
+ **Example:**
1564
+
1565
+ ```bash
1566
+ git commit -m "$(cat <<'EOF'
1567
+ docs(08-02): complete user registration plan
1568
+
1569
+ Tasks completed: 3/3
1570
+ - User registration endpoint
1571
+ - Password hashing with bcrypt
1572
+ - Email confirmation flow
1573
+
1574
+ SUMMARY: .planning/phases/08-user-auth/08-02-registration-SUMMARY.md
1575
+ EOF
1576
+ )"
1577
+ ```
1578
+
1579
+ **Git log after plan execution:**
1580
+
1581
+ ```
1582
+ abc123f docs(08-02): complete user registration plan
1583
+ def456g feat(08-02): add email confirmation flow
1584
+ hij789k feat(08-02): implement password hashing with bcrypt
1585
+ lmn012o feat(08-02): create user registration endpoint
1586
+ ```
1587
+
1588
+ Each task has its own commit, followed by one metadata commit documenting plan completion.
1589
+
1590
+ See `git-integration.md` (loaded via required_reading) for commit message conventions.
1591
+ </step>
1592
+
1593
+ <step name="update_codebase_map">
1594
+ **If .planning/codebase/ exists:**
1595
+
1596
+ Check what changed across all task commits in this plan:
1597
+
1598
+ ```bash
1599
+ # Find first task commit (right after previous plan's docs commit)
1600
+ FIRST_TASK=$(git log --oneline --grep="feat({phase}-{plan}):" --grep="fix({phase}-{plan}):" --grep="test({phase}-{plan}):" --reverse | head -1 | cut -d' ' -f1)
1601
+
1602
+ # Get all changes from first task through now
1603
+ git diff --name-only ${FIRST_TASK}^..HEAD 2>/dev/null
1604
+ ```
1605
+
1606
+ **Update only if structural changes occurred:**
1607
+
1608
+ | Change Detected | Update Action |
1609
+ |-----------------|---------------|
1610
+ | New directory in src/ | STRUCTURE.md: Add to directory layout |
1611
+ | package.json deps changed | STACK.md: Add/remove from dependencies list |
1612
+ | New file pattern (e.g., first .test.ts) | CONVENTIONS.md: Note new pattern |
1613
+ | New external API client | INTEGRATIONS.md: Add service entry with file path |
1614
+ | Config file added/changed | STACK.md: Update configuration section |
1615
+ | File renamed/moved | Update paths in relevant docs |
1616
+
1617
+ **Skip update if only:**
1618
+ - Code changes within existing files
1619
+ - Bug fixes
1620
+ - Content changes (no structural impact)
1621
+
1622
+ **Update format:**
1623
+ Make single targeted edits - add a bullet point, update a path, or remove a stale entry. Don't rewrite sections.
1624
+
1625
+ ```bash
1626
+ git add .planning/codebase/*.md
1627
+ git commit --amend --no-edit # Include in metadata commit
1628
+ ```
1629
+
1630
+ **If .planning/codebase/ doesn't exist:**
1631
+ Skip this step.
1632
+ </step>
1633
+
1634
+ <step name="offer_next">
1635
+ **MANDATORY: Verify remaining work before presenting next steps.**
1636
+
1637
+ Do NOT skip this verification. Do NOT assume phase or milestone completion without checking.
1638
+
1639
+ **Step 0: Check for USER-SETUP.md**
1640
+
1641
+ If `USER_SETUP_CREATED=true` (from generate_user_setup step), always include this warning block at the TOP of completion output:
1642
+
1643
+ ```
1644
+ ⚠️ USER SETUP REQUIRED
1645
+
1646
+ This phase introduced external services requiring manual configuration:
1647
+
1648
+ 📋 .planning/phases/{phase-dir}/{phase}-USER-SETUP.md
1649
+
1650
+ Quick view:
1651
+ - [ ] {ENV_VAR_1}
1652
+ - [ ] {ENV_VAR_2}
1653
+ - [ ] {Dashboard config task}
1654
+
1655
+ Complete this setup for the integration to function.
1656
+ Run `cat .planning/phases/{phase-dir}/{phase}-USER-SETUP.md` for full details.
1657
+
1658
+ ---
1659
+ ```
1660
+
1661
+ This warning appears BEFORE "Plan complete" messaging. User sees setup requirements prominently.
1662
+
1663
+ **Step 1: Count plans and summaries in current phase**
1664
+
1665
+ List files in the phase directory:
1666
+
1667
+ ```bash
1668
+ ls -1 .planning/phases/[current-phase-dir]/*-PLAN.md 2>/dev/null | wc -l
1669
+ ls -1 .planning/phases/[current-phase-dir]/*-SUMMARY.md 2>/dev/null | wc -l
1670
+ ```
1671
+
1672
+ State the counts: "This phase has [X] plans and [Y] summaries."
1673
+
1674
+ **Step 2: Route based on plan completion**
1675
+
1676
+ Compare the counts from Step 1:
1677
+
1678
+ | Condition | Meaning | Action |
1679
+ |-----------|---------|--------|
1680
+ | summaries < plans | More plans remain | Go to **Route A** |
1681
+ | summaries = plans | Phase complete | Go to Step 3 |
1682
+
1683
+ ---
1684
+
1685
+ **Route A: More plans remain in this phase**
1686
+
1687
+ Identify the next unexecuted plan:
1688
+ - Find the first PLAN.md file that has no matching SUMMARY.md
1689
+ - Read its `<objective>` section
1690
+
1691
+ <if mode="yolo">
1692
+ ```
1693
+ Plan {phase}-{plan} complete.
1694
+ Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1695
+
1696
+ {Y} of {X} plans complete for Phase {Z}.
1697
+
1698
+ ⚡ Auto-continuing: Execute next plan ({phase}-{next-plan})
1699
+ ```
1700
+
1701
+ Loop back to identify_plan step automatically.
1702
+ </if>
1703
+
1704
+ <if mode="interactive" OR="custom with gates.execute_next_plan true">
1705
+ ```
1706
+ Plan {phase}-{plan} complete.
1707
+ Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1708
+
1709
+ {Y} of {X} plans complete for Phase {Z}.
1710
+
1711
+ ---
1712
+
1713
+ ## ▶ Next Up
1714
+
1715
+ **{phase}-{next-plan}: [Plan Name]** — [objective from next PLAN.md]
1716
+
1717
+ `/grd:execute-phase {phase}`
1718
+
1719
+ <sub>`/clear` first → fresh context window</sub>
1720
+
1721
+ ---
1722
+
1723
+ **Also available:**
1724
+ - `/grd:verify-work {phase}-{plan}` — manual acceptance testing before continuing
1725
+ - Review what was built before continuing
1726
+
1727
+ ---
1728
+ ```
1729
+
1730
+ Wait for user to clear and run next command.
1731
+ </if>
1732
+
1733
+ **STOP here if Route A applies. Do not continue to Step 3.**
1734
+
1735
+ ---
1736
+
1737
+ **Step 3: Check milestone status (only when all plans in phase are complete)**
1738
+
1739
+ Read ROADMAP.md and extract:
1740
+ 1. Current phase number (from the plan just completed)
1741
+ 2. All phase numbers listed in the current milestone section
1742
+
1743
+ To find phases in the current milestone, look for:
1744
+ - Phase headers: lines starting with `### Phase` or `#### Phase`
1745
+ - Phase list items: lines like `- [ ] **Phase X:` or `- [x] **Phase X:`
1746
+
1747
+ Count total phases in the current milestone and identify the highest phase number.
1748
+
1749
+ State: "Current phase is {X}. Milestone has {N} phases (highest: {Y})."
1750
+
1751
+ **Step 4: Route based on milestone status**
1752
+
1753
+ | Condition | Meaning | Action |
1754
+ |-----------|---------|--------|
1755
+ | current phase < highest phase | More phases remain | Go to **Route B** |
1756
+ | current phase = highest phase | Milestone complete | Go to **Route C** |
1757
+
1758
+ ---
1759
+
1760
+ **Route B: Phase complete, more phases remain in milestone**
1761
+
1762
+ Read ROADMAP.md to get the next phase's name and goal.
1763
+
1764
+ ```
1765
+ Plan {phase}-{plan} complete.
1766
+ Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1767
+
1768
+ ## ✓ Phase {Z}: {Phase Name} Complete
1769
+
1770
+ All {Y} plans finished.
1771
+
1772
+ ---
1773
+
1774
+ ## ▶ Next Up
1775
+
1776
+ **Phase {Z+1}: {Next Phase Name}** — {Goal from ROADMAP.md}
1777
+
1778
+ `/grd:plan-phase {Z+1}`
1779
+
1780
+ <sub>`/clear` first → fresh context window</sub>
1781
+
1782
+ ---
1783
+
1784
+ **Also available:**
1785
+ - `/grd:verify-work {Z}` — manual acceptance testing before continuing
1786
+ - `/grd:discuss-phase {Z+1}` — gather context first
1787
+ - Review phase accomplishments before continuing
1788
+
1789
+ ---
1790
+ ```
1791
+
1792
+ ---
1793
+
1794
+ **Route C: Milestone complete (all phases done)**
1795
+
1796
+ ```
1797
+ 🎉 MILESTONE COMPLETE!
1798
+
1799
+ Plan {phase}-{plan} complete.
1800
+ Summary: .planning/phases/{phase-dir}/{phase}-{plan}-SUMMARY.md
1801
+
1802
+ ## ✓ Phase {Z}: {Phase Name} Complete
1803
+
1804
+ All {Y} plans finished.
1805
+
1806
+ ╔═══════════════════════════════════════════════════════╗
1807
+ ║ All {N} phases complete! Milestone is 100% done. ║
1808
+ ╚═══════════════════════════════════════════════════════╝
1809
+
1810
+ ---
1811
+
1812
+ ## ▶ Next Up
1813
+
1814
+ **Complete Milestone** — archive and prepare for next
1815
+
1816
+ `/grd:complete-milestone`
1817
+
1818
+ <sub>`/clear` first → fresh context window</sub>
1819
+
1820
+ ---
1821
+
1822
+ **Also available:**
1823
+ - `/grd:verify-work` — manual acceptance testing before completing milestone
1824
+ - `/grd:add-phase <description>` — add another phase before completing
1825
+ - Review accomplishments before archiving
1826
+
1827
+ ---
1828
+ ```
1829
+
1830
+ </step>
1831
+
1832
+ </process>
1833
+
1834
+ <success_criteria>
1835
+
1836
+ - All tasks from PLAN.md completed
1837
+ - All verifications pass
1838
+ - USER-SETUP.md generated if user_setup in frontmatter
1839
+ - SUMMARY.md created with substantive content
1840
+ - STATE.md updated (position, decisions, issues, session)
1841
+ - ROADMAP.md updated
1842
+ - If codebase map exists: map updated with execution changes (or skipped if no significant changes)
1843
+ - If USER-SETUP.md created: prominently surfaced in completion output
1844
+ </success_criteria>