@sienklogic/plan-build-run 2.0.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 (221) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/CLAUDE.md +149 -0
  3. package/LICENSE +21 -0
  4. package/README.md +247 -0
  5. package/dashboard/bin/cli.js +25 -0
  6. package/dashboard/package.json +34 -0
  7. package/dashboard/public/.gitkeep +0 -0
  8. package/dashboard/public/css/layout.css +406 -0
  9. package/dashboard/public/css/status-colors.css +98 -0
  10. package/dashboard/public/js/htmx-title.js +5 -0
  11. package/dashboard/public/js/sidebar-toggle.js +20 -0
  12. package/dashboard/src/app.js +78 -0
  13. package/dashboard/src/middleware/errorHandler.js +52 -0
  14. package/dashboard/src/middleware/notFoundHandler.js +9 -0
  15. package/dashboard/src/repositories/planning.repository.js +128 -0
  16. package/dashboard/src/routes/events.routes.js +40 -0
  17. package/dashboard/src/routes/index.routes.js +31 -0
  18. package/dashboard/src/routes/pages.routes.js +195 -0
  19. package/dashboard/src/server.js +42 -0
  20. package/dashboard/src/services/dashboard.service.js +222 -0
  21. package/dashboard/src/services/phase.service.js +167 -0
  22. package/dashboard/src/services/project.service.js +57 -0
  23. package/dashboard/src/services/roadmap.service.js +171 -0
  24. package/dashboard/src/services/sse.service.js +58 -0
  25. package/dashboard/src/services/todo.service.js +254 -0
  26. package/dashboard/src/services/watcher.service.js +48 -0
  27. package/dashboard/src/views/coming-soon.ejs +11 -0
  28. package/dashboard/src/views/error.ejs +13 -0
  29. package/dashboard/src/views/index.ejs +5 -0
  30. package/dashboard/src/views/layout.ejs +1 -0
  31. package/dashboard/src/views/partials/dashboard-content.ejs +77 -0
  32. package/dashboard/src/views/partials/footer.ejs +3 -0
  33. package/dashboard/src/views/partials/head.ejs +21 -0
  34. package/dashboard/src/views/partials/header.ejs +12 -0
  35. package/dashboard/src/views/partials/layout-bottom.ejs +15 -0
  36. package/dashboard/src/views/partials/layout-top.ejs +8 -0
  37. package/dashboard/src/views/partials/phase-content.ejs +181 -0
  38. package/dashboard/src/views/partials/phases-content.ejs +117 -0
  39. package/dashboard/src/views/partials/roadmap-content.ejs +142 -0
  40. package/dashboard/src/views/partials/sidebar.ejs +38 -0
  41. package/dashboard/src/views/partials/todo-create-content.ejs +53 -0
  42. package/dashboard/src/views/partials/todo-detail-content.ejs +38 -0
  43. package/dashboard/src/views/partials/todos-content.ejs +53 -0
  44. package/dashboard/src/views/phase-detail.ejs +5 -0
  45. package/dashboard/src/views/phases.ejs +5 -0
  46. package/dashboard/src/views/roadmap.ejs +5 -0
  47. package/dashboard/src/views/todo-create.ejs +5 -0
  48. package/dashboard/src/views/todo-detail.ejs +5 -0
  49. package/dashboard/src/views/todos.ejs +5 -0
  50. package/package.json +57 -0
  51. package/plugins/pbr/.claude-plugin/plugin.json +13 -0
  52. package/plugins/pbr/UI-CONSISTENCY-GAPS.md +61 -0
  53. package/plugins/pbr/agents/codebase-mapper.md +271 -0
  54. package/plugins/pbr/agents/debugger.md +281 -0
  55. package/plugins/pbr/agents/executor.md +407 -0
  56. package/plugins/pbr/agents/general.md +164 -0
  57. package/plugins/pbr/agents/integration-checker.md +141 -0
  58. package/plugins/pbr/agents/plan-checker.md +280 -0
  59. package/plugins/pbr/agents/planner.md +358 -0
  60. package/plugins/pbr/agents/researcher.md +363 -0
  61. package/plugins/pbr/agents/synthesizer.md +230 -0
  62. package/plugins/pbr/agents/verifier.md +454 -0
  63. package/plugins/pbr/commands/begin.md +5 -0
  64. package/plugins/pbr/commands/build.md +5 -0
  65. package/plugins/pbr/commands/config.md +5 -0
  66. package/plugins/pbr/commands/continue.md +5 -0
  67. package/plugins/pbr/commands/debug.md +5 -0
  68. package/plugins/pbr/commands/discuss.md +5 -0
  69. package/plugins/pbr/commands/explore.md +5 -0
  70. package/plugins/pbr/commands/health.md +5 -0
  71. package/plugins/pbr/commands/help.md +5 -0
  72. package/plugins/pbr/commands/import.md +5 -0
  73. package/plugins/pbr/commands/milestone.md +5 -0
  74. package/plugins/pbr/commands/note.md +5 -0
  75. package/plugins/pbr/commands/pause.md +5 -0
  76. package/plugins/pbr/commands/plan.md +5 -0
  77. package/plugins/pbr/commands/quick.md +5 -0
  78. package/plugins/pbr/commands/resume.md +5 -0
  79. package/plugins/pbr/commands/review.md +5 -0
  80. package/plugins/pbr/commands/scan.md +5 -0
  81. package/plugins/pbr/commands/setup.md +5 -0
  82. package/plugins/pbr/commands/status.md +5 -0
  83. package/plugins/pbr/commands/todo.md +5 -0
  84. package/plugins/pbr/contexts/dev.md +27 -0
  85. package/plugins/pbr/contexts/research.md +28 -0
  86. package/plugins/pbr/contexts/review.md +36 -0
  87. package/plugins/pbr/hooks/hooks.json +183 -0
  88. package/plugins/pbr/references/agent-anti-patterns.md +24 -0
  89. package/plugins/pbr/references/agent-interactions.md +134 -0
  90. package/plugins/pbr/references/agent-teams.md +54 -0
  91. package/plugins/pbr/references/checkpoints.md +157 -0
  92. package/plugins/pbr/references/common-bug-patterns.md +13 -0
  93. package/plugins/pbr/references/continuation-format.md +212 -0
  94. package/plugins/pbr/references/deviation-rules.md +112 -0
  95. package/plugins/pbr/references/git-integration.md +226 -0
  96. package/plugins/pbr/references/integration-patterns.md +117 -0
  97. package/plugins/pbr/references/model-profiles.md +99 -0
  98. package/plugins/pbr/references/model-selection.md +31 -0
  99. package/plugins/pbr/references/pbr-rules.md +193 -0
  100. package/plugins/pbr/references/plan-authoring.md +181 -0
  101. package/plugins/pbr/references/plan-format.md +283 -0
  102. package/plugins/pbr/references/planning-config.md +213 -0
  103. package/plugins/pbr/references/questioning.md +214 -0
  104. package/plugins/pbr/references/reading-verification.md +127 -0
  105. package/plugins/pbr/references/stub-patterns.md +160 -0
  106. package/plugins/pbr/references/subagent-coordination.md +119 -0
  107. package/plugins/pbr/references/ui-formatting.md +399 -0
  108. package/plugins/pbr/references/verification-patterns.md +198 -0
  109. package/plugins/pbr/references/wave-execution.md +95 -0
  110. package/plugins/pbr/scripts/auto-continue.js +80 -0
  111. package/plugins/pbr/scripts/check-dangerous-commands.js +136 -0
  112. package/plugins/pbr/scripts/check-doc-sprawl.js +102 -0
  113. package/plugins/pbr/scripts/check-phase-boundary.js +196 -0
  114. package/plugins/pbr/scripts/check-plan-format.js +270 -0
  115. package/plugins/pbr/scripts/check-roadmap-sync.js +252 -0
  116. package/plugins/pbr/scripts/check-skill-workflow.js +262 -0
  117. package/plugins/pbr/scripts/check-state-sync.js +476 -0
  118. package/plugins/pbr/scripts/check-subagent-output.js +144 -0
  119. package/plugins/pbr/scripts/config-schema.json +251 -0
  120. package/plugins/pbr/scripts/context-budget-check.js +287 -0
  121. package/plugins/pbr/scripts/event-handler.js +151 -0
  122. package/plugins/pbr/scripts/event-logger.js +92 -0
  123. package/plugins/pbr/scripts/hook-logger.js +76 -0
  124. package/plugins/pbr/scripts/hooks-schema.json +79 -0
  125. package/plugins/pbr/scripts/log-subagent.js +152 -0
  126. package/plugins/pbr/scripts/log-tool-failure.js +88 -0
  127. package/plugins/pbr/scripts/pbr-tools.js +1301 -0
  128. package/plugins/pbr/scripts/post-write-dispatch.js +66 -0
  129. package/plugins/pbr/scripts/post-write-quality.js +207 -0
  130. package/plugins/pbr/scripts/pre-bash-dispatch.js +56 -0
  131. package/plugins/pbr/scripts/pre-write-dispatch.js +62 -0
  132. package/plugins/pbr/scripts/progress-tracker.js +228 -0
  133. package/plugins/pbr/scripts/session-cleanup.js +254 -0
  134. package/plugins/pbr/scripts/status-line.js +285 -0
  135. package/plugins/pbr/scripts/suggest-compact.js +119 -0
  136. package/plugins/pbr/scripts/task-completed.js +45 -0
  137. package/plugins/pbr/scripts/track-context-budget.js +119 -0
  138. package/plugins/pbr/scripts/validate-commit.js +200 -0
  139. package/plugins/pbr/scripts/validate-plugin-structure.js +172 -0
  140. package/plugins/pbr/skills/begin/SKILL.md +545 -0
  141. package/plugins/pbr/skills/begin/templates/PROJECT.md.tmpl +33 -0
  142. package/plugins/pbr/skills/begin/templates/REQUIREMENTS.md.tmpl +18 -0
  143. package/plugins/pbr/skills/begin/templates/STATE.md.tmpl +49 -0
  144. package/plugins/pbr/skills/begin/templates/config.json.tmpl +63 -0
  145. package/plugins/pbr/skills/begin/templates/researcher-prompt.md.tmpl +19 -0
  146. package/plugins/pbr/skills/begin/templates/roadmap-prompt.md.tmpl +30 -0
  147. package/plugins/pbr/skills/begin/templates/synthesis-prompt.md.tmpl +16 -0
  148. package/plugins/pbr/skills/build/SKILL.md +962 -0
  149. package/plugins/pbr/skills/config/SKILL.md +241 -0
  150. package/plugins/pbr/skills/continue/SKILL.md +127 -0
  151. package/plugins/pbr/skills/debug/SKILL.md +489 -0
  152. package/plugins/pbr/skills/debug/templates/continuation-prompt.md.tmpl +16 -0
  153. package/plugins/pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +27 -0
  154. package/plugins/pbr/skills/discuss/SKILL.md +338 -0
  155. package/plugins/pbr/skills/discuss/templates/CONTEXT.md.tmpl +61 -0
  156. package/plugins/pbr/skills/discuss/templates/decision-categories.md +9 -0
  157. package/plugins/pbr/skills/explore/SKILL.md +362 -0
  158. package/plugins/pbr/skills/health/SKILL.md +186 -0
  159. package/plugins/pbr/skills/health/templates/check-pattern.md.tmpl +30 -0
  160. package/plugins/pbr/skills/health/templates/output-format.md.tmpl +63 -0
  161. package/plugins/pbr/skills/help/SKILL.md +140 -0
  162. package/plugins/pbr/skills/import/SKILL.md +490 -0
  163. package/plugins/pbr/skills/milestone/SKILL.md +673 -0
  164. package/plugins/pbr/skills/milestone/templates/audit-report.md.tmpl +48 -0
  165. package/plugins/pbr/skills/milestone/templates/stats-file.md.tmpl +30 -0
  166. package/plugins/pbr/skills/note/SKILL.md +212 -0
  167. package/plugins/pbr/skills/pause/SKILL.md +235 -0
  168. package/plugins/pbr/skills/pause/templates/continue-here.md.tmpl +71 -0
  169. package/plugins/pbr/skills/plan/SKILL.md +628 -0
  170. package/plugins/pbr/skills/plan/decimal-phase-calc.md +98 -0
  171. package/plugins/pbr/skills/plan/templates/checker-prompt.md.tmpl +21 -0
  172. package/plugins/pbr/skills/plan/templates/gap-closure-prompt.md.tmpl +32 -0
  173. package/plugins/pbr/skills/plan/templates/planner-prompt.md.tmpl +38 -0
  174. package/plugins/pbr/skills/plan/templates/researcher-prompt.md.tmpl +19 -0
  175. package/plugins/pbr/skills/plan/templates/revision-prompt.md.tmpl +23 -0
  176. package/plugins/pbr/skills/quick/SKILL.md +335 -0
  177. package/plugins/pbr/skills/resume/SKILL.md +388 -0
  178. package/plugins/pbr/skills/review/SKILL.md +652 -0
  179. package/plugins/pbr/skills/review/templates/debugger-prompt.md.tmpl +60 -0
  180. package/plugins/pbr/skills/review/templates/gap-planner-prompt.md.tmpl +40 -0
  181. package/plugins/pbr/skills/review/templates/verifier-prompt.md.tmpl +115 -0
  182. package/plugins/pbr/skills/scan/SKILL.md +269 -0
  183. package/plugins/pbr/skills/scan/templates/mapper-prompt.md.tmpl +201 -0
  184. package/plugins/pbr/skills/setup/SKILL.md +227 -0
  185. package/plugins/pbr/skills/shared/commit-planning-docs.md +35 -0
  186. package/plugins/pbr/skills/shared/config-loading.md +102 -0
  187. package/plugins/pbr/skills/shared/context-budget.md +40 -0
  188. package/plugins/pbr/skills/shared/context-loader-task.md +86 -0
  189. package/plugins/pbr/skills/shared/digest-select.md +79 -0
  190. package/plugins/pbr/skills/shared/domain-probes.md +125 -0
  191. package/plugins/pbr/skills/shared/error-reporting.md +79 -0
  192. package/plugins/pbr/skills/shared/gate-prompts.md +388 -0
  193. package/plugins/pbr/skills/shared/phase-argument-parsing.md +45 -0
  194. package/plugins/pbr/skills/shared/progress-display.md +53 -0
  195. package/plugins/pbr/skills/shared/revision-loop.md +81 -0
  196. package/plugins/pbr/skills/shared/state-loading.md +62 -0
  197. package/plugins/pbr/skills/shared/state-update.md +161 -0
  198. package/plugins/pbr/skills/shared/universal-anti-patterns.md +33 -0
  199. package/plugins/pbr/skills/status/SKILL.md +353 -0
  200. package/plugins/pbr/skills/todo/SKILL.md +181 -0
  201. package/plugins/pbr/templates/CONTEXT.md.tmpl +52 -0
  202. package/plugins/pbr/templates/INTEGRATION-REPORT.md.tmpl +151 -0
  203. package/plugins/pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  204. package/plugins/pbr/templates/ROADMAP.md.tmpl +40 -0
  205. package/plugins/pbr/templates/SUMMARY.md.tmpl +81 -0
  206. package/plugins/pbr/templates/VERIFICATION-DETAIL.md.tmpl +116 -0
  207. package/plugins/pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  208. package/plugins/pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  209. package/plugins/pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  210. package/plugins/pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  211. package/plugins/pbr/templates/codebase/STACK.md.tmpl +78 -0
  212. package/plugins/pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  213. package/plugins/pbr/templates/codebase/TESTING.md.tmpl +107 -0
  214. package/plugins/pbr/templates/continue-here.md.tmpl +73 -0
  215. package/plugins/pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  216. package/plugins/pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  217. package/plugins/pbr/templates/research/STACK.md.tmpl +71 -0
  218. package/plugins/pbr/templates/research/SUMMARY.md.tmpl +112 -0
  219. package/plugins/pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  220. package/plugins/pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  221. package/plugins/pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
@@ -0,0 +1,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
+ # /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
+ ```