@sienklogic/plan-build-run 2.54.0 → 2.55.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 (127) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/plugins/codex-pbr/agents/audit.md +223 -0
  4. package/plugins/codex-pbr/agents/codebase-mapper.md +196 -0
  5. package/plugins/codex-pbr/agents/debugger.md +245 -0
  6. package/plugins/codex-pbr/agents/dev-sync.md +142 -0
  7. package/plugins/codex-pbr/agents/executor.md +429 -0
  8. package/plugins/codex-pbr/agents/general.md +131 -0
  9. package/plugins/codex-pbr/agents/integration-checker.md +178 -0
  10. package/plugins/codex-pbr/agents/plan-checker.md +253 -0
  11. package/plugins/codex-pbr/agents/planner.md +343 -0
  12. package/plugins/codex-pbr/agents/researcher.md +253 -0
  13. package/plugins/codex-pbr/agents/synthesizer.md +183 -0
  14. package/plugins/codex-pbr/agents/verifier.md +352 -0
  15. package/plugins/codex-pbr/commands/audit.md +5 -0
  16. package/plugins/codex-pbr/commands/begin.md +5 -0
  17. package/plugins/codex-pbr/commands/build.md +5 -0
  18. package/plugins/codex-pbr/commands/config.md +5 -0
  19. package/plugins/codex-pbr/commands/continue.md +5 -0
  20. package/plugins/codex-pbr/commands/dashboard.md +5 -0
  21. package/plugins/codex-pbr/commands/debug.md +5 -0
  22. package/plugins/codex-pbr/commands/discuss.md +5 -0
  23. package/plugins/codex-pbr/commands/do.md +5 -0
  24. package/plugins/codex-pbr/commands/explore.md +5 -0
  25. package/plugins/codex-pbr/commands/health.md +5 -0
  26. package/plugins/codex-pbr/commands/help.md +5 -0
  27. package/plugins/codex-pbr/commands/import.md +5 -0
  28. package/plugins/codex-pbr/commands/milestone.md +5 -0
  29. package/plugins/codex-pbr/commands/note.md +5 -0
  30. package/plugins/codex-pbr/commands/pause.md +5 -0
  31. package/plugins/codex-pbr/commands/plan.md +5 -0
  32. package/plugins/codex-pbr/commands/quick.md +5 -0
  33. package/plugins/codex-pbr/commands/resume.md +5 -0
  34. package/plugins/codex-pbr/commands/review.md +5 -0
  35. package/plugins/codex-pbr/commands/scan.md +5 -0
  36. package/plugins/codex-pbr/commands/setup.md +5 -0
  37. package/plugins/codex-pbr/commands/status.md +5 -0
  38. package/plugins/codex-pbr/commands/statusline.md +5 -0
  39. package/plugins/codex-pbr/commands/test.md +5 -0
  40. package/plugins/codex-pbr/commands/todo.md +5 -0
  41. package/plugins/codex-pbr/commands/undo.md +5 -0
  42. package/plugins/codex-pbr/references/agent-contracts.md +324 -0
  43. package/plugins/codex-pbr/references/agent-teams.md +54 -0
  44. package/plugins/codex-pbr/references/common-bug-patterns.md +13 -0
  45. package/plugins/codex-pbr/references/config-reference.md +552 -0
  46. package/plugins/codex-pbr/references/continuation-format.md +212 -0
  47. package/plugins/codex-pbr/references/deviation-rules.md +112 -0
  48. package/plugins/codex-pbr/references/git-integration.md +256 -0
  49. package/plugins/codex-pbr/references/integration-patterns.md +117 -0
  50. package/plugins/codex-pbr/references/model-profiles.md +99 -0
  51. package/plugins/codex-pbr/references/model-selection.md +31 -0
  52. package/plugins/codex-pbr/references/pbr-tools-cli.md +400 -0
  53. package/plugins/codex-pbr/references/plan-authoring.md +246 -0
  54. package/plugins/codex-pbr/references/plan-format.md +313 -0
  55. package/plugins/codex-pbr/references/questioning.md +235 -0
  56. package/plugins/codex-pbr/references/reading-verification.md +127 -0
  57. package/plugins/codex-pbr/references/signal-files.md +41 -0
  58. package/plugins/codex-pbr/references/stub-patterns.md +160 -0
  59. package/plugins/codex-pbr/references/ui-formatting.md +444 -0
  60. package/plugins/codex-pbr/references/wave-execution.md +95 -0
  61. package/plugins/codex-pbr/skills/audit/SKILL.md +346 -0
  62. package/plugins/codex-pbr/skills/begin/SKILL.md +800 -0
  63. package/plugins/codex-pbr/skills/build/SKILL.md +958 -0
  64. package/plugins/codex-pbr/skills/config/SKILL.md +267 -0
  65. package/plugins/codex-pbr/skills/continue/SKILL.md +172 -0
  66. package/plugins/codex-pbr/skills/dashboard/SKILL.md +44 -0
  67. package/plugins/codex-pbr/skills/debug/SKILL.md +530 -0
  68. package/plugins/codex-pbr/skills/discuss/SKILL.md +355 -0
  69. package/plugins/codex-pbr/skills/do/SKILL.md +68 -0
  70. package/plugins/codex-pbr/skills/explore/SKILL.md +407 -0
  71. package/plugins/codex-pbr/skills/health/SKILL.md +300 -0
  72. package/plugins/codex-pbr/skills/help/SKILL.md +229 -0
  73. package/plugins/codex-pbr/skills/import/SKILL.md +538 -0
  74. package/plugins/codex-pbr/skills/milestone/SKILL.md +620 -0
  75. package/plugins/codex-pbr/skills/note/SKILL.md +215 -0
  76. package/plugins/codex-pbr/skills/pause/SKILL.md +258 -0
  77. package/plugins/codex-pbr/skills/plan/SKILL.md +650 -0
  78. package/plugins/codex-pbr/skills/quick/SKILL.md +417 -0
  79. package/plugins/codex-pbr/skills/resume/SKILL.md +403 -0
  80. package/plugins/codex-pbr/skills/review/SKILL.md +669 -0
  81. package/plugins/codex-pbr/skills/scan/SKILL.md +325 -0
  82. package/plugins/codex-pbr/skills/setup/SKILL.md +169 -0
  83. package/plugins/codex-pbr/skills/shared/commit-planning-docs.md +35 -0
  84. package/plugins/codex-pbr/skills/shared/config-loading.md +102 -0
  85. package/plugins/codex-pbr/skills/shared/context-budget.md +77 -0
  86. package/plugins/codex-pbr/skills/shared/context-loader-task.md +86 -0
  87. package/plugins/codex-pbr/skills/shared/digest-select.md +79 -0
  88. package/plugins/codex-pbr/skills/shared/domain-probes.md +125 -0
  89. package/plugins/codex-pbr/skills/shared/error-reporting.md +59 -0
  90. package/plugins/codex-pbr/skills/shared/gate-prompts.md +388 -0
  91. package/plugins/codex-pbr/skills/shared/phase-argument-parsing.md +45 -0
  92. package/plugins/codex-pbr/skills/shared/revision-loop.md +81 -0
  93. package/plugins/codex-pbr/skills/shared/state-update.md +169 -0
  94. package/plugins/codex-pbr/skills/shared/universal-anti-patterns.md +43 -0
  95. package/plugins/codex-pbr/skills/status/SKILL.md +449 -0
  96. package/plugins/codex-pbr/skills/statusline/SKILL.md +149 -0
  97. package/plugins/codex-pbr/skills/test/SKILL.md +210 -0
  98. package/plugins/codex-pbr/skills/todo/SKILL.md +281 -0
  99. package/plugins/codex-pbr/skills/undo/SKILL.md +172 -0
  100. package/plugins/codex-pbr/templates/CONTEXT.md.tmpl +52 -0
  101. package/plugins/codex-pbr/templates/INTEGRATION-REPORT.md.tmpl +167 -0
  102. package/plugins/codex-pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  103. package/plugins/codex-pbr/templates/ROADMAP.md.tmpl +47 -0
  104. package/plugins/codex-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  105. package/plugins/codex-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  106. package/plugins/codex-pbr/templates/SUMMARY.md.tmpl +81 -0
  107. package/plugins/codex-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  108. package/plugins/codex-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  109. package/plugins/codex-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  110. package/plugins/codex-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  111. package/plugins/codex-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  112. package/plugins/codex-pbr/templates/codebase/STACK.md.tmpl +78 -0
  113. package/plugins/codex-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  114. package/plugins/codex-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  115. package/plugins/codex-pbr/templates/continue-here.md.tmpl +73 -0
  116. package/plugins/codex-pbr/templates/pr-body.md.tmpl +22 -0
  117. package/plugins/codex-pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  118. package/plugins/codex-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  119. package/plugins/codex-pbr/templates/research/STACK.md.tmpl +71 -0
  120. package/plugins/codex-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  121. package/plugins/codex-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  122. package/plugins/codex-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  123. package/plugins/codex-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  124. package/plugins/copilot-pbr/plugin.json +1 -1
  125. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  126. package/plugins/jules-pbr/AGENTS.md +600 -0
  127. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,800 @@
1
+ ---
2
+ name: begin
3
+ description: "Start a new project. Deep questioning, research, requirements, and roadmap."
4
+ ---
5
+
6
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
7
+
8
+ # $pbr-begin — Project Initialization
9
+
10
+ You are the orchestrator for `$pbr-begin`. This skill initializes a new Plan-Build-Run project through deep questioning, optional research, requirements scoping, and roadmap generation. Your job is to stay lean — delegate heavy work to Task() agents 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 summaries, not full research docs
18
+ - **Delegate** all analysis work to agents — the orchestrator routes, it doesn't analyze
19
+
20
+ ## Step 0 — Immediate Output
21
+
22
+ **Before ANY tool calls**, display this banner:
23
+
24
+ ```
25
+ ╔══════════════════════════════════════════════════════════════╗
26
+ ║ PLAN-BUILD-RUN ► STARTING PROJECT ║
27
+ ╚══════════════════════════════════════════════════════════════╝
28
+ ```
29
+
30
+ Then proceed to Step 1.
31
+
32
+ ## Prerequisites
33
+
34
+ - Working directory should be the project root
35
+ - No existing `.planning/` directory (or user confirms overwrite)
36
+
37
+ ---
38
+
39
+ ## Orchestration Flow
40
+
41
+ Execute these steps in order. Each step specifies whether it runs inline (in your context) or is delegated to a subagent.
42
+
43
+ ---
44
+
45
+ ### Step 1: Detect Brownfield (inline)
46
+
47
+ > **Cross-platform note**: Use the Glob tool (not Bash `ls` or `find`) for all file and directory discovery. Bash file commands fail on Windows due to path separator issues.
48
+
49
+ Check if the current directory has existing code:
50
+
51
+ ```
52
+ 1. Use Glob to check directory contents (e.g., pattern "*" at project root)
53
+ 2. Look for indicators of existing code:
54
+ - package.json, requirements.txt, CMakeLists.txt, go.mod, Cargo.toml
55
+ - src/, lib/, app/ directories
56
+ - .git/ directory with commits
57
+ 3. Use Glob to check if .planning/ already exists (e.g., pattern ".planning/*")
58
+ ```
59
+
60
+ **If existing code found:**
61
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
62
+ question: "This looks like an existing codebase. Run $pbr-scan to analyze what's here first?"
63
+ options:
64
+ - label: "Yes, scan" description: "Run $pbr-scan first to analyze existing code"
65
+ - label: "No, begin" description: "Proceed with $pbr-begin on top of existing code"
66
+ - If user selects "Yes, scan": suggest `$pbr-scan` and stop
67
+ - If user selects "No, begin": proceed to Step 2
68
+
69
+ **If `.planning/` already exists:**
70
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
71
+ question: "A .planning/ directory already exists. This will overwrite it. Continue?"
72
+ options:
73
+ - label: "Yes" description: "Overwrite existing planning directory"
74
+ - label: "No" description: "Cancel — keep existing planning"
75
+ - If user selects "No": **STOP IMMEDIATELY. Do not ask again. Do not proceed to Step 2. End the skill with this message:**
76
+ ```
77
+ Keeping existing .planning/ directory. Use `$pbr-status` to see current project state, or `$pbr-plan` to continue planning.
78
+ ```
79
+ **Do NOT re-prompt the same question or any other question. The skill is finished.**
80
+ - If user selects "Yes": proceed (existing directory will be overwritten during state initialization)
81
+
82
+ ---
83
+
84
+ ### Step 2: Deep Questioning (inline)
85
+
86
+ **Reference**: Read `references/questioning.md` for technique details.
87
+
88
+ Have a natural conversation to understand the user's vision. Do NOT present a form or checklist. Instead, have a flowing conversation that covers these areas organically:
89
+
90
+ **Required context to gather:**
91
+
92
+ 1. **What they want to build** — The core product/feature/system
93
+ 2. **Problem being solved** — Why does this need to exist? Who is it for?
94
+ 3. **Success criteria** — How will they know it works? What does "done" look like?
95
+ 4. **Existing constraints** — Technology choices already made, hosting, budget, timeline, team size
96
+ 5. **Key decisions already made** — Framework, language, architecture preferences
97
+ 6. **Edge cases and concerns** — What worries them? What's the hardest part?
98
+
99
+ **Conversation approach:**
100
+ - Start broad: "What are you building?"
101
+ - Go deeper on each answer: "What does that mean exactly?" "Show me an example."
102
+ - Surface assumptions: "Why do you assume that?" "Have you considered X?"
103
+ - Find edges: "What happens when...?" "What about...?"
104
+ - Reveal motivation: "Why does that matter?"
105
+ - Avoid leading questions — let the user define their vision
106
+
107
+ **Keep going until you have:**
108
+ - A clear, concrete understanding of what they want to build
109
+ - At least 3 specific success criteria
110
+ - Known constraints and decisions
111
+ - A sense of complexity and scope
112
+
113
+ **Anti-patterns:**
114
+ - DO NOT present a bulleted checklist and ask them to fill it in
115
+ - DO NOT ask all questions at once — have a conversation
116
+ - DO NOT assume technologies — let them tell you
117
+ - DO NOT rush — this is the foundation for everything that follows
118
+
119
+ ---
120
+
121
+ ### Step 2.5: Fast-Path Offer (inline)
122
+
123
+ Before asking any workflow preference questions, offer the user a quick-start option:
124
+
125
+ Use AskUserQuestion:
126
+ question: "How do you want to configure this project?"
127
+ header: "Setup mode"
128
+ options:
129
+ - label: "Quick start"
130
+ description: "Use all defaults — model balanced, depth standard, interactive mode, parallel on. Writes config in seconds."
131
+ - label: "Custom setup"
132
+ description: "Walk through model selection, features, and preferences step by step."
133
+
134
+ **If user selects "Quick start":**
135
+ - Write `.planning/config.json` immediately using the default config below (no further questions):
136
+ ```json
137
+ {
138
+ "version": 2,
139
+ "context_strategy": "aggressive",
140
+ "mode": "interactive",
141
+ "depth": "standard",
142
+ "features": {
143
+ "structured_planning": true,
144
+ "goal_verification": true,
145
+ "integration_verification": true,
146
+ "context_isolation": true,
147
+ "atomic_commits": true,
148
+ "session_persistence": true,
149
+ "research_phase": true,
150
+ "plan_checking": true,
151
+ "tdd_mode": false,
152
+ "status_line": true,
153
+ "auto_continue": false,
154
+ "auto_advance": false,
155
+ "team_discussions": false,
156
+ "inline_verify": false
157
+ },
158
+ "models": {
159
+ "researcher": "sonnet",
160
+ "planner": "inherit",
161
+ "executor": "inherit",
162
+ "verifier": "sonnet",
163
+ "integration_checker": "sonnet",
164
+ "debugger": "inherit",
165
+ "mapper": "sonnet",
166
+ "synthesizer": "haiku"
167
+ },
168
+ "parallelization": {
169
+ "enabled": true,
170
+ "plan_level": true,
171
+ "task_level": false,
172
+ "max_concurrent_agents": 3,
173
+ "min_plans_for_parallel": 2,
174
+ "use_teams": false
175
+ },
176
+ "planning": {
177
+ "commit_docs": true,
178
+ "max_tasks_per_plan": 3,
179
+ "search_gitignored": false
180
+ },
181
+ "git": {
182
+ "branching": "none",
183
+ "commit_format": "{type}({phase}-{plan}): {description}",
184
+ "phase_branch_template": "plan-build-run/phase-{phase}-{slug}",
185
+ "milestone_branch_template": "plan-build-run/{milestone}-{slug}",
186
+ "mode": "enabled"
187
+ },
188
+ "gates": {
189
+ "confirm_project": true,
190
+ "confirm_roadmap": true,
191
+ "confirm_plan": true,
192
+ "confirm_execute": false,
193
+ "confirm_transition": true,
194
+ "issues_review": true
195
+ },
196
+ "safety": {
197
+ "always_confirm_destructive": true,
198
+ "always_confirm_external_services": true
199
+ }
200
+ }
201
+ ```
202
+ - Write `.planning/.active-skill` with text "begin"
203
+ - Write CLAUDE.md integration block (see Step 3d-claude below) using the project name gathered in Step 2
204
+ - Skip to Step 4 (Research Decision)
205
+ - Tell the user: "Quick start selected. Using all defaults — you can adjust later with `$pbr-config`."
206
+
207
+ **If user selects "Custom setup":** proceed to Step 3 normally.
208
+
209
+ ---
210
+
211
+ ### Step 3: Workflow Preferences (inline)
212
+
213
+ After understanding the project, configure the Plan-Build-Run workflow. Use AskUserQuestion for each preference below. Present them sequentially with conversational bridging (e.g., "Great. Next...") to keep the flow natural.
214
+
215
+ **3-model. Model Profile:**
216
+ Use AskUserQuestion:
217
+ question: "Which model profile should agents use?"
218
+ header: "Models"
219
+ options:
220
+ - label: "Balanced (Recommended)"
221
+ description: "Sonnet for most agents, Haiku for synthesizer. Good quality/cost tradeoff."
222
+ - label: "Quality"
223
+ description: "Opus for executor and planner, Sonnet for others. Best results, highest cost."
224
+ - label: "Budget"
225
+ description: "Haiku for most agents. Fastest and cheapest, but lower quality."
226
+
227
+ Apply the selected profile to the models block in config.json:
228
+ - **Balanced**: executor=sonnet, researcher=sonnet, planner=sonnet, verifier=sonnet, synthesizer=haiku
229
+ - **Quality**: executor=opus, researcher=sonnet, planner=opus, verifier=sonnet, synthesizer=sonnet
230
+ - **Budget**: executor=haiku, researcher=haiku, planner=sonnet, verifier=haiku, synthesizer=haiku
231
+
232
+ **3-features. Workflow Features:**
233
+ Use AskUserQuestion:
234
+ question: "Any extra workflow features?"
235
+ header: "Features"
236
+ multiSelect: true
237
+ options:
238
+ - label: "Auto-continue"
239
+ description: "Automatically chain commands (build → review → next phase) without prompting"
240
+ - label: "TDD mode"
241
+ description: "Write tests before implementation in executor agents"
242
+ - label: "Strict gates"
243
+ description: "Require verification AND review to pass before advancing phases"
244
+ - label: "Git branching"
245
+ description: "Create a branch per phase for cleaner PR history"
246
+
247
+ Apply selections:
248
+ - **Auto-continue**: Set `features.auto_continue: true`
249
+ - **TDD mode**: Set `features.tdd_mode: true`
250
+ - **Strict gates**: Set `gates.verification: true`, `gates.review: true`, `gates.plan_approval: true`
251
+ - **Git branching**: Set `git.branching: "phase"`
252
+
253
+ **3a. Mode:**
254
+ Use the **toggle-confirm** pattern from `skills/shared/gate-prompts.md`:
255
+ question: "How do you want to work?"
256
+ header: "Mode"
257
+ options:
258
+ - label: "Interactive" description: "Pause at key gates for your approval (default)"
259
+ - label: "Autonomous" description: "Auto-proceed, only stop for critical decisions"
260
+ - `interactive` (default) — confirm at gates (roadmap, plans, transitions)
261
+ - `autonomous` — auto-proceed, only stop for critical decisions
262
+
263
+ **3b. Depth:**
264
+ Use the **depth-select** pattern from `skills/shared/gate-prompts.md`:
265
+ question: "How thorough should planning be?"
266
+ - `quick` — 3-5 phases, skip research, ~50% cheaper
267
+ - `standard` (default) — 5-8 phases, includes research
268
+ - `comprehensive` — 8-12 phases, full deep research, ~2x cost
269
+
270
+ **3c. Parallelization:**
271
+ Use the **toggle-confirm** pattern from `skills/shared/gate-prompts.md`:
272
+ question: "Run multiple agents in parallel when plans are independent?"
273
+ header: "Parallel"
274
+ options:
275
+ - label: "Enable" description: "Parallel execution of independent plans (default)"
276
+ - label: "Disable" description: "Sequential execution only"
277
+ - `enabled` (default) — parallel execution of independent plans
278
+ - `disabled` — sequential execution
279
+
280
+ **3d. Git Branching:**
281
+ Use the **git-strategy-select** pattern from `skills/shared/gate-prompts.md`:
282
+ question: "Git branching strategy?"
283
+ - `none` (default) — commit to current branch
284
+ - `phase` — create branch per phase
285
+ - `milestone` — create branch per milestone
286
+
287
+ **3e. Commit Planning Docs:**
288
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
289
+ question: "Should planning documents (.planning/ directory) be committed to git?"
290
+ options:
291
+ - label: "Yes" description: "Commit planning docs (default)"
292
+ - label: "No" description: "Add .planning/ to .gitignore"
293
+ - `yes` (default) — commit planning docs
294
+ - `no` — add .planning/ to .gitignore
295
+
296
+ **3d-claude. CLAUDE.md Integration:**
297
+
298
+ Check if a `CLAUDE.md` file exists in the project root.
299
+
300
+ **If it exists**: Read it. If it does NOT already contain a "Plan-Build-Run" section, append the block below.
301
+ **If it does NOT exist**: Create `CLAUDE.md` with the block below.
302
+
303
+ Append/create:
304
+
305
+ ```markdown
306
+ ## Plan-Build-Run
307
+
308
+ This project uses [Plan-Build-Run](https://github.com/SienkLogic/plan-build-run) for structured development.
309
+
310
+ - Project state: `.planning/STATE.md` (source of truth for current phase and progress)
311
+ - Configuration: `.planning/config.json`
312
+ - Run `$pbr-status` to see current project state and suggested next action.
313
+
314
+ **After compaction or context recovery**: Read `.planning/STATE.md` (especially the `## Session Continuity` section) before proceeding with any work. The PreCompact hook writes recovery state there automatically.
315
+ ```
316
+
317
+ **After gathering preferences:**
318
+
319
+ **CRITICAL (no hook): You MUST create the .planning/ directory and write config.json NOW. Do not proceed without this.**
320
+
321
+ 1. Read the config template from `skills/begin/templates/config.json.tmpl`
322
+ 2. Apply the user's choices to the template (including 3d-claude CLAUDE.md integration)
323
+ 3. Create `.planning/` directory
324
+ 4. Write `.planning/config.json` with the user's preferences
325
+
326
+ **IMPORTANT**: This step MUST happen BEFORE research (Step 5) because depth controls how many researchers to spawn.
327
+
328
+ **CRITICAL (hook-enforced): Write .active-skill NOW.** Write the text "begin" to `.planning/.active-skill` using the Write tool. Verify the file exists before proceeding.
329
+
330
+ ---
331
+
332
+ ### Step 4: Research Decision (inline)
333
+
334
+ Based on the depth setting from Step 3, determine the research approach:
335
+
336
+ **Depth-to-Discovery mapping:**
337
+
338
+ | Depth | Discovery Level | Researchers | Topics |
339
+ |-------|----------------|-------------|--------|
340
+ | quick | Level 0 | 0 | Skip research entirely |
341
+ | standard | Level 1 | 2 | STACK.md, FEATURES.md |
342
+ | standard + brownfield | Level 2 | 2-3 | STACK.md, FEATURES.md, + codebase mapping |
343
+ | comprehensive | Level 3 | 4 | STACK.md, FEATURES.md, ARCHITECTURE.md, PITFALLS.md |
344
+
345
+ **If depth is `quick`:**
346
+ - Skip to Step 7 (Requirements Scoping)
347
+ - Tell user: "Skipping research phase (depth: quick). Moving straight to requirements."
348
+
349
+ **If depth is `standard` or `comprehensive`:**
350
+ - If `gates.confirm_research` is `true` in config:
351
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
352
+ question: "I'd like to research the technology landscape before planning. This helps create better plans. Proceed with research?"
353
+ options:
354
+ - label: "Yes" description: "Run research agents (recommended for standard/comprehensive)"
355
+ - label: "No" description: "Skip research, move straight to requirements"
356
+ - If user selects "No": skip to Step 7
357
+ - If user selects "Yes": proceed to Step 5
358
+ - If `gates.confirm_research` is `false` (default): proceed directly to Step 5 (research runs automatically)
359
+
360
+ ---
361
+
362
+ ### Step 5: Research (delegated to agents)
363
+
364
+ Spawn parallel Task() agents for research. Each researcher writes to `.planning/research/`.
365
+
366
+ **CRITICAL (no hook): Create .planning/research/ directory NOW before spawning researchers. Do NOT skip this step.**
367
+
368
+ **Learnings injection (opt-in):** Before spawning researchers, check if global learnings exist:
369
+
370
+ ```bash
371
+ node {resolved_plugin_root}/scripts/pbr-tools.js learnings query --tags "stack,tech" 2>/dev/null
372
+ ```
373
+
374
+ If the command succeeds AND returns a non-empty JSON array:
375
+
376
+ - Write the results to a temp file:
377
+
378
+ ```bash
379
+ node {resolved_plugin_root}/scripts/pbr-tools.js learnings query --tags "stack,tech" > /tmp/pbr-learnings-$$.md
380
+ ```
381
+
382
+ - Note the temp file path as `{learnings_temp_path}`
383
+ - Add this file to the researcher's `files_to_read` block (see below)
384
+
385
+ If no learnings exist or the command fails: skip injection silently.
386
+
387
+ **For each research topic, spawn a Task():**
388
+
389
+ ```
390
+ Task({
391
+ subagent_type: "pbr:researcher",
392
+ // After researcher: check for ## RESEARCH COMPLETE or ## RESEARCH BLOCKED
393
+ prompt: <see researcher prompt template below>
394
+ })
395
+ ```
396
+
397
+ **NOTE**: The `pbr:researcher` subagent type auto-loads the agent definition from `agents/researcher.md`. Do NOT inline the agent definition — it wastes main context.
398
+
399
+ **Path resolution**: Before constructing any agent prompt, resolve `${PLUGIN_ROOT}` to its absolute path. Do not pass the variable literally in prompts — Task() contexts may not expand it. Use the resolved absolute path for any pbr-tools.js or template references included in the prompt.
400
+
401
+ #### Researcher Prompt Template
402
+
403
+ For each researcher, construct the prompt by reading the template and filling in placeholders:
404
+
405
+ Read `skills/begin/templates/researcher-prompt.md.tmpl` for the prompt structure.
406
+
407
+ **Prepend this block to the researcher prompt before sending:**
408
+
409
+ ```
410
+ <files_to_read>
411
+ CRITICAL (no hook): Read these files BEFORE any other action:
412
+ 1. .planning/REQUIREMENTS.md — scoped requirements (if exists)
413
+ {if learnings_temp_path exists}2. {learnings_temp_path} — cross-project learnings (tech stack patterns from past PBR projects){/if}
414
+ </files_to_read>
415
+ ```
416
+
417
+ If `{learnings_temp_path}` was produced in the learnings injection step above, replace `{if...}{/if}` with the actual line. If no learnings were found, omit line 2 entirely.
418
+
419
+ **Placeholders to fill:**
420
+ - `{project name from questioning}` — project name gathered in Step 2
421
+ - `{2-3 sentence description from questioning}` — project description from Step 2
422
+ - `{any locked technology choices}` — technology constraints from Step 2
423
+ - `{budget, timeline, skill level, etc.}` — user constraints from Step 2
424
+ - `{topic}` — the research topic being assigned (e.g., "Technology Stack Analysis")
425
+ - `{TOPIC}` — the output filename (e.g., STACK, FEATURES, ARCHITECTURE, PITFALLS)
426
+ - `{topic-specific questions}` — see topic-specific questions below
427
+
428
+ **Topic-specific questions:**
429
+
430
+ **STACK.md** (Level 1+):
431
+ - What is the standard technology stack for this type of project?
432
+ - What are the current recommended versions?
433
+ - What are the key dependencies and their compatibility?
434
+ - What build tools and development workflow is standard?
435
+
436
+ **FEATURES.md** (Level 1+):
437
+ - How are similar features typically implemented in this stack?
438
+ - What libraries/packages are commonly used for each feature area?
439
+ - What are standard patterns for the key features described?
440
+ - What third-party integrations are typically needed?
441
+
442
+ **ARCHITECTURE.md** (Level 3 only):
443
+ - What is the recommended architecture for this type of project?
444
+ - How should the codebase be organized?
445
+ - What are the standard patterns for data flow, state management, etc.?
446
+ - How should components communicate?
447
+
448
+ **PITFALLS.md** (Level 3 only):
449
+ - What commonly goes wrong with this type of project?
450
+ - What are the most common mistakes developers make?
451
+ - What performance issues are typical?
452
+ - What security concerns exist?
453
+
454
+ **Parallelization:**
455
+ - Spawn ALL researchers in parallel (multiple Task() calls in one response)
456
+ - Use `run_in_background: true` for each researcher
457
+ - Before spawning, display to the user: `◐ Spawning {N} researchers in parallel...`
458
+ - While waiting, display progress to the user:
459
+ - After spawning: list of topics being researched
460
+ - Periodically (every ~30s): check `TaskOutput` with `block: false` for each agent and report status
461
+ - When each completes: "✓ {topic} researcher complete ({duration})"
462
+ - When all complete: "All {N} researchers finished. Proceeding to synthesis."
463
+ - Wait for all to complete before proceeding
464
+
465
+ ---
466
+
467
+ ### Step 6: Synthesis (delegated to subagent)
468
+
469
+ After all researchers complete, display to the user: `◐ Spawning synthesizer...`
470
+
471
+ Spawn a synthesis agent:
472
+
473
+ ```
474
+ Task({
475
+ subagent_type: "pbr:synthesizer",
476
+ prompt: <synthesis prompt>
477
+ })
478
+ ```
479
+
480
+ **NOTE**: The `pbr:synthesizer` subagent type auto-loads the agent definition. Do NOT inline it. The agent definition specifies `model: sonnet` — do not override it.
481
+
482
+ **Path resolution**: Before constructing the agent prompt, resolve `${PLUGIN_ROOT}` to its absolute path. Do not pass the variable literally in prompts — Task() contexts may not expand it.
483
+
484
+ #### Synthesis Prompt Template
485
+
486
+ Read `skills/begin/templates/synthesis-prompt.md.tmpl` for the prompt structure.
487
+
488
+ **Prepend this block to the synthesizer prompt before sending:**
489
+ ```
490
+ <files_to_read>
491
+ CRITICAL (no hook): Read these files BEFORE any other action:
492
+ 1. .planning/research/*.md — all research output files from Step 5
493
+ </files_to_read>
494
+ ```
495
+
496
+ **Placeholders to fill:**
497
+ - `{List all .planning/research/*.md files that were created}` — list the research files produced in Step 5
498
+
499
+ **After the synthesizer completes**, check for completion markers in the Task() output:
500
+
501
+ - If `## SYNTHESIS COMPLETE` is present: proceed normally
502
+ - If `## SYNTHESIS BLOCKED` is present: warn the user and offer to proceed without synthesis:
503
+ ```
504
+ ⚠ Synthesizer reported BLOCKED: {reason from output}
505
+ Research files are still available individually in .planning/research/.
506
+ ```
507
+ Use AskUserQuestion (pattern: yes-no from `skills/shared/gate-prompts.md`):
508
+ question: "Synthesis was blocked. Continue without synthesis?"
509
+ header: "Blocked"
510
+ options:
511
+ - label: "Yes" description: "Proceed to requirements — use individual research files"
512
+ - label: "No" description: "Stop and investigate"
513
+ - If "Yes": proceed to Step 7 without SUMMARY.md
514
+ - If "No": stop and suggest reviewing .planning/research/ files
515
+ - If neither marker is found: warn the user that the synthesizer may not have completed successfully, but proceed if SUMMARY.md exists on disk
516
+
517
+ If synthesis succeeded, display:
518
+ ```
519
+ ✓ Research synthesis complete — see .planning/research/SUMMARY.md
520
+ ```
521
+
522
+ ---
523
+
524
+ ### Step 7: Requirements Scoping (inline)
525
+
526
+ Present research findings (if any) and interactively scope requirements with the user.
527
+
528
+ **7a. Present findings:**
529
+ If research was done, read `.planning/research/SUMMARY.md` and present key findings:
530
+ - Recommended stack
531
+ - Key architectural decisions
532
+ - Notable pitfalls to be aware of
533
+
534
+ **7b. Feature identification:**
535
+ From the questioning session, list all features and capabilities discussed. Group them into categories.
536
+
537
+ Example categories: Auth, UI, API, Data, Infrastructure, Testing, etc.
538
+
539
+ **7c. Scope each category:**
540
+ For each category, present the features and ask the user to classify each:
541
+ - **v1 (committed)** — Will be built in this project
542
+ - **v2 (deferred)** — Will be built later, not now
543
+ - **Out of scope** — Will NOT be built
544
+
545
+ **7d. Assign REQ-IDs:**
546
+ For each committed requirement, assign an ID in the format `{CATEGORY}-{NN}`:
547
+ - `AUTH-01`: User can log in with Discord OAuth
548
+ - `AUTH-02`: Protected routes redirect to login
549
+ - `UI-01`: Dashboard shows player statistics
550
+ - `UI-02`: Mobile-responsive layout
551
+
552
+ Each requirement must be:
553
+ - **User-centric** — describes a capability from the user's perspective
554
+ - **Testable** — you can verify whether it's met or not
555
+ - **Specific** — not vague ("fast" is bad, "page loads in <2s" is good)
556
+
557
+ **7e. Write REQUIREMENTS.md:**
558
+
559
+ **CRITICAL (no hook): Write REQUIREMENTS.md NOW. The roadmap planner depends on this file.**
560
+
561
+ Read the template from `skills/begin/templates/REQUIREMENTS.md.tmpl` and write `.planning/REQUIREMENTS.md` with:
562
+ - All v1 requirements grouped by category
563
+ - All v2 requirements with deferral reasons
564
+ - Out-of-scope items with rationale
565
+ - Traceability table (all REQ-IDs, no phases assigned yet)
566
+
567
+ ---
568
+
569
+ ### Step 8: Roadmap Generation (delegated to subagent)
570
+
571
+ Display to the user: `◐ Spawning planner (roadmap)...`
572
+
573
+ Spawn the planner in roadmap mode:
574
+
575
+ ```
576
+ Task({
577
+ subagent_type: "pbr:planner",
578
+ // After planner: check for ## PLANNING COMPLETE or ## PLANNING FAILED
579
+ prompt: <roadmap prompt>
580
+ })
581
+ ```
582
+
583
+ **NOTE**: The `pbr:planner` subagent type auto-loads the agent definition. Do NOT inline it. The planner agent will read REQUIREMENTS.md and SUMMARY.md from disk — you only need to tell it what to do and where files are.
584
+
585
+ **Path resolution**: Before constructing the agent prompt, resolve `${PLUGIN_ROOT}` to its absolute path. Do not pass the variable literally in prompts — Task() contexts may not expand it.
586
+
587
+ #### Roadmap Prompt Template
588
+
589
+ Read `skills/begin/templates/roadmap-prompt.md.tmpl` for the prompt structure.
590
+
591
+ **Prepend this block to the roadmap planner prompt before sending:**
592
+ ```
593
+ <files_to_read>
594
+ CRITICAL (no hook): Read these files BEFORE any other action:
595
+ 1. .planning/REQUIREMENTS.md — scoped requirements for phase planning
596
+ 2. .planning/research/SUMMARY.md — research synthesis (if exists)
597
+ </files_to_read>
598
+ ```
599
+
600
+ **Placeholders to fill:**
601
+ - `{project name}` — project name from Step 2
602
+ - `{description}` — project description from Step 2
603
+ - `{quick|standard|comprehensive}` — depth setting from Step 3
604
+
605
+ **After the planner completes:**
606
+ - **Spot-check:** Verify `.planning/ROADMAP.md` exists on disk using Glob before attempting to read it. If missing, the planner may have failed silently — warn: `⚠ ROADMAP.md not found after planner completed. Re-spawning planner...` and retry once.
607
+ - Read `.planning/ROADMAP.md`
608
+ - Count the phases from the roadmap content
609
+ - Verify the roadmap contains a `## Milestone:` section wrapping the phases (the planner should generate this). If not, the initial set of phases constitutes the first milestone — add the section header yourself.
610
+ - Display:
611
+ ```
612
+ ✓ Roadmap created — {N} phases in milestone "{name}"
613
+ ```
614
+ - If `gates.confirm_roadmap` is true in config, use the **approve-revise-abort** pattern from `skills/shared/gate-prompts.md`:
615
+ question: "Approve this roadmap?"
616
+ options:
617
+ - label: "Approve" description: "Proceed with this roadmap"
618
+ - label: "Request changes" description: "Discuss adjustments before proceeding"
619
+ - label: "Abort" description: "Cancel and start over"
620
+ - If user selects "Request changes": edit the roadmap inline (small changes) or re-spawn planner
621
+ - If user selects "Approve": proceed to Step 9
622
+ - If user selects "Abort": stop execution
623
+
624
+ ---
625
+
626
+ ### Step 9: State Initialization (inline)
627
+
628
+ Write the project state files from templates:
629
+
630
+ **CRITICAL (no hook): You MUST write all 5 state initialization files (Steps 9a-9e). Do NOT skip any.**
631
+
632
+ **CRITICAL (no hook): Write PROJECT.md NOW. Do NOT skip this step.**
633
+
634
+ **9a. Write PROJECT.md:**
635
+ 1. Read `skills/begin/templates/PROJECT.md.tmpl`
636
+ 2. Fill in:
637
+ - `{project_name}` — from questioning
638
+ - `{2-3 sentences}` — project description from questioning
639
+ - `{ONE sentence}` — core value statement
640
+ - Out-of-scope features
641
+ - Technical context and constraints
642
+ - Initial key decisions from the questioning conversation
643
+ 3. Write to `.planning/PROJECT.md`
644
+ 4. Ensure the `## Milestones` section is filled in with the project name and phase count from the roadmap
645
+
646
+ **CRITICAL (no hook): Write STATE.md NOW. Do NOT skip this step.**
647
+
648
+ **9b. Write STATE.md:**
649
+ 1. Read `skills/begin/templates/STATE.md.tmpl`
650
+ 2. Fill in:
651
+ - `{date}` — today's date
652
+ - `{total}` — total phase count from roadmap
653
+ - `{Phase 1 name}` — from roadmap
654
+ - Core value one-liner
655
+ - Decisions from initialization
656
+ 3. Write to `.planning/STATE.md`
657
+ 4. Fill in the `## Milestone` section with the project name and total phase count
658
+ 5. **STATE.md size limit**: Follow size limit enforcement rules in `skills/shared/state-update.md` (150 lines max).
659
+
660
+ **CRITICAL (no hook): Write CONTEXT.md NOW. Do NOT skip this step.**
661
+
662
+ **9c. Write CONTEXT.md:**
663
+ Create `.planning/CONTEXT.md` from information gathered during questioning:
664
+
665
+ ```markdown
666
+ # Project Context
667
+
668
+ ## Locked Decisions
669
+ {Technology choices, architecture decisions, and constraints that are NON-NEGOTIABLE}
670
+
671
+ | Decision | Rationale | Locked By |
672
+ |----------|-----------|-----------|
673
+ | {e.g., "Use TypeScript"} | {User preference, team skill} | User |
674
+
675
+ ## User Constraints
676
+ {Budget, timeline, skill level, hosting, team size}
677
+
678
+ ## Deferred Ideas
679
+ {Features explicitly moved to v2 or out-of-scope}
680
+
681
+ | Idea | Reason Deferred |
682
+ |------|----------------|
683
+ | {feature} | {reason} |
684
+ ```
685
+
686
+ **CRITICAL (no hook): Write HISTORY.md NOW. Do NOT skip this step.**
687
+
688
+ **9d. Write HISTORY.md:**
689
+ Create `.planning/HISTORY.md` with an initial entry:
690
+
691
+ ```markdown
692
+ # Project History
693
+
694
+ ## {date} — Project Created
695
+
696
+ - Initialized Plan-Build-Run project
697
+ - Depth: {depth}, Mode: {mode}
698
+ - Roadmap: {N} phases planned
699
+ ```
700
+
701
+ **CRITICAL (no hook): Create phase directories NOW. Do NOT skip this step.**
702
+
703
+ **9e. Create phase directories:**
704
+ For each phase in the roadmap, create the directory structure:
705
+ ```
706
+ .planning/phases/01-{slug}/
707
+ .planning/phases/02-{slug}/
708
+ ...
709
+ ```
710
+
711
+ Where `{slug}` is the phase name in kebab-case (e.g., `project-setup`, `authentication`).
712
+
713
+ ---
714
+
715
+ ### Step 10: Git Setup (inline)
716
+
717
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
718
+
719
+ **10a. Gitignore:**
720
+ If `planning.commit_docs` is `false` in config:
721
+ - Add `.planning/` to `.gitignore`
722
+
723
+ If `planning.commit_docs` is `true`:
724
+ - Add `.planning/research/` to `.gitignore` (research is always excluded — it's reference material, not project state)
725
+
726
+ **10b. Initial commit (if desired):**
727
+ If `gates.confirm_project` is true in config:
728
+ - Present a summary of everything created:
729
+ - Project: {name}
730
+ - Core value: {one-liner}
731
+ - Phases: {count} phases in roadmap
732
+ - Requirements: {count} v1 requirements
733
+ - Config: depth={depth}, mode={mode}
734
+ - If `gates.confirm_commit_docs` is `true` OR this is a **brownfield** project (existing code detected in Step 1):
735
+ Use the **yes-no** pattern from `skills/shared/gate-prompts.md`:
736
+ question: "Everything look good? Commit the planning docs?"
737
+ options:
738
+ - label: "Yes" description: "Stage and commit .planning/ files"
739
+ - label: "No" description: "Let me review and adjust first"
740
+ - If user selects "Yes" and `planning.commit_docs` is true:
741
+ - Stage `.planning/` files (excluding research/ if gitignored)
742
+ - Commit: `chore: initialize plan-build-run project planning`
743
+ - If user selects "No": let user review and adjust
744
+ - If `gates.confirm_commit_docs` is `false` AND greenfield: skip the question and commit automatically if `planning.commit_docs` is true
745
+
746
+ ---
747
+
748
+ ## Cleanup
749
+
750
+ Delete `.planning/.active-skill` if it exists. This must happen on all paths (success, partial, and failure) before reporting results.
751
+
752
+ ## Completion
753
+
754
+ After all steps complete, present the final summary using the stage banner format from Read `references/ui-formatting.md`:
755
+
756
+ Display the `PROJECT INITIALIZED ✓` banner with project name, core value, phase list, and requirement counts. Then display the "Next Up" block (see § "Next Up Block" in ui-formatting.md) pointing to `$pbr-discuss 1` with alternatives: `$pbr-explore`, `$pbr-plan 1`, `$pbr-milestone new`, `$pbr-config`. Include `<sub>/clear first → fresh context window</sub>` inside the Next Up routing block.
757
+
758
+ ---
759
+
760
+ ## Error Handling
761
+
762
+ ### Research agent fails
763
+ If a researcher Task() fails or times out:
764
+ - Note which topic wasn't researched
765
+ - Continue with available research
766
+ - Display: `⚠ Research on {topic} failed. Proceeding without it. You can re-research during $pbr-plan.`
767
+
768
+ ### User wants to restart
769
+ If user says they want to start over mid-flow:
770
+ - Confirm: "Start over from the beginning? Current progress will be lost."
771
+ - If yes: restart from Step 2
772
+
773
+ ### Config write fails
774
+ If `.planning/` directory can't be created, display:
775
+ ```
776
+ ╔══════════════════════════════════════════════════════════════╗
777
+ ║ ERROR ║
778
+ ╚══════════════════════════════════════════════════════════════╝
779
+
780
+ Cannot create .planning/ directory.
781
+
782
+ **To fix:** Check directory permissions or specify an alternative path.
783
+ ```
784
+
785
+ ---
786
+
787
+ ## Files Created by $pbr-begin
788
+
789
+ | File | Purpose | When |
790
+ |------|---------|------|
791
+ | `.planning/config.json` | Workflow configuration | Step 3 |
792
+ | `.planning/research/*.md` | Research documents | Step 5 (if research enabled) |
793
+ | `.planning/research/SUMMARY.md` | Research synthesis | Step 6 (if research enabled) |
794
+ | `.planning/REQUIREMENTS.md` | Scoped requirements | Step 7 |
795
+ | `.planning/ROADMAP.md` | Phase roadmap | Step 8 |
796
+ | `.planning/PROJECT.md` | Project overview | Step 9 |
797
+ | `.planning/STATE.md` | Current state tracker | Step 9 |
798
+ | `.planning/CONTEXT.md` | Decisions and constraints | Step 9 |
799
+ | `.planning/HISTORY.md` | Project history log | Step 9 |
800
+ | `.planning/phases/NN-*/` | Phase directories | Step 9 |