@sienklogic/plan-build-run 2.0.0 → 2.0.2

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 (233) hide show
  1. package/CHANGELOG.md +56 -56
  2. package/CLAUDE.md +149 -149
  3. package/LICENSE +21 -21
  4. package/README.md +247 -247
  5. package/dashboard/bin/cli.js +25 -25
  6. package/dashboard/package.json +34 -34
  7. package/dashboard/public/css/layout.css +406 -406
  8. package/dashboard/public/css/status-colors.css +98 -98
  9. package/dashboard/public/js/htmx-title.js +5 -5
  10. package/dashboard/public/js/sidebar-toggle.js +20 -20
  11. package/dashboard/src/app.js +78 -78
  12. package/dashboard/src/middleware/errorHandler.js +52 -52
  13. package/dashboard/src/middleware/notFoundHandler.js +9 -9
  14. package/dashboard/src/repositories/planning.repository.js +128 -128
  15. package/dashboard/src/routes/events.routes.js +40 -40
  16. package/dashboard/src/routes/index.routes.js +31 -31
  17. package/dashboard/src/routes/pages.routes.js +245 -195
  18. package/dashboard/src/server.js +42 -42
  19. package/dashboard/src/services/dashboard.service.js +222 -222
  20. package/dashboard/src/services/phase.service.js +220 -167
  21. package/dashboard/src/services/project.service.js +57 -57
  22. package/dashboard/src/services/roadmap.service.js +171 -171
  23. package/dashboard/src/services/sse.service.js +58 -58
  24. package/dashboard/src/services/todo.service.js +254 -254
  25. package/dashboard/src/services/watcher.service.js +48 -48
  26. package/dashboard/src/views/coming-soon.ejs +11 -11
  27. package/dashboard/src/views/error.ejs +13 -13
  28. package/dashboard/src/views/index.ejs +5 -5
  29. package/dashboard/src/views/layout.ejs +1 -1
  30. package/dashboard/src/views/partials/dashboard-content.ejs +77 -77
  31. package/dashboard/src/views/partials/footer.ejs +3 -3
  32. package/dashboard/src/views/partials/head.ejs +21 -21
  33. package/dashboard/src/views/partials/header.ejs +12 -12
  34. package/dashboard/src/views/partials/layout-bottom.ejs +15 -15
  35. package/dashboard/src/views/partials/layout-top.ejs +8 -8
  36. package/dashboard/src/views/partials/phase-content.ejs +188 -181
  37. package/dashboard/src/views/partials/phase-doc-content.ejs +38 -0
  38. package/dashboard/src/views/partials/phases-content.ejs +117 -117
  39. package/dashboard/src/views/partials/roadmap-content.ejs +142 -142
  40. package/dashboard/src/views/partials/sidebar.ejs +38 -38
  41. package/dashboard/src/views/partials/todo-create-content.ejs +53 -53
  42. package/dashboard/src/views/partials/todo-detail-content.ejs +38 -38
  43. package/dashboard/src/views/partials/todos-content.ejs +53 -53
  44. package/dashboard/src/views/phase-detail.ejs +5 -5
  45. package/dashboard/src/views/phase-doc.ejs +5 -0
  46. package/dashboard/src/views/phases.ejs +5 -5
  47. package/dashboard/src/views/roadmap.ejs +5 -5
  48. package/dashboard/src/views/todo-create.ejs +5 -5
  49. package/dashboard/src/views/todo-detail.ejs +5 -5
  50. package/dashboard/src/views/todos.ejs +5 -5
  51. package/package.json +57 -57
  52. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +22 -0
  53. package/plugins/cursor-pbr/agents/.gitkeep +0 -0
  54. package/plugins/cursor-pbr/assets/.gitkeep +0 -0
  55. package/plugins/cursor-pbr/hooks/hooks.json +11 -0
  56. package/plugins/cursor-pbr/references/.gitkeep +0 -0
  57. package/plugins/cursor-pbr/rules/.gitkeep +0 -0
  58. package/plugins/cursor-pbr/skills/.gitkeep +0 -0
  59. package/plugins/cursor-pbr/templates/.gitkeep +0 -0
  60. package/plugins/pbr/.claude-plugin/plugin.json +13 -13
  61. package/plugins/pbr/UI-CONSISTENCY-GAPS.md +61 -61
  62. package/plugins/pbr/agents/codebase-mapper.md +279 -271
  63. package/plugins/pbr/agents/debugger.md +281 -281
  64. package/plugins/pbr/agents/executor.md +428 -407
  65. package/plugins/pbr/agents/general.md +164 -164
  66. package/plugins/pbr/agents/integration-checker.md +169 -141
  67. package/plugins/pbr/agents/plan-checker.md +296 -280
  68. package/plugins/pbr/agents/planner.md +358 -358
  69. package/plugins/pbr/agents/researcher.md +363 -363
  70. package/plugins/pbr/agents/synthesizer.md +230 -230
  71. package/plugins/pbr/agents/verifier.md +489 -454
  72. package/plugins/pbr/commands/begin.md +5 -5
  73. package/plugins/pbr/commands/build.md +5 -5
  74. package/plugins/pbr/commands/config.md +5 -5
  75. package/plugins/pbr/commands/continue.md +5 -5
  76. package/plugins/pbr/commands/debug.md +5 -5
  77. package/plugins/pbr/commands/discuss.md +5 -5
  78. package/plugins/pbr/commands/explore.md +5 -5
  79. package/plugins/pbr/commands/health.md +5 -5
  80. package/plugins/pbr/commands/help.md +5 -5
  81. package/plugins/pbr/commands/import.md +5 -5
  82. package/plugins/pbr/commands/milestone.md +5 -5
  83. package/plugins/pbr/commands/note.md +5 -5
  84. package/plugins/pbr/commands/pause.md +5 -5
  85. package/plugins/pbr/commands/plan.md +5 -5
  86. package/plugins/pbr/commands/quick.md +5 -5
  87. package/plugins/pbr/commands/resume.md +5 -5
  88. package/plugins/pbr/commands/review.md +5 -5
  89. package/plugins/pbr/commands/scan.md +5 -5
  90. package/plugins/pbr/commands/setup.md +5 -5
  91. package/plugins/pbr/commands/status.md +5 -5
  92. package/plugins/pbr/commands/todo.md +5 -5
  93. package/plugins/pbr/contexts/dev.md +27 -27
  94. package/plugins/pbr/contexts/research.md +28 -28
  95. package/plugins/pbr/contexts/review.md +36 -36
  96. package/plugins/pbr/hooks/hooks.json +183 -183
  97. package/plugins/pbr/references/agent-anti-patterns.md +24 -24
  98. package/plugins/pbr/references/agent-interactions.md +134 -134
  99. package/plugins/pbr/references/agent-teams.md +54 -54
  100. package/plugins/pbr/references/checkpoints.md +157 -157
  101. package/plugins/pbr/references/common-bug-patterns.md +13 -13
  102. package/plugins/pbr/references/config-reference.md +441 -0
  103. package/plugins/pbr/references/continuation-format.md +212 -212
  104. package/plugins/pbr/references/deviation-rules.md +112 -112
  105. package/plugins/pbr/references/git-integration.md +226 -226
  106. package/plugins/pbr/references/integration-patterns.md +117 -117
  107. package/plugins/pbr/references/model-profiles.md +99 -99
  108. package/plugins/pbr/references/model-selection.md +31 -31
  109. package/plugins/pbr/references/pbr-rules.md +193 -193
  110. package/plugins/pbr/references/plan-authoring.md +181 -181
  111. package/plugins/pbr/references/plan-format.md +287 -283
  112. package/plugins/pbr/references/planning-config.md +213 -213
  113. package/plugins/pbr/references/questioning.md +214 -214
  114. package/plugins/pbr/references/reading-verification.md +127 -127
  115. package/plugins/pbr/references/stub-patterns.md +160 -160
  116. package/plugins/pbr/references/subagent-coordination.md +119 -119
  117. package/plugins/pbr/references/ui-formatting.md +461 -399
  118. package/plugins/pbr/references/verification-patterns.md +198 -198
  119. package/plugins/pbr/references/wave-execution.md +95 -95
  120. package/plugins/pbr/scripts/auto-continue.js +80 -80
  121. package/plugins/pbr/scripts/check-dangerous-commands.js +136 -136
  122. package/plugins/pbr/scripts/check-doc-sprawl.js +102 -102
  123. package/plugins/pbr/scripts/check-phase-boundary.js +196 -196
  124. package/plugins/pbr/scripts/check-plan-format.js +270 -270
  125. package/plugins/pbr/scripts/check-roadmap-sync.js +322 -252
  126. package/plugins/pbr/scripts/check-skill-workflow.js +262 -262
  127. package/plugins/pbr/scripts/check-state-sync.js +476 -476
  128. package/plugins/pbr/scripts/check-subagent-output.js +144 -144
  129. package/plugins/pbr/scripts/config-schema.json +251 -251
  130. package/plugins/pbr/scripts/context-budget-check.js +287 -287
  131. package/plugins/pbr/scripts/event-handler.js +151 -151
  132. package/plugins/pbr/scripts/event-logger.js +92 -92
  133. package/plugins/pbr/scripts/hook-logger.js +80 -76
  134. package/plugins/pbr/scripts/hooks-schema.json +79 -79
  135. package/plugins/pbr/scripts/log-subagent.js +164 -152
  136. package/plugins/pbr/scripts/log-tool-failure.js +88 -88
  137. package/plugins/pbr/scripts/pbr-tools.js +1378 -1301
  138. package/plugins/pbr/scripts/post-write-dispatch.js +66 -66
  139. package/plugins/pbr/scripts/post-write-quality.js +207 -207
  140. package/plugins/pbr/scripts/pre-bash-dispatch.js +86 -56
  141. package/plugins/pbr/scripts/pre-write-dispatch.js +97 -62
  142. package/plugins/pbr/scripts/progress-tracker.js +281 -228
  143. package/plugins/pbr/scripts/run-hook.js +92 -0
  144. package/plugins/pbr/scripts/session-cleanup.js +254 -254
  145. package/plugins/pbr/scripts/status-line.js +288 -285
  146. package/plugins/pbr/scripts/suggest-compact.js +119 -119
  147. package/plugins/pbr/scripts/task-completed.js +45 -45
  148. package/plugins/pbr/scripts/track-context-budget.js +149 -119
  149. package/plugins/pbr/scripts/validate-commit.js +200 -200
  150. package/plugins/pbr/scripts/validate-plugin-structure.js +183 -172
  151. package/plugins/pbr/scripts/validate-task.js +106 -0
  152. package/plugins/pbr/skills/begin/SKILL.md +594 -545
  153. package/plugins/pbr/skills/begin/templates/PROJECT.md.tmpl +33 -33
  154. package/plugins/pbr/skills/begin/templates/REQUIREMENTS.md.tmpl +18 -18
  155. package/plugins/pbr/skills/begin/templates/STATE.md.tmpl +49 -49
  156. package/plugins/pbr/skills/begin/templates/config.json.tmpl +64 -63
  157. package/plugins/pbr/skills/begin/templates/researcher-prompt.md.tmpl +19 -19
  158. package/plugins/pbr/skills/begin/templates/roadmap-prompt.md.tmpl +30 -30
  159. package/plugins/pbr/skills/begin/templates/synthesis-prompt.md.tmpl +16 -16
  160. package/plugins/pbr/skills/build/SKILL.md +943 -962
  161. package/plugins/pbr/skills/config/SKILL.md +256 -241
  162. package/plugins/pbr/skills/continue/SKILL.md +164 -127
  163. package/plugins/pbr/skills/debug/SKILL.md +515 -489
  164. package/plugins/pbr/skills/debug/templates/continuation-prompt.md.tmpl +16 -16
  165. package/plugins/pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +27 -27
  166. package/plugins/pbr/skills/discuss/SKILL.md +347 -338
  167. package/plugins/pbr/skills/discuss/templates/CONTEXT.md.tmpl +61 -61
  168. package/plugins/pbr/skills/discuss/templates/decision-categories.md +9 -9
  169. package/plugins/pbr/skills/explore/SKILL.md +378 -362
  170. package/plugins/pbr/skills/health/SKILL.md +221 -186
  171. package/plugins/pbr/skills/health/templates/check-pattern.md.tmpl +30 -30
  172. package/plugins/pbr/skills/health/templates/output-format.md.tmpl +63 -63
  173. package/plugins/pbr/skills/help/SKILL.md +155 -140
  174. package/plugins/pbr/skills/import/SKILL.md +504 -490
  175. package/plugins/pbr/skills/milestone/SKILL.md +704 -673
  176. package/plugins/pbr/skills/milestone/templates/audit-report.md.tmpl +48 -48
  177. package/plugins/pbr/skills/milestone/templates/stats-file.md.tmpl +30 -30
  178. package/plugins/pbr/skills/note/SKILL.md +231 -212
  179. package/plugins/pbr/skills/pause/SKILL.md +249 -235
  180. package/plugins/pbr/skills/pause/templates/continue-here.md.tmpl +71 -71
  181. package/plugins/pbr/skills/plan/SKILL.md +685 -628
  182. package/plugins/pbr/skills/plan/decimal-phase-calc.md +98 -98
  183. package/plugins/pbr/skills/plan/templates/checker-prompt.md.tmpl +21 -21
  184. package/plugins/pbr/skills/plan/templates/gap-closure-prompt.md.tmpl +32 -32
  185. package/plugins/pbr/skills/plan/templates/planner-prompt.md.tmpl +38 -38
  186. package/plugins/pbr/skills/plan/templates/researcher-prompt.md.tmpl +19 -19
  187. package/plugins/pbr/skills/plan/templates/revision-prompt.md.tmpl +23 -23
  188. package/plugins/pbr/skills/quick/SKILL.md +354 -335
  189. package/plugins/pbr/skills/resume/SKILL.md +402 -388
  190. package/plugins/pbr/skills/review/SKILL.md +686 -652
  191. package/plugins/pbr/skills/review/templates/debugger-prompt.md.tmpl +60 -60
  192. package/plugins/pbr/skills/review/templates/gap-planner-prompt.md.tmpl +40 -40
  193. package/plugins/pbr/skills/review/templates/verifier-prompt.md.tmpl +115 -115
  194. package/plugins/pbr/skills/scan/SKILL.md +304 -269
  195. package/plugins/pbr/skills/scan/templates/mapper-prompt.md.tmpl +201 -201
  196. package/plugins/pbr/skills/setup/SKILL.md +253 -227
  197. package/plugins/pbr/skills/shared/commit-planning-docs.md +35 -35
  198. package/plugins/pbr/skills/shared/config-loading.md +102 -102
  199. package/plugins/pbr/skills/shared/context-budget.md +40 -40
  200. package/plugins/pbr/skills/shared/context-loader-task.md +86 -86
  201. package/plugins/pbr/skills/shared/digest-select.md +79 -79
  202. package/plugins/pbr/skills/shared/domain-probes.md +125 -125
  203. package/plugins/pbr/skills/shared/error-reporting.md +79 -79
  204. package/plugins/pbr/skills/shared/gate-prompts.md +388 -388
  205. package/plugins/pbr/skills/shared/phase-argument-parsing.md +45 -45
  206. package/plugins/pbr/skills/shared/progress-display.md +53 -53
  207. package/plugins/pbr/skills/shared/revision-loop.md +81 -81
  208. package/plugins/pbr/skills/shared/state-loading.md +62 -62
  209. package/plugins/pbr/skills/shared/state-update.md +161 -161
  210. package/plugins/pbr/skills/shared/universal-anti-patterns.md +33 -33
  211. package/plugins/pbr/skills/status/SKILL.md +367 -353
  212. package/plugins/pbr/skills/todo/SKILL.md +198 -181
  213. package/plugins/pbr/templates/CONTEXT.md.tmpl +52 -52
  214. package/plugins/pbr/templates/INTEGRATION-REPORT.md.tmpl +151 -151
  215. package/plugins/pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -97
  216. package/plugins/pbr/templates/ROADMAP.md.tmpl +40 -40
  217. package/plugins/pbr/templates/SUMMARY.md.tmpl +81 -81
  218. package/plugins/pbr/templates/VERIFICATION-DETAIL.md.tmpl +116 -116
  219. package/plugins/pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -98
  220. package/plugins/pbr/templates/codebase/CONCERNS.md.tmpl +93 -93
  221. package/plugins/pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -104
  222. package/plugins/pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -78
  223. package/plugins/pbr/templates/codebase/STACK.md.tmpl +78 -78
  224. package/plugins/pbr/templates/codebase/STRUCTURE.md.tmpl +80 -80
  225. package/plugins/pbr/templates/codebase/TESTING.md.tmpl +107 -107
  226. package/plugins/pbr/templates/continue-here.md.tmpl +73 -73
  227. package/plugins/pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -37
  228. package/plugins/pbr/templates/research/ARCHITECTURE.md.tmpl +124 -124
  229. package/plugins/pbr/templates/research/STACK.md.tmpl +71 -71
  230. package/plugins/pbr/templates/research/SUMMARY.md.tmpl +112 -112
  231. package/plugins/pbr/templates/research-outputs/phase-research.md.tmpl +81 -81
  232. package/plugins/pbr/templates/research-outputs/project-research.md.tmpl +99 -99
  233. package/plugins/pbr/templates/research-outputs/synthesis.md.tmpl +36 -36
@@ -1,628 +1,685 @@
1
- ---
2
- name: plan
3
- description: "Create a detailed plan for a phase. Research, plan, and verify before building."
4
- allowed-tools: Read, Write, Bash, Glob, Grep, WebFetch, WebSearch, Task, AskUserQuestion
5
- argument-hint: "<phase-number> [--skip-research] [--assumptions] [--gaps] | add | insert <N> | remove <N>"
6
- ---
7
-
8
- # /pbr:plan Phase Planning
9
-
10
- You are the orchestrator for `/pbr:plan`. This skill creates detailed, executable plans for a specific phase. Plans are the bridge between the roadmap and actual code they must be specific enough for an executor agent to follow mechanically. Your job is to stay lean, delegate heavy work to Task() subagents, and keep the user's main context window clean.
11
-
12
- ## Context Budget
13
-
14
- Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
15
-
16
- Additionally for this skill:
17
- - **Minimize** reading subagent output — read only plan frontmatter for summaries
18
- - **Delegate** all research and planning work to subagents — the orchestrator routes, it doesn't plan
19
-
20
- ## Prerequisites
21
-
22
- - `.planning/config.json` exists (run `/pbr:begin` first)
23
- - `.planning/ROADMAP.md` exists with at least one phase
24
- - `.planning/REQUIREMENTS.md` exists
25
-
26
- ---
27
-
28
- ## Argument Parsing
29
-
30
- Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
31
-
32
- ### Standard Invocation
33
-
34
- `/pbr:plan <N>` — Plan phase N
35
-
36
- Parse the phase number and optional flags:
37
-
38
- | Argument | Meaning |
39
- |----------|---------|
40
- | `3` | Plan phase 3 |
41
- | `3 --skip-research` | Plan phase 3, skip research step |
42
- | `3 --assumptions` | Surface assumptions before planning phase 3 |
43
- | `3 --gaps` | Create gap-closure plans for phase 3 (from VERIFICATION.md) |
44
- | `3 --teams` | Plan phase 3 using specialist agent teams |
45
- | (no number) | Use current phase from STATE.md |
46
-
47
- ### Subcommands
48
-
49
- | Subcommand | Meaning |
50
- |------------|---------|
51
- | `add` | Append a new phase to the end of the roadmap |
52
- | `insert <N>` | Insert a new phase at position N (uses decimal numbering) |
53
- | `remove <N>` | Remove phase N from the roadmap |
54
-
55
- ### Freeform Text Guard
56
-
57
- **Before any context loading**, check whether `$ARGUMENTS` looks like freeform text rather than a valid invocation. Valid patterns are:
58
-
59
- - Empty (no arguments)
60
- - A phase number: integer (`3`, `03`) or decimal (`3.1`)
61
- - A subcommand: `add`, `insert <N>`, `remove <N>`
62
- - A phase number followed by flags: `3 --skip-research`, `3 --assumptions`, `3 --gaps`, `3 --teams`
63
- - The word `check` (legacy alias)
64
-
65
- If `$ARGUMENTS` does NOT match any of these patterns — i.e., it contains freeform words that are not a recognized subcommand or flag then **stop execution** and respond:
66
-
67
- ```
68
- `/pbr:plan` expects a phase number or subcommand.
69
-
70
- Usage:
71
- /pbr:plan <N> Plan phase N
72
- /pbr:plan <N> --gaps Create gap-closure plans
73
- /pbr:plan add Add a new phase
74
- /pbr:plan insert <N> Insert a phase at position N
75
- /pbr:plan remove <N> Remove phase N
76
- ```
77
-
78
- Then suggest the appropriate skill based on the text content:
79
-
80
- | If the text looks like... | Suggest |
81
- |---------------------------|---------|
82
- | A task, idea, or feature request | `/pbr:todo` to capture it, or `/pbr:explore` to investigate |
83
- | A bug or debugging request | `/pbr:debug` to investigate the issue |
84
- | A review or quality concern | `/pbr:review` to assess existing work |
85
- | Anything else | `/pbr:explore` for open-ended work |
86
-
87
- Do NOT proceed with planning. The user needs to use the correct skill.
88
-
89
- ---
90
-
91
- ## Orchestration Flow: Standard Planning
92
-
93
- Execute these steps in order for standard `/pbr:plan <N>` invocations.
94
-
95
- ---
96
-
97
- ### Step 1: Parse and Validate (inline)
98
-
99
- Reference: `skills/shared/config-loading.md` for the tooling shortcut (`state load`, `plan-index`, `phase-info`) and config field reference.
100
-
101
- 1. Parse `$ARGUMENTS` for phase number and flags
102
- 2. Read `.planning/config.json` for settings (see config-loading.md for field reference)
103
- 3. Resolve depth profile: run `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` to get the effective feature/gate settings for the current depth. Store the result for use in later gating decisions.
104
- 4. Validate:
105
- - Phase exists in ROADMAP.md
106
- - Phase directory exists at `.planning/phases/{NN}-{slug}/`
107
- - Phase does not already have PLAN.md files (unless user confirms re-planning)
108
- 4. If no phase number given, read current phase from `.planning/STATE.md`
109
- 5. **CONTEXT.md existence check**: If the phase is non-trivial (has 2+ requirements or success criteria), check whether `.planning/CONTEXT.md` exists. If missing, 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.
110
-
111
- **If phase already has plans:**
112
- - Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
113
- question: "Phase {N} already has plans. Re-plan from scratch?"
114
- header: "Re-plan?"
115
- options:
116
- - label: "Yes" description: "Delete existing plans and create new ones"
117
- - label: "No" description: "Keep existing plans unchanged"
118
- - If "Yes": delete existing PLAN.md files in the phase directory
119
- - If "No" or "Other": stop
120
-
121
- ---
122
-
123
- ### Step 2: Load Context (inline)
124
-
125
- Read context file PATHS and metadata. Build lean context bundles for subagent prompts — include paths and one-line descriptions, NOT full file bodies. Agents have the Read tool and will pull file contents on-demand.
126
-
127
- ```
128
- 1. Read .planning/ROADMAP.md — extract current phase goal, dependencies, requirements
129
- 2. Read .planning/REQUIREMENTS.md — extract requirements mapped to this phase
130
- 3. Read .planning/CONTEXT.md (if exists) extract only the `## Decision Summary` section (everything from `## Decision Summary` to the next `##` heading). If no Decision Summary section exists (legacy CONTEXT.md), fall back to extracting the full `## Decisions (LOCKED...)` and `## Deferred Ideas` sections.
131
- 4. Read .planning/phases/{NN}-{slug}/CONTEXT.md (if exists) extract only the `## Decision Summary` section. Fall back to full locked decisions + deferred sections if no Decision Summary exists.
132
- 5. Read .planning/config.json extract feature flags, depth, model settings
133
- 6. List prior SUMMARY.md file paths and extract frontmatter metadata only (status, provides, key_files). Do NOT read full SUMMARY bodies — agents pull these on-demand via Read tool.
134
- 7. Read .planning/research/SUMMARY.md (if exists) — extract research findings
135
- ```
136
-
137
- **Digest-select depth for prior SUMMARYs (Step 6):**
138
-
139
- Reference: `skills/shared/digest-select.md` for the full depth rules and examples. In short: direct dependencies get frontmatter + key decisions, transitive get frontmatter only, 2+ back get skipped.
140
-
141
- Collect all of this into a context bundle that will be passed to subagents.
142
-
143
- ---
144
-
145
- ### Step 3: Assumption Surfacing (inline, if `--assumptions` flag)
146
-
147
- **IMPORTANT**: This step is FREE (no subagents). It happens entirely inline.
148
-
149
- Before spawning any agents, present your assumptions about how this phase should be approached:
150
-
151
- ```
152
- Phase {N}: {Name}
153
- Goal: {from roadmap}
154
-
155
- My assumptions about this phase:
156
-
157
- 1. **Approach**: I'm assuming we'll {approach}
158
- - Correct? [yes/no/adjust]
159
-
160
- 2. **Key technology**: I'm assuming we'll use {tech}
161
- - Correct? [yes/no/adjust]
162
-
163
- 3. **Architecture**: I'm assuming {architectural assumption}
164
- - Correct? [yes/no/adjust]
165
-
166
- 4. **Scope boundary**: I'm assuming {scope assumption}
167
- - Correct? [yes/no/adjust]
168
- ```
169
-
170
- For each assumption the user corrects:
171
- - Record the correction
172
- - These corrections become additional CONTEXT.md entries
173
-
174
- After all assumptions are confirmed/corrected:
175
- - Update `.planning/CONTEXT.md` with any new locked decisions
176
- - Continue to Step 4
177
-
178
- ---
179
-
180
- ### Step 4: Phase Research (delegated, conditional)
181
-
182
- **Skip this step if ANY of these are true:**
183
- - `--skip-research` flag is set
184
- - `--gaps` flag is set
185
- - Depth profile has `features.research_phase: false`
186
-
187
- To check: run `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` and read `profile["features.research_phase"]`. This replaces checking `features.research_phase` and `depth` separately -- the depth profile already incorporates both.
188
-
189
- **Conditional research (standard/balanced mode):** When the profile has `features.research_phase: true`, also check whether `.planning/codebase/` or `.planning/research/` already contains relevant context for this phase. If substantial context exists (>3 files in codebase/ or a RESEARCH.md mentioning this phase's technologies), skip research and note: "Skipping research -- existing context found in {directory}." This implements the balanced mode's "conditional research" behavior.
190
-
191
- **If research is needed:**
192
-
193
- Display to the user: `◐ Spawning researcher...`
194
-
195
- Spawn a researcher Task():
196
-
197
- ```
198
- Task({
199
- subagent_type: "pbr:researcher",
200
- prompt: <phase research prompt>
201
- })
202
-
203
- NOTE: The pbr:researcher subagent type auto-loads the agent definition. Do NOT inline it.
204
- ```
205
-
206
- #### Phase Research Prompt Template
207
-
208
- Read `skills/plan/templates/researcher-prompt.md.tmpl` and use it as the prompt template for spawning the researcher agent. Fill in the placeholders with phase-specific context:
209
- - `{NN}` - phase number (zero-padded)
210
- - `{phase name}` - phase name from roadmap
211
- - `{goal from roadmap}` - phase goal statement
212
- - `{REQ-IDs mapped to this phase}` - requirement IDs
213
- - `{dependencies from roadmap}` - dependency list
214
- - Fill `<project_context>` and `<prior_work>` blocks per the shared partial (`templates/prompt-partials/phase-project-context.md.tmpl`): Decision Summary for context, manifest table for prior work
215
-
216
- Wait for the researcher to complete before proceeding.
217
-
218
- ---
219
-
220
- ### Step 4.5: Seed Scanning (inline, before planning)
221
-
222
- Before spawning the planner, scan `.planning/seeds/` for seeds whose trigger matches the current phase:
223
-
224
- 1. Glob for `.planning/seeds/*.md`
225
- 2. For each seed file, read its frontmatter and check the `trigger` field
226
- 3. A seed matches if ANY of these are true:
227
- - `trigger` equals the phase slug (e.g., `trigger: authentication`) — **preferred**
228
- - `trigger` is a substring of the phase directory name (e.g., `trigger: auth` matches `03-authentication`)
229
- - `trigger` equals the current phase number as integer (e.g., `trigger: 3`) backward compatible but NOT recommended for new seeds (breaks with decimal phases like 3.1)
230
- - `trigger` equals `*` (always matches)
231
- 4. If matching seeds are found, present them to the user:
232
- ```
233
- Found {N} seeds related to Phase {NN}:
234
- - {seed_name}: {seed description}
235
- - {seed_name}: {seed description}
236
- ```
237
-
238
- Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`):
239
- question: "Include these {N} seeds in planning?"
240
- header: "Seeds?"
241
- options:
242
- - label: "Yes, all" description: "Include all {N} matching seeds"
243
- - label: "Let me pick" description: "Choose which seeds to include"
244
- - label: "No" description: "Proceed without seeds"
245
- 5. If "Yes, all": include all matching seed content in the planner's context
246
- 6. If "Let me pick": present individual seeds for selection
247
- 7. If "No" or "Other": proceed without seeds
248
- 8. If no matching seeds found: proceed silently
249
-
250
- ---
251
-
252
- ### Step 5: Planning (delegated)
253
-
254
- #### Team Mode (--teams)
255
-
256
- Reference: `references/agent-teams.md` for team role definitions and coordination details.
257
-
258
- If `--teams` flag is set OR `config.parallelization.use_teams` is true:
259
-
260
- 1. Create the team output directory: `.planning/phases/{NN}-{slug}/team/`
261
- 2. Display to the user: `◐ Spawning 3 planners in parallel (architect, security, test)...`
262
-
263
- Spawn THREE planner agents in parallel using Task():
264
-
265
- **Agent 1 -- Architect**:
266
- - subagent_type: "pbr:planner"
267
- - Prompt includes: "You are the ARCHITECT role in a planning team. Focus on: structure, file boundaries, dependency ordering, wave assignment. Write your output to `.planning/phases/{NN}-{slug}/team/architect-PLAN.md`. Do NOT write final PLAN.md files -- your output will be synthesized."
268
- - Include phase goal, research doc paths, CONTEXT.md path in the prompt
269
-
270
- **Agent 2 -- Security Reviewer**:
271
- - subagent_type: "pbr:planner"
272
- - Prompt includes: "You are the SECURITY REVIEWER role in a planning team. Focus on: authentication checks, input validation tasks, secrets handling, permission boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/security-PLAN.md`. Do NOT write final PLAN.md files."
273
- - Include same context as Agent 1
274
-
275
- **Agent 3 -- Test Designer**:
276
- - subagent_type: "pbr:planner"
277
- - Prompt includes: "You are the TEST DESIGNER role in a planning team. Focus on: test strategy, coverage targets, edge cases, which tasks should use TDD, integration test boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/test-PLAN.md`. Do NOT write final PLAN.md files."
278
- - Include same context as Agent 1
279
-
280
- 3. Wait for all three to complete
281
- 4. Display to the user: `◐ Spawning synthesizer...`
282
-
283
- Spawn the synthesizer agent:
284
- - subagent_type: "pbr:synthesizer"
285
- - Prompt: "Read all files in `.planning/phases/{NN}-{slug}/team/`. Synthesize them into unified PLAN.md files in `.planning/phases/{NN}-{slug}/`. The architect output provides structure, the security output adds security-related tasks or checks, and the test output informs TDD flags and test tasks. Resolve any contradictions by preferring the architect's structure with security and test additions."
286
- 5. Proceed to plan checking as normal
287
-
288
- If `--teams` is NOT set and `config.parallelization.use_teams` is false or unset, proceed with the existing single-planner flow below.
289
-
290
- #### Single-Planner Flow (default)
291
-
292
- Display to the user: `◐ Spawning planner...`
293
-
294
- Spawn the planner Task() with all context inlined:
295
-
296
- ```
297
- Task({
298
- subagent_type: "pbr:planner",
299
- prompt: <planning prompt>
300
- })
301
-
302
- NOTE: The pbr:planner subagent type auto-loads the agent definition. Do NOT inline it.
303
- ```
304
-
305
- #### Planning Prompt Template
306
-
307
- Read `skills/plan/templates/planner-prompt.md.tmpl` and use it as the prompt template for spawning the planner agent. Fill in all placeholder blocks with phase-specific context:
308
- - `<phase_context>` - phase number, directory, goal, requirements, dependencies, success criteria
309
- - `<project_context>` - locked decisions, user constraints, deferred ideas, phase-specific decisions
310
- - `<prior_work>` - manifest table of preceding phase SUMMARY.md file paths with status and one-line exports (NOT full bodies)
311
- - `<research>` - file path to RESEARCH.md if it exists (NOT inlined content)
312
- - `<config>` - max tasks, parallelization, TDD mode from config.json
313
- - `<planning_instructions>` - phase-specific planning rules and output path
314
-
315
- Wait for the planner to complete.
316
-
317
- ---
318
-
319
- ### Step 6: Plan Validation (delegated, conditional)
320
-
321
- **Skip this step if:**
322
- - Depth profile has `features.plan_checking: false`
323
-
324
- To check: use the resolved depth profile from Step 1. The profile consolidates the depth setting and any user overrides into a single boolean.
325
-
326
- **If validation is enabled:**
327
-
328
- Display to the user: `◐ Spawning plan checker...`
329
-
330
- Spawn the plan checker Task():
331
-
332
- ```
333
- Task({
334
- subagent_type: "pbr:plan-checker",
335
- prompt: <checker prompt>
336
- })
337
-
338
- NOTE: The pbr:plan-checker subagent type auto-loads the agent definition. Do NOT inline it.
339
- ```
340
-
341
- #### Checker Prompt Template
342
-
343
- Read `skills/plan/templates/checker-prompt.md.tmpl` and use it as the prompt template for spawning the plan checker agent. Fill in the placeholders:
344
- - `<plans_to_check>` - manifest table of PLAN.md file paths (checker reads each via Read tool)
345
- - `<phase_context>` - phase goal and requirement IDs
346
- - `<context>` - file paths to project-level and phase-level CONTEXT.md files (checker reads via Read tool)
347
-
348
- **Process checker results:**
349
- - If `VERIFICATION PASSED`: proceed to Step 8
350
- - If issues found: proceed to Step 7
351
-
352
- ---
353
-
354
- ### Step 7: Revision Loop (max 3 iterations)
355
-
356
- Reference: `skills/shared/revision-loop.md` for the full Check-Revise-Escalate pattern.
357
-
358
- Follow the revision loop pattern with:
359
- - **Producer**: planner (re-spawned with `skills/plan/templates/revision-prompt.md.tmpl`)
360
- - **Checker**: plan-checker (back to Step 6)
361
- - **Escalation**: present issues to user, offer "Proceed anyway" or "Adjust approach" (re-enter Step 5)
362
-
363
- ---
364
-
365
- ### Step 8: User Approval (inline, conditional)
366
-
367
- **Skip if:**
368
- - `gates.confirm_plan` is `false` in config
369
- - `mode` is `autonomous` in config
370
-
371
- **If approval is needed:**
372
-
373
- Present a summary of all plans to the user:
374
-
375
- ```
376
- Phase {N}: {name}
377
- Plans: {count}
378
-
379
- Plan {phase}-01: {plan name} (Wave {W}, {task_count} tasks)
380
- Must-haves: {list truths}
381
- Files: {list files_modified}
382
- Tasks:
383
- 1. {task name}
384
- 2. {task name}
385
-
386
- Plan {phase}-02: {plan name} (Wave {W}, {task_count} tasks)
387
- ...
388
-
389
- Wave execution order:
390
- Wave 1: Plan 01, Plan 02 (parallel)
391
- Wave 2: Plan 03 (depends on 01, 02)
392
-
393
- Use AskUserQuestion (pattern: approve-revise-abort from `skills/shared/gate-prompts.md`):
394
- question: "Approve these {count} plans for Phase {N}?"
395
- header: "Approve?"
396
- options:
397
- - label: "Approve" description: "Proceed to build phase"
398
- - label: "Request changes" description: "Discuss adjustments before proceeding"
399
- - label: "Abort" description: "Cancel planning for this phase"
400
- ```
401
-
402
- **If user selects 'Request changes' or 'Other':**
403
- - Discuss what needs to change
404
- - Re-enter Step 5 with updated context/constraints
405
- - Or make small inline edits to plan files directly
406
-
407
- **If user selects 'Approve':**
408
- - **CONTEXT.md compliance reporting**: If `.planning/CONTEXT.md` exists, compare all locked decisions against the generated plans. Print: "CONTEXT.md compliance: {M}/{N} locked decisions mapped to tasks" where M = locked decisions that are reflected in at least one task, N = total locked decisions. If any locked decisions are unmapped, list them as warnings.
409
- - **Dependency fingerprinting**: For each dependency phase (phases that this phase depends on, per ROADMAP.md):
410
- 1. Find all SUMMARY.md files in the dependency phase directory
411
- 2. Compute a simple hash of each SUMMARY.md file (e.g., first 8 chars of a SHA-256 of the file content, or a simpler approach: use the file's byte length + last-modified timestamp as a fingerprint string)
412
- 3. Add a `dependency_fingerprints` field to each plan's YAML frontmatter:
413
- ```yaml
414
- dependency_fingerprints:
415
- "01-01": "len:4856-mod:2025-02-08T09:40"
416
- "01-02": "len:4375-mod:2025-02-08T09:43"
417
- ```
418
- 4. This allows the build skill to detect if dependency phases were re-built after this plan was created
419
- - **Update ROADMAP.md Progress table** (REQUIRED — do this BEFORE updating STATE.md):
420
-
421
- **Tooling shortcut**: Use the CLI for atomic updates:
422
- ```bash
423
- node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-plans {phase} 0 {N}
424
- node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-status {phase} planned
425
- node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state update status planned
426
- node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state update last_activity now
427
- ```
428
-
429
- 1. Open `.planning/ROADMAP.md`
430
- 2. Find the `## Progress` table
431
- 3. Locate the row matching this phase number
432
- 4. Update the `Plans Complete` column to `0/{N}` where N = number of plan files just created
433
- 5. Update the `Status` column to `planned`
434
- 6. Save the file — do NOT skip this step
435
- - Update STATE.md: set current phase plan status to "planned"
436
- - **If `features.auto_advance` is `true` AND `mode` is `autonomous`:** Chain directly to build: `Skill({ skill: "dev:build", args: "{N}" })`. This continues the build→review→plan→build cycle automatically.
437
- - **Otherwise:** Suggest next action: `/pbr:build {N}`
438
-
439
- ---
440
-
441
- ## Orchestration Flow: Subcommands
442
-
443
- ### Subcommand: `add`
444
-
445
- 1. Read `.planning/ROADMAP.md`
446
- 2. Calculate next phase number (last phase + 1)
447
- 3. Ask user: "What's the goal for this new phase?"
448
- 4. Ask user: "What requirements does it address?" (show available unassigned REQ-IDs)
449
- 5. Ask user: "What phases does it depend on?"
450
- 6. Append phase to ROADMAP.md
451
- 7. Create phase directory: `.planning/phases/{NN}-{slug}/`
452
- 8. Update STATE.md if needed
453
- 9. Suggest: `/pbr:plan {N}` to plan the new phase
454
-
455
- ### Subcommand: `insert <N>`
456
-
457
- Reference: `skills/plan/decimal-phase-calc.md` for decimal numbering rules.
458
-
459
- 1. Read `.planning/ROADMAP.md`
460
- 2. Calculate decimal phase number:
461
- - If inserting at position 3: becomes 3.1
462
- - If 3.1 already exists: becomes 3.2
463
- - Etc. (see decimal-phase-calc.md)
464
- 3. Ask user for phase goal, requirements, dependencies
465
- 4. Insert phase into ROADMAP.md at the correct position
466
- 5. Create phase directory: `.planning/phases/{NN.M}-{slug}/`
467
- 6. Update dependencies of subsequent phases if affected
468
- 7. Suggest: `/pbr:plan {N.M}` to plan the new phase
469
-
470
- ### Subcommand: `remove <N>`
471
-
472
- 1. Read `.planning/ROADMAP.md`
473
- 2. Validate:
474
- - Phase must exist
475
- - Phase must be in `pending` or `not started` status (cannot remove completed/in-progress phases)
476
- - No other phases depend on this phase (or user confirms breaking dependencies)
477
- 3. Confirm with user: "Remove Phase {N}: {name}? This will delete the phase directory and renumber subsequent phases."
478
- 4. If confirmed:
479
- - Delete `.planning/phases/{NN}-{slug}/` directory
480
- - Remove phase from ROADMAP.md
481
- - Renumber subsequent phases (N+1 becomes N, etc.)
482
- - Update all `depends_on` references in ROADMAP.md
483
- - Update STATE.md if needed
484
-
485
- ---
486
-
487
- ## Orchestration Flow: Gap Closure (`--gaps`)
488
-
489
- When invoked with `--gaps`:
490
-
491
- 1. Read `.planning/phases/{NN}-{slug}/VERIFICATION.md`
492
- - If no VERIFICATION.md exists: tell user "No verification report found. Run `/pbr:review {N}` first."
493
- 2. Extract all gaps from the verification report
494
- 3. Spawn planner Task() in Gap Closure mode:
495
-
496
- Read `skills/plan/templates/gap-closure-prompt.md.tmpl` and use it as the prompt template for the gap closure planner. Fill in the placeholders:
497
- - `<verification_report>` - inline the FULL VERIFICATION.md content
498
- - `<existing_plans>` - inline all existing PLAN.md files for the phase
499
- - `<gap_closure_instructions>` - specify output path and gap_closure frontmatter flag
500
-
501
- 4. After gap-closure plans are created:
502
- - Run plan checker (if enabled)
503
- - Present to user for approval
504
- - Suggest: `/pbr:build {N} --gaps-only`
505
-
506
- ---
507
-
508
- ## Error Handling
509
-
510
- ### Phase not found
511
- If the specified phase doesn't exist in ROADMAP.md, display:
512
- ```
513
- ╔══════════════════════════════════════════════════════════════╗
514
- ║ ERROR ║
515
- ╚══════════════════════════════════════════════════════════════╝
516
-
517
- Phase {N} not found in ROADMAP.md.
518
-
519
- **To fix:** Run `/pbr:status` to see available phases.
520
- ```
521
-
522
- ### Missing prerequisites
523
- If REQUIREMENTS.md or ROADMAP.md don't exist, display:
524
- ```
525
- ╔══════════════════════════════════════════════════════════════╗
526
- ║ ERROR ║
527
- ╚══════════════════════════════════════════════════════════════╝
528
-
529
- Project not initialized. Missing REQUIREMENTS.md or ROADMAP.md.
530
-
531
- **To fix:** Run `/pbr:begin` first.
532
- ```
533
-
534
- ### Research agent fails
535
- If the researcher Task() fails, display:
536
- ```
537
- Research agent failed. Planning without phase-specific research.
538
- This may result in less accurate plans.
539
- ```
540
- Continue to the planning step.
541
-
542
- ### Planner agent fails
543
- If the planner Task() fails, display:
544
- ```
545
- ╔══════════════════════════════════════════════════════════════╗
546
- ║ ERROR ║
547
- ╚══════════════════════════════════════════════════════════════╝
548
-
549
- Planner agent failed for Phase {N}.
550
-
551
- **To fix:**
552
- - Try again with `/pbr:plan {N} --skip-research`
553
- - Check `.planning/CONTEXT.md` for conflicting constraints
554
- ```
555
-
556
- ### Checker loops forever
557
- After 3 revision iterations without passing, display:
558
- ```
559
- ╔══════════════════════════════════════════════════════════════╗
560
- ║ ERROR ║
561
- ╚══════════════════════════════════════════════════════════════╝
562
-
563
- Plan checker failed to pass after 3 revision iterations for Phase {N}.
564
-
565
- **To fix:**
566
- - Review the remaining issues below and decide whether to proceed or revise manually
567
- - Run `/pbr:plan {N}` to restart planning from scratch
568
- ```
569
-
570
- Present remaining issues and ask user to decide: proceed or intervene.
571
-
572
- ---
573
-
574
- ## Files Created/Modified by /pbr:plan
575
-
576
- | File | Purpose | When |
577
- |------|---------|------|
578
- | `.planning/phases/{NN}-{slug}/RESEARCH.md` | Phase-specific research | Step 4 |
579
- | `.planning/phases/{NN}-{slug}/{phase}-{NN}-PLAN.md` | Executable plan files | Step 5 |
580
- | `.planning/CONTEXT.md` | Updated with assumptions | Step 3 (--assumptions) |
581
- | `.planning/ROADMAP.md` | Plans Complete + Status → `planned`; updated for add/insert/remove | Step 8, Subcommands |
582
- | `.planning/STATE.md` | Updated with plan status | Step 8 |
583
-
584
- ---
585
-
586
- ## Completion
587
-
588
- After planning completes, present:
589
-
590
- Use the branded stage banner from `references/ui-formatting.md`:
591
-
592
- ```
593
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
594
- PLAN-BUILD-RUN PLANNING PHASE {N}
595
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
596
-
597
- **Phase {N}: {name}** {plan_count} plans created
598
-
599
- Plans:
600
- {phase}-01: {name} (Wave 1, {task_count} tasks)
601
- {phase}-02: {name} (Wave 1, {task_count} tasks)
602
- {phase}-03: {name} (Wave 2, {task_count} tasks)
603
-
604
- Wave execution:
605
- Wave 1: Plans 01, 02 (parallel)
606
- Wave 2: Plan 03
607
- ```
608
-
609
- Then use the "Next Up" routing block:
610
- ```
611
- ───────────────────────────────────────────────────────────────
612
-
613
- ## Next Up
614
-
615
- **Build Phase {N}** — execute these plans
616
-
617
- /pbr:build {N}
618
-
619
- <sub>/clear first → fresh context window</sub>
620
-
621
- ───────────────────────────────────────────────────────────────
622
-
623
- **Also available:**
624
- - /pbr:plan {N} --assumptions review assumptions first
625
- - /pbr:discuss {N} — talk through details before building
626
-
627
- ───────────────────────────────────────────────────────────────
628
- ```
1
+ ---
2
+ name: plan
3
+ description: "Create a detailed plan for a phase. Research, plan, and verify before building."
4
+ allowed-tools: Read, Write, Bash, Glob, Grep, WebFetch, WebSearch, Task, AskUserQuestion
5
+ argument-hint: "<phase-number> [--skip-research] [--assumptions] [--gaps] | add | insert <N> | remove <N>"
6
+ ---
7
+
8
+ **STOPDO 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.**
9
+
10
+ # /pbr:plan — Phase Planning
11
+
12
+ You are the orchestrator for `/pbr:plan`. This skill creates detailed, executable plans for a specific phase. Plans are the bridge between the roadmap and actual code — they must be specific enough for an executor agent to follow mechanically. Your job is to stay lean, delegate heavy work to Task() subagents, and keep the user's main context window clean.
13
+
14
+ ## Context Budget
15
+
16
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
17
+
18
+ Additionally for this skill:
19
+ - **Minimize** reading subagent output — read only plan frontmatter for summaries
20
+ - **Delegate** all research and planning work to subagents — the orchestrator routes, it doesn't plan
21
+
22
+ ## Step 0 Immediate Output
23
+
24
+ **Before ANY tool calls**, display this banner:
25
+
26
+ ```
27
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28
+ PLAN-BUILD-RUN ► PLANNING PHASE {N}
29
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
30
+ ```
31
+
32
+ Where `{N}` is the phase number from `$ARGUMENTS`. Then proceed to Step 1.
33
+
34
+ ## Prerequisites
35
+
36
+ - `.planning/config.json` exists (run `/pbr:begin` first)
37
+ - `.planning/ROADMAP.md` exists with at least one phase
38
+ - `.planning/REQUIREMENTS.md` exists
39
+
40
+ ---
41
+
42
+ ## Argument Parsing
43
+
44
+ Parse `$ARGUMENTS` according to `skills/shared/phase-argument-parsing.md`.
45
+
46
+ ### Standard Invocation
47
+
48
+ `/pbr:plan <N>` — Plan phase N
49
+
50
+ Parse the phase number and optional flags:
51
+
52
+ | Argument | Meaning |
53
+ |----------|---------|
54
+ | `3` | Plan phase 3 |
55
+ | `3 --skip-research` | Plan phase 3, skip research step |
56
+ | `3 --assumptions` | Surface assumptions before planning phase 3 |
57
+ | `3 --gaps` | Create gap-closure plans for phase 3 (from VERIFICATION.md) |
58
+ | `3 --teams` | Plan phase 3 using specialist agent teams |
59
+ | (no number) | Use current phase from STATE.md |
60
+
61
+ ### Subcommands
62
+
63
+ | Subcommand | Meaning |
64
+ |------------|---------|
65
+ | `add` | Append a new phase to the end of the roadmap |
66
+ | `insert <N>` | Insert a new phase at position N (uses decimal numbering) |
67
+ | `remove <N>` | Remove phase N from the roadmap |
68
+
69
+ ### Freeform Text Guard
70
+
71
+ **Before any context loading**, check whether `$ARGUMENTS` looks like freeform text rather than a valid invocation. Valid patterns are:
72
+
73
+ - Empty (no arguments)
74
+ - A phase number: integer (`3`, `03`) or decimal (`3.1`)
75
+ - A subcommand: `add`, `insert <N>`, `remove <N>`
76
+ - A phase number followed by flags: `3 --skip-research`, `3 --assumptions`, `3 --gaps`, `3 --teams`
77
+ - The word `check` (legacy alias)
78
+
79
+ If `$ARGUMENTS` does NOT match any of these patterns — i.e., it contains freeform words that are not a recognized subcommand or flag — then **stop execution** and respond:
80
+
81
+ ```
82
+ `/pbr:plan` expects a phase number or subcommand.
83
+
84
+ Usage:
85
+ /pbr:plan <N> Plan phase N
86
+ /pbr:plan <N> --gaps Create gap-closure plans
87
+ /pbr:plan add Add a new phase
88
+ /pbr:plan insert <N> Insert a phase at position N
89
+ /pbr:plan remove <N> Remove phase N
90
+ ```
91
+
92
+ Then suggest the appropriate skill based on the text content:
93
+
94
+ | If the text looks like... | Suggest |
95
+ |---------------------------|---------|
96
+ | A task, idea, or feature request | `/pbr:todo` to capture it, or `/pbr:explore` to investigate |
97
+ | A bug or debugging request | `/pbr:debug` to investigate the issue |
98
+ | A review or quality concern | `/pbr:review` to assess existing work |
99
+ | Anything else | `/pbr:explore` for open-ended work |
100
+
101
+ Do NOT proceed with planning. The user needs to use the correct skill.
102
+
103
+ ---
104
+
105
+ ## Orchestration Flow: Standard Planning
106
+
107
+ Execute these steps in order for standard `/pbr:plan <N>` invocations.
108
+
109
+ ---
110
+
111
+ ### Step 1: Parse and Validate (inline)
112
+
113
+ Reference: `skills/shared/config-loading.md` for the tooling shortcut (`state load`, `plan-index`, `phase-info`) and config field reference.
114
+
115
+ 1. Parse `$ARGUMENTS` for phase number and flags
116
+ 2. Read `.planning/config.json` for settings (see config-loading.md for field reference)
117
+ 3. Resolve depth profile: run `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` to get the effective feature/gate settings for the current depth. Store the result for use in later gating decisions.
118
+ 4. Validate:
119
+ - Phase exists in ROADMAP.md
120
+ - Phase directory exists at `.planning/phases/{NN}-{slug}/`
121
+ - Phase does not already have PLAN.md files (unless user confirms re-planning)
122
+ 5. If no phase number given, read current phase from `.planning/STATE.md`
123
+ 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.
124
+
125
+ **If phase already has plans:**
126
+ - Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
127
+ question: "Phase {N} already has plans. Re-plan from scratch?"
128
+ header: "Re-plan?"
129
+ options:
130
+ - label: "Yes" description: "Delete existing plans and create new ones"
131
+ - label: "No" description: "Keep existing plans unchanged"
132
+ - If "Yes": delete existing PLAN.md files in the phase directory
133
+ - If "No" or "Other": stop
134
+
135
+ ---
136
+
137
+ ### Step 2: Load Context (inline)
138
+
139
+ Read context file PATHS and metadata. Build lean context bundles for subagent prompts include paths and one-line descriptions, NOT full file bodies. Agents have the Read tool and will pull file contents on-demand.
140
+
141
+ ```
142
+ 1. Read .planning/ROADMAP.md — extract current phase goal, dependencies, requirements
143
+ 2. Read .planning/REQUIREMENTS.md — extract requirements mapped to this phase
144
+ 3. Read .planning/CONTEXT.md (if exists) — extract only the `## Decision Summary` section (everything from `## Decision Summary` to the next `##` heading). If no Decision Summary section exists (legacy CONTEXT.md), fall back to extracting the full `## Decisions (LOCKED...)` and `## Deferred Ideas` sections.
145
+ 4. Read .planning/phases/{NN}-{slug}/CONTEXT.md (if exists) extract only the `## Decision Summary` section. Fall back to full locked decisions + deferred sections if no Decision Summary exists.
146
+ 5. Read .planning/config.json — extract feature flags, depth, model settings
147
+ 6. List prior SUMMARY.md file paths and extract frontmatter metadata only (status, provides, key_files). Do NOT read full SUMMARY bodies — agents pull these on-demand via Read tool.
148
+ 7. Read .planning/research/SUMMARY.md (if exists) — extract research findings
149
+ ```
150
+
151
+ **Digest-select depth for prior SUMMARYs (Step 6):**
152
+
153
+ Reference: `skills/shared/digest-select.md` for the full depth rules and examples. In short: direct dependencies get frontmatter + key decisions, transitive get frontmatter only, 2+ back get skipped.
154
+
155
+ Collect all of this into a context bundle that will be passed to subagents.
156
+
157
+ ---
158
+
159
+ ### Step 3: Assumption Surfacing (inline, if `--assumptions` flag)
160
+
161
+ **IMPORTANT**: This step is FREE (no subagents). It happens entirely inline.
162
+
163
+ Before spawning any agents, present your assumptions about how this phase should be approached:
164
+
165
+ ```
166
+ Phase {N}: {Name}
167
+ Goal: {from roadmap}
168
+
169
+ My assumptions about this phase:
170
+
171
+ 1. **Approach**: I'm assuming we'll {approach}
172
+ - Correct? [yes/no/adjust]
173
+
174
+ 2. **Key technology**: I'm assuming we'll use {tech}
175
+ - Correct? [yes/no/adjust]
176
+
177
+ 3. **Architecture**: I'm assuming {architectural assumption}
178
+ - Correct? [yes/no/adjust]
179
+
180
+ 4. **Scope boundary**: I'm assuming {scope assumption}
181
+ - Correct? [yes/no/adjust]
182
+ ```
183
+
184
+ For each assumption the user corrects:
185
+ - Record the correction
186
+ - These corrections become additional CONTEXT.md entries
187
+
188
+ After all assumptions are confirmed/corrected:
189
+ - Update `.planning/CONTEXT.md` with any new locked decisions
190
+ - Continue to Step 4
191
+
192
+ ---
193
+
194
+ ### Step 4: Phase Research (delegated, conditional)
195
+
196
+ **Skip this step if ANY of these are true:**
197
+ - `--skip-research` flag is set
198
+ - `--gaps` flag is set
199
+ - Depth profile has `features.research_phase: false`
200
+
201
+ To check: run `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` and read `profile["features.research_phase"]`. This replaces checking `features.research_phase` and `depth` separately -- the depth profile already incorporates both.
202
+
203
+ **Conditional research (standard/balanced mode):** When the profile has `features.research_phase: true`, also check whether `.planning/codebase/` or `.planning/research/` already contains relevant context for this phase. If substantial context exists (>3 files in codebase/ or a RESEARCH.md mentioning this phase's technologies), skip research and note: "Skipping research -- existing context found in {directory}." This implements the balanced mode's "conditional research" behavior.
204
+
205
+ **If research is needed:**
206
+
207
+ Display to the user: `◐ Spawning researcher...`
208
+
209
+ Spawn a researcher Task():
210
+
211
+ ```
212
+ Task({
213
+ subagent_type: "pbr:researcher",
214
+ prompt: <phase research prompt>
215
+ })
216
+
217
+ NOTE: The pbr:researcher subagent type auto-loads the agent definition. Do NOT inline it.
218
+ ```
219
+
220
+ **Path resolution**: Before constructing the agent prompt, resolve `${CLAUDE_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.
221
+
222
+ #### Phase Research Prompt Template
223
+
224
+ Read `skills/plan/templates/researcher-prompt.md.tmpl` and use it as the prompt template for spawning the researcher agent. Fill in the placeholders with phase-specific context:
225
+ - `{NN}` - phase number (zero-padded)
226
+ - `{phase name}` - phase name from roadmap
227
+ - `{goal from roadmap}` - phase goal statement
228
+ - `{REQ-IDs mapped to this phase}` - requirement IDs
229
+ - `{dependencies from roadmap}` - dependency list
230
+ - Fill `<project_context>` and `<prior_work>` blocks per the shared partial (`templates/prompt-partials/phase-project-context.md.tmpl`): Decision Summary for context, manifest table for prior work
231
+
232
+ Wait for the researcher to complete before proceeding.
233
+
234
+ ---
235
+
236
+ ### Step 4.5: Seed Scanning (inline, before planning)
237
+
238
+ Before spawning the planner, scan `.planning/seeds/` for seeds whose trigger matches the current phase:
239
+
240
+ 1. Glob for `.planning/seeds/*.md`
241
+ 2. For each seed file, read its frontmatter and check the `trigger` field
242
+ 3. A seed matches if ANY of these are true:
243
+ - `trigger` equals the phase slug (e.g., `trigger: authentication`) — **preferred**
244
+ - `trigger` is a substring of the phase directory name (e.g., `trigger: auth` matches `03-authentication`)
245
+ - `trigger` equals the current phase number as integer (e.g., `trigger: 3`) backward compatible but NOT recommended for new seeds (breaks with decimal phases like 3.1)
246
+ - `trigger` equals `*` (always matches)
247
+ 4. If matching seeds are found, present them to the user:
248
+ ```
249
+ Found {N} seeds related to Phase {NN}:
250
+ - {seed_name}: {seed description}
251
+ - {seed_name}: {seed description}
252
+ ```
253
+
254
+ Use AskUserQuestion (pattern: yes-no-pick from `skills/shared/gate-prompts.md`):
255
+ question: "Include these {N} seeds in planning?"
256
+ header: "Seeds?"
257
+ options:
258
+ - label: "Yes, all" description: "Include all {N} matching seeds"
259
+ - label: "Let me pick" description: "Choose which seeds to include"
260
+ - label: "No" description: "Proceed without seeds"
261
+ 5. If "Yes, all": include all matching seed content in the planner's context
262
+ 6. If "Let me pick": present individual seeds for selection
263
+ 7. If "No" or "Other": proceed without seeds
264
+ 8. If no matching seeds found: proceed silently
265
+
266
+ ---
267
+
268
+ ### Step 4.6: Surface Deferred Ideas (inline, before planning)
269
+
270
+ Before spawning the planner, check `.planning/CONTEXT.md` for deferred ideas that may be relevant to this phase:
271
+
272
+ 1. If `.planning/CONTEXT.md` does NOT exist, skip this step silently
273
+ 2. If it exists, scan for sections named "Deferred Ideas", "Deferred", "Ideas", or "Seeds" (case-insensitive heading match)
274
+ 3. For each deferred item found, check relevance to the current phase by comparing the item text against the phase goal, requirements, and slug
275
+ 4. If relevant deferred items are found, present them to the user:
276
+ ```
277
+ Found {N} deferred idea(s) from previous discussions that may be relevant to Phase {NN}:
278
+ - {deferred item summary}
279
+ - {deferred item summary}
280
+ ```
281
+ Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
282
+ question: "Include these deferred ideas in the planning context?"
283
+ header: "Deferred Ideas"
284
+ options:
285
+ - label: "Yes" description: "Pass relevant deferred ideas to the planner"
286
+ - label: "No" description: "Proceed without deferred ideas"
287
+ 5. If "Yes": append the relevant deferred items to the context bundle for the planner prompt (add them to the `<project_context>` block under a `Deferred ideas to consider:` heading)
288
+ 6. If "No" or no relevant items found: proceed without changes
289
+
290
+ This is a lightweight relevance filter — do NOT spawn a subagent for this. Just match keywords from the deferred items against the phase goal and requirement text.
291
+
292
+ ---
293
+
294
+ ### Step 5: Planning (delegated)
295
+
296
+ #### Team Mode (--teams)
297
+
298
+ Reference: `references/agent-teams.md` for team role definitions and coordination details.
299
+
300
+ If `--teams` flag is set OR `config.parallelization.use_teams` is true:
301
+
302
+ 1. Create the team output directory: `.planning/phases/{NN}-{slug}/team/`
303
+ 2. Display to the user: `◐ Spawning 3 planners in parallel (architect, security, test)...`
304
+
305
+ Spawn THREE planner agents in parallel using Task():
306
+
307
+ **Agent 1 -- Architect**:
308
+ - subagent_type: "pbr:planner"
309
+ - Prompt includes: "You are the ARCHITECT role in a planning team. Focus on: structure, file boundaries, dependency ordering, wave assignment. Write your output to `.planning/phases/{NN}-{slug}/team/architect-PLAN.md`. Do NOT write final PLAN.md files -- your output will be synthesized."
310
+ - Include phase goal, research doc paths, CONTEXT.md path in the prompt
311
+
312
+ **Agent 2 -- Security Reviewer**:
313
+ - subagent_type: "pbr:planner"
314
+ - Prompt includes: "You are the SECURITY REVIEWER role in a planning team. Focus on: authentication checks, input validation tasks, secrets handling, permission boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/security-PLAN.md`. Do NOT write final PLAN.md files."
315
+ - Include same context as Agent 1
316
+
317
+ **Agent 3 -- Test Designer**:
318
+ - subagent_type: "pbr:planner"
319
+ - Prompt includes: "You are the TEST DESIGNER role in a planning team. Focus on: test strategy, coverage targets, edge cases, which tasks should use TDD, integration test boundaries. Write your output to `.planning/phases/{NN}-{slug}/team/test-PLAN.md`. Do NOT write final PLAN.md files."
320
+ - Include same context as Agent 1
321
+
322
+ 3. Wait for all three to complete
323
+ 4. Display to the user: `◐ Spawning synthesizer...`
324
+
325
+ Spawn the synthesizer agent:
326
+ - subagent_type: "pbr:synthesizer"
327
+ - Prompt: "Read all files in `.planning/phases/{NN}-{slug}/team/`. Synthesize them into unified PLAN.md files in `.planning/phases/{NN}-{slug}/`. The architect output provides structure, the security output adds security-related tasks or checks, and the test output informs TDD flags and test tasks. Resolve any contradictions by preferring the architect's structure with security and test additions."
328
+ 5. Proceed to plan checking as normal
329
+
330
+ If `--teams` is NOT set and `config.parallelization.use_teams` is false or unset, proceed with the existing single-planner flow below.
331
+
332
+ #### Single-Planner Flow (default)
333
+
334
+ Display to the user: `◐ Spawning planner...`
335
+
336
+ Spawn the planner Task() with all context inlined:
337
+
338
+ ```
339
+ Task({
340
+ subagent_type: "pbr:planner",
341
+ prompt: <planning prompt>
342
+ })
343
+
344
+ NOTE: The pbr:planner subagent type auto-loads the agent definition. Do NOT inline it.
345
+ ```
346
+
347
+ **Path resolution**: Before constructing the agent prompt, resolve `${CLAUDE_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.
348
+
349
+ #### Planning Prompt Template
350
+
351
+ Read `skills/plan/templates/planner-prompt.md.tmpl` and use it as the prompt template for spawning the planner agent. Fill in all placeholder blocks with phase-specific context:
352
+ - `<phase_context>` - phase number, directory, goal, requirements, dependencies, success criteria
353
+ - `<project_context>` - locked decisions, user constraints, deferred ideas, phase-specific decisions
354
+ - `<prior_work>` - manifest table of preceding phase SUMMARY.md file paths with status and one-line exports (NOT full bodies)
355
+ - `<research>` - file path to RESEARCH.md if it exists (NOT inlined content)
356
+ - `<config>` - max tasks, parallelization, TDD mode from config.json
357
+ - `<planning_instructions>` - phase-specific planning rules and output path
358
+
359
+ Wait for the planner to complete.
360
+
361
+ After the planner returns, read the plan files it created to extract counts. Display a completion summary:
362
+
363
+ ```
364
+ ✓ Planner created {N} plan(s) across {M} wave(s)
365
+ ```
366
+
367
+ Where `{N}` is the number of PLAN.md files written and `{M}` is the number of distinct wave values across those plans (from frontmatter).
368
+
369
+ ---
370
+
371
+ ### Step 6: Plan Validation (delegated, conditional)
372
+
373
+ **Skip this step if:**
374
+ - Depth profile has `features.plan_checking: false`
375
+
376
+ To check: use the resolved depth profile from Step 1. The profile consolidates the depth setting and any user overrides into a single boolean.
377
+
378
+ **If validation is enabled:**
379
+
380
+ Display to the user: `◐ Spawning plan checker...`
381
+
382
+ Spawn the plan checker Task():
383
+
384
+ ```
385
+ Task({
386
+ subagent_type: "pbr:plan-checker",
387
+ prompt: <checker prompt>
388
+ })
389
+
390
+ NOTE: The pbr:plan-checker subagent type auto-loads the agent definition. Do NOT inline it.
391
+ ```
392
+
393
+ **Path resolution**: Before constructing the agent prompt, resolve `${CLAUDE_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.
394
+
395
+ #### Checker Prompt Template
396
+
397
+ Read `skills/plan/templates/checker-prompt.md.tmpl` and use it as the prompt template for spawning the plan checker agent. Fill in the placeholders:
398
+ - `<plans_to_check>` - manifest table of PLAN.md file paths (checker reads each via Read tool)
399
+ - `<phase_context>` - phase goal and requirement IDs
400
+ - `<context>` - file paths to project-level and phase-level CONTEXT.md files (checker reads via Read tool)
401
+
402
+ **Process checker results:**
403
+
404
+ After the plan checker returns, display its result:
405
+
406
+ - If `VERIFICATION PASSED`: display `✓ Plan checker: all plans passed` and proceed to Step 8
407
+ - If issues found: display `⚠ Plan checker found {N} issue(s) — entering revision loop` and proceed to Step 7
408
+
409
+ ---
410
+
411
+ ### Step 7: Revision Loop (max 3 iterations)
412
+
413
+ Reference: `skills/shared/revision-loop.md` for the full Check-Revise-Escalate pattern.
414
+
415
+ Follow the revision loop pattern with:
416
+ - **Producer**: planner (re-spawned with `skills/plan/templates/revision-prompt.md.tmpl`)
417
+ - **Checker**: plan-checker (back to Step 6)
418
+ - **Escalation**: present issues to user, offer "Proceed anyway" or "Adjust approach" (re-enter Step 5)
419
+
420
+ ---
421
+
422
+ ### Step 8: User Approval (inline, conditional)
423
+
424
+ **Skip if:**
425
+ - `gates.confirm_plan` is `false` in config
426
+ - `mode` is `autonomous` in config
427
+
428
+ **If approval is needed:**
429
+
430
+ Present a summary of all plans to the user:
431
+
432
+ ```
433
+ Phase {N}: {name}
434
+ Plans: {count}
435
+
436
+ Plan {phase}-01: {plan name} (Wave {W}, {task_count} tasks)
437
+ Must-haves: {list truths}
438
+ Files: {list files_modified}
439
+ Tasks:
440
+ 1. {task name}
441
+ 2. {task name}
442
+
443
+ Plan {phase}-02: {plan name} (Wave {W}, {task_count} tasks)
444
+ ...
445
+
446
+ Wave execution order:
447
+ Wave 1: Plan 01, Plan 02 (parallel)
448
+ Wave 2: Plan 03 (depends on 01, 02)
449
+
450
+ Use AskUserQuestion (pattern: approve-revise-abort from `skills/shared/gate-prompts.md`):
451
+ question: "Approve these {count} plans for Phase {N}?"
452
+ header: "Approve?"
453
+ options:
454
+ - label: "Approve" description: "Proceed to build phase"
455
+ - label: "Request changes" description: "Discuss adjustments before proceeding"
456
+ - label: "Abort" description: "Cancel planning for this phase"
457
+ ```
458
+
459
+ **If user selects 'Request changes' or 'Other':**
460
+ - Discuss what needs to change
461
+ - Re-enter Step 5 with updated context/constraints
462
+ - Or make small inline edits to plan files directly
463
+
464
+ **If user selects 'Approve':**
465
+ - **CONTEXT.md compliance reporting**: If `.planning/CONTEXT.md` exists, compare all locked decisions against the generated plans. Print: "CONTEXT.md compliance: {M}/{N} locked decisions mapped to tasks" where M = locked decisions that are reflected in at least one task, N = total locked decisions. If any locked decisions are unmapped, list them as warnings.
466
+ - **Dependency fingerprinting**: For each dependency phase (phases that this phase depends on, per ROADMAP.md):
467
+ 1. Find all SUMMARY.md files in the dependency phase directory
468
+ 2. Compute a simple hash of each SUMMARY.md file (e.g., first 8 chars of a SHA-256 of the file content, or a simpler approach: use the file's byte length + last-modified timestamp as a fingerprint string)
469
+ 3. Add a `dependency_fingerprints` field to each plan's YAML frontmatter:
470
+ ```yaml
471
+ dependency_fingerprints:
472
+ "01-01": "len:4856-mod:2025-02-08T09:40"
473
+ "01-02": "len:4375-mod:2025-02-08T09:43"
474
+ ```
475
+ 4. This allows the build skill to detect if dependency phases were re-built after this plan was created
476
+ - **Update ROADMAP.md Progress table** (REQUIRED do this BEFORE updating STATE.md):
477
+
478
+ **Tooling shortcut**: Use the CLI for atomic updates:
479
+ ```bash
480
+ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-plans {phase} 0 {N}
481
+ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js roadmap update-status {phase} planned
482
+ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state update status planned
483
+ node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state update last_activity now
484
+ ```
485
+
486
+ 1. Open `.planning/ROADMAP.md`
487
+ 2. Find the `## Progress` table
488
+ 3. Locate the row matching this phase number
489
+ 4. Update the `Plans Complete` column to `0/{N}` where N = number of plan files just created
490
+ 5. Update the `Status` column to `planned`
491
+ 6. Save the file — do NOT skip this step
492
+ - Update STATE.md: set current phase plan status to "planned"
493
+ - **If `features.auto_advance` is `true` AND `mode` is `autonomous`:** Chain directly to build: `Skill({ skill: "pbr:build", args: "{N}" })`. This continues the build→review→plan→build cycle automatically.
494
+ - **Otherwise:** Suggest next action: `/pbr:build {N}`
495
+
496
+ ---
497
+
498
+ ## Orchestration Flow: Subcommands
499
+
500
+ ### Subcommand: `add`
501
+
502
+ 1. Read `.planning/ROADMAP.md`
503
+ 2. Calculate next phase number (last phase + 1)
504
+ 3. Ask user: "What's the goal for this new phase?"
505
+ 4. Ask user: "What requirements does it address?" (show available unassigned REQ-IDs)
506
+ 5. Ask user: "What phases does it depend on?"
507
+ 6. Append phase to ROADMAP.md
508
+ 7. Create phase directory: `.planning/phases/{NN}-{slug}/`
509
+ 8. Update STATE.md if needed
510
+ 9. Suggest: `/pbr:plan {N}` to plan the new phase
511
+
512
+ ### Subcommand: `insert <N>`
513
+
514
+ Reference: `skills/plan/decimal-phase-calc.md` for decimal numbering rules.
515
+
516
+ 1. Read `.planning/ROADMAP.md`
517
+ 2. Calculate decimal phase number:
518
+ - If inserting at position 3: becomes 3.1
519
+ - If 3.1 already exists: becomes 3.2
520
+ - Etc. (see decimal-phase-calc.md)
521
+ 3. Ask user for phase goal, requirements, dependencies
522
+ 4. Insert phase into ROADMAP.md at the correct position
523
+ 5. Create phase directory: `.planning/phases/{NN.M}-{slug}/`
524
+ 6. Update dependencies of subsequent phases if affected
525
+ 7. Suggest: `/pbr:plan {N.M}` to plan the new phase
526
+
527
+ ### Subcommand: `remove <N>`
528
+
529
+ 1. Read `.planning/ROADMAP.md`
530
+ 2. Validate:
531
+ - Phase must exist
532
+ - Phase must be in `pending` or `not started` status (cannot remove completed/in-progress phases)
533
+ - No other phases depend on this phase (or user confirms breaking dependencies)
534
+ 3. Confirm with user: "Remove Phase {N}: {name}? This will delete the phase directory and renumber subsequent phases."
535
+ 4. If confirmed:
536
+ - Delete `.planning/phases/{NN}-{slug}/` directory
537
+ - Remove phase from ROADMAP.md
538
+ - Renumber subsequent phases (N+1 becomes N, etc.)
539
+ - Update all `depends_on` references in ROADMAP.md
540
+ - Update STATE.md if needed
541
+
542
+ ---
543
+
544
+ ## Orchestration Flow: Gap Closure (`--gaps`)
545
+
546
+ When invoked with `--gaps`:
547
+
548
+ 1. Read `.planning/phases/{NN}-{slug}/VERIFICATION.md`
549
+ - If no VERIFICATION.md exists: tell user "No verification report found. Run `/pbr:review {N}` first."
550
+ 2. Extract all gaps from the verification report
551
+ 3. Spawn planner Task() in Gap Closure mode:
552
+
553
+ Read `skills/plan/templates/gap-closure-prompt.md.tmpl` and use it as the prompt template for the gap closure planner. Fill in the placeholders:
554
+ - `<verification_report>` - inline the FULL VERIFICATION.md content
555
+ - `<existing_plans>` - inline all existing PLAN.md files for the phase
556
+ - `<gap_closure_instructions>` - specify output path and gap_closure frontmatter flag
557
+
558
+ 4. After gap-closure plans are created:
559
+ - Run plan checker (if enabled)
560
+ - Present to user for approval
561
+ - Suggest: `/pbr:build {N} --gaps-only`
562
+
563
+ ---
564
+
565
+ ## Error Handling
566
+
567
+ ### Phase not found
568
+ If the specified phase doesn't exist in ROADMAP.md, display:
569
+ ```
570
+ ╔══════════════════════════════════════════════════════════════╗
571
+ ║ ERROR ║
572
+ ╚══════════════════════════════════════════════════════════════╝
573
+
574
+ Phase {N} not found in ROADMAP.md.
575
+
576
+ **To fix:** Run `/pbr:status` to see available phases.
577
+ ```
578
+
579
+ ### Missing prerequisites
580
+ If REQUIREMENTS.md or ROADMAP.md don't exist, display:
581
+ ```
582
+ ╔══════════════════════════════════════════════════════════════╗
583
+ ║ ERROR ║
584
+ ╚══════════════════════════════════════════════════════════════╝
585
+
586
+ Project not initialized. Missing REQUIREMENTS.md or ROADMAP.md.
587
+
588
+ **To fix:** Run `/pbr:begin` first.
589
+ ```
590
+
591
+ ### Research agent fails
592
+ If the researcher Task() fails, display:
593
+ ```
594
+ Research agent failed. Planning without phase-specific research.
595
+ This may result in less accurate plans.
596
+ ```
597
+ Continue to the planning step.
598
+
599
+ ### Planner agent fails
600
+ If the planner Task() fails, display:
601
+ ```
602
+ ╔══════════════════════════════════════════════════════════════╗
603
+ ║ ERROR ║
604
+ ╚══════════════════════════════════════════════════════════════╝
605
+
606
+ Planner agent failed for Phase {N}.
607
+
608
+ **To fix:**
609
+ - Try again with `/pbr:plan {N} --skip-research`
610
+ - Check `.planning/CONTEXT.md` for conflicting constraints
611
+ ```
612
+
613
+ ### Checker loops forever
614
+ After 3 revision iterations without passing, display:
615
+ ```
616
+ ╔══════════════════════════════════════════════════════════════╗
617
+ ║ ERROR ║
618
+ ╚══════════════════════════════════════════════════════════════╝
619
+
620
+ Plan checker failed to pass after 3 revision iterations for Phase {N}.
621
+
622
+ **To fix:**
623
+ - Review the remaining issues below and decide whether to proceed or revise manually
624
+ - Run `/pbr:plan {N}` to restart planning from scratch
625
+ ```
626
+
627
+ Present remaining issues and ask user to decide: proceed or intervene.
628
+
629
+ ---
630
+
631
+ ## Files Created/Modified by /pbr:plan
632
+
633
+ | File | Purpose | When |
634
+ |------|---------|------|
635
+ | `.planning/phases/{NN}-{slug}/RESEARCH.md` | Phase-specific research | Step 4 |
636
+ | `.planning/phases/{NN}-{slug}/{phase}-{NN}-PLAN.md` | Executable plan files | Step 5 |
637
+ | `.planning/CONTEXT.md` | Updated with assumptions | Step 3 (--assumptions) |
638
+ | `.planning/ROADMAP.md` | Plans Complete + Status → `planned`; updated for add/insert/remove | Step 8, Subcommands |
639
+ | `.planning/STATE.md` | Updated with plan status | Step 8 |
640
+
641
+ ---
642
+
643
+ ## Completion
644
+
645
+ After planning completes, present:
646
+
647
+ Use the branded stage banner from `references/ui-formatting.md`:
648
+
649
+ ```
650
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
651
+ PLAN-BUILD-RUN ► PLANNING PHASE {N} ✓
652
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
653
+
654
+ **Phase {N}: {name}** — {plan_count} plans created
655
+
656
+ Plans:
657
+ {phase}-01: {name} (Wave 1, {task_count} tasks)
658
+ {phase}-02: {name} (Wave 1, {task_count} tasks)
659
+ {phase}-03: {name} (Wave 2, {task_count} tasks)
660
+
661
+ Wave execution:
662
+ Wave 1: Plans 01, 02 (parallel)
663
+ Wave 2: Plan 03
664
+ ```
665
+
666
+ Then use the "Next Up" routing block:
667
+ ```
668
+ ───────────────────────────────────────────────────────────────
669
+
670
+ ## ▶ Next Up
671
+
672
+ **Build Phase {N}** — execute these plans
673
+
674
+ /pbr:build {N}
675
+
676
+ <sub>/clear first → fresh context window</sub>
677
+
678
+ ───────────────────────────────────────────────────────────────
679
+
680
+ **Also available:**
681
+ - /pbr:plan {N} --assumptions — review assumptions first
682
+ - /pbr:discuss {N} — talk through details before building
683
+
684
+ ───────────────────────────────────────────────────────────────
685
+ ```