renn-studio 0.6.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 (112) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +36 -0
  3. package/agents/renn-architect.md +1463 -0
  4. package/agents/renn-auditor.md +1053 -0
  5. package/agents/renn-codebase-mapper.md +908 -0
  6. package/agents/renn-design-reviewer.md +422 -0
  7. package/agents/renn-designer.md +814 -0
  8. package/agents/renn-detective.md +1204 -0
  9. package/agents/renn-integration-checker.md +957 -0
  10. package/agents/renn-navigator.md +659 -0
  11. package/agents/renn-plan-reviewer.md +812 -0
  12. package/agents/renn-project-scout.md +880 -0
  13. package/agents/renn-runner.md +842 -0
  14. package/agents/renn-stage-scout.md +705 -0
  15. package/agents/renn-synthesizer.md +256 -0
  16. package/bin/install.js +1466 -0
  17. package/commands/renn.add-stage.md +211 -0
  18. package/commands/renn.add-todo.md +194 -0
  19. package/commands/renn.audit-milestone.md +280 -0
  20. package/commands/renn.audit.md +219 -0
  21. package/commands/renn.check-todos.md +229 -0
  22. package/commands/renn.complete-milestone.md +136 -0
  23. package/commands/renn.continue.md +46 -0
  24. package/commands/renn.dash.md +308 -0
  25. package/commands/renn.debug.md +169 -0
  26. package/commands/renn.design-screens.md +107 -0
  27. package/commands/renn.design-system.md +100 -0
  28. package/commands/renn.discuss-stage.md +86 -0
  29. package/commands/renn.help.md +550 -0
  30. package/commands/renn.insert-stage.md +231 -0
  31. package/commands/renn.list-stage-assumptions.md +49 -0
  32. package/commands/renn.map-codebase.md +72 -0
  33. package/commands/renn.new-milestone.md +80 -0
  34. package/commands/renn.pause.md +132 -0
  35. package/commands/renn.plan-milestone-gaps.md +314 -0
  36. package/commands/renn.plan-stage.md +118 -0
  37. package/commands/renn.remove-stage.md +353 -0
  38. package/commands/renn.research-stage.md +200 -0
  39. package/commands/renn.restyle.md +98 -0
  40. package/commands/renn.run-stage.md +343 -0
  41. package/commands/renn.set-profile.md +116 -0
  42. package/commands/renn.settings.md +151 -0
  43. package/commands/renn.ship.md +52 -0
  44. package/commands/renn.start.md +95 -0
  45. package/commands/renn.status.md +530 -0
  46. package/commands/renn.watch.md +51 -0
  47. package/hooks/dist/renn-check-update.js +67 -0
  48. package/hooks/dist/renn-statusline.js +96 -0
  49. package/package.json +89 -0
  50. package/renn/references/continuation-format.md +249 -0
  51. package/renn/references/design-artifacts.md +674 -0
  52. package/renn/references/design-tokens.md +162 -0
  53. package/renn/references/gates.md +1078 -0
  54. package/renn/references/git-integration.md +254 -0
  55. package/renn/references/horsepower-profiles.md +84 -0
  56. package/renn/references/planning-config.md +189 -0
  57. package/renn/references/questioning.md +141 -0
  58. package/renn/references/security-checklist.md +2184 -0
  59. package/renn/references/tdd.md +263 -0
  60. package/renn/references/ui-brand.md +189 -0
  61. package/renn/references/verification-patterns.md +612 -0
  62. package/renn/templates/DEBUG.md +159 -0
  63. package/renn/templates/INTEL.md +283 -0
  64. package/renn/templates/RECAP.md +246 -0
  65. package/renn/templates/UAT.md +247 -0
  66. package/renn/templates/architect-prompt.md +119 -0
  67. package/renn/templates/brief.md +190 -0
  68. package/renn/templates/codebase/architecture.md +264 -0
  69. package/renn/templates/codebase/concerns.md +310 -0
  70. package/renn/templates/codebase/conventions.md +307 -0
  71. package/renn/templates/codebase/design.md +336 -0
  72. package/renn/templates/codebase/integrations.md +280 -0
  73. package/renn/templates/codebase/stack.md +186 -0
  74. package/renn/templates/codebase/structure.md +295 -0
  75. package/renn/templates/codebase/testing.md +480 -0
  76. package/renn/templates/config.json +36 -0
  77. package/renn/templates/continue-here.md +80 -0
  78. package/renn/templates/detective-prompt.md +93 -0
  79. package/renn/templates/milestone-archive.md +123 -0
  80. package/renn/templates/milestone.md +117 -0
  81. package/renn/templates/proof.md +326 -0
  82. package/renn/templates/pulse.md +176 -0
  83. package/renn/templates/research/architecture.md +206 -0
  84. package/renn/templates/research/features.md +149 -0
  85. package/renn/templates/research/pitfalls.md +202 -0
  86. package/renn/templates/research/recap.md +187 -0
  87. package/renn/templates/research/stack.md +122 -0
  88. package/renn/templates/research/ux.md +283 -0
  89. package/renn/templates/research-lite.md +146 -0
  90. package/renn/templates/research.md +582 -0
  91. package/renn/templates/specs.md +233 -0
  92. package/renn/templates/stage-prompt.md +571 -0
  93. package/renn/templates/track.md +211 -0
  94. package/renn/templates/user-setup.md +315 -0
  95. package/renn/workflows/audit-stage.md +717 -0
  96. package/renn/workflows/audit-work.md +596 -0
  97. package/renn/workflows/complete-milestone.md +875 -0
  98. package/renn/workflows/continue-project.md +306 -0
  99. package/renn/workflows/design-stage.md +2019 -0
  100. package/renn/workflows/diagnose-issues.md +231 -0
  101. package/renn/workflows/initialize-project.md +1039 -0
  102. package/renn/workflows/list-assumptions.md +178 -0
  103. package/renn/workflows/map-codebase.md +374 -0
  104. package/renn/workflows/new-milestone.md +718 -0
  105. package/renn/workflows/plan-stage.md +810 -0
  106. package/renn/workflows/research-stage.md +289 -0
  107. package/renn/workflows/run-plan.md +1844 -0
  108. package/renn/workflows/run-stage.md +692 -0
  109. package/renn/workflows/scope-stage.md +546 -0
  110. package/renn/workflows/ship-project.md +859 -0
  111. package/renn/workflows/transition.md +556 -0
  112. package/renn/workflows/watch-project.md +797 -0
@@ -0,0 +1,1844 @@
1
+ <purpose>
2
+ Execute a stage prompt (run.md) and create the outcome summary (recap.md).
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ Read pulse.md before any operation to load project context.
7
+ Read config.json for planning behavior settings.
8
+
9
+ @~/.claude/renn/references/git-integration.md
10
+ </required_reading>
11
+
12
+ <process>
13
+
14
+ <step name="resolve_horsepower" priority="first">
15
+ Read horsepower profile for agent spawning:
16
+
17
+ ```bash
18
+ HORSEPOWER=$(cat .renn/config.json 2>/dev/null | grep -o '"horsepower"[[: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 | max | balanced | eco |
26
+ |-------|---------|----------|--------|
27
+ | renn-runner | 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 .renn/pulse.md 2>/dev/null
37
+ ```
38
+
39
+ **If file exists:** Parse and internalize:
40
+
41
+ - Current position (stage, run, 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 .renn/ exists:**
47
+
48
+ ```
49
+ pulse.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 .renn/ 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 .renn/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 .renn 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_run">
72
+ Find the next run to execute:
73
+ - Check track for "In progress" stage
74
+ - Find runs in that stage directory
75
+ - Identify first run without corresponding RECAP
76
+
77
+ ```bash
78
+ cat .renn/track.md
79
+ # Look for stage with "In progress" status
80
+ # Then find runs in that stage
81
+ ls .renn/stages/XX-name/*-run.md 2>/dev/null | sort
82
+ ls .renn/stages/XX-name/*-recap.md 2>/dev/null | sort
83
+ ```
84
+
85
+ **Logic:**
86
+
87
+ - If `01.01-run.md` exists but `01.01-recap.md` doesn't → execute 01.01
88
+ - If `01.01-recap.md` exists but `01.02-recap.md` doesn't → execute 01.02
89
+ - Pattern: Find first RUN file without matching RECAP file
90
+
91
+ **Decimal stage handling:**
92
+
93
+ Stage directories can be integer or decimal format:
94
+
95
+ - Integer: `.renn/stages/01-foundation/01.01-run.md`
96
+ - Decimal: `.renn/stages/01.1-hotfix/01.1.01-run.md`
97
+
98
+ Parse stage number from path (handles both formats):
99
+
100
+ ```bash
101
+ # Extract stage number (handles XX or XX.Y format)
102
+ STAGE=$(echo "$RUN_PATH" | grep -oE '[0-9]+(\.[0-9]+)?-[0-9]+')
103
+ ```
104
+
105
+ RECAP naming follows same pattern:
106
+
107
+ - Integer: `01.01-recap.md`
108
+ - Decimal: `01.1.01-recap.md`
109
+
110
+ Confirm with user if ambiguous.
111
+
112
+ <config-check>
113
+ ```bash
114
+ cat .renn/config.json 2>/dev/null
115
+ ```
116
+ </config-check>
117
+
118
+ <if style="turbo">
119
+ ```
120
+ ⚡ Auto-approved: Execute {stage}.{run}-run.md
121
+ [Run X of Y for Stage Z]
122
+
123
+ Starting execution...
124
+ ```
125
+
126
+ Proceed directly to parse_segments step.
127
+ </if>
128
+
129
+ <if style="guided" OR="custom with gates.execute_next_run true">
130
+ Present:
131
+
132
+ ```
133
+ Found run to execute: {stage}.{run}-run.md
134
+ [Run X of Y for Stage 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
+ RUN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
148
+ RUN_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 run into execution segments.**
156
+
157
+ Runs are divided into segments by gates. Each segment is routed to optimal execution context (subagent or main).
158
+
159
+ **1. Check for gates:**
160
+
161
+ ```bash
162
+ # Find all gates and their types
163
+ grep -n "type=\"checkpoint" .renn/stages/XX-name/{stage}.{run}-run.md
164
+ ```
165
+
166
+ **2. Analyze execution strategy:**
167
+
168
+ **If NO gates found:**
169
+
170
+ - **Fully autonomous run** - spawn single subagent for entire run
171
+ - Subagent gets fresh 200k context, executes all tasks, creates RECAP, commits
172
+ - Main context: Just orchestration (~5% usage)
173
+
174
+ **If gates found, parse into segments:**
175
+
176
+ Segment = tasks between gates (or start→first gate, or last gate→end)
177
+
178
+ **For each segment, determine routing:**
179
+
180
+ ```
181
+ Segment routing rules:
182
+
183
+ IF segment has no prior gate:
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 gates)**
196
+
197
+ ```
198
+ Spawn subagent → execute all tasks → RECAP → commit → report back
199
+ ```
200
+
201
+ **Pattern B: Segmented with verify-only gates**
202
+
203
+ ```
204
+ Segment 1 (tasks 1-3): Spawn subagent → execute → report back
205
+ Gate 4 (human-verify): Main context → you verify → continue
206
+ Segment 2 (tasks 5-6): Spawn NEW subagent → execute → report back
207
+ Gate 7 (human-verify): Main context → you verify → continue
208
+ Aggregate results → RECAP → commit
209
+ ```
210
+
211
+ **Pattern C: Decision-dependent (must stay in main)**
212
+
213
+ ```
214
+ Gate 1 (decision): Main context → you decide → continue in main
215
+ Tasks 2-5: Main context (need decision from gate 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 runs:**
224
+
225
+ ```
226
+ 1. Run init_agent_tracking step first (see step below)
227
+
228
+ 2. Use Task tool with subagent_type="renn-runner" and model="{runner_model}":
229
+
230
+ Prompt: "Execute run at .renn/stages/{stage}.{run}-run.md
231
+
232
+ This is an autonomous run (no gates). Execute all tasks, create recap.md in stage directory, commit with message following run's commit guidance.
233
+
234
+ Follow all drift rules and authentication gate protocols from the run.
235
+
236
+ When complete, report: run name, tasks completed, RECAP 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]" > .renn/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 run {stage}.{run} (autonomous)",
247
+ "stage": "{stage}",
248
+ "run": "{run}",
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 .renn/current-agent-id.txt
266
+
267
+ 6. Report completion to user
268
+ ```
269
+
270
+ **For segmented runs (has verify-only gates):**
271
+
272
+ ```
273
+ Execute segment-by-segment:
274
+
275
+ For each autonomous segment:
276
+ Spawn subagent with prompt: "Execute tasks [X-Y] from run at .renn/stages/{stage}.{run}-run.md. Read the run for full context and drift rules. Do NOT create RECAP or commit - just execute these tasks and report results."
277
+
278
+ Wait for subagent completion
279
+
280
+ For each gate:
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 recap.md
288
+ Commit with all changes
289
+ ```
290
+
291
+ **For decision-dependent runs:**
292
+
293
+ ```
294
+ Execute in main context (standard flow below)
295
+ No subagent routing
296
+ Quality maintained through small scope (2-3 tasks per run)
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 .renn/agent-history.json ]; then
312
+ echo '{"version":"1.0","max_entries":50,"entries":[]}' > .renn/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 .renn/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 .renn/current-agent-id.txt ]; then
325
+ INTERRUPTED_ID=$(cat .renn/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 runs.**
352
+
353
+ **This step applies ONLY to segmented runs (Pattern B: has gates, 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 run to identify segments:
361
+ - Read run file
362
+ - Find gate locations: grep -n "type=\"checkpoint" run.md
363
+ - Identify gate types: grep "type=\"checkpoint" run.md | grep -o 'gate:[^"]*'
364
+ - Build segment map:
365
+ * Segment 1: Start → first gate (tasks 1-X)
366
+ * Gate 1: Type and location
367
+ * Segment 2: After gate 1 → next gate (tasks X+1 to Y)
368
+ * Gate 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 gate? → Subagent
375
+ - Prior gate was human-verify? → Subagent
376
+ - Prior gate was decision/human-action? → Main context
377
+
378
+ B. If routing = Subagent:
379
+ ```
380
+ Spawn Task tool with subagent_type="renn-runner" and model="{runner_model}":
381
+
382
+ Prompt: "Execute tasks [task numbers/names] from run at [run path].
383
+
384
+ **Context:**
385
+ - Read the full run for objective, context files, and drift rules
386
+ - You are executing a SEGMENT of this run (not the full run)
387
+ - Other segments will be executed separately
388
+
389
+ **Your responsibilities:**
390
+ - Execute only the tasks assigned to you
391
+ - Follow all drift rules and authentication gate protocols
392
+ - Track drifts for later Recap
393
+ - DO NOT create recap.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
+ - Drifts 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]" > .renn/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 run {stage}.{run}",
411
+ "stage": "{stage}",
412
+ "run": "{run}",
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, drifts, 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 .renn/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 gate/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 drifts from all segments
446
+ - Collect decisions from all gates
447
+ - Merge into complete picture
448
+
449
+ B. Create recap.md:
450
+ - Use aggregated results
451
+ - Document all work from all segments
452
+ - Include drifts from all segments
453
+ - Note which segments were subagented
454
+
455
+ C. Commit:
456
+ - Stage all files from all segments
457
+ - Stage recap.md
458
+ - Commit with message following run guidance
459
+ - Include note about segmented execution if relevant
460
+
461
+ D. Report completion
462
+
463
+ **Example execution trace:**
464
+
465
+ ````
466
+
467
+ Run: 01.02-run.md (8 tasks, 2 verify gates)
468
+
469
+ Parsing segments...
470
+
471
+ - Segment 1: Tasks 1-3 (autonomous)
472
+ - Gate 4: human-verify
473
+ - Segment 2: Tasks 5-6 (autonomous)
474
+ - Gate 7: human-verify
475
+ - Segment 3: Task 8 (autonomous)
476
+
477
+ Routing analysis:
478
+
479
+ - Segment 1: No prior gate → SUBAGENT ✓
480
+ - Gate 4: Verify only → MAIN (required)
481
+ - Segment 2: After verify → SUBAGENT ✓
482
+ - Gate 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 drifts
488
+ [2] Executing gate 4 (human-verify)...
489
+ ╔═══════════════════════════════════════════════════════╗
490
+ ║ GATE: 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 drift (added error handling)
507
+ [4] Executing gate 7 (human-verify)...
508
+ User: "approved"
509
+ [5] Spawning subagent for task 8...
510
+ → Subagent completes: 1 file modified, 0 drifts
511
+
512
+ Aggregating results...
513
+
514
+ - Total files: 6 modified
515
+ - Total drifts: 1
516
+ - Segmented execution: 3 subagents, 2 gates
517
+
518
+ Creating recap.md...
519
+ Committing...
520
+ ✓ Complete
521
+
522
+ ````
523
+
524
+ **Benefit:** Each subagent starts fresh (~20-30% context), enabling larger runs without quality degradation.
525
+ </step>
526
+
527
+ <step name="load_prompt">
528
+ Read the run prompt:
529
+ ```bash
530
+ cat .renn/stages/XX-name/{stage}.{run}-run.md
531
+ ````
532
+
533
+ This IS the execution instructions. Follow it exactly.
534
+
535
+ **If run references intel.md:**
536
+ The intel.md file provides the user's vision for this stage — 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_stage_check">
540
+ Before executing, check if previous stage had issues:
541
+
542
+ ```bash
543
+ # Find previous stage recap
544
+ ls .renn/stages/*/recap.md 2>/dev/null | sort -r | head -2 | tail -1
545
+ ```
546
+
547
+ If previous stage recap.md has "Issues Encountered" != "None" or "Next Stage Readiness" mentions blockers:
548
+
549
+ Use AskUserQuestion:
550
+
551
+ - header: "Previous Issues"
552
+ - question: "Previous stage had unresolved items: [summary]. How to proceed?"
553
+ - options:
554
+ - "Proceed anyway" - Issues won't block this stage
555
+ - "Address first" - Let's resolve before continuing
556
+ - "Review previous" - Show me the full recap
557
+ </step>
558
+
559
+ <step name="execute">
560
+ Execute each task in the prompt. **Drifts 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 run:** Apply drift 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 Recap documentation
580
+ - Continue to next task
581
+
582
+ **If `type="checkpoint:*"`:**
583
+
584
+ - STOP immediately (do not continue to next task)
585
+ - Execute gate_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 drifts in Recap (automatic - see drift_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 Recap
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 gate dynamically]
629
+
630
+ ╔═══════════════════════════════════════════════════════╗
631
+ ║ GATE: 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 Recap documentation:**
666
+
667
+ Document authentication gates as normal flow, not drifts:
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 drifts
689
+ </authentication_gates>
690
+
691
+ <drift_rules>
692
+
693
+ ## Automatic Drift Handling
694
+
695
+ **While executing tasks, you WILL discover work not in the run.** This is normal.
696
+
697
+ Apply these rules automatically. Track all drifts for Recap 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 Recap
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 drifts 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 Recap
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 drifts 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 Recap
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 drifts 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 Recap 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 Recap
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
+ </drift_rules>
851
+
852
+ <drift_documentation>
853
+
854
+ ## Documenting Drifts in Recap
855
+
856
+ After all tasks complete, Recap MUST include drifts section.
857
+
858
+ **If no drifts:**
859
+
860
+ ```markdown
861
+ ## Drifts from Run
862
+
863
+ None - run executed exactly as written.
864
+ ```
865
+
866
+ **If drifts occurred:**
867
+
868
+ ```markdown
869
+ ## Drifts from Run
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 drifts:** 4 auto-fixed (1 bug, 1 missing critical, 1 blocking, 1 architectural with approval)
894
+ **Impact on run:** All auto-fixes necessary for correctness/security/performance. No scope creep.
895
+ ```
896
+
897
+ **This provides complete transparency:**
898
+
899
+ - Every drift documented
900
+ - Why it was needed
901
+ - What rule applied
902
+ - What was done
903
+ - User can see exactly what happened beyond the run
904
+
905
+ </drift_documentation>
906
+
907
+ <tdd_run_execution>
908
+ ## TDD Run Execution
909
+
910
+ When executing a run with `type: tdd` in frontmatter, follow the RED-GREEN-REFACTOR cycle for the single feature defined in the run.
911
+
912
+ **1. Check test infrastructure (if first TDD run):**
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 stage, 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({stage}.{run}): 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({stage}.{run}): 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({stage}.{run}): clean up [feature]`
937
+
938
+ **Commit pattern for TDD runs:**
939
+ Each TDD run produces 2-3 atomic commits:
940
+ 1. `test({stage}.{run}): add failing test for X`
941
+ 2. `feat({stage}.{run}): implement X`
942
+ 3. `refactor({stage}.{run}): clean up X` (optional)
943
+
944
+ **Error handling:**
945
+ - If test doesn't fail in RED stage: Test is wrong or feature already exists. Investigate before proceeding.
946
+ - If test doesn't pass in GREEN stage: Debug implementation, keep iterating until green.
947
+ - If tests fail in REFACTOR stage: Undo refactor, commit was premature.
948
+
949
+ **Verification:**
950
+ After TDD run 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 runs:** 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 runs ensure full quality throughout the cycle.
956
+
957
+ **Comparison:**
958
+ - Standard runs: Multiple tasks, 1 commit per task, 2-4 commits total
959
+ - TDD runs: Single feature, 2-3 commits for RED/GREEN/REFACTOR cycle
960
+
961
+ See `~/.claude/renn/references/tdd.md` for TDD run structure.
962
+ </tdd_run_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 run):
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 stage) | test(08.02): add failing test for password hashing |
994
+ | `refactor` | Code cleanup, no behavior change (TDD REFACTOR stage) | 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}({stage}.{run}): {task-name-or-description}`
1003
+
1004
+ ```bash
1005
+ git commit -m "{type}({stage}.{run}): {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 run 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 runs have their own commit pattern (test/feat/refactor for RED/GREEN/REFACTOR stages). See `<tdd_run_execution>` section above.
1033
+
1034
+ **5. Record commit hash:**
1035
+
1036
+ After committing, capture hash for recap.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 RECAP generation:
1044
+ ```bash
1045
+ TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
1046
+ ```
1047
+
1048
+ </task_commit>
1049
+
1050
+ <step name="gate_protocol">
1051
+ When encountering `type="checkpoint:*"`:
1052
+
1053
+ **Critical: Claude automates everything with CLI/API before gates.** Gates are for verification and decisions, not manual work.
1054
+
1055
+ **Display gate clearly:**
1056
+
1057
+ ```
1058
+ ╔═══════════════════════════════════════════════════════╗
1059
+ ║ GATE: [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 gates):**
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 gates):**
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/renn/references/gates.md for complete gate guidance.
1130
+ </step>
1131
+
1132
+ <step name="gate_return_for_orchestrator">
1133
+ **When spawned by an orchestrator (run-stage or run-plan command):**
1134
+
1135
+ If you were spawned via Task tool and hit a gate, you cannot directly interact with the user. Instead, RETURN to the orchestrator with structured gate state so it can present to the user and spawn a fresh continuation agent.
1136
+
1137
+ **Return format for gates:**
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. **Gate 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
+ ## GATE REACHED ⏸
1150
+
1151
+ **Type:** human-action
1152
+ **Run:** 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
+ ### Gate 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 gate 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 gate return instructions. Follow those instructions when you hit a gate.
1202
+
1203
+ **If running in main context (not spawned):**
1204
+
1205
+ Use the standard gate_protocol - display gate 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 recap.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
+ RUN_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
1235
+ RUN_END_EPOCH=$(date +%s)
1236
+
1237
+ DURATION_SEC=$(( RUN_END_EPOCH - RUN_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 recap.md creation.
1250
+ </step>
1251
+
1252
+ <step name="generate_user_setup">
1253
+ **Generate USER-SETUP.md if run has user_setup in frontmatter.**
1254
+
1255
+ Check run.md frontmatter for `user_setup` field:
1256
+
1257
+ ```bash
1258
+ grep -A 50 "^user_setup:" .renn/stages/XX-name/{stage}.{run}-run.md | head -50
1259
+ ```
1260
+
1261
+ **If user_setup exists and is not empty:**
1262
+
1263
+ Create `.renn/stages/XX-name/{stage}-USER-SETUP.md` using template from `~/.claude/renn/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
+ # Stage 10: User Setup Required
1280
+
1281
+ **Generated:** 2025-01-14
1282
+ **Stage:** 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_recap">
1323
+ Create `{stage}.{run}-recap.md` as specified in the prompt's `<output>` section.
1324
+ Use ~/.claude/renn/templates/recap.md for structure.
1325
+
1326
+ **File location:** `.renn/stages/XX-name/{stage}.{run}-recap.md`
1327
+
1328
+ **Frontmatter population:**
1329
+
1330
+ Before writing recap content, populate frontmatter fields from execution context:
1331
+
1332
+ 1. **Basic identification:**
1333
+ - stage: From run.md frontmatter
1334
+ - run: From run.md frontmatter
1335
+ - subsystem: Categorize based on stage 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 stages this built upon (check run.md context section for referenced prior recaps)
1340
+ - provides: Extract from accomplishments - what was delivered
1341
+ - affects: Infer from stage description/goal what future stages 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 $RUN_END_TIME (date only, format YYYY-MM-DD)
1357
+
1358
+ Note: If subsystem/affects are unclear, use best judgment based on stage name and accomplishments. Can be refined later.
1359
+
1360
+ **Title format:** `# Stage [X] Run [Y]: [Name] Recap`
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: `$RUN_START_TIME`
1371
+ - Completed: `$RUN_END_TIME`
1372
+ - Tasks completed: (count from execution)
1373
+ - Files modified: (count from execution)
1374
+
1375
+ **Next Step section:**
1376
+
1377
+ - If more runs exist in this stage: "Ready for {stage}.{next-run}-run.md"
1378
+ - If this is the last run: "Stage complete, ready for transition"
1379
+ </step>
1380
+
1381
+ <step name="update_current_position">
1382
+ Update Current Position section in pulse.md to reflect run completion.
1383
+
1384
+ **Format:**
1385
+
1386
+ ```markdown
1387
+ Stage: [current] of [total] ([stage name])
1388
+ Run: [just completed] of [total in stage]
1389
+ Status: [In progress / Stage complete]
1390
+ Last activity: [today] - Completed {stage}.{run}-run.md
1391
+
1392
+ Progress: [progress bar]
1393
+ ```
1394
+
1395
+ **Calculate progress bar:**
1396
+
1397
+ - Count total runs across all stages (from track.md)
1398
+ - Count completed runs (count recap.md files that exist)
1399
+ - Progress = (completed / total) × 100%
1400
+ - Render: ░ for incomplete, █ for complete
1401
+
1402
+ **Example - completing 02.01-run.md (run 5 of 10 total):**
1403
+
1404
+ Before:
1405
+
1406
+ ```markdown
1407
+ ## Current Position
1408
+
1409
+ Stage: 2 of 4 (Authentication)
1410
+ Run: Not started
1411
+ Status: Ready to execute
1412
+ Last activity: 2025-01-18 - Stage 1 complete
1413
+
1414
+ Progress: ██████░░░░ 40%
1415
+ ```
1416
+
1417
+ After:
1418
+
1419
+ ```markdown
1420
+ ## Current Position
1421
+
1422
+ Stage: 2 of 4 (Authentication)
1423
+ Run: 1 of 2 in current stage
1424
+ Status: In progress
1425
+ Last activity: 2025-01-19 - Completed 02.01-run.md
1426
+
1427
+ Progress: ███████░░░ 50%
1428
+ ```
1429
+
1430
+ **Step complete when:**
1431
+
1432
+ - [ ] Stage number shows current stage (X of total)
1433
+ - [ ] Run number shows runs complete in current stage (N of total-in-stage)
1434
+ - [ ] Status reflects current state (In progress / Stage complete)
1435
+ - [ ] Last activity shows today's date and the run just completed
1436
+ - [ ] Progress bar calculated correctly from total completed runs
1437
+ </step>
1438
+
1439
+ <step name="extract_decisions_and_issues">
1440
+ Extract decisions, issues, and concerns from recap.md into pulse.md accumulated context.
1441
+
1442
+ **Decisions Made:**
1443
+
1444
+ - Read recap.md "## Decisions Made" section
1445
+ - If content exists (not "None"):
1446
+ - Add each decision to pulse.md Decisions table
1447
+ - Format: `| [stage number] | [decision summary] | [rationale] |`
1448
+
1449
+ **Blockers/Concerns:**
1450
+
1451
+ - Read recap.md "## Next Stage Readiness" section
1452
+ - If contains blockers or concerns:
1453
+ - Add to pulse.md "Blockers/Concerns Carried Forward"
1454
+ </step>
1455
+
1456
+ <step name="update_session_continuity">
1457
+ Update Session Continuity section in pulse.md to enable resumption in future sessions.
1458
+
1459
+ **Format:**
1460
+
1461
+ ```markdown
1462
+ Last session: [current date and time]
1463
+ Stopped at: Completed {stage}.{run}-run.md
1464
+ Resume file: [path to .continue-here if exists, else "None"]
1465
+ ```
1466
+
1467
+ **Size constraint note:** Keep pulse.md under 150 lines total.
1468
+ </step>
1469
+
1470
+ <step name="issues_review_gate">
1471
+ Before proceeding, check recap.md content.
1472
+
1473
+ If "Issues Encountered" is NOT "None":
1474
+
1475
+ <if style="turbo">
1476
+ ```
1477
+ ⚡ Auto-approved: Issues acknowledgment
1478
+ ⚠️ Note: Issues were encountered during execution:
1479
+ - [Issue 1]
1480
+ - [Issue 2]
1481
+ (Logged - continuing in turbo mode)
1482
+ ```
1483
+
1484
+ Continue without waiting.
1485
+ </if>
1486
+
1487
+ <if style="guided" 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_track">
1493
+ Update the track file:
1494
+
1495
+ ```bash
1496
+ TRACK_FILE=".renn/track.md"
1497
+ ```
1498
+
1499
+ **If more runs remain in this stage:**
1500
+
1501
+ - Update run count: "2/3 runs complete"
1502
+ - Keep stage status as "In progress"
1503
+
1504
+ **If this was the last run in the stage:**
1505
+
1506
+ - Mark stage complete: status → "Complete"
1507
+ - Add completion date
1508
+ </step>
1509
+
1510
+ <step name="git_commit_metadata">
1511
+ Commit execution metadata (RECAP + PULSE + TRACK):
1512
+
1513
+ **Note:** All task code has already been committed during execution (one commit per task).
1514
+ run.md was already committed during plan-stage. 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 .renn/ 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 .renn/stages/XX-name/{stage}.{run}-recap.md
1531
+ git add .renn/pulse.md
1532
+ ```
1533
+
1534
+ **2. Stage track:**
1535
+
1536
+ ```bash
1537
+ git add .renn/track.md
1538
+ ```
1539
+
1540
+ **3. Verify staging:**
1541
+
1542
+ ```bash
1543
+ git status
1544
+ # Should show only execution artifacts (RECAP, PULSE, TRACK), no code files
1545
+ ```
1546
+
1547
+ **4. Commit metadata:**
1548
+
1549
+ ```bash
1550
+ git commit -m "$(cat <<'EOF'
1551
+ docs({stage}.{run}): complete [run-name] run
1552
+
1553
+ Tasks completed: [N]/[N]
1554
+ - [Task 1 name]
1555
+ - [Task 2 name]
1556
+ - [Task 3 name]
1557
+
1558
+ RECAP: .renn/stages/XX-name/{stage}.{run}-recap.md
1559
+ EOF
1560
+ )"
1561
+ ```
1562
+
1563
+ **Example:**
1564
+
1565
+ ```bash
1566
+ git commit -m "$(cat <<'EOF'
1567
+ docs(08.02): complete user registration run
1568
+
1569
+ Tasks completed: 3/3
1570
+ - User registration endpoint
1571
+ - Password hashing with bcrypt
1572
+ - Email confirmation flow
1573
+
1574
+ RECAP: .renn/stages/08-user-auth/08.02-registration-recap.md
1575
+ EOF
1576
+ )"
1577
+ ```
1578
+
1579
+ **Git log after run execution:**
1580
+
1581
+ ```
1582
+ abc123f docs(08.02): complete user registration run
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 run 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 .renn/codebase/ exists:**
1595
+
1596
+ Check what changed across all task commits in this run:
1597
+
1598
+ ```bash
1599
+ # Find first task commit (right after previous run's docs commit)
1600
+ FIRST_TASK=$(git log --oneline --grep="feat({stage}.{run}):" --grep="fix({stage}.{run}):" --grep="test({stage}.{run}):" --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 .renn/codebase/*.md
1627
+ git commit --amend --no-edit # Include in metadata commit
1628
+ ```
1629
+
1630
+ **If .renn/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 stage 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 stage introduced external services requiring manual configuration:
1647
+
1648
+ 📋 .renn/stages/{stage-dir}/{stage}-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 .renn/stages/{stage-dir}/{stage}-USER-SETUP.md` for full details.
1657
+
1658
+ ---
1659
+ ```
1660
+
1661
+ This warning appears BEFORE "Run complete" messaging. User sees setup requirements prominently.
1662
+
1663
+ **Step 1: Count runs and recaps in current stage**
1664
+
1665
+ List files in the stage directory:
1666
+
1667
+ ```bash
1668
+ ls -1 .renn/stages/[current-stage-dir]/*-run.md 2>/dev/null | wc -l
1669
+ ls -1 .renn/stages/[current-stage-dir]/*-recap.md 2>/dev/null | wc -l
1670
+ ```
1671
+
1672
+ State the counts: "This stage has [X] runs and [Y] recaps."
1673
+
1674
+ **Step 2: Route based on run completion**
1675
+
1676
+ Compare the counts from Step 1:
1677
+
1678
+ | Condition | Meaning | Action |
1679
+ |-----------|---------|--------|
1680
+ | recaps < runs | More runs remain | Go to **Route A** |
1681
+ | recaps = runs | Stage complete | Go to Step 3 |
1682
+
1683
+ ---
1684
+
1685
+ **Route A: More runs remain in this stage**
1686
+
1687
+ Identify the next unexecuted run:
1688
+ - Find the first run.md file that has no matching recap.md
1689
+ - Read its `<objective>` section
1690
+
1691
+ <if style="turbo">
1692
+ ```
1693
+ Run {stage}.{run} complete.
1694
+ Recap: .renn/stages/{stage-dir}/{stage}.{run}-recap.md
1695
+
1696
+ {Y} of {X} runs complete for Stage {Z}.
1697
+
1698
+ ⚡ Auto-continuing: Execute next run ({stage}.{next-run})
1699
+ ```
1700
+
1701
+ Loop back to identify_run step automatically.
1702
+ </if>
1703
+
1704
+ <if style="guided" OR="custom with gates.execute_next_run true">
1705
+ ```
1706
+ Run {stage}.{run} complete.
1707
+ Recap: .renn/stages/{stage-dir}/{stage}.{run}-recap.md
1708
+
1709
+ {Y} of {X} runs complete for Stage {Z}.
1710
+
1711
+ ---
1712
+
1713
+ ## ▶ Next Up
1714
+
1715
+ **{stage}.{next-run}: [Run Name]** — [objective from next run.md]
1716
+
1717
+ `/renn.run-stage {stage}`
1718
+
1719
+ <sub>`/clear` first → fresh context window</sub>
1720
+
1721
+ ---
1722
+
1723
+ **Also available:**
1724
+ - `/renn.audit {stage}.{run}` — 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 runs in stage are complete)**
1738
+
1739
+ Read track.md and extract:
1740
+ 1. Current stage number (from the run just completed)
1741
+ 2. All stage numbers listed in the current milestone section
1742
+
1743
+ To find stages in the current milestone, look for:
1744
+ - Stage headers: lines starting with `### Stage` or `#### Stage`
1745
+ - Stage list items: lines like `- [ ] **Stage X:` or `- [x] **Stage X:`
1746
+
1747
+ Count total stages in the current milestone and identify the highest stage number.
1748
+
1749
+ State: "Current stage is {X}. Milestone has {N} stages (highest: {Y})."
1750
+
1751
+ **Step 4: Route based on milestone status**
1752
+
1753
+ | Condition | Meaning | Action |
1754
+ |-----------|---------|--------|
1755
+ | current stage < highest stage | More stages remain | Go to **Route B** |
1756
+ | current stage = highest stage | Milestone complete | Go to **Route C** |
1757
+
1758
+ ---
1759
+
1760
+ **Route B: Stage complete, more stages remain in milestone**
1761
+
1762
+ Read track.md to get the next stage's name and goal.
1763
+
1764
+ ```
1765
+ Run {stage}.{run} complete.
1766
+ Recap: .renn/stages/{stage-dir}/{stage}.{run}-recap.md
1767
+
1768
+ ## ✓ Stage {Z}: {Stage Name} Complete
1769
+
1770
+ All {Y} runs finished.
1771
+
1772
+ ---
1773
+
1774
+ ## ▶ Next Up
1775
+
1776
+ **Stage {Z+1}: {Next Stage Name}** — {Goal from track.md}
1777
+
1778
+ `/renn.plan-stage {Z+1}`
1779
+
1780
+ <sub>`/clear` first → fresh context window</sub>
1781
+
1782
+ ---
1783
+
1784
+ **Also available:**
1785
+ - `/renn.audit {Z}` — manual acceptance testing before continuing
1786
+ - `/renn.discuss-stage {Z+1}` — gather context first
1787
+ - Review stage accomplishments before continuing
1788
+
1789
+ ---
1790
+ ```
1791
+
1792
+ ---
1793
+
1794
+ **Route C: Milestone complete (all stages done)**
1795
+
1796
+ ```
1797
+ 🎉 MILESTONE COMPLETE!
1798
+
1799
+ Run {stage}.{run} complete.
1800
+ Recap: .renn/stages/{stage-dir}/{stage}.{run}-recap.md
1801
+
1802
+ ## ✓ Stage {Z}: {Stage Name} Complete
1803
+
1804
+ All {Y} runs finished.
1805
+
1806
+ ╔═══════════════════════════════════════════════════════╗
1807
+ ║ All {N} stages complete! Milestone is 100% done. ║
1808
+ ╚═══════════════════════════════════════════════════════╝
1809
+
1810
+ ---
1811
+
1812
+ ## ▶ Next Up
1813
+
1814
+ **Complete Milestone** — archive and prepare for next
1815
+
1816
+ `/renn.complete-milestone`
1817
+
1818
+ <sub>`/clear` first → fresh context window</sub>
1819
+
1820
+ ---
1821
+
1822
+ **Also available:**
1823
+ - `/renn.audit` — manual acceptance testing before completing milestone
1824
+ - `/renn.add-stage <description>` — add another stage 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 run.md completed
1837
+ - All verifications pass
1838
+ - USER-SETUP.md generated if user_setup in frontmatter
1839
+ - recap.md created with substantive content
1840
+ - pulse.md updated (position, decisions, issues, session)
1841
+ - track.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>