@sienklogic/plan-build-run 2.53.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 (43) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +2 -2
  3. package/plugins/copilot-pbr/commands/setup.md +1 -1
  4. package/plugins/copilot-pbr/commands/undo.md +5 -0
  5. package/plugins/copilot-pbr/plugin.json +1 -1
  6. package/plugins/copilot-pbr/skills/begin/SKILL.md +170 -17
  7. package/plugins/copilot-pbr/skills/build/SKILL.md +73 -8
  8. package/plugins/copilot-pbr/skills/plan/SKILL.md +67 -17
  9. package/plugins/copilot-pbr/skills/review/SKILL.md +12 -1
  10. package/plugins/copilot-pbr/skills/setup/SKILL.md +66 -214
  11. package/plugins/copilot-pbr/skills/shared/context-budget.md +27 -0
  12. package/plugins/copilot-pbr/skills/status/SKILL.md +44 -2
  13. package/plugins/copilot-pbr/skills/undo/SKILL.md +172 -0
  14. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  15. package/plugins/cursor-pbr/commands/setup.md +1 -1
  16. package/plugins/cursor-pbr/commands/undo.md +5 -0
  17. package/plugins/cursor-pbr/skills/begin/SKILL.md +170 -17
  18. package/plugins/cursor-pbr/skills/build/SKILL.md +73 -8
  19. package/plugins/cursor-pbr/skills/plan/SKILL.md +67 -17
  20. package/plugins/cursor-pbr/skills/review/SKILL.md +12 -1
  21. package/plugins/cursor-pbr/skills/setup/SKILL.md +66 -214
  22. package/plugins/cursor-pbr/skills/shared/context-budget.md +27 -0
  23. package/plugins/cursor-pbr/skills/status/SKILL.md +44 -2
  24. package/plugins/cursor-pbr/skills/undo/SKILL.md +173 -0
  25. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
  26. package/plugins/pbr/commands/setup.md +1 -1
  27. package/plugins/pbr/commands/undo.md +5 -0
  28. package/plugins/pbr/scripts/config-schema.json +5 -1
  29. package/plugins/pbr/scripts/lib/alternatives.js +203 -0
  30. package/plugins/pbr/scripts/lib/preview.js +174 -0
  31. package/plugins/pbr/scripts/lib/skill-section.js +99 -0
  32. package/plugins/pbr/scripts/lib/step-verify.js +149 -0
  33. package/plugins/pbr/scripts/pbr-tools.js +122 -2
  34. package/plugins/pbr/scripts/validate-commit.js +2 -2
  35. package/plugins/pbr/skills/begin/SKILL.md +170 -17
  36. package/plugins/pbr/skills/begin/templates/config.json.tmpl +5 -1
  37. package/plugins/pbr/skills/build/SKILL.md +73 -8
  38. package/plugins/pbr/skills/plan/SKILL.md +67 -17
  39. package/plugins/pbr/skills/review/SKILL.md +12 -1
  40. package/plugins/pbr/skills/setup/SKILL.md +66 -214
  41. package/plugins/pbr/skills/shared/context-budget.md +27 -0
  42. package/plugins/pbr/skills/status/SKILL.md +44 -2
  43. package/plugins/pbr/skills/undo/SKILL.md +174 -0
@@ -57,6 +57,7 @@ Parse the phase number and optional flags:
57
57
  | `3 --gaps` | Create gap-closure plans for phase 3 (from VERIFICATION.md) |
58
58
  | `3 --teams` | Plan phase 3 using specialist agent teams |
59
59
  | (no number) | Use current phase from STATE.md |
60
+ | `3 --preview` | Preview what planning would produce for phase 3 without spawning agents |
60
61
 
61
62
  ### Subcommands
62
63
 
@@ -125,6 +126,35 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut (`state lo
125
126
  5. If no phase number given, read current phase from `.planning/STATE.md`
126
127
  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.
127
128
 
129
+ #### --preview mode
130
+
131
+ If `--preview` is present in `$ARGUMENTS`:
132
+
133
+ 1. Detect the `--preview` flag and extract the phase number.
134
+ 2. Render the following dry-run banner:
135
+
136
+ ```
137
+ ╔══════════════════════════════════════════════════════════════╗
138
+ ║ DRY RUN — /pbr:plan {N} --preview ║
139
+ ║ No researchers or planners will be spawned ║
140
+ ╚══════════════════════════════════════════════════════════════╝
141
+ ```
142
+
143
+ 3. Show the 5 steps that would occur:
144
+
145
+ 1. Parse ROADMAP.md for phase {N} goal, dependencies, and requirements
146
+ 2. Spawn researcher agents to investigate codebase and gather context
147
+ 3. Spawn planner agent to write PLAN files based on research
148
+ 4. Run plan-checker to validate structure and completeness
149
+ 5. Present plans for your approval before building
150
+
151
+ 4. Show estimated agent spawns: ~2-4 agents (1-2 researchers + 1 planner + 1 plan-checker)
152
+ 5. Show output location: `.planning/phases/{NN}-{slug}/PLAN-NN.md`
153
+
154
+ 6. **STOP** — do not proceed to Step 2.
155
+
156
+ ---
157
+
128
158
  **If phase already has plans:**
129
159
  - Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
130
160
  question: "Phase {N} already has plans. Re-plan from scratch?"
@@ -253,21 +283,25 @@ Output format: Return both sections as markdown. End with ## BRIEFING COMPLETE."
253
283
  ```
254
284
 
255
285
  After the Task() completes:
256
- - If `## Seeds` section contains matches: present them to the user via AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`):
257
- question: "Include these {N} seeds in planning?"
258
- header: "Seeds?"
259
- options:
260
- - label: "Yes, all" description: "Include all {N} matching seeds"
261
- - label: "Let me pick" description: "Choose which seeds to include"
262
- - label: "No" description: "Proceed without seeds"
263
- - If "Yes, all": include seed content in planner context
264
- - If "Let me pick": present individual seeds for selection
265
- - If "No": proceed without seeds
266
-
267
- - If `## Deferred Ideas` section has items: present via AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
268
- question: "Include these deferred ideas in planning context?"
269
- - If "Yes": append to planner context under `Deferred ideas to consider:`
270
- - If "No": proceed without changes
286
+ - If `## Seeds` section contains matches:
287
+ - 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`):
288
+ question: "Include these {N} seeds in planning?"
289
+ header: "Seeds?"
290
+ options:
291
+ - label: "Yes, all" description: "Include all {N} matching seeds"
292
+ - label: "Let me pick" description: "Choose which seeds to include"
293
+ - label: "No" description: "Proceed without seeds"
294
+ - If "Yes, all": include seed content in planner context
295
+ - If "Let me pick": present individual seeds for selection
296
+ - If "No": proceed without seeds
297
+ - 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)."
298
+
299
+ - If `## Deferred Ideas` section has items:
300
+ - If `gates.confirm_deferred` is `true` in config: present via AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
301
+ question: "Include these deferred ideas in planning context?"
302
+ - If "Yes": append to planner context under `Deferred ideas to consider:`
303
+ - If "No": proceed without changes
304
+ - 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)."
271
305
 
272
306
  - If both sections are empty: proceed silently to Step 5 (no AskUserQuestion needed)
273
307
 
@@ -556,10 +590,26 @@ Read `skills/plan/templates/gap-closure-prompt.md.tmpl` and use it as the prompt
556
590
  ## Error Handling
557
591
 
558
592
  ### Phase not found
559
- 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.
593
+ If the specified phase doesn't exist in ROADMAP.md, use conversational recovery:
594
+
595
+ 1. Run: `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives phase-not-found {slug}`
596
+ 2. Parse the JSON response to get `available` phases and `suggestions` (closest matches).
597
+ 3. Display: "Phase '{slug}' not found. Did you mean one of these?"
598
+ - List `suggestions` (if any) as numbered options.
599
+ - Offer "Show all phases" to list `available`.
600
+ 4. Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`) to let the user pick a phase or abort.
601
+ - If user picks a valid phase slug: re-run with that slug.
602
+ - If user chooses to abort: stop cleanly with a friendly message.
560
603
 
561
604
  ### Missing prerequisites
562
- If REQUIREMENTS.md or ROADMAP.md don't exist, display a branded error box — see `skills/shared/error-reporting.md`, pattern: Missing prerequisites.
605
+ If REQUIREMENTS.md or ROADMAP.md don't exist, use conversational recovery:
606
+
607
+ 1. Run: `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives missing-prereq {phase}`
608
+ 2. Parse the JSON response to get `existing_summaries`, `missing_summaries`, and `suggested_action`.
609
+ 3. Display what is already complete and what is missing.
610
+ 4. Use AskUserQuestion to offer: "Run /pbr:build {prerequisite-phase} first, or continue anyway?"
611
+ - If user chooses to continue: proceed with planning (note missing prereqs in plan frontmatter).
612
+ - If user chooses to build first: stop and display the suggested build command.
563
613
 
564
614
  ### Research agent fails
565
615
  If the researcher Task() fails, display:
@@ -77,7 +77,18 @@ Execute these steps in order.
77
77
  5. If no phase number given, read current phase from `.planning/STATE.md`
78
78
  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).
79
79
 
80
- **Validation errors — use branded error boxes:**
80
+ **Validation errors:**
81
+
82
+ If phase directory not found, use conversational recovery:
83
+
84
+ 1. Run: `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js suggest-alternatives phase-not-found {slug}`
85
+ 2. Parse the JSON response to get `available` phases and `suggestions` (closest matches).
86
+ 3. Display: "Phase '{slug}' not found. Did you mean one of these?"
87
+ - List `suggestions` (if any) as numbered options.
88
+ - Offer "Show all phases" to list `available`.
89
+ 4. Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`) to let the user pick a phase or abort.
90
+ - If user picks a valid phase slug: re-run with that slug.
91
+ - If user chooses to abort: stop cleanly with a friendly message.
81
92
 
82
93
  If no SUMMARY.md files:
83
94
  ```
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  name: setup
3
- description: "Onboarding wizard. Initialize project, select models, verify setup."
3
+ description: "Reconfigure an existing Plan-Build-Run project (models, features, CLAUDE.md)."
4
4
  allowed-tools: Read, Write, Bash, Glob, AskUserQuestion
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.**
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 tokens. Begin executing Step 1 immediately.**
8
8
 
9
9
  ## Step 0 — Immediate Output
10
10
 
@@ -12,198 +12,54 @@ allowed-tools: Read, Write, Bash, Glob, AskUserQuestion
12
12
 
13
13
  ```
14
14
  ╔══════════════════════════════════════════════════════════════╗
15
- ║ PLAN-BUILD-RUN ► SETUP
15
+ ║ PLAN-BUILD-RUN ► RECONFIGURE
16
16
  ╚══════════════════════════════════════════════════════════════╝
17
17
  ```
18
18
 
19
19
  Then proceed to Step 1.
20
20
 
21
- # /pbr:setup — Plan-Build-Run Setup Wizard
21
+ # /pbr:setup — Plan-Build-Run Reconfigure
22
22
 
23
- You are running the **setup** skill. This is an interactive onboarding wizard that guides users through Plan-Build-Run project setup. Use AskUserQuestion at each step for clear choices.
23
+ You are running the **setup** skill in **reconfigure mode**. This wizard lets existing Plan-Build-Run projects change model profiles, workflow features, and CLAUDE.md integration. It does NOT re-initialize or overwrite project state.
24
24
 
25
25
  ---
26
26
 
27
- ## Step 1: Detect Project State — Idempotency Guard
27
+ ## Step 1: Detect Project State
28
28
 
29
- Check if `.planning/` directory exists in the current working directory.
29
+ Check if `.planning/config.json` exists.
30
30
 
31
- **If `.planning/` exists**:
32
- - Check for existing core files: `STATE.md`, `ROADMAP.md`, `config.json`
33
- - If ANY of these exist, present a checkpoint:
34
-
35
- Use AskUserQuestion:
36
- question: "Existing project detected with {list of found files}. How should we proceed?"
37
- header: "Setup"
38
- options:
39
- - label: "Resume" description: "Keep existing .planning/ and review configuration (recommended)"
40
- - label: "Reset" description: "Archive current .planning/ to .planning.bak/ and start fresh"
41
- - label: "Abort" description: "Cancel setup — keep everything as-is"
42
-
43
- - If "Resume": Tell the user: "Keeping existing project. Reviewing configuration." Skip to Step 3 (model selection)
44
- - If "Reset": Run `mv .planning .planning.bak` (creating a backup), then proceed with fresh setup below
45
- - If "Abort": Display "Setup cancelled. Run `/pbr:status` to see current project state." and stop
46
-
47
- - If `.planning/` exists but has NONE of the core files (empty or only has subdirs):
48
- - Tell the user: "Found empty .planning/ directory. Proceeding with initialization."
49
- - Continue to fresh setup below
50
-
51
- **If `.planning/` does NOT exist**:
52
- - Ask the user:
53
-
54
- ```
55
- AskUserQuestion:
56
- question: "No Plan-Build-Run project found. Would you like to initialize one?"
57
- header: "Initialize"
58
- options:
59
- - label: "Yes, initialize here"
60
- description: "Creates .planning/ directory with default config, STATE.md, and ROADMAP.md"
61
- - label: "No, just exploring"
62
- description: "Exit the wizard — you can run /pbr:begin later for full project setup"
63
- ```
64
-
65
- If "No", display: "Run `/pbr:begin` when you're ready to start a project. It includes deep requirements gathering and roadmap creation." Then stop.
66
-
67
- If "Yes", create the minimal `.planning/` structure:
68
-
69
- **CRITICAL: Create .planning/ directory structure NOW. Do NOT skip this step.**
70
-
71
- ```bash
72
- mkdir -p .planning/phases .planning/todos/pending .planning/todos/done .planning/logs .planning/research
73
- ```
74
-
75
- **CRITICAL: Write .planning/config.json NOW. Do NOT skip this step.**
76
-
77
- Before writing config.json, check for user-level defaults:
78
-
79
- ```bash
80
- node "${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js" config load-defaults
81
- ```
82
-
83
- If user defaults exist (the output has keys like `mode`, `features`, etc.), inform the user: "Found your saved preferences from ~/.claude/pbr-defaults.json. These will be merged into your project config (project-specific settings take precedence)." Then deep-merge user defaults into the config below before writing.
84
-
85
- Create `.planning/config.json` with defaults (merged with user defaults if they exist):
86
- ```json
87
- {
88
- "version": 2,
89
- "context_strategy": "aggressive",
90
- "mode": "interactive",
91
- "depth": "standard",
92
- "features": {
93
- "structured_planning": true,
94
- "goal_verification": true,
95
- "integration_verification": true,
96
- "context_isolation": true,
97
- "atomic_commits": true,
98
- "session_persistence": true,
99
- "research_phase": true,
100
- "plan_checking": true,
101
- "tdd_mode": false,
102
- "status_line": true,
103
- "auto_continue": false,
104
- "auto_advance": false,
105
- "team_discussions": false,
106
- "inline_verify": false
107
- },
108
- "models": {
109
- "researcher": "sonnet",
110
- "planner": "inherit",
111
- "executor": "inherit",
112
- "verifier": "sonnet",
113
- "integration_checker": "sonnet",
114
- "debugger": "inherit",
115
- "mapper": "sonnet",
116
- "synthesizer": "sonnet"
117
- },
118
- "parallelization": {
119
- "enabled": true,
120
- "plan_level": true,
121
- "task_level": false,
122
- "max_concurrent_agents": 3,
123
- "min_plans_for_parallel": 2,
124
- "use_teams": false
125
- },
126
- "planning": {
127
- "commit_docs": true,
128
- "max_tasks_per_plan": 3,
129
- "search_gitignored": false
130
- },
131
- "git": {
132
- "branching": "none",
133
- "commit_format": "{type}({phase}-{plan}): {description}",
134
- "phase_branch_template": "plan-build-run/phase-{phase}-{slug}",
135
- "milestone_branch_template": "plan-build-run/{milestone}-{slug}",
136
- "mode": "enabled"
137
- },
138
- "gates": {
139
- "confirm_project": true,
140
- "confirm_roadmap": true,
141
- "confirm_plan": true,
142
- "confirm_execute": false,
143
- "confirm_transition": true,
144
- "issues_review": true
145
- },
146
- "safety": {
147
- "always_confirm_destructive": true,
148
- "always_confirm_external_services": true
149
- }
150
- }
151
- ```
152
-
153
- **CRITICAL: Write .planning/STATE.md NOW. Do NOT skip this step.**
154
-
155
- Create `.planning/STATE.md`:
156
- ```markdown
157
- ---
158
- version: 2
159
- current_phase: 0
160
- total_phases: 0
161
- status: "initialized"
162
- progress_percent: 0
163
- last_activity: "{today's date}"
164
- last_command: "/pbr:setup"
165
- blockers: []
166
- ---
167
- # Project State
168
-
169
- ## Current Position
170
- Phase: 0 of 0
171
- Status: initialized
172
-
173
- Plan-Build-Run project initialized via /pbr:setup. Run /pbr:begin to start requirements gathering and roadmap creation.
31
+ **If `.planning/config.json` does NOT exist:**
32
+ Display:
174
33
  ```
34
+ No Plan-Build-Run project found in this directory.
175
35
 
176
- ---
177
-
178
- ## Step 2: Project Type (new projects only)
36
+ /pbr:setup is for reconfiguring existing projects.
37
+ To start a new project, run: /pbr:begin
179
38
 
39
+ /pbr:begin includes everything /pbr:setup used to do, plus deep requirements gathering and roadmap creation.
180
40
  ```
181
- AskUserQuestion:
182
- question: "What kind of project is this?"
183
- header: "Project type"
184
- options:
185
- - label: "Greenfield"
186
- description: "Starting from scratch — full planning cycle recommended"
187
- - label: "Existing codebase"
188
- description: "Adding Plan-Build-Run to an existing project — run /pbr:scan first"
189
- - label: "Prototype/experiment"
190
- description: "Quick iteration — lighter workflow with fewer gates"
191
- ```
192
-
193
- Based on selection:
194
- - **Greenfield**: Keep defaults (full gates, structured planning)
195
- - **Existing codebase**: Suggest running `/pbr:scan` after setup to map the codebase
196
- - **Prototype**: Set `depth: "quick"`, disable `gates.verification`, disable `gates.review`, set `features.research_phase: false`
41
+ Stop. Do not proceed further.
197
42
 
198
- Update config.json with any changes.
43
+ **If `.planning/config.json` exists:**
44
+ - Read `.planning/config.json`
45
+ - Display the current settings summary:
46
+ ```
47
+ Current configuration:
48
+ - Model profile: {derived from models block — balanced/quality/budget or custom}
49
+ - Depth: {depth}
50
+ - Mode: {mode}
51
+ - Auto-continue: {features.auto_continue}
52
+ - TDD mode: {features.tdd_mode}
53
+ - Git branching: {git.branching}
54
+ ```
55
+ - Proceed to Step 2.
199
56
 
200
57
  ---
201
58
 
202
- ## Step 3: Model Selection
59
+ ## Step 2: Model Selection
203
60
 
204
- ```
205
- AskUserQuestion:
206
- question: "Which model profile should Plan-Build-Run use for agents?"
61
+ Use AskUserQuestion:
62
+ question: "Which model profile should agents use?"
207
63
  header: "Models"
208
64
  options:
209
65
  - label: "Balanced (Recommended)"
@@ -212,19 +68,20 @@ AskUserQuestion:
212
68
  description: "Opus for executor and planner, Sonnet for others. Best results, highest cost."
213
69
  - label: "Budget"
214
70
  description: "Haiku for most agents. Fastest and cheapest, but lower quality."
215
- ```
71
+ - label: "Keep current"
72
+ description: "Leave model settings unchanged."
216
73
 
217
- Apply the selected profile to `config.json`:
74
+ Apply the selected profile to the models block in config.json:
218
75
  - **Balanced**: executor=sonnet, researcher=sonnet, planner=sonnet, verifier=sonnet, synthesizer=haiku
219
76
  - **Quality**: executor=opus, researcher=sonnet, planner=opus, verifier=sonnet, synthesizer=sonnet
220
77
  - **Budget**: executor=haiku, researcher=haiku, planner=sonnet, verifier=haiku, synthesizer=haiku
78
+ - **Keep current**: no change to models block
221
79
 
222
80
  ---
223
81
 
224
- ## Step 4: Workflow Preferences
82
+ ## Step 3: Workflow Features
225
83
 
226
- ```
227
- AskUserQuestion:
84
+ Use AskUserQuestion:
228
85
  question: "Which workflow features do you want enabled?"
229
86
  header: "Features"
230
87
  multiSelect: true
@@ -237,9 +94,8 @@ AskUserQuestion:
237
94
  description: "Require verification AND review to pass before advancing phases"
238
95
  - label: "Git branching"
239
96
  description: "Create a branch per phase for cleaner PR history"
240
- ```
241
97
 
242
- Apply selections:
98
+ Apply selections (others unchanged):
243
99
  - **Auto-continue**: Set `features.auto_continue: true`
244
100
  - **TDD mode**: Set `features.tdd_mode: true`
245
101
  - **Strict gates**: Set `gates.verification: true`, `gates.review: true`, `gates.plan_approval: true`
@@ -247,15 +103,23 @@ Apply selections:
247
103
 
248
104
  ---
249
105
 
250
- ## Step 4b: CLAUDE.md Integration
106
+ ## Step 4: CLAUDE.md Integration
251
107
 
252
108
  Check if a `CLAUDE.md` file exists in the project root.
253
109
 
254
- **If it exists**: Read it. If it does NOT already contain a "Plan-Build-Run" section, append the block below.
255
- **If it does NOT exist**: Create `CLAUDE.md` with the block below.
110
+ **If it exists**: Read it. If it does NOT already contain a "Plan-Build-Run" section, offer to append the integration block.
111
+ **If it does NOT exist**: Offer to create `CLAUDE.md` with the integration block.
256
112
 
257
- Append/create this content:
113
+ Use AskUserQuestion:
114
+ question: "Update CLAUDE.md with Plan-Build-Run integration notes?"
115
+ header: "CLAUDE.md"
116
+ options:
117
+ - label: "Yes"
118
+ description: "Add or update the Plan-Build-Run section in CLAUDE.md"
119
+ - label: "No"
120
+ description: "Skip — leave CLAUDE.md as-is"
258
121
 
122
+ If "Yes", append/create:
259
123
  ```markdown
260
124
  ## Plan-Build-Run
261
125
 
@@ -270,49 +134,37 @@ This project uses [Plan-Build-Run](https://github.com/SienkLogic/plan-build-run)
270
134
 
271
135
  ---
272
136
 
273
- ## Step 5: Verification
137
+ ## Step 5: Write Updated Config
274
138
 
275
- **CRITICAL: Run validation checks NOW to confirm setup succeeded. Do NOT skip this step.**
139
+ **CRITICAL: Write `.planning/config.json` NOW with all changes from Steps 2-3. Do NOT skip this step.**
276
140
 
277
- Run a quick health check:
141
+ Write the updated config.json to disk with all applied changes.
278
142
 
279
- 1. Verify `.planning/config.json` is valid JSON
280
- 2. Verify `.planning/STATE.md` exists and is parseable
281
- 3. Verify hook scripts are accessible: `node ${CLAUDE_PLUGIN_ROOT}/scripts/progress-tracker.js` from the project directory
282
- 4. Check that `npm test` works (if package.json exists)
143
+ ---
283
144
 
284
- Display results:
145
+ ## Step 6: Verification
285
146
 
286
- ```
287
- ╔══════════════════════════════════════════════════════════════╗
288
- ║ PLAN-BUILD-RUN SETUP COMPLETE ✓ ║
289
- ╚══════════════════════════════════════════════════════════════╝
290
-
291
- Project: {cwd basename}
292
- Model profile: {balanced/quality/budget}
293
- Depth: {quick/standard/comprehensive}
294
- Features: {list of enabled non-default features}
147
+ Run a quick check:
148
+ 1. Verify `.planning/config.json` is valid JSON (read it back)
149
+ 2. Display updated settings summary
295
150
 
151
+ Display:
152
+ ```
296
153
  ╔══════════════════════════════════════════════════════════════╗
297
- NEXT UP
154
+ PLAN-BUILD-RUN RECONFIGURE COMPLETE ✓
298
155
  ╚══════════════════════════════════════════════════════════════╝
299
156
 
300
- **Start your project** — define requirements and create a roadmap
301
-
302
- `/pbr:begin`
303
-
304
- <sub>`/clear` first → fresh context window</sub>
157
+ Updated:
158
+ - Model profile: {new profile}
159
+ - Features changed: {list or "none"}
160
+ - CLAUDE.md: {updated/skipped}
305
161
 
306
- **Also available:**
307
- - `/pbr:scan` — analyze existing codebase (if adding to existing project)
308
- - `/pbr:config` — fine-tune individual settings
309
- - `/pbr:help` — command reference
162
+ Run /pbr:status to see current project state.
310
163
  ```
311
164
 
312
165
  ---
313
166
 
314
167
  ## Error Handling
315
168
 
316
- - If `.planning/` creation fails (permissions): Tell user to create it manually and retry
169
+ - If config.json parse fails: Display the raw content and ask user to fix it manually, then retry
317
170
  - If config.json write fails: Display the JSON content and ask user to save it manually
318
- - If health check fails: Display specific failure and suggest `/pbr:health` for diagnostics
@@ -48,3 +48,30 @@ Additionally for this skill:
48
48
  - {Skill-specific rule 1}
49
49
  - {Skill-specific rule 2}
50
50
  ```
51
+
52
+ ## Agent Elapsed Time Estimates
53
+
54
+ When displaying agent spawn lines (e.g., "Spawning researcher..."), append a parenthetical estimate:
55
+
56
+ | Agent Type | Display Text | Estimate |
57
+ |------------|-------------|----------|
58
+ | researcher | Spawning researcher... | (est. 1-3 min) |
59
+ | planner | Spawning planner... | (est. 2-5 min) |
60
+ | executor | Spawning executor... | (est. 3-8 min) |
61
+ | verifier | Spawning verifier... | (est. 1-2 min) |
62
+ | codebase-mapper | Spawning codebase-mapper... | (est. 1-2 min) |
63
+ | plan-checker | Spawning plan-checker... | (est. 1-2 min) |
64
+ | integration-checker | Spawning integration-checker... | (est. 2-4 min) |
65
+ | debugger | Spawning debugger... | (est. 2-5 min) |
66
+ | general | Spawning agent... | (est. 1-4 min) |
67
+ | audit | Spawning audit... | (est. 2-4 min) |
68
+
69
+ **Usage**: In any skill that spawns Task() agents, prefix spawn displays with the agent name and append the estimate from this table. Example:
70
+
71
+ ```
72
+ Spawning researcher... (est. 1-3 min)
73
+ Spawning planner... (est. 2-5 min)
74
+ [Wave 1: 3 plans in parallel] Spawning executors... (est. 3-8 min each)
75
+ ```
76
+
77
+ Skills that spawn agents: build, plan, review, debug, scan, milestone, quick.
@@ -98,6 +98,20 @@ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js llm metrics --session <content-o
98
98
 
99
99
  If `local_llm.enabled` is `false` or commands fail, skip this step silently.
100
100
 
101
+ ### Step 1c: Read Context Budget (advisory — skip on any error)
102
+
103
+ Run:
104
+ ```bash
105
+ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js context-triage
106
+ ```
107
+
108
+ Parse the JSON response. Capture:
109
+ - `tier` — one of PEAK / GOOD / DEGRADING / POOR / CRITICAL
110
+ - `percentage` — numeric 0-100 (or null if unavailable)
111
+ - `recommendation` — PROCEED / CHECKPOINT / COMPACT
112
+
113
+ Store these for use in Step 4 display and Step 5 routing.
114
+
101
115
  ### Step 2: Scan Phase Directories
102
116
 
103
117
  For each phase listed in ROADMAP.md:
@@ -171,6 +185,18 @@ If any discrepancy found, add: `Run /pbr:resume to auto-reconcile STATE.md.`
171
185
  - Check `.planning/todos/pending/` for pending todo files
172
186
  - Count and summarize if any exist
173
187
 
188
+ #### Critical Path
189
+ Identify the single next-blocking item — the one phase or plan whose completion unblocks the most downstream work.
190
+
191
+ Logic:
192
+ 1. From ROADMAP.md dependency graph, find all phases that are NOT yet verified.
193
+ 2. For each unverified phase, count how many other unverified phases list it in `depends_on` (direct + transitive).
194
+ 3. The phase with the highest downstream dependent count is the critical-path phase.
195
+ 4. If all unverified phases are independent (no dependencies between them), the critical path is the current phase from STATE.md.
196
+ 5. Within the critical-path phase, the critical-path plan is the lowest-numbered plan without a SUMMARY.md.
197
+
198
+ Store: `criticalPhase` (number + name), `criticalPlan` (plan ID or null if phase not yet planned), `criticalCount` (number of downstream phases blocked).
199
+
174
200
  #### Quick Notes
175
201
  - Check `.planning/notes/` directory for note files (individual `.md` files)
176
202
  - Count active notes (files where frontmatter does NOT contain `promoted: true`)
@@ -196,6 +222,19 @@ Phase Status:
196
222
  | 2. {name} | {status indicator} {status text} | {completed}/{total} | {percentage}% |
197
223
  | ...
198
224
 
225
+ {If context tier is DEGRADING, POOR, or CRITICAL:}
226
+ ⚠ Context: {percentage}% used ({tier}) — {recommendation_text}
227
+ Run `/compact` to reclaim context before spawning more agents.
228
+
229
+ Where `{recommendation_text}` maps:
230
+ - DEGRADING → "quality may degrade on complex agents"
231
+ - POOR → "context window is filling up"
232
+ - CRITICAL → "STOP — compact before continuing"
233
+
234
+ {If criticalPhase is identified AND criticalCount >= 1 AND there are 2+ unverified phases with dependencies:}
235
+ Critical Path: Phase {N} — {phase name}{, Plan {criticalPlan} is next} [BLOCKING {criticalCount} downstream phase(s)]
236
+ {Else: omit — not meaningful when only one phase remains or no inter-phase dependencies exist}
237
+
199
238
  {If blockers exist:}
200
239
  Blockers:
201
240
  - {blocker 1}
@@ -313,7 +352,10 @@ Based on the project state, suggest the single most logical next action:
313
352
 
314
353
  `{suggested command}`
315
354
 
316
- <sub>`/clear` first fresh context window</sub>
355
+ {If context percentage > 40% OR tier is DEGRADING/POOR/CRITICAL:}
356
+ <sub>`/clear` first → fresh context window ({percentage}% used)</sub>
357
+ {Else: omit the /clear hint entirely}
358
+ {If `percentage` is null (no context data): omit the hint}
317
359
 
318
360
 
319
361
  ```
@@ -390,7 +432,7 @@ This skill should be fast. It's a status check, not an analysis.
390
432
 
391
433
  - Read full SUMMARY.md contents (frontmatter is enough)
392
434
  - Read plan file contents (just check existence)
393
- - Run Bash commands except for Step 1b (2-3 `pbr-tools` calls only when `local_llm.enabled: true`, skipped entirely otherwise)
435
+ - Run Bash commands except for Step 1b (`pbr-tools llm` calls only when `local_llm.enabled: true`) and Step 1c (`pbr-tools context-triage`, always run but skip on error)
394
436
  - Modify any files
395
437
  - Spawn any Task agents
396
438