@undeemed/get-shit-done-codex 1.6.12 → 1.20.3

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