@sienklogic/plan-build-run 2.52.0 → 2.54.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 (68) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/package.json +2 -2
  3. package/plugins/copilot-pbr/agents/executor.agent.md +0 -2
  4. package/plugins/copilot-pbr/commands/setup.md +1 -1
  5. package/plugins/copilot-pbr/commands/undo.md +5 -0
  6. package/plugins/copilot-pbr/plugin.json +1 -1
  7. package/plugins/copilot-pbr/references/signal-files.md +41 -0
  8. package/plugins/copilot-pbr/skills/begin/SKILL.md +170 -17
  9. package/plugins/copilot-pbr/skills/build/SKILL.md +73 -8
  10. package/plugins/copilot-pbr/skills/plan/SKILL.md +67 -17
  11. package/plugins/copilot-pbr/skills/review/SKILL.md +12 -1
  12. package/plugins/copilot-pbr/skills/setup/SKILL.md +66 -214
  13. package/plugins/copilot-pbr/skills/shared/context-budget.md +27 -0
  14. package/plugins/copilot-pbr/skills/status/SKILL.md +44 -2
  15. package/plugins/copilot-pbr/skills/undo/SKILL.md +172 -0
  16. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  17. package/plugins/cursor-pbr/agents/executor.md +0 -2
  18. package/plugins/cursor-pbr/commands/setup.md +1 -1
  19. package/plugins/cursor-pbr/commands/undo.md +5 -0
  20. package/plugins/cursor-pbr/references/signal-files.md +41 -0
  21. package/plugins/cursor-pbr/skills/begin/SKILL.md +170 -17
  22. package/plugins/cursor-pbr/skills/build/SKILL.md +73 -8
  23. package/plugins/cursor-pbr/skills/plan/SKILL.md +67 -17
  24. package/plugins/cursor-pbr/skills/review/SKILL.md +12 -1
  25. package/plugins/cursor-pbr/skills/setup/SKILL.md +66 -214
  26. package/plugins/cursor-pbr/skills/shared/context-budget.md +27 -0
  27. package/plugins/cursor-pbr/skills/status/SKILL.md +44 -2
  28. package/plugins/cursor-pbr/skills/undo/SKILL.md +173 -0
  29. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
  30. package/plugins/pbr/agents/executor.md +0 -2
  31. package/plugins/pbr/commands/setup.md +1 -1
  32. package/plugins/pbr/commands/undo.md +5 -0
  33. package/plugins/pbr/references/signal-files.md +41 -0
  34. package/plugins/pbr/scripts/check-skill-workflow.js +7 -8
  35. package/plugins/pbr/scripts/check-subagent-output.js +7 -6
  36. package/plugins/pbr/scripts/config-schema.json +5 -1
  37. package/plugins/pbr/scripts/enforce-pbr-workflow.js +15 -6
  38. package/plugins/pbr/scripts/lib/alternatives.js +203 -0
  39. package/plugins/pbr/scripts/lib/preview.js +174 -0
  40. package/plugins/pbr/scripts/lib/skill-section.js +99 -0
  41. package/plugins/pbr/scripts/lib/step-verify.js +149 -0
  42. package/plugins/pbr/scripts/log-subagent.js +7 -10
  43. package/plugins/pbr/scripts/pbr-tools.js +122 -2
  44. package/plugins/pbr/scripts/validate-commit.js +2 -2
  45. package/plugins/pbr/skills/begin/SKILL.md +170 -17
  46. package/plugins/pbr/skills/begin/templates/config.json.tmpl +5 -1
  47. package/plugins/pbr/skills/build/SKILL.md +73 -8
  48. package/plugins/pbr/skills/plan/SKILL.md +67 -17
  49. package/plugins/pbr/skills/review/SKILL.md +12 -1
  50. package/plugins/pbr/skills/setup/SKILL.md +66 -214
  51. package/plugins/pbr/skills/shared/context-budget.md +27 -0
  52. package/plugins/pbr/skills/status/SKILL.md +44 -2
  53. package/plugins/pbr/skills/undo/SKILL.md +174 -0
  54. /package/plugins/copilot-pbr/references/{agent-anti-patterns.md → archive/agent-anti-patterns.md} +0 -0
  55. /package/plugins/copilot-pbr/references/{checkpoints.md → archive/checkpoints.md} +0 -0
  56. /package/plugins/copilot-pbr/references/{context-quality-tiers.md → archive/context-quality-tiers.md} +0 -0
  57. /package/plugins/copilot-pbr/references/{pbr-rules.md → archive/pbr-rules.md} +0 -0
  58. /package/plugins/copilot-pbr/references/{verification-patterns.md → archive/verification-patterns.md} +0 -0
  59. /package/plugins/cursor-pbr/references/{agent-anti-patterns.md → archive/agent-anti-patterns.md} +0 -0
  60. /package/plugins/cursor-pbr/references/{checkpoints.md → archive/checkpoints.md} +0 -0
  61. /package/plugins/cursor-pbr/references/{context-quality-tiers.md → archive/context-quality-tiers.md} +0 -0
  62. /package/plugins/cursor-pbr/references/{pbr-rules.md → archive/pbr-rules.md} +0 -0
  63. /package/plugins/cursor-pbr/references/{verification-patterns.md → archive/verification-patterns.md} +0 -0
  64. /package/plugins/pbr/references/{agent-anti-patterns.md → archive/agent-anti-patterns.md} +0 -0
  65. /package/plugins/pbr/references/{checkpoints.md → archive/checkpoints.md} +0 -0
  66. /package/plugins/pbr/references/{context-quality-tiers.md → archive/context-quality-tiers.md} +0 -0
  67. /package/plugins/pbr/references/{pbr-rules.md → archive/pbr-rules.md} +0 -0
  68. /package/plugins/pbr/references/{verification-patterns.md → archive/verification-patterns.md} +0 -0
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: "Revert recent PBR-generated commits by phase/plan, safely using git revert."
3
+ ---
4
+
5
+ This command is provided by the `pbr:undo` skill.
@@ -0,0 +1,41 @@
1
+ # Signal Files Reference
2
+
3
+ Signal files are ephemeral files in `.planning/` that coordinate state between hook scripts
4
+ and skills. They are scoped to either the current session or the current phase/plan.
5
+
6
+ ## Session-Scoped Files
7
+
8
+ All 5 session signals are consolidated in `.planning/.session.json`. Scripts must read and write
9
+ `.session.json` via `pbr-tools session get|set|clear` — never read the raw `.session.json` file directly.
10
+ The `.session.json` schema is an object with the keys documented below.
11
+
12
+ | JSON Key | Former File | Written By | Read By | Semantics |
13
+ |----------|-------------|------------|---------|-----------|
14
+ | `activeSkill` | `.active-skill` | Skills (Write tool) | check-skill-workflow, enforce-pbr-workflow, check-subagent-output, log-subagent, block-skill-self-read | Which skill is active. Written at skill start, cleared at skill end (session-cleanup). |
15
+ | `compactCounter` | `.compact-counter` | suggest-compact.js | suggest-compact.js | Write count since last /compact. Resets on SessionStart. |
16
+ | `sessionStart` | `.session-start` | progress-tracker.js | local-llm metrics | ISO timestamp of session start. Used for LLM metrics correlation. |
17
+ | `activeOperation` | `.active-operation` | context-budget-check.js | context-budget-check.js | Current named operation for budget display. |
18
+ | `activePlan` | `.active-plan` | context-budget-check.js | context-budget-check.js | Current plan ID for budget display. |
19
+
20
+ **Atomic access**: Use `pbr-tools session get|set|clear` for safe reads/writes from hook scripts.
21
+
22
+ **Lifecycle**: Written during SessionStart (progress-tracker), cleared during SessionEnd (session-cleanup).
23
+ Stale sessions (> 60 min) are auto-cleaned by progress-tracker.js on next SessionStart.
24
+
25
+ ## One-Shot Files
26
+
27
+ These files are NOT consolidated — they use write-once, delete-on-read semantics.
28
+
29
+ | File | Written By | Read By | Semantics |
30
+ |------|------------|---------|-----------|
31
+ | `.planning/.auto-next` | auto-continue.js | auto-continue.js (Stop hook) | Next command to run after session stops. Deleted after read. |
32
+ | `.planning/.auto-verify` | event-handler.js | event-handler.js (SubagentStop hook) | Trigger auto-verification after agent completes. Deleted after read. |
33
+
34
+ ## Phase-Scoped Files
35
+
36
+ These files persist across sessions, scoped to a specific phase or plan.
37
+
38
+ | File Pattern | Written By | Read By | Semantics |
39
+ |-------------|------------|---------|-----------|
40
+ | `.planning/phases/{id}/.checkpoint-manifest.json` | build skill | validate-task.js, session-cleanup.js | Checkpoint state for a plan in progress. Cleaned up after 24h. |
41
+ | `.planning/phases/{id}/.PROGRESS-{taskId}` | executor agent | validate-task.js | Task progress marker for crash recovery. Orphaned files warn on SessionStart. |
@@ -118,10 +118,138 @@ Have a natural conversation to understand the user's vision. Do NOT present a fo
118
118
 
119
119
  ---
120
120
 
121
+ ### Step 2.5: Fast-Path Offer (inline)
122
+
123
+ Before asking any workflow preference questions, offer the user a quick-start option:
124
+
125
+ Use AskUserQuestion:
126
+ question: "How do you want to configure this project?"
127
+ header: "Setup mode"
128
+ options:
129
+ - label: "Quick start"
130
+ description: "Use all defaults — model balanced, depth standard, interactive mode, parallel on. Writes config in seconds."
131
+ - label: "Custom setup"
132
+ description: "Walk through model selection, features, and preferences step by step."
133
+
134
+ **If user selects "Quick start":**
135
+ - Write `.planning/config.json` immediately using the default config below (no further questions):
136
+ ```json
137
+ {
138
+ "version": 2,
139
+ "context_strategy": "aggressive",
140
+ "mode": "interactive",
141
+ "depth": "standard",
142
+ "features": {
143
+ "structured_planning": true,
144
+ "goal_verification": true,
145
+ "integration_verification": true,
146
+ "context_isolation": true,
147
+ "atomic_commits": true,
148
+ "session_persistence": true,
149
+ "research_phase": true,
150
+ "plan_checking": true,
151
+ "tdd_mode": false,
152
+ "status_line": true,
153
+ "auto_continue": false,
154
+ "auto_advance": false,
155
+ "team_discussions": false,
156
+ "inline_verify": false
157
+ },
158
+ "models": {
159
+ "researcher": "sonnet",
160
+ "planner": "inherit",
161
+ "executor": "inherit",
162
+ "verifier": "sonnet",
163
+ "integration_checker": "sonnet",
164
+ "debugger": "inherit",
165
+ "mapper": "sonnet",
166
+ "synthesizer": "haiku"
167
+ },
168
+ "parallelization": {
169
+ "enabled": true,
170
+ "plan_level": true,
171
+ "task_level": false,
172
+ "max_concurrent_agents": 3,
173
+ "min_plans_for_parallel": 2,
174
+ "use_teams": false
175
+ },
176
+ "planning": {
177
+ "commit_docs": true,
178
+ "max_tasks_per_plan": 3,
179
+ "search_gitignored": false
180
+ },
181
+ "git": {
182
+ "branching": "none",
183
+ "commit_format": "{type}({phase}-{plan}): {description}",
184
+ "phase_branch_template": "plan-build-run/phase-{phase}-{slug}",
185
+ "milestone_branch_template": "plan-build-run/{milestone}-{slug}",
186
+ "mode": "enabled"
187
+ },
188
+ "gates": {
189
+ "confirm_project": true,
190
+ "confirm_roadmap": true,
191
+ "confirm_plan": true,
192
+ "confirm_execute": false,
193
+ "confirm_transition": true,
194
+ "issues_review": true
195
+ },
196
+ "safety": {
197
+ "always_confirm_destructive": true,
198
+ "always_confirm_external_services": true
199
+ }
200
+ }
201
+ ```
202
+ - Write `.planning/.active-skill` with text "begin"
203
+ - Write CLAUDE.md integration block (see Step 3d-claude below) using the project name gathered in Step 2
204
+ - Skip to Step 4 (Research Decision)
205
+ - Tell the user: "Quick start selected. Using all defaults — you can adjust later with `/pbr:config`."
206
+
207
+ **If user selects "Custom setup":** proceed to Step 3 normally.
208
+
209
+ ---
210
+
121
211
  ### Step 3: Workflow Preferences (inline)
122
212
 
123
213
  After understanding the project, configure the Plan-Build-Run workflow. Use AskUserQuestion for each preference below. Present them sequentially with conversational bridging (e.g., "Great. Next...") to keep the flow natural.
124
214
 
215
+ **3-model. Model Profile:**
216
+ Use AskUserQuestion:
217
+ question: "Which model profile should agents use?"
218
+ header: "Models"
219
+ options:
220
+ - label: "Balanced (Recommended)"
221
+ description: "Sonnet for most agents, Haiku for synthesizer. Good quality/cost tradeoff."
222
+ - label: "Quality"
223
+ description: "Opus for executor and planner, Sonnet for others. Best results, highest cost."
224
+ - label: "Budget"
225
+ description: "Haiku for most agents. Fastest and cheapest, but lower quality."
226
+
227
+ Apply the selected profile to the models block in config.json:
228
+ - **Balanced**: executor=sonnet, researcher=sonnet, planner=sonnet, verifier=sonnet, synthesizer=haiku
229
+ - **Quality**: executor=opus, researcher=sonnet, planner=opus, verifier=sonnet, synthesizer=sonnet
230
+ - **Budget**: executor=haiku, researcher=haiku, planner=sonnet, verifier=haiku, synthesizer=haiku
231
+
232
+ **3-features. Workflow Features:**
233
+ Use AskUserQuestion:
234
+ question: "Any extra workflow features?"
235
+ header: "Features"
236
+ multiSelect: true
237
+ options:
238
+ - label: "Auto-continue"
239
+ description: "Automatically chain commands (build → review → next phase) without prompting"
240
+ - label: "TDD mode"
241
+ description: "Write tests before implementation in executor agents"
242
+ - label: "Strict gates"
243
+ description: "Require verification AND review to pass before advancing phases"
244
+ - label: "Git branching"
245
+ description: "Create a branch per phase for cleaner PR history"
246
+
247
+ Apply selections:
248
+ - **Auto-continue**: Set `features.auto_continue: true`
249
+ - **TDD mode**: Set `features.tdd_mode: true`
250
+ - **Strict gates**: Set `gates.verification: true`, `gates.review: true`, `gates.plan_approval: true`
251
+ - **Git branching**: Set `git.branching: "phase"`
252
+
125
253
  **3a. Mode:**
126
254
  Use the **toggle-confirm** pattern from `skills/shared/gate-prompts.md`:
127
255
  question: "How do you want to work?"
@@ -165,12 +293,33 @@ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
165
293
  - `yes` (default) — commit planning docs
166
294
  - `no` — add .planning/ to .gitignore
167
295
 
296
+ **3d-claude. CLAUDE.md Integration:**
297
+
298
+ Check if a `CLAUDE.md` file exists in the project root.
299
+
300
+ **If it exists**: Read it. If it does NOT already contain a "Plan-Build-Run" section, append the block below.
301
+ **If it does NOT exist**: Create `CLAUDE.md` with the block below.
302
+
303
+ Append/create:
304
+
305
+ ```markdown
306
+ ## Plan-Build-Run
307
+
308
+ This project uses [Plan-Build-Run](https://github.com/SienkLogic/plan-build-run) for structured development.
309
+
310
+ - Project state: `.planning/STATE.md` (source of truth for current phase and progress)
311
+ - Configuration: `.planning/config.json`
312
+ - Run `/pbr:status` to see current project state and suggested next action.
313
+
314
+ **After compaction or context recovery**: Read `.planning/STATE.md` (especially the `## Session Continuity` section) before proceeding with any work. The PreCompact hook writes recovery state there automatically.
315
+ ```
316
+
168
317
  **After gathering preferences:**
169
318
 
170
319
  **CRITICAL (no hook): You MUST create the .planning/ directory and write config.json NOW. Do not proceed without this.**
171
320
 
172
321
  1. Read the config template from `skills/begin/templates/config.json.tmpl`
173
- 2. Apply the user's choices to the template
322
+ 2. Apply the user's choices to the template (including 3d-claude CLAUDE.md integration)
174
323
  3. Create `.planning/` directory
175
324
  4. Write `.planning/config.json` with the user's preferences
176
325
 
@@ -198,13 +347,15 @@ Based on the depth setting from Step 3, determine the research approach:
198
347
  - Tell user: "Skipping research phase (depth: quick). Moving straight to requirements."
199
348
 
200
349
  **If depth is `standard` or `comprehensive`:**
201
- Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
202
- question: "I'd like to research the technology landscape before planning. This helps create better plans. Proceed with research?"
203
- options:
204
- - label: "Yes" description: "Run research agents (recommended for standard/comprehensive)"
205
- - label: "No" description: "Skip research, move straight to requirements"
206
- - If user selects "No": skip to Step 7
207
- - If user selects "Yes": proceed to Step 5
350
+ - If `gates.confirm_research` is `true` in config:
351
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
352
+ question: "I'd like to research the technology landscape before planning. This helps create better plans. Proceed with research?"
353
+ options:
354
+ - label: "Yes" description: "Run research agents (recommended for standard/comprehensive)"
355
+ - label: "No" description: "Skip research, move straight to requirements"
356
+ - If user selects "No": skip to Step 7
357
+ - If user selects "Yes": proceed to Step 5
358
+ - If `gates.confirm_research` is `false` (default): proceed directly to Step 5 (research runs automatically)
208
359
 
209
360
  ---
210
361
 
@@ -580,15 +731,17 @@ If `gates.confirm_project` is true in config:
580
731
  - Phases: {count} phases in roadmap
581
732
  - Requirements: {count} v1 requirements
582
733
  - Config: depth={depth}, mode={mode}
583
- - Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
584
- question: "Everything look good? Commit the planning docs?"
585
- options:
586
- - label: "Yes" description: "Stage and commit .planning/ files"
587
- - label: "No" description: "Let me review and adjust first"
588
- - If user selects "Yes" and `planning.commit_docs` is true:
589
- - Stage `.planning/` files (excluding research/ if gitignored)
590
- - Commit: `chore: initialize plan-build-run project planning`
591
- - If user selects "No": let user review and adjust
734
+ - If `gates.confirm_commit_docs` is `true` OR this is a **brownfield** project (existing code detected in Step 1):
735
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
736
+ question: "Everything look good? Commit the planning docs?"
737
+ options:
738
+ - label: "Yes" description: "Stage and commit .planning/ files"
739
+ - label: "No" description: "Let me review and adjust first"
740
+ - If user selects "Yes" and `planning.commit_docs` is true:
741
+ - Stage `.planning/` files (excluding research/ if gitignored)
742
+ - Commit: `chore: initialize plan-build-run project planning`
743
+ - If user selects "No": let user review and adjust
744
+ - If `gates.confirm_commit_docs` is `false` AND greenfield: skip the question and commit automatically if `planning.commit_docs` is true
592
745
 
593
746
  ---
594
747
 
@@ -17,6 +17,8 @@ Reference: `skills/shared/context-budget.md` for the universal orchestrator rule
17
17
  Additionally for this skill:
18
18
  - **Minimize** reading executor output — read only SUMMARY.md frontmatter, not full content
19
19
  - **Delegate** all building work to executor agents — the orchestrator routes, it doesn't build
20
+ - **Lazy-load steps**: Instead of reading ahead, fetch the next step's instructions on demand:
21
+ `node ${PLUGIN_ROOT}/scripts/pbr-tools.js skill-section build "step-6"` → returns that step's content as JSON. Use this when context budget is DEGRADING.
20
22
 
21
23
  ## Step 0 — Immediate Output
22
24
 
@@ -48,6 +50,53 @@ Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
48
50
  | `3 --gaps-only` | Build only gap-closure plans in phase 3 |
49
51
  | `3 --team` | Use Agent Teams for complex inter-agent coordination |
50
52
  | (no number) | Use current phase from STATE.md |
53
+ | `3 --preview` | Preview what build would do for phase 3 without executing |
54
+
55
+ ---
56
+
57
+ ### --preview mode
58
+
59
+ If `--preview` is present in `$ARGUMENTS`:
60
+
61
+ 1. Extract the phase slug from `$ARGUMENTS` (use the phase number to look up the slug, or pass the number directly — the CLI accepts partial slug matches).
62
+ 2. Run:
63
+
64
+ ```bash
65
+ node ${PLUGIN_ROOT}/scripts/pbr-tools.js build-preview {phase-slug}
66
+ ```
67
+
68
+ Capture the JSON output.
69
+ 3. Render the following preview document (do NOT proceed to Step 2):
70
+
71
+ ```
72
+ ╔══════════════════════════════════════════════════════════════╗
73
+ ║ DRY RUN — /pbr:build {N} --preview ║
74
+ ║ No executor agents will be spawned ║
75
+ ╚══════════════════════════════════════════════════════════════╝
76
+
77
+ PHASE: {phase}
78
+
79
+ ## Plans
80
+ {for each plan: - {id} (wave {wave}, {task_count} tasks)}
81
+
82
+ ## Wave Structure
83
+ {for each wave: Wave {wave}: {plan IDs} [parallel | sequential]}
84
+
85
+ ## Files That Would Be Modified
86
+ {for each file in files_affected: - {file}}
87
+ (Total: {count} files)
88
+
89
+ ## Estimated Agent Spawns
90
+ {agent_count} executor task(s)
91
+
92
+ ## Critical Path
93
+ {critical_path joined with " → "}
94
+
95
+ ## Dependency Chain
96
+ {for each entry in dependency_chain: - {id} (wave {wave}) depends on: {depends_on or "none"}}
97
+ ```
98
+
99
+ 4. **STOP** — do not proceed to Step 2.
51
100
 
52
101
  ---
53
102
 
@@ -108,16 +157,23 @@ Phase {N} has no plans.
108
157
  **To fix:** Run `/pbr:plan {N}` first.
109
158
  ```
110
159
 
111
- If dependencies incomplete:
112
- ```
113
- ╔══════════════════════════════════════════════════════════════╗
114
- ║ ERROR ║
115
- ╚══════════════════════════════════════════════════════════════╝
160
+ If dependencies incomplete, use conversational recovery:
116
161
 
117
- Phase {N} depends on Phase {M}, which is not complete.
162
+ 1. Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives missing-prereq {dependency-phase-slug}`
163
+ 2. Parse the JSON response to get `existing_summaries`, `missing_summaries`, and `suggested_action`.
164
+ 3. Display what summaries exist and what is still missing.
165
+ 4. Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`) to offer:
166
+ - "Build {dependency-phase} first" — stop and show: `/pbr:build {dependency-phase}`
167
+ - "Continue anyway (skip dependency check)" — proceed with build, note unmet deps in output
118
168
 
119
- **To fix:** Build Phase {M} first with `/pbr:build {M}`.
120
- ```
169
+ If config validation fails for a specific field, use conversational recovery:
170
+
171
+ 1. Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives config-invalid {field} {value}`
172
+ 2. Parse the JSON response to get `valid_values` and `suggested_fix`.
173
+ 3. Display the invalid field, its current value, and the valid options.
174
+ 4. Use AskUserQuestion to offer: "Fix config.json now, or continue with current value?"
175
+ - If "Fix now": stop and display the `suggested_fix` instruction.
176
+ - If "Continue": proceed with default value for that field.
121
177
 
122
178
  ---
123
179
 
@@ -565,6 +621,9 @@ node ${PLUGIN_ROOT}/scripts/pbr-tools.js state update last_activity now
565
621
  - [ ] STATE.md body progress bar updated
566
622
  - [ ] `last_activity` timestamp refreshed
567
623
 
624
+ To verify programmatically: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js step-verify build step-6f '["STATE.md updated","SUMMARY.md exists","commit made"]'`
625
+ If any item fails, investigate before proceeding to Step 7.
626
+
568
627
  ---
569
628
 
570
629
  ### Step 7: Phase Verification (delegated, conditional)
@@ -697,6 +756,9 @@ These return `{ success, old_status, new_status }` or `{ success, old_plans, new
697
756
  - [ ] STATE.md body ## Current Position updated: Phase, Status, Last activity, Progress bar
698
757
  - [ ] Frontmatter and body are consistent (same status value in both)
699
758
 
759
+ To verify programmatically: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js step-verify build step-8b '["STATE.md updated","ROADMAP.md updated","commit made"]'`
760
+ If any item fails, investigate before marking phase complete.
761
+
700
762
  **8c. Commit planning docs (if configured):**
701
763
  Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
702
764
  If `planning.commit_docs` is `true`:
@@ -766,6 +828,9 @@ Write `.planning/.auto-next` containing the next logical command (e.g., `/pbr:pl
766
828
  - [ ] Pending todos evaluated (Step 8e-ii)
767
829
  - [ ] Clearly-satisfied todos auto-closed via `pbr-tools.js todo done`
768
830
 
831
+ To verify programmatically: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js step-verify build step-8e '["STATE.md updated","commit made"]'`
832
+ If any item fails, investigate before closing the session.
833
+
769
834
  **8e-ii. Check Pending Todos:**
770
835
 
771
836
  **CRITICAL (no hook): Check pending todos after build. Do NOT skip this step.**
@@ -56,6 +56,7 @@ Parse the phase number and optional flags:
56
56
  | `3 --gaps` | Create gap-closure plans for phase 3 (from VERIFICATION.md) |
57
57
  | `3 --teams` | Plan phase 3 using specialist agent teams |
58
58
  | (no number) | Use current phase from STATE.md |
59
+ | `3 --preview` | Preview what planning would produce for phase 3 without spawning agents |
59
60
 
60
61
  ### Subcommands
61
62
 
@@ -124,6 +125,35 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut (`state lo
124
125
  5. If no phase number given, read current phase from `.planning/STATE.md`
125
126
  6. **CONTEXT.md existence check**: If the phase is non-trivial (has 2+ requirements or success criteria), check whether a CONTEXT.md exists at EITHER `.planning/CONTEXT.md` (project-level) OR `.planning/phases/{NN}-{slug}/CONTEXT.md` (phase-level). If NEITHER exists, warn: "Phase {N} has no CONTEXT.md. Consider running `/pbr:discuss {N}` first to capture your preferences. Continue anyway?" If user says no, stop. If yes, continue. If at least one exists, proceed without warning.
126
127
 
128
+ #### --preview mode
129
+
130
+ If `--preview` is present in `$ARGUMENTS`:
131
+
132
+ 1. Detect the `--preview` flag and extract the phase number.
133
+ 2. Render the following dry-run banner:
134
+
135
+ ```
136
+ ╔══════════════════════════════════════════════════════════════╗
137
+ ║ DRY RUN — /pbr:plan {N} --preview ║
138
+ ║ No researchers or planners will be spawned ║
139
+ ╚══════════════════════════════════════════════════════════════╝
140
+ ```
141
+
142
+ 3. Show the 5 steps that would occur:
143
+
144
+ 1. Parse ROADMAP.md for phase {N} goal, dependencies, and requirements
145
+ 2. Spawn researcher agents to investigate codebase and gather context
146
+ 3. Spawn planner agent to write PLAN files based on research
147
+ 4. Run plan-checker to validate structure and completeness
148
+ 5. Present plans for your approval before building
149
+
150
+ 4. Show estimated agent spawns: ~2-4 agents (1-2 researchers + 1 planner + 1 plan-checker)
151
+ 5. Show output location: `.planning/phases/{NN}-{slug}/PLAN-NN.md`
152
+
153
+ 6. **STOP** — do not proceed to Step 2.
154
+
155
+ ---
156
+
127
157
  **If phase already has plans:**
128
158
  - Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
129
159
  question: "Phase {N} already has plans. Re-plan from scratch?"
@@ -252,21 +282,25 @@ Output format: Return both sections as markdown. End with ## BRIEFING COMPLETE."
252
282
  ```
253
283
 
254
284
  After the Task() completes:
255
- - If `## Seeds` section contains matches: present them to the user via AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`):
256
- question: "Include these {N} seeds in planning?"
257
- header: "Seeds?"
258
- options:
259
- - label: "Yes, all" description: "Include all {N} matching seeds"
260
- - label: "Let me pick" description: "Choose which seeds to include"
261
- - label: "No" description: "Proceed without seeds"
262
- - If "Yes, all": include seed content in planner context
263
- - If "Let me pick": present individual seeds for selection
264
- - If "No": proceed without seeds
265
-
266
- - If `## Deferred Ideas` section has items: present via AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
267
- question: "Include these deferred ideas in planning context?"
268
- - If "Yes": append to planner context under `Deferred ideas to consider:`
269
- - If "No": proceed without changes
285
+ - If `## Seeds` section contains matches:
286
+ - If `gates.confirm_seeds` is `true` in config: present them to the user via AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`):
287
+ question: "Include these {N} seeds in planning?"
288
+ header: "Seeds?"
289
+ options:
290
+ - label: "Yes, all" description: "Include all {N} matching seeds"
291
+ - label: "Let me pick" description: "Choose which seeds to include"
292
+ - label: "No" description: "Proceed without seeds"
293
+ - If "Yes, all": include seed content in planner context
294
+ - If "Let me pick": present individual seeds for selection
295
+ - If "No": proceed without seeds
296
+ - If `gates.confirm_seeds` is `false` (default): automatically include all matching seeds in planner context without prompting. Log: "Including {N} seeds automatically (gates.confirm_seeds=false)."
297
+
298
+ - If `## Deferred Ideas` section has items:
299
+ - If `gates.confirm_deferred` is `true` in config: present via AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
300
+ question: "Include these deferred ideas in planning context?"
301
+ - If "Yes": append to planner context under `Deferred ideas to consider:`
302
+ - If "No": proceed without changes
303
+ - If `gates.confirm_deferred` is `false` (default): automatically append deferred ideas to planner context without prompting. Log: "Including deferred ideas automatically (gates.confirm_deferred=false)."
270
304
 
271
305
  - If both sections are empty: proceed silently to Step 5 (no AskUserQuestion needed)
272
306
 
@@ -555,10 +589,26 @@ Read `skills/plan/templates/gap-closure-prompt.md.tmpl` and use it as the prompt
555
589
  ## Error Handling
556
590
 
557
591
  ### Phase not found
558
- If the specified phase doesn't exist in ROADMAP.md, display a branded error box — see `skills/shared/error-reporting.md`, pattern: Phase not found.
592
+ If the specified phase doesn't exist in ROADMAP.md, use conversational recovery:
593
+
594
+ 1. Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives phase-not-found {slug}`
595
+ 2. Parse the JSON response to get `available` phases and `suggestions` (closest matches).
596
+ 3. Display: "Phase '{slug}' not found. Did you mean one of these?"
597
+ - List `suggestions` (if any) as numbered options.
598
+ - Offer "Show all phases" to list `available`.
599
+ 4. Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`) to let the user pick a phase or abort.
600
+ - If user picks a valid phase slug: re-run with that slug.
601
+ - If user chooses to abort: stop cleanly with a friendly message.
559
602
 
560
603
  ### Missing prerequisites
561
- If REQUIREMENTS.md or ROADMAP.md don't exist, display a branded error box — see `skills/shared/error-reporting.md`, pattern: Missing prerequisites.
604
+ If REQUIREMENTS.md or ROADMAP.md don't exist, use conversational recovery:
605
+
606
+ 1. Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives missing-prereq {phase}`
607
+ 2. Parse the JSON response to get `existing_summaries`, `missing_summaries`, and `suggested_action`.
608
+ 3. Display what is already complete and what is missing.
609
+ 4. Use AskUserQuestion to offer: "Run /pbr:build {prerequisite-phase} first, or continue anyway?"
610
+ - If user chooses to continue: proceed with planning (note missing prereqs in plan frontmatter).
611
+ - If user chooses to build first: stop and display the suggested build command.
562
612
 
563
613
  ### Research agent fails
564
614
  If the researcher Task() fails, display:
@@ -76,7 +76,18 @@ Execute these steps in order.
76
76
  5. If no phase number given, read current phase from `.planning/STATE.md`
77
77
  6. If `.planning/.auto-verify` signal file exists, read it and note the auto-verification was already queued. Delete the signal file after reading (one-shot, same pattern as auto-continue.js).
78
78
 
79
- **Validation errors — use branded error boxes:**
79
+ **Validation errors:**
80
+
81
+ If phase directory not found, use conversational recovery:
82
+
83
+ 1. Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives phase-not-found {slug}`
84
+ 2. Parse the JSON response to get `available` phases and `suggestions` (closest matches).
85
+ 3. Display: "Phase '{slug}' not found. Did you mean one of these?"
86
+ - List `suggestions` (if any) as numbered options.
87
+ - Offer "Show all phases" to list `available`.
88
+ 4. Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`) to let the user pick a phase or abort.
89
+ - If user picks a valid phase slug: re-run with that slug.
90
+ - If user chooses to abort: stop cleanly with a friendly message.
80
91
 
81
92
  If no SUMMARY.md files:
82
93
  ```