@sienklogic/plan-build-run 2.4.1 → 2.5.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.
@@ -3,11 +3,13 @@ name: quick
3
3
  description: "Execute an ad-hoc task with atomic commits. Skips full plan/review."
4
4
  ---
5
5
 
6
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
7
+
6
8
  # /pbr:quick — Quick Ad-Hoc Task Execution
7
9
 
8
10
  You are running the **quick** skill. Your job is to execute a small, self-contained task outside the normal plan/build/review cycle. Quick tasks get their own tracking, atomic commits, and state integration, but skip the overhead of full planning.
9
11
 
10
- This skill **spawns a single Task(subagent_type: "pbr:executor")** for execution.
12
+ This skill **spawns a single Task(agent_type: "pbr:executor")** for execution.
11
13
 
12
14
  ---
13
15
 
@@ -28,7 +30,7 @@ Then proceed to Step 1.
28
30
  Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
29
31
 
30
32
  Additionally for this skill:
31
- - **Never** implement the task yourself — you are a router, not a builder. ALL code changes go through a spawned `Task(subagent_type: "pbr:executor")`
33
+ - **Never** implement the task yourself — you are a router, not a builder. ALL code changes go through a spawned `Task(agent_type: "pbr:executor")`
32
34
  - **Never** skip creating `.planning/quick/{NNN}-{slug}/` and writing PLAN.md — even trivial tasks need tracking artifacts
33
35
  - **Minimize** reading executor output into main context — read only SUMMARY.md frontmatter
34
36
 
@@ -44,11 +46,13 @@ Additionally for this skill:
44
46
 
45
47
  1. Check if `.planning/` directory exists
46
48
  - If yes: read config.json for settings
47
- - If no: create `.planning/` directory first, then warn "No Plan-Build-Run project found. This will create a standalone quick task. Consider running `/pbr:begin` first for full project tracking."
49
+ - If no: create **both** `.planning/` and `.planning/quick/` directories, then warn "No Plan-Build-Run project found. This will create a standalone quick task. Consider running `/pbr:begin` first for full project tracking."
50
+
51
+ 2. If `.planning/` exists but `.planning/quick/` does not: create `.planning/quick/` now. **Every quick task gets tracked in `.planning/quick/` — this directory MUST exist before Step 4.**
48
52
 
49
- 2. **After** confirming `.planning/` directory exists (created in step 1 if needed), write `.planning/.active-skill` with the content `quick` (single word, no newline). This registers you with the workflow enforcement hook — it will block source code writes until PLAN.md exists.
53
+ 3. **After** confirming both directories exist, write `.planning/.active-skill` with the content `quick` (single word, no newline). This registers you with the workflow enforcement hook — it will block source code writes until PLAN.md exists.
50
54
 
51
- 3. Check if ROADMAP.md exists
55
+ 4. Check if ROADMAP.md exists
52
56
  - If yes: note the current phase context (quick tasks may relate to the active phase)
53
57
  - If no: proceed without phase context
54
58
 
@@ -87,6 +91,8 @@ If user types something else (freeform): interpret their response and proceed ac
87
91
 
88
92
  ### Step 4: Generate Slug and Task Number
89
93
 
94
+ **CRITICAL: You MUST complete Steps 4, 5, and 6 before any executor is spawned. If you skip these steps, the quick task will have no tracking artifacts and no PLAN.md for the executor to follow. This is the #1 failure mode of this skill.**
95
+
90
96
  **Generate slug:**
91
97
  - Take the first 4-5 meaningful words from the description
92
98
  - Lowercase, hyphen-separated
@@ -102,8 +108,12 @@ If user types something else (freeform): interpret their response and proceed ac
102
108
 
103
109
  ### Step 5: Create Quick Task Directory
104
110
 
111
+ **STOP — Use the Write or Bash tool RIGHT NOW to create this directory. Do not skip this step.**
112
+
105
113
  Create: `.planning/quick/{NNN}-{slug}/`
106
114
 
115
+ Verify the directory exists with `ls .planning/quick/{NNN}-{slug}/` before proceeding. If the directory doesn't exist, you have a bug — go back and create it.
116
+
107
117
  ### Step 6: Create Minimal PLAN.md
108
118
 
109
119
  Write `.planning/quick/{NNN}-{slug}/PLAN.md`:
@@ -143,7 +153,7 @@ If either check fails, you have skipped steps. Go back and complete Steps 4-6. D
143
153
 
144
154
  Display to the user: `◐ Spawning executor...`
145
155
 
146
- Spawn a `Task(subagent_type: "pbr:executor")` with the following prompt:
156
+ Spawn a `Task(agent_type: "pbr:executor")` with the following prompt:
147
157
 
148
158
  ```
149
159
  You are executor. Execute the following quick task plan.
@@ -207,6 +217,24 @@ If `planning.commit_docs: true` in config.json:
207
217
  - Stage STATE.md changes
208
218
  - Commit: `docs(planning): quick task {NNN} - {slug}`
209
219
 
220
+ ### Step 11b: Check Pending Todos
221
+
222
+ After completing work, check if any pending todos are now satisfied:
223
+
224
+ 1. Check if `.planning/todos/pending/` exists and contains files
225
+ 2. If no pending todos: skip to Step 12
226
+ 3. If pending todos exist:
227
+ a. Read the title and description from each pending todo's YAML frontmatter
228
+ b. Compare each todo against the work just completed (the task description, files changed, commits made)
229
+ c. If a todo is **clearly satisfied** by the work (the todo's goal matches what was built):
230
+ - Move it: read the file, update `status: done`, add `completed: {YYYY-MM-DD}`, write to `.planning/todos/done/{filename}`, delete from `pending/` via Bash `rm`
231
+ - Display: `✓ Auto-closed todo {NNN}: {title} (satisfied by quick task {NNN})`
232
+ d. If a todo is **partially related** but not fully satisfied: do NOT close it, but mention it:
233
+ - Display: `ℹ Related pending todo {NNN}: {title} — may be partially addressed`
234
+ e. If a todo is unrelated: skip silently
235
+
236
+ **Important:** Only auto-close todos where the match is unambiguous. When in doubt, leave it open — false closures are worse than missed closures.
237
+
210
238
  ### Step 12: Report Results
211
239
 
212
240
  **Artifact check** — Before reporting, verify all required artifacts exist:
@@ -338,7 +366,7 @@ Choose verification based on context:
338
366
 
339
367
  **These are the most common failure modes. If you violate any of these, the skill has not executed correctly.**
340
368
 
341
- 1. **DO NOT** implement the task yourself — you MUST spawn a `Task(subagent_type: "pbr:executor")`. This is the single most important rule.
369
+ 1. **DO NOT** implement the task yourself — you MUST spawn a `Task(agent_type: "pbr:executor")`. This is the single most important rule.
342
370
  2. **DO NOT** skip creating `.planning/quick/{NNN}-{slug}/` — every quick task gets a tracking directory
343
371
  3. **DO NOT** skip writing PLAN.md — the executor needs a plan file to follow
344
372
  4. **DO NOT** create elaborate multi-wave plans — quick tasks should be 1-3 tasks max
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pbr",
3
3
  "displayName": "Plan-Build-Run",
4
- "version": "2.4.1",
4
+ "version": "2.5.0",
5
5
  "description": "Plan-Build-Run — Structured development workflow for Cursor. Solves context rot through disciplined subagent delegation, structured planning, atomic execution, and goal-backward verification.",
6
6
  "author": {
7
7
  "name": "SienkLogic",
@@ -4,9 +4,11 @@ description: "Execute all plans in a phase. Spawns agents to build in parallel,
4
4
  argument-hint: "<phase-number> [--gaps-only] [--team]"
5
5
  ---
6
6
 
7
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
8
+
7
9
  # /pbr:build — Phase Execution
8
10
 
9
- You are the orchestrator for `/pbr:build`. This skill executes all plans in a phase by invoking executor agents. Plans are grouped by wave and executed in order — independent plans run in parallel, dependent plans wait. Your job is to stay lean, delegate ALL building work to agents, and keep the user's main context window clean.
11
+ You are the orchestrator for `/pbr:build`. This skill executes all plans in a phase by spawning executor agents. Plans are grouped by wave and executed in order — independent plans run in parallel, dependent plans wait. Your job is to stay lean, delegate ALL building work to Task() agents, and keep the user's main context window clean.
10
12
 
11
13
  ## Context Budget
12
14
 
@@ -69,7 +71,7 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
69
71
  - Prior phase dependencies are met (check for SUMMARY.md files in dependency phases)
70
72
  6. If no phase number given, read current phase from `.planning/STATE.md`
71
73
  - `config.models.complexity_map` — adaptive model mapping (default: `{ simple: "haiku", medium: "sonnet", complex: "inherit" }`)
72
- 7. If `gates.confirm_execute` is true: use the yes-no pattern from `skills/shared/gate-prompts.md`:
74
+ 7. If `gates.confirm_execute` is true: use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
73
75
  question: "Ready to build Phase {N}? This will execute {count} plans."
74
76
  header: "Build?"
75
77
  options:
@@ -84,7 +86,7 @@ After validating prerequisites, check plan staleness:
84
86
  1. Read each PLAN.md file's `dependency_fingerprints` field (if present)
85
87
  2. For each fingerprinted dependency, check the current SUMMARY.md file (length + modification time)
86
88
  3. If any fingerprint doesn't match: the dependency phase was re-built after this plan was created
87
- 4. Use the stale-continue pattern from `skills/shared/gate-prompts.md`:
89
+ 4. Use AskUserQuestion (pattern: stale-continue from `skills/shared/gate-prompts.md`):
88
90
  question: "Plan {plan_id} may be stale — dependency phase {M} was re-built after this plan was created."
89
91
  header: "Stale"
90
92
  options:
@@ -107,7 +109,9 @@ After validating prerequisites, check plan staleness:
107
109
 
108
110
  If no plans found:
109
111
  ```
110
- ERROR
112
+ ╔══════════════════════════════════════════════════════════════╗
113
+ ║ ERROR ║
114
+ ╚══════════════════════════════════════════════════════════════╝
111
115
 
112
116
  Phase {N} has no plans.
113
117
 
@@ -116,7 +120,9 @@ Phase {N} has no plans.
116
120
 
117
121
  If dependencies incomplete:
118
122
  ```
119
- ERROR
123
+ ╔══════════════════════════════════════════════════════════════╗
124
+ ║ ERROR ║
125
+ ╚══════════════════════════════════════════════════════════════╝
120
126
 
121
127
  Phase {N} depends on Phase {M}, which is not complete.
122
128
 
@@ -167,7 +173,7 @@ Check for existing SUMMARY.md files from previous runs (crash recovery):
167
173
  3. Build the skip list of plans to exclude
168
174
 
169
175
  **If all plans already have completed SUMMARYs:**
170
- Use the yes-no pattern from `skills/shared/gate-prompts.md`:
176
+ Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
171
177
  question: "Phase {N} has already been built. All plans have completed SUMMARYs. Re-build from scratch?"
172
178
  header: "Re-build?"
173
179
  options:
@@ -240,7 +246,7 @@ For each plan in the current wave (excluding skipped plans):
240
246
  Display to the user before spawning:
241
247
 
242
248
  ```
243
- Spawning {N} executor(s) for Wave {W}...
249
+ Spawning {N} executor(s) for Wave {W}...
244
250
  ```
245
251
 
246
252
  Then present a brief narrative for each plan to give the user context on what's about to happen:
@@ -261,13 +267,13 @@ This is a read-only presentation step — extract descriptions from plan frontma
261
267
  **State fragment rule:** Executors MUST NOT modify STATE.md directly. The build skill orchestrator is the sole STATE.md writer during execution. Executors report results via SUMMARY.md only; the orchestrator reads those summaries and updates STATE.md itself.
262
268
 
263
269
  **Model Selection (Adaptive)**:
264
- Before invoking the executor for each plan, determine the model:
270
+ Before spawning the executor for each plan, determine the model:
265
271
  1. Read the plan's task elements for `complexity` and `model` attributes
266
272
  2. If ANY task has an explicit `model` attribute, use the most capable model among them (inherit > sonnet > haiku)
267
273
  3. Otherwise, use the HIGHEST complexity among the plan's tasks to select the model:
268
274
  - Look up `config.models.complexity_map.{complexity}` (defaults: simple->haiku, medium->sonnet, complex->inherit)
269
275
  4. If `config.models.executor` is set (non-null), it overrides adaptive selection entirely — use that model for all executors
270
- 5. Pass the selected model to the agent invocation
276
+ 5. Pass the selected model to the Task() spawn
271
277
 
272
278
  Reference: `references/model-selection.md` for full details.
273
279
 
@@ -277,7 +283,7 @@ Reference: `references/model-selection.md` for full details.
277
283
  4. Read prior SUMMARY.md files from the same phase (completed plans in earlier waves)
278
284
  5. Read `.planning/config.json`
279
285
 
280
- Construct the executor prompt and invoke `@executor`:
286
+ Construct the executor prompt:
281
287
 
282
288
  ```
283
289
  You are the executor agent. Execute the following plan.
@@ -330,26 +336,35 @@ After all tasks complete:
330
336
  If you hit a checkpoint task, STOP and return the checkpoint response format immediately.
331
337
  ```
332
338
 
333
- **NOTE**: The `@executor` agent is defined in `agents/executor.md`. Do NOT inline it.
334
-
335
339
  **Spawn strategy based on config:**
336
340
 
337
341
  - If `parallelization.enabled: true` AND multiple plans in this wave:
338
- - Invoke up to `max_concurrent_agents` executors in parallel
339
- - Each invocation is independent
342
+ - Spawn up to `max_concurrent_agents` Task() calls in parallel
343
+ - Each Task() call is independent
344
+ - Use `run_in_background: true` for each executor
340
345
  - While waiting, display progress to the user:
341
346
  - After spawning: "Wave {W}: launched {N} executors in parallel: {list of plan names}"
347
+ - Periodically (~30s): check `TaskOutput` with `block: false` and report status
342
348
  - When each completes: "Plan {id} complete ({duration})"
343
349
  - When all complete: "Wave {W} finished. {passed}/{total} plans succeeded."
344
350
 
345
351
  - If `parallelization.enabled: false` OR single plan in wave:
346
- - Invoke executors sequentially, one at a time
352
+ - Spawn Task() calls sequentially, one at a time
347
353
 
348
- **Path resolution**: Before constructing the agent prompt, resolve plugin root to its absolute path. Do not pass the variable literally in prompts. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
354
+ ```
355
+ Task({
356
+ agent_type: "pbr:executor",
357
+ prompt: <executor prompt constructed above>
358
+ })
359
+
360
+ NOTE: The pbr:executor agent type auto-loads the agent definition. Do NOT inline it.
361
+ ```
362
+
363
+ **Path resolution**: Before constructing the agent prompt, resolve `${PLUGIN_ROOT}` to its absolute path. Do not pass the variable literally in prompts — Task() contexts may not expand it. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
349
364
 
350
365
  #### 6b. Wait for Wave Completion
351
366
 
352
- Block until all executor agents for this wave complete.
367
+ Block until all executor Task() calls for this wave complete.
353
368
 
354
369
  #### 6c. Read Results
355
370
 
@@ -360,7 +375,7 @@ For each completed executor:
360
375
  3. Extract status: `completed` | `partial` | `checkpoint` | `failed`
361
376
  4. Display per-plan completion to the user:
362
377
  ```
363
- Plan {id} complete — {brief summary from SUMMARY.md frontmatter description or first key_file}
378
+ Plan {id} complete — {brief summary from SUMMARY.md frontmatter description or first key_file}
364
379
  ```
365
380
  Extract the brief summary from the SUMMARY.md frontmatter (use the `description` field if present, otherwise use the first entry from `key_files`).
366
381
  5. Record commit hashes, files created, deviations
@@ -407,12 +422,20 @@ When inline verification is enabled, each completed plan gets a targeted verific
407
422
  For each plan that completed successfully in this wave:
408
423
 
409
424
  1. Read the plan's SUMMARY.md to get `key_files` (the files this plan created/modified)
410
- 2. Display to the user: `Spawning inline verifier for plan {plan_id}...`
425
+ 2. Display to the user: `◐ Spawning inline verifier for plan {plan_id}...`
426
+
427
+ Spawn a lightweight verifier:
411
428
 
412
- Invoke `@verifier` with a lightweight targeted verification prompt:
429
+ <!-- NOTE: This is a targeted inline check (existence/substantiveness/wiring for specific files),
430
+ NOT the full must-have verifier. The canonical full verifier prompt lives in
431
+ agents/verifier.md and is templated via skills/review/templates/verifier-prompt.md.tmpl.
432
+ Keep this lightweight prompt distinct from the full verifier. -->
413
433
 
414
434
  ```
415
- Targeted inline verification for plan {plan_id}.
435
+ Task({
436
+ agent_type: "pbr:verifier",
437
+ model: "haiku",
438
+ prompt: "Targeted inline verification for plan {plan_id}.
416
439
 
417
440
  Verify ONLY these files: {comma-separated key_files list}
418
441
 
@@ -422,16 +445,17 @@ For each file, check three layers:
422
445
  3. Wiring — is it imported/used by at least one other file?
423
446
 
424
447
  Report PASS or FAIL with a one-line reason per file.
425
- Write nothing to disk — just return your results as text.
448
+ Write nothing to disk — just return your results as text."
449
+ })
426
450
  ```
427
451
 
428
452
  3. If verifier reports FAIL for any file:
429
453
  - Present the failure to the user: "Inline verify failed for plan {plan_id}: {details}"
430
- - Re-invoke the executor for just the failed items: include only the failing file context in the prompt
454
+ - Re-spawn the executor for just the failed items: include only the failing file context in the prompt
431
455
  - If the retry also fails: proceed but flag in the wave results table (don't block indefinitely)
432
456
  4. If verifier reports all PASS: continue to next wave
433
457
 
434
- **Note:** This adds latency (~10-20s per plan for the verifier). It's opt-in via `features.inline_verify: true` for projects where early detection outweighs speed.
458
+ **Note:** This adds latency (~10-20s per plan for the haiku verifier). It's opt-in via `features.inline_verify: true` for projects where early detection outweighs speed.
435
459
 
436
460
  ---
437
461
 
@@ -441,7 +465,7 @@ If any executor returned `failed` or `partial`:
441
465
 
442
466
  **Handoff bug check (false-failure detection):**
443
467
 
444
- Before presenting failure options, check whether the executor actually completed its work despite reporting failure:
468
+ Before presenting failure options, check whether the executor actually completed its work despite reporting failure (known Claude Code platform bug where handoff reports failure but work is done):
445
469
 
446
470
  1. Check if SUMMARY.md exists at the expected path for this plan
447
471
  2. If SUMMARY.md exists:
@@ -463,17 +487,17 @@ Plan {id} {status}:
463
487
  Last verify output: {output}
464
488
  ```
465
489
 
466
- Use the multi-option-failure pattern from `skills/shared/gate-prompts.md`:
490
+ Use AskUserQuestion (pattern: multi-option-failure from `skills/shared/gate-prompts.md`):
467
491
  question: "Plan {id} failed at task {N} ({name}). How should we proceed?"
468
492
  header: "Failed"
469
493
  options:
470
- - label: "Retry" description: "Re-invoke the executor for this plan"
494
+ - label: "Retry" description: "Re-spawn the executor for this plan"
471
495
  - label: "Skip" description: "Mark as skipped, continue to next wave"
472
496
  - label: "Rollback" description: "Undo commits from this plan, revert to last good state"
473
497
  - label: "Abort" description: "Stop the entire build"
474
498
 
475
499
  **If user selects 'Retry':**
476
- - Re-invoke executor with the same prompt
500
+ - Re-spawn executor Task() with the same prompt
477
501
  - If retry also fails: ask user again (max 2 retries total)
478
502
 
479
503
  **If user selects 'Skip':**
@@ -514,7 +538,7 @@ Checkpoint in Plan {id}, Task {N}: {checkpoint type}
514
538
  ```
515
539
 
516
540
  3. Wait for user response
517
- 4. Invoke a FRESH continuation executor:
541
+ 4. Spawn a FRESH continuation executor:
518
542
 
519
543
  Reference: `references/continuation-format.md` for the continuation protocol.
520
544
 
@@ -584,7 +608,7 @@ node ${PLUGIN_ROOT}/scripts/pbr-tools.js state update last_activity now
584
608
 
585
609
  ### Step 7: Phase Verification (delegated, conditional)
586
610
 
587
- **Event-driven auto-verify signal:** Check if `.planning/.auto-verify` exists (written by event hooks). If the signal file exists, read it and delete it (one-shot). The signal confirms that auto-verification was triggered — proceed with verification even if the build just finished.
611
+ **Event-driven auto-verify signal:** Check if `.planning/.auto-verify` exists (written by `event-handler.js` SubagentStop hook). If the signal file exists, read it and delete it (one-shot). The signal confirms that auto-verification was triggered — proceed with verification even if the build just finished.
588
612
 
589
613
  **Skip if:**
590
614
  - Build was aborted
@@ -600,13 +624,20 @@ Note for Step 8f completion summary: append "Note: Automatic verification was sk
600
624
 
601
625
  **If verification is enabled:**
602
626
 
603
- Display to the user: `Spawning verifier...`
627
+ Display to the user: `◐ Spawning verifier...`
604
628
 
605
- Invoke the `@verifier` agent with the verifier prompt.
629
+ Spawn a verifier Task():
606
630
 
607
- **NOTE**: The `@verifier` agent is defined in `agents/verifier.md`. Do NOT inline it.
631
+ ```
632
+ Task({
633
+ agent_type: "pbr:verifier",
634
+ prompt: <verifier prompt>
635
+ })
636
+
637
+ NOTE: The pbr:verifier agent type auto-loads the agent definition. Do NOT inline it.
638
+ ```
608
639
 
609
- **Path resolution**: Before constructing the agent prompt, resolve plugin root to its absolute path. Do not pass the variable literally in prompts. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
640
+ **Path resolution**: Before constructing the agent prompt, resolve `${PLUGIN_ROOT}` to its absolute path. Do not pass the variable literally in prompts — Task() contexts may not expand it. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
610
641
 
611
642
  #### Verifier Prompt Template
612
643
 
@@ -614,8 +645,8 @@ Use the same verifier prompt template as defined in `/pbr:review`: read `skills/
614
645
 
615
646
  After the verifier returns, read the VERIFICATION.md frontmatter and display the results:
616
647
 
617
- - If status is `passed`: display `Verifier: {X}/{Y} must-haves verified` (where X = `must_haves_passed` and Y = `must_haves_checked`)
618
- - If status is `gaps_found`: display `Verifier found {N} gap(s) — see VERIFICATION.md` (where N = `must_haves_failed`)
648
+ - If status is `passed`: display `✓ Verifier: {X}/{Y} must-haves verified` (where X = `must_haves_passed` and Y = `must_haves_checked`)
649
+ - If status is `gaps_found`: display `⚠ Verifier found {N} gap(s) — see VERIFICATION.md` (where N = `must_haves_failed`)
619
650
 
620
651
  ---
621
652
 
@@ -649,10 +680,17 @@ Only run if ALL of these are true:
649
680
  If triggered:
650
681
  1. Record the pre-build commit SHA at the start of Step 1 (before any executors run) for comparison
651
682
  2. Run `git diff --name-only {pre_build_commit}..HEAD` to get the list of changed files
652
- 3. Display to the user: `Spawning codebase mapper (incremental update)...`
683
+ 3. Display to the user: `◐ Spawning codebase mapper (incremental update)...`
653
684
 
654
- Invoke `@codebase-mapper` with: "Incremental codebase map update. These files changed during the Phase {N} build:\n{diff file list}\n\nRead the existing .planning/codebase/ documents. Update ONLY the sections affected by these changes. Do NOT rewrite entire documents — make targeted updates. If a new dependency was added, update STACK.md. If new directories/modules were created, update STRUCTURE.md. If new patterns were introduced, update CONVENTIONS.md. Write updated files to .planning/codebase/."
655
- 4. Do NOT block on this — run in background and continue to Step 8a. Report completion in Step 8f if it finishes in time.
685
+ Spawn a lightweight mapper Task():
686
+ ```
687
+ Task({
688
+ agent_type: "pbr:codebase-mapper",
689
+ model: "haiku",
690
+ prompt: "Incremental codebase map update. These files changed during the Phase {N} build:\n{diff file list}\n\nRead the existing .planning/codebase/ documents. Update ONLY the sections affected by these changes. Do NOT rewrite entire documents — make targeted updates. If a new dependency was added, update STACK.md. If new directories/modules were created, update STRUCTURE.md. If new patterns were introduced, update CONVENTIONS.md. Write updated files to .planning/codebase/."
691
+ })
692
+ ```
693
+ 4. Do NOT block on this — use `run_in_background: true` and continue to Step 8a. Report completion in Step 8f if it finishes in time.
656
694
 
657
695
  **8a. Update ROADMAP.md Progress table** (REQUIRED — do this BEFORE updating STATE.md):
658
696
 
@@ -686,7 +724,7 @@ If `planning.commit_docs` is `true`:
686
724
  If `git.branching` is `phase`:
687
725
  - All work was done on the phase branch (created in Step 1)
688
726
  - Squash merge to main: `git checkout main && git merge --squash plan-build-run/phase-{NN}-{name}`
689
- - Use the yes-no pattern from `skills/shared/gate-prompts.md`:
727
+ - Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
690
728
  question: "Phase {N} complete on branch `plan-build-run/phase-{NN}-{name}`. Squash merge to main?"
691
729
  header: "Merge?"
692
730
  options:
@@ -702,26 +740,43 @@ Chain to the next skill directly within this session. This eliminates manual pha
702
740
 
703
741
  | Build Result | Next Action | How |
704
742
  |-------------|-------------|-----|
705
- | Verification passed, more phases | Plan next phase | Chain to `/pbr:plan {N+1}` |
706
- | Verification skipped | Run review | Chain to `/pbr:review {N}` |
743
+ | Verification passed, more phases | Plan next phase | `Skill({ skill: "pbr:plan", args: "{N+1}" })` |
744
+ | Verification skipped | Run review | `Skill({ skill: "pbr:review", args: "{N}" })` |
707
745
  | Verification gaps found | **HARD STOP** — present gaps to user | Do NOT auto-advance past failures |
708
- | Last phase complete | **HARD STOP** — milestone boundary | Suggest `/pbr:milestone audit` |
746
+ | Last phase in current milestone | **HARD STOP** — milestone boundary | Suggest `/pbr:milestone audit`. Explain: "auto_advance pauses at milestone boundaries — your sign-off is required." |
709
747
  | Build errors occurred | **HARD STOP** — errors need human review | Do NOT auto-advance past errors |
710
748
 
711
- After invoking the chained skill, it runs within the same session. When it completes, the chained skill may itself chain further (review->plan, plan->build) if auto_advance remains true. This creates the full cycle: build->review->plan->build->...
749
+ After invoking the chained skill, it runs within the same session. When it completes, the chained skill may itself chain further (reviewplan, planbuild) if auto_advance remains true. This creates the full cycle: buildreviewplanbuild→...
712
750
 
713
751
  **Else if `features.auto_continue` is `true`:**
714
752
  Write `.planning/.auto-next` containing the next logical command (e.g., `/pbr:plan {N+1}` or `/pbr:review {N}`)
715
753
  - This file signals to the user or to wrapper scripts that the next step is ready
716
754
 
755
+ **8e-ii. Check Pending Todos:**
756
+
757
+ After completing the build, check if any pending todos are now satisfied:
758
+
759
+ 1. Check if `.planning/todos/pending/` exists and contains files
760
+ 2. If no pending todos: skip to 8f
761
+ 3. If pending todos exist:
762
+ a. Read the title and description from each pending todo's YAML frontmatter
763
+ b. Compare each todo against the phase work (plans executed, files changed, features built)
764
+ c. If a todo is **clearly satisfied**: move it to `.planning/todos/done/`, update `status: done`, add `completed: {YYYY-MM-DD}`, delete from `pending/` via Bash `rm`. Display: `✓ Auto-closed todo {NNN}: {title} (satisfied by Phase {N} build)`
765
+ d. If **partially related**: display `ℹ Related pending todo {NNN}: {title} — may be partially addressed`
766
+ e. If unrelated: skip silently
767
+
768
+ Only auto-close when the match is unambiguous. When in doubt, leave it open.
769
+
717
770
  **8f. Present completion summary:**
718
771
 
719
772
  Use the branded output templates from `references/ui-formatting.md`. Route based on status:
720
773
 
721
774
  | Status | Template |
722
775
  |--------|----------|
723
- | `passed` + more phases | "Phase Complete" template |
724
- | `passed` + last phase | "Milestone Complete" template |
776
+ | `passed` + more phases in current milestone | "Phase Complete" template |
777
+ | `passed` + last phase in current milestone | "Milestone Complete" template |
778
+
779
+ **Milestone boundary detection:** To determine "last phase in current milestone", read ROADMAP.md and find the `## Milestone:` section containing the current phase. Check its `**Phases:** start - end` range. If the current phase equals `end`, this is the last phase in the milestone. For projects with a single milestone or no explicit milestone sections, "last phase in ROADMAP" is equivalent.
725
780
  | `gaps_found` | "Gaps Found" template |
726
781
 
727
782
  Before the branded banner, include the results table:
@@ -748,66 +803,66 @@ Then present the appropriate branded banner:
748
803
  **If `passed` + more phases:**
749
804
  ```
750
805
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
751
- PLAN-BUILD-RUN ► PHASE {N} COMPLETE
806
+ PLAN-BUILD-RUN ► PHASE {N} COMPLETE
752
807
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
753
808
 
754
809
  **Phase {N}: {Name}**
755
810
 
756
811
  {X} plans executed
757
- Goal verified
812
+ Goal verified
758
813
 
759
- ---
814
+ ───────────────────────────────────────────────────────────────
760
815
 
761
- ## Next Up
816
+ ## Next Up
762
817
 
763
818
  **Phase {N+1}: {Name}** — {Goal from ROADMAP.md}
764
819
 
765
820
  `/pbr:plan {N+1}`
766
821
 
767
- `/clear` first for a fresh context window
822
+ <sub>`/clear` first fresh context window</sub>
768
823
 
769
- ---
824
+ ───────────────────────────────────────────────────────────────
770
825
 
771
826
  **Also available:**
772
827
  - `/pbr:review {N}` — manual acceptance testing before continuing
773
828
  - `/pbr:discuss {N+1}` — talk through the next phase before planning
774
829
  - `/pbr:status` — see full project status
775
830
 
776
- ---
831
+ ───────────────────────────────────────────────────────────────
777
832
  ```
778
833
 
779
834
  **If `passed` + last phase:**
780
835
  ```
781
836
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
782
- PLAN-BUILD-RUN ► MILESTONE COMPLETE
837
+ PLAN-BUILD-RUN ► MILESTONE COMPLETE 🎉
783
838
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
784
839
 
785
840
  {N} phases completed
786
- All phase goals verified
841
+ All phase goals verified
787
842
 
788
- ---
843
+ ───────────────────────────────────────────────────────────────
789
844
 
790
- ## Next Up
845
+ ## Next Up
791
846
 
792
847
  **Audit milestone** — verify requirements, cross-phase integration, E2E flows
793
848
 
794
849
  `/pbr:milestone audit`
795
850
 
796
- `/clear` first for a fresh context window
851
+ <sub>`/clear` first fresh context window</sub>
797
852
 
798
- ---
853
+ ───────────────────────────────────────────────────────────────
799
854
 
800
855
  **Also available:**
801
856
  - `/pbr:review` — manual acceptance testing
802
- - `/pbr:milestone complete` — skip audit, archive directly
857
+ - `/pbr:milestone complete` — archive milestone after audit passes
803
858
 
804
- ---
859
+ ───────────────────────────────────────────────────────────────
805
860
  ```
806
861
 
807
862
  **If `gaps_found`:**
808
863
  ```
809
864
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
810
- PLAN-BUILD-RUN ► PHASE {N} GAPS FOUND
865
+ PLAN-BUILD-RUN ► PHASE {N} GAPS FOUND
811
866
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
812
867
 
813
868
  **Phase {N}: {Name}**
@@ -819,23 +874,23 @@ Report: .planning/phases/{phase_dir}/VERIFICATION.md
819
874
 
820
875
  {Extract gap summaries from VERIFICATION.md}
821
876
 
822
- ---
877
+ ───────────────────────────────────────────────────────────────
823
878
 
824
- ## Next Up
879
+ ## Next Up
825
880
 
826
881
  **Plan gap closure** — create additional plans to complete the phase
827
882
 
828
883
  `/pbr:plan {N} --gaps`
829
884
 
830
- `/clear` first for a fresh context window
885
+ <sub>`/clear` first fresh context window</sub>
831
886
 
832
- ---
887
+ ───────────────────────────────────────────────────────────────
833
888
 
834
889
  **Also available:**
835
890
  - `cat .planning/phases/{phase_dir}/VERIFICATION.md` — see full report
836
891
  - `/pbr:review {N}` — manual testing before planning
837
892
 
838
- ---
893
+ ───────────────────────────────────────────────────────────────
839
894
  ```
840
895
 
841
896
  **8g. Display USER-SETUP.md (conditional):**
@@ -857,9 +912,11 @@ This ensures the user sees setup requirements prominently instead of buried in S
857
912
  ## Error Handling
858
913
 
859
914
  ### Executor agent timeout
860
- If an executor agent doesn't return within a reasonable time, display:
915
+ If a Task() doesn't return within a reasonable time, display:
861
916
  ```
862
- ERROR
917
+ ╔══════════════════════════════════════════════════════════════╗
918
+ ║ ERROR ║
919
+ ╚══════════════════════════════════════════════════════════════╝
863
920
 
864
921
  Executor agent timed out for Plan {id}.
865
922
 
@@ -872,7 +929,7 @@ For commit conventions and git workflow details, see `references/git-integration
872
929
  ### Git lock conflicts
873
930
  If multiple parallel executors create git lock conflicts:
874
931
  - The executor agent handles retries internally (see executor agent definition)
875
- - If lock conflicts persist, display: "Git lock conflicts detected with parallel execution. Consider reducing max_concurrent_agents to 1."
932
+ - If lock conflicts persist, display: `⚠ Git lock conflicts detected with parallel execution. Consider reducing max_concurrent_agents to 1.`
876
933
 
877
934
  ### Executor produces unexpected files
878
935
  If SUMMARY.md shows files not listed in the plan's `files_modified`:
@@ -896,7 +953,7 @@ If `git.branching` is `phase` but we're not on the phase branch:
896
953
  | `.planning/phases/{NN}-{slug}/USER-SETUP.md` | External setup requirements | Step 6 (executor, if needed) |
897
954
  | `.planning/phases/{NN}-{slug}/VERIFICATION.md` | Phase verification report | Step 7 |
898
955
  | `.planning/codebase/*.md` | Incremental codebase map updates | Step 8-pre-c (if codebase/ exists) |
899
- | `.planning/ROADMAP.md` | Plans Complete + Status -> `built` or `partial` | Step 8a |
956
+ | `.planning/ROADMAP.md` | Plans Complete + Status `built` or `partial` | Step 8a |
900
957
  | `.planning/STATE.md` | Updated progress | Steps 6f, 8b |
901
958
  | `.planning/.auto-next` | Next command signal (if auto_continue enabled) | Step 8e |
902
959
  | Project source files | Actual code | Step 6 (executors) |
@@ -232,6 +232,7 @@ After creating artifacts (or if user chose "Skip"), display:
232
232
  - If a phase decision was captured: **Plan the phase** → `/pbr:plan {N}`
233
233
  - If a new phase was added: **Discuss the new phase** → `/pbr:discuss {N}`
234
234
  - If research questions were logged: **Plan with research** → `/pbr:plan {N}`
235
+ - If current milestone is complete (STATE.md status is "milestone-complete"): **Start next milestone** → `/pbr:milestone new`
235
236
  - Default: **See project status** → `/pbr:status`
236
237
 
237
238
  `{primary command}`
@@ -243,6 +244,7 @@ After creating artifacts (or if user chose "Skip"), display:
243
244
  **Also available:**
244
245
  - `/pbr:status` — see project status
245
246
  - `/pbr:continue` — execute next logical step
247
+ - `/pbr:milestone new` — start a new milestone with new phases
246
248
 
247
249
  ───────────────────────────────────────────────────────────────
248
250
  ```