@sienklogic/plan-build-run 2.60.0 → 2.61.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to Plan-Build-Run will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.61.0](https://github.com/SienkLogic/plan-build-run/compare/plan-build-run-v2.60.0...plan-build-run-v2.61.0) (2026-03-06)
9
+
10
+
11
+ ### Features
12
+
13
+ * **prd-import:** add --prd flag and Steps A-G to import skill ([1260658](https://github.com/SienkLogic/plan-build-run/commit/1260658fc4341f61f7e5c7e8bc47b70932f34bd8))
14
+ * **prd-import:** add prd.auto_extract config schema key ([5ba6b8a](https://github.com/SienkLogic/plan-build-run/commit/5ba6b8a57c6d99ef7ceb8279dda8e25acf5352fb))
15
+ * **prd-import:** sync --prd import flow to derivative plugins ([0d5fa67](https://github.com/SienkLogic/plan-build-run/commit/0d5fa67dcf0b84411dbe09b3ba77f278d7c178cc))
16
+
8
17
  ## [2.60.0](https://github.com/SienkLogic/plan-build-run/compare/plan-build-run-v2.59.0...plan-build-run-v2.60.0) (2026-03-06)
9
18
 
10
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sienklogic/plan-build-run",
3
- "version": "2.60.0",
3
+ "version": "2.61.0",
4
4
  "description": "Plan it, Build it, Run it — structured development workflow for Claude Code",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -49,7 +49,15 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
49
49
  1. Parse `$ARGUMENTS` for phase number
50
50
  2. Parse optional `--from <filepath>` flag (path to the external document to import)
51
51
  3. Parse optional `--skip-checker` flag (skip plan validation step)
52
+ 3b. Parse optional `--prd <filepath>` flag.
53
+ - If `--prd` is present: **branch into PRD Import Flow (Steps A–G below)** immediately after writing `.active-skill`.
54
+ - Do NOT proceed to Step 2 (standard import flow). The --prd branch is a completely separate execution path.
55
+ - If both `--prd` and `--from` are present: treat `--prd` as the primary flag; `--from` is ignored with an [INFO] note.
56
+ - If `--prd` is present but no filepath follows: display error "Missing filepath for --prd flag." and stop.
52
57
  4. **CRITICAL: Write .active-skill NOW.** Write the text "import" to `.planning/.active-skill` using the Write tool.
58
+
59
+ **→ If --prd flag was set: jump to PRD Import Flow (Step A). Do not continue to Step 2.**
60
+
53
61
  5. Validate:
54
62
  - Phase exists in ROADMAP.md
55
63
  - Phase directory exists at `.planning/phases/{NN}-{slug}/`
@@ -61,6 +69,253 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
61
69
 
62
70
  ---
63
71
 
72
+ ## PRD Import Flow
73
+
74
+ > **Entered when `--prd <filepath>` is present in $ARGUMENTS. Steps A–G replace Steps 2–11 entirely for this path.**
75
+
76
+ ---
77
+
78
+ ### Step A: Read and Validate PRD File
79
+
80
+ 1. Read the file at the `--prd <filepath>` path.
81
+ 2. If the file does not exist: display the "Import file not found" error from the Error Handling section and stop.
82
+ 3. If the file is empty or < 100 characters: display error "PRD file appears empty or too short to extract meaningful content." and stop.
83
+ 4. Store the full PRD content for use in Steps B–E.
84
+
85
+ ---
86
+
87
+ ### Step B: Gap Detection — Identify Missing Sections (inline)
88
+
89
+ Analyze the PRD content for the presence of these six required sections:
90
+
91
+ | Section | What to look for |
92
+ |---------|-----------------|
93
+ | Project name / title | A clear product name or title |
94
+ | Problem statement | What problem the product solves, who it's for |
95
+ | Goals / success criteria | Measurable outcomes, KPIs, or acceptance tests |
96
+ | Functional requirements | Feature list, user stories, or capabilities |
97
+ | Non-functional requirements | Performance, security, reliability constraints |
98
+ | Out of scope / deferred | Explicitly excluded features |
99
+
100
+ For each section that is **absent or ambiguous**, record it as a gap.
101
+
102
+ **If 1–3 gaps found:** Batch all gaps into ≤ 3 AskUserQuestion calls (max 4 options each). Ask the user to supply the missing info:
103
+
104
+ - If 1 gap: one AskUserQuestion with a freeform prompt.
105
+ - If 2–3 gaps: group into 2 AskUserQuestion calls of related topics (e.g., "Requirements" and "Constraints/Scope").
106
+ - If > 3 gaps: group all into exactly 3 AskUserQuestion calls. Do NOT exceed 3 calls.
107
+
108
+ Example AskUserQuestion for missing requirements:
109
+
110
+ ```
111
+ Use AskUserQuestion:
112
+ question: "The PRD doesn't clearly specify functional requirements. Please describe the main features or capabilities this product must have."
113
+ header: "Fill Gap"
114
+ options: [] ← freeform (no options means free text input)
115
+ multiSelect: false
116
+ ```
117
+
118
+ **If 0 gaps:** proceed directly to Step C with no prompts.
119
+
120
+ Incorporate user answers into the extraction context used in Step C.
121
+
122
+ ---
123
+
124
+ ### Step C: Extract 3 Files Inline (PROJECT.md, REQUIREMENTS.md, CONTEXT.md)
125
+
126
+ Using the PRD content (plus any gap-fill answers from Step B), generate the content for three files. Do this inline in your context — no agents for these three files.
127
+
128
+ **C1. Generate PROJECT.md content** using `templates/PROJECT.md.tmpl` as the structure:
129
+
130
+ - `{project_name}`: extract from PRD title/header
131
+ - `{ONE sentence core value statement}`: extract from problem statement / vision
132
+ - Vision section: 2-3 sentences from PRD problem statement
133
+ - Scope — In Scope: features from functional requirements section
134
+ - Scope — Out of Scope: features from "out of scope" section (or mark "None specified" if absent)
135
+ - Success Criteria: from goals/KPIs section
136
+ - Stakeholders: extract if present; default to "Primary user: end users of the product"
137
+ - Milestones line: leave as "Planned in {N} phases across 1 milestone — see .planning/ROADMAP.md"
138
+
139
+ **C2. Generate REQUIREMENTS.md content** using `templates/REQUIREMENTS.md.tmpl` as the structure:
140
+
141
+ - Functional Requirements: each feature/capability from PRD becomes one REQ-F-xxx row
142
+ - Number from REQ-F-001 sequentially
143
+ - Priority: "Must" for core features, "Should" for nice-to-haves (infer from PRD language)
144
+ - Non-Functional Requirements: from performance/security/reliability section if present
145
+ - Deferred Requirements: items from "out of scope" section
146
+ - Traceability table: leave "Implemented In" and "Verified In" columns as "—"
147
+
148
+ **C3. Generate CONTEXT.md content** using `templates/project-CONTEXT.md.tmpl` as the structure:
149
+
150
+ - Locked Decisions: extract any explicit technology choices or constraints from PRD
151
+ - User Constraints: extract deployment, team size, budget, timeline if mentioned
152
+ - Deferred Ideas: items from "out of scope" section
153
+ - Claude's Discretion Areas: leave empty (executor will fill as they work)
154
+
155
+ ---
156
+
157
+ ### Step D: Confirmation Gate
158
+
159
+ **Check config:** Read `.planning/config.json`. If `prd.auto_extract` is `true`, skip this step entirely and proceed directly to Step E.
160
+
161
+ **If prd.auto_extract is false (default):**
162
+
163
+ Display a preview of the three generated files (show first 10 lines of each with a `...` truncation).
164
+
165
+ Then present the confirmation gate using the **approve-revise-abort** pattern from `skills/shared/gate-prompts.md`:
166
+
167
+ ```
168
+ Use AskUserQuestion:
169
+ question: "Approve these extracted files? (PROJECT.md, REQUIREMENTS.md, CONTEXT.md — ROADMAP.md will be generated next)"
170
+ header: "Approve?"
171
+ options:
172
+ - label: "Approve" description: "Write files and generate ROADMAP.md"
173
+ - label: "Request changes" description: "Describe what to adjust before writing"
174
+ - label: "Abort" description: "Cancel PRD import"
175
+ multiSelect: false
176
+ ```
177
+
178
+ - **Approve**: proceed to Step E.
179
+ - **Request changes**: ask user what to change (AskUserQuestion freeform), revise the affected file(s) inline, and re-display the gate. Repeat until Approve or Abort.
180
+ - **Abort**: delete `.planning/.active-skill` and stop with message: "PRD import cancelled."
181
+
182
+ ---
183
+
184
+ ### Step E: Check for Existing Files and Write PROJECT.md, REQUIREMENTS.md, CONTEXT.md
185
+
186
+ For each of the three files (`PROJECT.md`, `REQUIREMENTS.md`, `CONTEXT.md` in `.planning/`):
187
+
188
+ 1. Check if the file already exists (Glob `.planning/PROJECT.md`, etc.).
189
+ 2. If it exists: use AskUserQuestion yes-no pattern:
190
+ ```
191
+ question: ".planning/{filename} already exists. Overwrite it?"
192
+ header: "Overwrite?"
193
+ options:
194
+ - label: "Yes" description: "Replace existing file"
195
+ - label: "No" description: "Keep existing, skip this file"
196
+ ```
197
+ - If No: skip writing that file.
198
+ 3. Write approved content to:
199
+ - `.planning/PROJECT.md`
200
+ - `.planning/REQUIREMENTS.md`
201
+ - `.planning/CONTEXT.md`
202
+
203
+ ---
204
+
205
+ ### Step F: Delegate ROADMAP.md Generation to pbr:planner
206
+
207
+ Display: `◐ Generating ROADMAP.md via planner...`
208
+
209
+ Spawn the planner subagent:
210
+
211
+ ```
212
+ Task({
213
+ subagent_type: "pbr:planner",
214
+ prompt: "
215
+ You are the planner agent in Roadmap Mode.
216
+
217
+ <files_to_read>
218
+ CRITICAL: Read these files BEFORE any other action:
219
+ 1. .planning/PROJECT.md
220
+ 2. .planning/REQUIREMENTS.md
221
+ 3. .planning/CONTEXT.md
222
+ </files_to_read>
223
+
224
+ Generate `.planning/ROADMAP.md` from the project files above.
225
+
226
+ Use the roadmap template at `${PLUGIN_ROOT}/templates/ROADMAP.md.tmpl`.
227
+ Apply Requirement Coverage Validation: every requirement in REQUIREMENTS.md must appear in at least one phase.
228
+ Apply the Dual Format requirement: Quick-scan checklist at top + detailed phase descriptions.
229
+ Wrap all phases in a Milestone section named after the project.
230
+
231
+ Write ROADMAP.md to `.planning/ROADMAP.md`.
232
+ Output your completion marker when done: ## PLANNING COMPLETE
233
+ "
234
+ })
235
+ ```
236
+
237
+ After the Task() completes:
238
+
239
+ - Confirm `.planning/ROADMAP.md` exists (Glob check).
240
+ - If missing: display error "Planner failed to generate ROADMAP.md. Run $pbr-plan to retry." and proceed to Step G anyway (the other 3 files are already written).
241
+
242
+ ---
243
+
244
+ ### Step G: State Updates, Commit, and Summary
245
+
246
+ **G1. Initialize STATE.md** (if it does not already exist):
247
+
248
+ - Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js state load`
249
+ - If STATE.md does not exist: create `.planning/STATE.md` with frontmatter fields:
250
+ ```
251
+ project: {project_name from PROJECT.md}
252
+ current_phase: 1
253
+ status: planning
254
+ source: prd-import
255
+ prd_file: {filepath}
256
+ ```
257
+
258
+ **G2. Update STATE.md** with PRD import status:
259
+
260
+ - Set `status: planning`
261
+ - Note `source: prd-import` and `prd_file: {filepath}`
262
+
263
+ **G3. Commit (if planning.commit_docs is true in config):**
264
+
265
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
266
+
267
+ ```
268
+ docs(planning): init project docs from PRD import
269
+ ```
270
+
271
+ Stage: `.planning/PROJECT.md`, `.planning/REQUIREMENTS.md`, `.planning/CONTEXT.md`, `.planning/ROADMAP.md` (if generated), `.planning/STATE.md`.
272
+
273
+ **G4. Delete `.planning/.active-skill`.**
274
+
275
+ **G5. Display completion banner:**
276
+
277
+ ```
278
+ ╔══════════════════════════════════════════════════════════════╗
279
+ ║ PLAN-BUILD-RUN ► PRD IMPORT COMPLETE ✓ ║
280
+ ╚══════════════════════════════════════════════════════════════╝
281
+
282
+ **Project**: {project_name}
283
+ **Source**: {prd_filepath}
284
+
285
+ Files generated:
286
+ ✓ .planning/PROJECT.md
287
+ ✓ .planning/REQUIREMENTS.md
288
+ ✓ .planning/CONTEXT.md
289
+ {✓ or ✗} .planning/ROADMAP.md
290
+
291
+ Requirements extracted: {count} REQ-IDs
292
+ Gaps filled: {count} (via interactive prompts)
293
+
294
+
295
+
296
+ ╔══════════════════════════════════════════════════════════════╗
297
+ ║ ▶ NEXT UP ║
298
+ ╚══════════════════════════════════════════════════════════════╝
299
+
300
+ **Plan Phase 1** — generate execution plans for the first phase
301
+
302
+ `$pbr-plan 1`
303
+
304
+ <sub>`/clear` first → fresh context window</sub>
305
+
306
+
307
+
308
+ **Also available:**
309
+ - `$pbr-discuss` — review and refine decisions before planning
310
+ - `$pbr-status` — see full project overview
311
+ ```
312
+
313
+ ---
314
+
315
+ > **End of PRD Import Flow. Steps 2–11 below apply only to the standard --from flow.**
316
+
317
+ ---
318
+
64
319
  ### Step 2: Load Full Project Context (inline)
65
320
 
66
321
  Read all relevant context files. This context is used for conflict detection in Step 4.
@@ -500,6 +755,22 @@ File not found: {filepath}
500
755
  **To fix:** Check the path and try again.
501
756
  ```
502
757
 
758
+ ### PRD file too short
759
+ If the PRD file is < 100 characters:
760
+ ```
761
+ ╔══════════════════════════════════════════════════════════════╗
762
+ ║ ERROR ║
763
+ ╚══════════════════════════════════════════════════════════════╝
764
+
765
+ PRD file appears empty or too short to extract meaningful content.
766
+
767
+ **To fix:** Provide a more complete PRD document (minimum ~100 characters).
768
+ ```
769
+
770
+ ### PRD import cancelled
771
+ If user selects "Abort" at the confirmation gate (Step D):
772
+ Display: "PRD import cancelled." and delete `.planning/.active-skill`.
773
+
503
774
  ### Import document too vague
504
775
  If the imported document contains no actionable tasks, display:
505
776
  ```
@@ -536,3 +807,7 @@ Present remaining issues and ask user to decide: proceed or intervene.
536
807
  | `.planning/ROADMAP.md` | Plans Complete + Status updated to `planned` | Step 8a |
537
808
  | `.planning/STATE.md` | Updated with plan status and import source | Step 8b |
538
809
  | `.planning/CONTEXT.md` | Updated if blockers surfaced new locked decisions | Step 8d |
810
+ | `.planning/PROJECT.md` | Generated from PRD | Step E (PRD flow) |
811
+ | `.planning/REQUIREMENTS.md` | Generated from PRD | Step E (PRD flow) |
812
+ | `.planning/CONTEXT.md` | Generated from PRD | Step E (PRD flow) |
813
+ | `.planning/ROADMAP.md` | Generated by planner subagent | Step F (PRD flow) |
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pbr",
3
3
  "displayName": "Plan-Build-Run",
4
- "version": "2.60.0",
4
+ "version": "2.61.0",
5
5
  "description": "Plan-Build-Run — Structured development workflow for GitHub Copilot CLI. Solves context rot through disciplined agent delegation, structured planning, atomic execution, and goal-backward verification.",
6
6
  "author": {
7
7
  "name": "SienkLogic",
@@ -49,7 +49,15 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
49
49
  1. Parse `$ARGUMENTS` for phase number
50
50
  2. Parse optional `--from <filepath>` flag (path to the external document to import)
51
51
  3. Parse optional `--skip-checker` flag (skip plan validation step)
52
+ 3b. Parse optional `--prd <filepath>` flag.
53
+ - If `--prd` is present: **branch into PRD Import Flow (Steps A–G below)** immediately after writing `.active-skill`.
54
+ - Do NOT proceed to Step 2 (standard import flow). The --prd branch is a completely separate execution path.
55
+ - If both `--prd` and `--from` are present: treat `--prd` as the primary flag; `--from` is ignored with an [INFO] note.
56
+ - If `--prd` is present but no filepath follows: display error "Missing filepath for --prd flag." and stop.
52
57
  4. **CRITICAL: Write .active-skill NOW.** Write the text "import" to `.planning/.active-skill` using the Write tool.
58
+
59
+ **→ If --prd flag was set: jump to PRD Import Flow (Step A). Do not continue to Step 2.**
60
+
53
61
  5. Validate:
54
62
  - Phase exists in ROADMAP.md
55
63
  - Phase directory exists at `.planning/phases/{NN}-{slug}/`
@@ -61,6 +69,253 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
61
69
 
62
70
  ---
63
71
 
72
+ ## PRD Import Flow
73
+
74
+ > **Entered when `--prd <filepath>` is present in $ARGUMENTS. Steps A–G replace Steps 2–11 entirely for this path.**
75
+
76
+ ---
77
+
78
+ ### Step A: Read and Validate PRD File
79
+
80
+ 1. Read the file at the `--prd <filepath>` path.
81
+ 2. If the file does not exist: display the "Import file not found" error from the Error Handling section and stop.
82
+ 3. If the file is empty or < 100 characters: display error "PRD file appears empty or too short to extract meaningful content." and stop.
83
+ 4. Store the full PRD content for use in Steps B–E.
84
+
85
+ ---
86
+
87
+ ### Step B: Gap Detection — Identify Missing Sections (inline)
88
+
89
+ Analyze the PRD content for the presence of these six required sections:
90
+
91
+ | Section | What to look for |
92
+ |---------|-----------------|
93
+ | Project name / title | A clear product name or title |
94
+ | Problem statement | What problem the product solves, who it's for |
95
+ | Goals / success criteria | Measurable outcomes, KPIs, or acceptance tests |
96
+ | Functional requirements | Feature list, user stories, or capabilities |
97
+ | Non-functional requirements | Performance, security, reliability constraints |
98
+ | Out of scope / deferred | Explicitly excluded features |
99
+
100
+ For each section that is **absent or ambiguous**, record it as a gap.
101
+
102
+ **If 1–3 gaps found:** Batch all gaps into ≤ 3 AskUserQuestion calls (max 4 options each). Ask the user to supply the missing info:
103
+
104
+ - If 1 gap: one AskUserQuestion with a freeform prompt.
105
+ - If 2–3 gaps: group into 2 AskUserQuestion calls of related topics (e.g., "Requirements" and "Constraints/Scope").
106
+ - If > 3 gaps: group all into exactly 3 AskUserQuestion calls. Do NOT exceed 3 calls.
107
+
108
+ Example AskUserQuestion for missing requirements:
109
+
110
+ ```
111
+ Use AskUserQuestion:
112
+ question: "The PRD doesn't clearly specify functional requirements. Please describe the main features or capabilities this product must have."
113
+ header: "Fill Gap"
114
+ options: [] ← freeform (no options means free text input)
115
+ multiSelect: false
116
+ ```
117
+
118
+ **If 0 gaps:** proceed directly to Step C with no prompts.
119
+
120
+ Incorporate user answers into the extraction context used in Step C.
121
+
122
+ ---
123
+
124
+ ### Step C: Extract 3 Files Inline (PROJECT.md, REQUIREMENTS.md, CONTEXT.md)
125
+
126
+ Using the PRD content (plus any gap-fill answers from Step B), generate the content for three files. Do this inline in your context — no agents for these three files.
127
+
128
+ **C1. Generate PROJECT.md content** using `templates/PROJECT.md.tmpl` as the structure:
129
+
130
+ - `{project_name}`: extract from PRD title/header
131
+ - `{ONE sentence core value statement}`: extract from problem statement / vision
132
+ - Vision section: 2-3 sentences from PRD problem statement
133
+ - Scope — In Scope: features from functional requirements section
134
+ - Scope — Out of Scope: features from "out of scope" section (or mark "None specified" if absent)
135
+ - Success Criteria: from goals/KPIs section
136
+ - Stakeholders: extract if present; default to "Primary user: end users of the product"
137
+ - Milestones line: leave as "Planned in {N} phases across 1 milestone — see .planning/ROADMAP.md"
138
+
139
+ **C2. Generate REQUIREMENTS.md content** using `templates/REQUIREMENTS.md.tmpl` as the structure:
140
+
141
+ - Functional Requirements: each feature/capability from PRD becomes one REQ-F-xxx row
142
+ - Number from REQ-F-001 sequentially
143
+ - Priority: "Must" for core features, "Should" for nice-to-haves (infer from PRD language)
144
+ - Non-Functional Requirements: from performance/security/reliability section if present
145
+ - Deferred Requirements: items from "out of scope" section
146
+ - Traceability table: leave "Implemented In" and "Verified In" columns as "—"
147
+
148
+ **C3. Generate CONTEXT.md content** using `templates/project-CONTEXT.md.tmpl` as the structure:
149
+
150
+ - Locked Decisions: extract any explicit technology choices or constraints from PRD
151
+ - User Constraints: extract deployment, team size, budget, timeline if mentioned
152
+ - Deferred Ideas: items from "out of scope" section
153
+ - Claude's Discretion Areas: leave empty (executor will fill as they work)
154
+
155
+ ---
156
+
157
+ ### Step D: Confirmation Gate
158
+
159
+ **Check config:** Read `.planning/config.json`. If `prd.auto_extract` is `true`, skip this step entirely and proceed directly to Step E.
160
+
161
+ **If prd.auto_extract is false (default):**
162
+
163
+ Display a preview of the three generated files (show first 10 lines of each with a `...` truncation).
164
+
165
+ Then present the confirmation gate using the **approve-revise-abort** pattern from `skills/shared/gate-prompts.md`:
166
+
167
+ ```
168
+ Use AskUserQuestion:
169
+ question: "Approve these extracted files? (PROJECT.md, REQUIREMENTS.md, CONTEXT.md — ROADMAP.md will be generated next)"
170
+ header: "Approve?"
171
+ options:
172
+ - label: "Approve" description: "Write files and generate ROADMAP.md"
173
+ - label: "Request changes" description: "Describe what to adjust before writing"
174
+ - label: "Abort" description: "Cancel PRD import"
175
+ multiSelect: false
176
+ ```
177
+
178
+ - **Approve**: proceed to Step E.
179
+ - **Request changes**: ask user what to change (AskUserQuestion freeform), revise the affected file(s) inline, and re-display the gate. Repeat until Approve or Abort.
180
+ - **Abort**: delete `.planning/.active-skill` and stop with message: "PRD import cancelled."
181
+
182
+ ---
183
+
184
+ ### Step E: Check for Existing Files and Write PROJECT.md, REQUIREMENTS.md, CONTEXT.md
185
+
186
+ For each of the three files (`PROJECT.md`, `REQUIREMENTS.md`, `CONTEXT.md` in `.planning/`):
187
+
188
+ 1. Check if the file already exists (Glob `.planning/PROJECT.md`, etc.).
189
+ 2. If it exists: use AskUserQuestion yes-no pattern:
190
+ ```
191
+ question: ".planning/{filename} already exists. Overwrite it?"
192
+ header: "Overwrite?"
193
+ options:
194
+ - label: "Yes" description: "Replace existing file"
195
+ - label: "No" description: "Keep existing, skip this file"
196
+ ```
197
+ - If No: skip writing that file.
198
+ 3. Write approved content to:
199
+ - `.planning/PROJECT.md`
200
+ - `.planning/REQUIREMENTS.md`
201
+ - `.planning/CONTEXT.md`
202
+
203
+ ---
204
+
205
+ ### Step F: Delegate ROADMAP.md Generation to pbr:planner
206
+
207
+ Display: `◐ Generating ROADMAP.md via planner...`
208
+
209
+ Spawn the planner subagent:
210
+
211
+ ```
212
+ Task({
213
+ subagent_type: "pbr:planner",
214
+ prompt: "
215
+ You are the planner agent in Roadmap Mode.
216
+
217
+ <files_to_read>
218
+ CRITICAL: Read these files BEFORE any other action:
219
+ 1. .planning/PROJECT.md
220
+ 2. .planning/REQUIREMENTS.md
221
+ 3. .planning/CONTEXT.md
222
+ </files_to_read>
223
+
224
+ Generate `.planning/ROADMAP.md` from the project files above.
225
+
226
+ Use the roadmap template at `${PLUGIN_ROOT}/templates/ROADMAP.md.tmpl`.
227
+ Apply Requirement Coverage Validation: every requirement in REQUIREMENTS.md must appear in at least one phase.
228
+ Apply the Dual Format requirement: Quick-scan checklist at top + detailed phase descriptions.
229
+ Wrap all phases in a Milestone section named after the project.
230
+
231
+ Write ROADMAP.md to `.planning/ROADMAP.md`.
232
+ Output your completion marker when done: ## PLANNING COMPLETE
233
+ "
234
+ })
235
+ ```
236
+
237
+ After the Task() completes:
238
+
239
+ - Confirm `.planning/ROADMAP.md` exists (Glob check).
240
+ - If missing: display error "Planner failed to generate ROADMAP.md. Run /pbr:plan to retry." and proceed to Step G anyway (the other 3 files are already written).
241
+
242
+ ---
243
+
244
+ ### Step G: State Updates, Commit, and Summary
245
+
246
+ **G1. Initialize STATE.md** (if it does not already exist):
247
+
248
+ - Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js state load`
249
+ - If STATE.md does not exist: create `.planning/STATE.md` with frontmatter fields:
250
+ ```
251
+ project: {project_name from PROJECT.md}
252
+ current_phase: 1
253
+ status: planning
254
+ source: prd-import
255
+ prd_file: {filepath}
256
+ ```
257
+
258
+ **G2. Update STATE.md** with PRD import status:
259
+
260
+ - Set `status: planning`
261
+ - Note `source: prd-import` and `prd_file: {filepath}`
262
+
263
+ **G3. Commit (if planning.commit_docs is true in config):**
264
+
265
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
266
+
267
+ ```
268
+ docs(planning): init project docs from PRD import
269
+ ```
270
+
271
+ Stage: `.planning/PROJECT.md`, `.planning/REQUIREMENTS.md`, `.planning/CONTEXT.md`, `.planning/ROADMAP.md` (if generated), `.planning/STATE.md`.
272
+
273
+ **G4. Delete `.planning/.active-skill`.**
274
+
275
+ **G5. Display completion banner:**
276
+
277
+ ```
278
+ ╔══════════════════════════════════════════════════════════════╗
279
+ ║ PLAN-BUILD-RUN ► PRD IMPORT COMPLETE ✓ ║
280
+ ╚══════════════════════════════════════════════════════════════╝
281
+
282
+ **Project**: {project_name}
283
+ **Source**: {prd_filepath}
284
+
285
+ Files generated:
286
+ ✓ .planning/PROJECT.md
287
+ ✓ .planning/REQUIREMENTS.md
288
+ ✓ .planning/CONTEXT.md
289
+ {✓ or ✗} .planning/ROADMAP.md
290
+
291
+ Requirements extracted: {count} REQ-IDs
292
+ Gaps filled: {count} (via interactive prompts)
293
+
294
+
295
+
296
+ ╔══════════════════════════════════════════════════════════════╗
297
+ ║ ▶ NEXT UP ║
298
+ ╚══════════════════════════════════════════════════════════════╝
299
+
300
+ **Plan Phase 1** — generate execution plans for the first phase
301
+
302
+ `/pbr:plan 1`
303
+
304
+ <sub>`/clear` first → fresh context window</sub>
305
+
306
+
307
+
308
+ **Also available:**
309
+ - `/pbr:discuss` — review and refine decisions before planning
310
+ - `/pbr:status` — see full project overview
311
+ ```
312
+
313
+ ---
314
+
315
+ > **End of PRD Import Flow. Steps 2–11 below apply only to the standard --from flow.**
316
+
317
+ ---
318
+
64
319
  ### Step 2: Load Full Project Context (inline)
65
320
 
66
321
  Read all relevant context files. This context is used for conflict detection in Step 4.
@@ -500,6 +755,22 @@ File not found: {filepath}
500
755
  **To fix:** Check the path and try again.
501
756
  ```
502
757
 
758
+ ### PRD file too short
759
+ If the PRD file is < 100 characters:
760
+ ```
761
+ ╔══════════════════════════════════════════════════════════════╗
762
+ ║ ERROR ║
763
+ ╚══════════════════════════════════════════════════════════════╝
764
+
765
+ PRD file appears empty or too short to extract meaningful content.
766
+
767
+ **To fix:** Provide a more complete PRD document (minimum ~100 characters).
768
+ ```
769
+
770
+ ### PRD import cancelled
771
+ If user selects "Abort" at the confirmation gate (Step D):
772
+ Display: "PRD import cancelled." and delete `.planning/.active-skill`.
773
+
503
774
  ### Import document too vague
504
775
  If the imported document contains no actionable tasks, display:
505
776
  ```
@@ -536,3 +807,7 @@ Present remaining issues and ask user to decide: proceed or intervene.
536
807
  | `.planning/ROADMAP.md` | Plans Complete + Status updated to `planned` | Step 8a |
537
808
  | `.planning/STATE.md` | Updated with plan status and import source | Step 8b |
538
809
  | `.planning/CONTEXT.md` | Updated if blockers surfaced new locked decisions | Step 8d |
810
+ | `.planning/PROJECT.md` | Generated from PRD | Step E (PRD flow) |
811
+ | `.planning/REQUIREMENTS.md` | Generated from PRD | Step E (PRD flow) |
812
+ | `.planning/CONTEXT.md` | Generated from PRD | Step E (PRD flow) |
813
+ | `.planning/ROADMAP.md` | Generated by planner subagent | Step F (PRD flow) |
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pbr",
3
3
  "displayName": "Plan-Build-Run",
4
- "version": "2.60.0",
4
+ "version": "2.61.0",
5
5
  "description": "Plan-Build-Run — Structured development workflow for Cursor. Solves context rot through disciplined subagent delegation, structured planning, atomic execution, and goal-backward verification.",
6
6
  "author": {
7
7
  "name": "SienkLogic",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: import
3
3
  description: "Import external plans. Validates context, detects conflicts, generates PLAN.md."
4
- argument-hint: "<phase-number> [--from <filepath>] [--skip-checker]"
4
+ argument-hint: "<phase-number> [--from <filepath>] [--skip-checker] | --prd <filepath>"
5
5
  ---
6
6
 
7
7
  **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
@@ -50,7 +50,15 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
50
50
  1. Parse `$ARGUMENTS` for phase number
51
51
  2. Parse optional `--from <filepath>` flag (path to the external document to import)
52
52
  3. Parse optional `--skip-checker` flag (skip plan validation step)
53
+ 3b. Parse optional `--prd <filepath>` flag.
54
+ - If `--prd` is present: **branch into PRD Import Flow (Steps A–G below)** immediately after writing `.active-skill`.
55
+ - Do NOT proceed to Step 2 (standard import flow). The --prd branch is a completely separate execution path.
56
+ - If both `--prd` and `--from` are present: treat `--prd` as the primary flag; `--from` is ignored with an [INFO] note.
57
+ - If `--prd` is present but no filepath follows: display error "Missing filepath for --prd flag." and stop.
53
58
  4. **CRITICAL: Write .active-skill NOW.** Write the text "import" to `.planning/.active-skill` using the Write tool.
59
+
60
+ **→ If --prd flag was set: jump to PRD Import Flow (Step A). Do not continue to Step 2.**
61
+
54
62
  5. Validate:
55
63
  - Phase exists in ROADMAP.md
56
64
  - Phase directory exists at `.planning/phases/{NN}-{slug}/`
@@ -62,6 +70,253 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
62
70
 
63
71
  ---
64
72
 
73
+ ## PRD Import Flow
74
+
75
+ > **Entered when `--prd <filepath>` is present in $ARGUMENTS. Steps A–G replace Steps 2–11 entirely for this path.**
76
+
77
+ ---
78
+
79
+ ### Step A: Read and Validate PRD File
80
+
81
+ 1. Read the file at the `--prd <filepath>` path.
82
+ 2. If the file does not exist: display the "Import file not found" error from the Error Handling section and stop.
83
+ 3. If the file is empty or < 100 characters: display error "PRD file appears empty or too short to extract meaningful content." and stop.
84
+ 4. Store the full PRD content for use in Steps B–E.
85
+
86
+ ---
87
+
88
+ ### Step B: Gap Detection — Identify Missing Sections (inline)
89
+
90
+ Analyze the PRD content for the presence of these six required sections:
91
+
92
+ | Section | What to look for |
93
+ |---------|-----------------|
94
+ | Project name / title | A clear product name or title |
95
+ | Problem statement | What problem the product solves, who it's for |
96
+ | Goals / success criteria | Measurable outcomes, KPIs, or acceptance tests |
97
+ | Functional requirements | Feature list, user stories, or capabilities |
98
+ | Non-functional requirements | Performance, security, reliability constraints |
99
+ | Out of scope / deferred | Explicitly excluded features |
100
+
101
+ For each section that is **absent or ambiguous**, record it as a gap.
102
+
103
+ **If 1–3 gaps found:** Batch all gaps into ≤ 3 AskUserQuestion calls (max 4 options each). Ask the user to supply the missing info:
104
+
105
+ - If 1 gap: one AskUserQuestion with a freeform prompt.
106
+ - If 2–3 gaps: group into 2 AskUserQuestion calls of related topics (e.g., "Requirements" and "Constraints/Scope").
107
+ - If > 3 gaps: group all into exactly 3 AskUserQuestion calls. Do NOT exceed 3 calls.
108
+
109
+ Example AskUserQuestion for missing requirements:
110
+
111
+ ```
112
+ Use AskUserQuestion:
113
+ question: "The PRD doesn't clearly specify functional requirements. Please describe the main features or capabilities this product must have."
114
+ header: "Fill Gap"
115
+ options: [] ← freeform (no options means free text input)
116
+ multiSelect: false
117
+ ```
118
+
119
+ **If 0 gaps:** proceed directly to Step C with no prompts.
120
+
121
+ Incorporate user answers into the extraction context used in Step C.
122
+
123
+ ---
124
+
125
+ ### Step C: Extract 3 Files Inline (PROJECT.md, REQUIREMENTS.md, CONTEXT.md)
126
+
127
+ Using the PRD content (plus any gap-fill answers from Step B), generate the content for three files. Do this inline in your context — no agents for these three files.
128
+
129
+ **C1. Generate PROJECT.md content** using `templates/PROJECT.md.tmpl` as the structure:
130
+
131
+ - `{project_name}`: extract from PRD title/header
132
+ - `{ONE sentence core value statement}`: extract from problem statement / vision
133
+ - Vision section: 2-3 sentences from PRD problem statement
134
+ - Scope — In Scope: features from functional requirements section
135
+ - Scope — Out of Scope: features from "out of scope" section (or mark "None specified" if absent)
136
+ - Success Criteria: from goals/KPIs section
137
+ - Stakeholders: extract if present; default to "Primary user: end users of the product"
138
+ - Milestones line: leave as "Planned in {N} phases across 1 milestone — see .planning/ROADMAP.md"
139
+
140
+ **C2. Generate REQUIREMENTS.md content** using `templates/REQUIREMENTS.md.tmpl` as the structure:
141
+
142
+ - Functional Requirements: each feature/capability from PRD becomes one REQ-F-xxx row
143
+ - Number from REQ-F-001 sequentially
144
+ - Priority: "Must" for core features, "Should" for nice-to-haves (infer from PRD language)
145
+ - Non-Functional Requirements: from performance/security/reliability section if present
146
+ - Deferred Requirements: items from "out of scope" section
147
+ - Traceability table: leave "Implemented In" and "Verified In" columns as "—"
148
+
149
+ **C3. Generate CONTEXT.md content** using `templates/project-CONTEXT.md.tmpl` as the structure:
150
+
151
+ - Locked Decisions: extract any explicit technology choices or constraints from PRD
152
+ - User Constraints: extract deployment, team size, budget, timeline if mentioned
153
+ - Deferred Ideas: items from "out of scope" section
154
+ - Claude's Discretion Areas: leave empty (executor will fill as they work)
155
+
156
+ ---
157
+
158
+ ### Step D: Confirmation Gate
159
+
160
+ **Check config:** Read `.planning/config.json`. If `prd.auto_extract` is `true`, skip this step entirely and proceed directly to Step E.
161
+
162
+ **If prd.auto_extract is false (default):**
163
+
164
+ Display a preview of the three generated files (show first 10 lines of each with a `...` truncation).
165
+
166
+ Then present the confirmation gate using the **approve-revise-abort** pattern from `skills/shared/gate-prompts.md`:
167
+
168
+ ```
169
+ Use AskUserQuestion:
170
+ question: "Approve these extracted files? (PROJECT.md, REQUIREMENTS.md, CONTEXT.md — ROADMAP.md will be generated next)"
171
+ header: "Approve?"
172
+ options:
173
+ - label: "Approve" description: "Write files and generate ROADMAP.md"
174
+ - label: "Request changes" description: "Describe what to adjust before writing"
175
+ - label: "Abort" description: "Cancel PRD import"
176
+ multiSelect: false
177
+ ```
178
+
179
+ - **Approve**: proceed to Step E.
180
+ - **Request changes**: ask user what to change (AskUserQuestion freeform), revise the affected file(s) inline, and re-display the gate. Repeat until Approve or Abort.
181
+ - **Abort**: delete `.planning/.active-skill` and stop with message: "PRD import cancelled."
182
+
183
+ ---
184
+
185
+ ### Step E: Check for Existing Files and Write PROJECT.md, REQUIREMENTS.md, CONTEXT.md
186
+
187
+ For each of the three files (`PROJECT.md`, `REQUIREMENTS.md`, `CONTEXT.md` in `.planning/`):
188
+
189
+ 1. Check if the file already exists (Glob `.planning/PROJECT.md`, etc.).
190
+ 2. If it exists: use AskUserQuestion yes-no pattern:
191
+ ```
192
+ question: ".planning/{filename} already exists. Overwrite it?"
193
+ header: "Overwrite?"
194
+ options:
195
+ - label: "Yes" description: "Replace existing file"
196
+ - label: "No" description: "Keep existing, skip this file"
197
+ ```
198
+ - If No: skip writing that file.
199
+ 3. Write approved content to:
200
+ - `.planning/PROJECT.md`
201
+ - `.planning/REQUIREMENTS.md`
202
+ - `.planning/CONTEXT.md`
203
+
204
+ ---
205
+
206
+ ### Step F: Delegate ROADMAP.md Generation to pbr:planner
207
+
208
+ Display: `◐ Generating ROADMAP.md via planner...`
209
+
210
+ Spawn the planner subagent:
211
+
212
+ ```
213
+ Task({
214
+ subagent_type: "pbr:planner",
215
+ prompt: "
216
+ You are the planner agent in Roadmap Mode.
217
+
218
+ <files_to_read>
219
+ CRITICAL: Read these files BEFORE any other action:
220
+ 1. .planning/PROJECT.md
221
+ 2. .planning/REQUIREMENTS.md
222
+ 3. .planning/CONTEXT.md
223
+ </files_to_read>
224
+
225
+ Generate `.planning/ROADMAP.md` from the project files above.
226
+
227
+ Use the roadmap template at `${PLUGIN_ROOT}/templates/ROADMAP.md.tmpl`.
228
+ Apply Requirement Coverage Validation: every requirement in REQUIREMENTS.md must appear in at least one phase.
229
+ Apply the Dual Format requirement: Quick-scan checklist at top + detailed phase descriptions.
230
+ Wrap all phases in a Milestone section named after the project.
231
+
232
+ Write ROADMAP.md to `.planning/ROADMAP.md`.
233
+ Output your completion marker when done: ## PLANNING COMPLETE
234
+ "
235
+ })
236
+ ```
237
+
238
+ After the Task() completes:
239
+
240
+ - Confirm `.planning/ROADMAP.md` exists (Glob check).
241
+ - If missing: display error "Planner failed to generate ROADMAP.md. Run /pbr:plan to retry." and proceed to Step G anyway (the other 3 files are already written).
242
+
243
+ ---
244
+
245
+ ### Step G: State Updates, Commit, and Summary
246
+
247
+ **G1. Initialize STATE.md** (if it does not already exist):
248
+
249
+ - Run: `node ${PLUGIN_ROOT}/scripts/pbr-tools.js state load`
250
+ - If STATE.md does not exist: create `.planning/STATE.md` with frontmatter fields:
251
+ ```
252
+ project: {project_name from PROJECT.md}
253
+ current_phase: 1
254
+ status: planning
255
+ source: prd-import
256
+ prd_file: {filepath}
257
+ ```
258
+
259
+ **G2. Update STATE.md** with PRD import status:
260
+
261
+ - Set `status: planning`
262
+ - Note `source: prd-import` and `prd_file: {filepath}`
263
+
264
+ **G3. Commit (if planning.commit_docs is true in config):**
265
+
266
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
267
+
268
+ ```
269
+ docs(planning): init project docs from PRD import
270
+ ```
271
+
272
+ Stage: `.planning/PROJECT.md`, `.planning/REQUIREMENTS.md`, `.planning/CONTEXT.md`, `.planning/ROADMAP.md` (if generated), `.planning/STATE.md`.
273
+
274
+ **G4. Delete `.planning/.active-skill`.**
275
+
276
+ **G5. Display completion banner:**
277
+
278
+ ```
279
+ ╔══════════════════════════════════════════════════════════════╗
280
+ ║ PLAN-BUILD-RUN ► PRD IMPORT COMPLETE ✓ ║
281
+ ╚══════════════════════════════════════════════════════════════╝
282
+
283
+ **Project**: {project_name}
284
+ **Source**: {prd_filepath}
285
+
286
+ Files generated:
287
+ ✓ .planning/PROJECT.md
288
+ ✓ .planning/REQUIREMENTS.md
289
+ ✓ .planning/CONTEXT.md
290
+ {✓ or ✗} .planning/ROADMAP.md
291
+
292
+ Requirements extracted: {count} REQ-IDs
293
+ Gaps filled: {count} (via interactive prompts)
294
+
295
+
296
+
297
+ ╔══════════════════════════════════════════════════════════════╗
298
+ ║ ▶ NEXT UP ║
299
+ ╚══════════════════════════════════════════════════════════════╝
300
+
301
+ **Plan Phase 1** — generate execution plans for the first phase
302
+
303
+ `/pbr:plan 1`
304
+
305
+ <sub>`/clear` first → fresh context window</sub>
306
+
307
+
308
+
309
+ **Also available:**
310
+ - `/pbr:discuss` — review and refine decisions before planning
311
+ - `/pbr:status` — see full project overview
312
+ ```
313
+
314
+ ---
315
+
316
+ > **End of PRD Import Flow. Steps 2–11 below apply only to the standard --from flow.**
317
+
318
+ ---
319
+
65
320
  ### Step 2: Load Full Project Context (inline)
66
321
 
67
322
  Read all relevant context files. This context is used for conflict detection in Step 4.
@@ -501,6 +756,22 @@ File not found: {filepath}
501
756
  **To fix:** Check the path and try again.
502
757
  ```
503
758
 
759
+ ### PRD file too short
760
+ If the PRD file is < 100 characters:
761
+ ```
762
+ ╔══════════════════════════════════════════════════════════════╗
763
+ ║ ERROR ║
764
+ ╚══════════════════════════════════════════════════════════════╝
765
+
766
+ PRD file appears empty or too short to extract meaningful content.
767
+
768
+ **To fix:** Provide a more complete PRD document (minimum ~100 characters).
769
+ ```
770
+
771
+ ### PRD import cancelled
772
+ If user selects "Abort" at the confirmation gate (Step D):
773
+ Display: "PRD import cancelled." and delete `.planning/.active-skill`.
774
+
504
775
  ### Import document too vague
505
776
  If the imported document contains no actionable tasks, display:
506
777
  ```
@@ -537,3 +808,7 @@ Present remaining issues and ask user to decide: proceed or intervene.
537
808
  | `.planning/ROADMAP.md` | Plans Complete + Status updated to `planned` | Step 8a |
538
809
  | `.planning/STATE.md` | Updated with plan status and import source | Step 8b |
539
810
  | `.planning/CONTEXT.md` | Updated if blockers surfaced new locked decisions | Step 8d |
811
+ | `.planning/PROJECT.md` | Generated from PRD | Step E (PRD flow) |
812
+ | `.planning/REQUIREMENTS.md` | Generated from PRD | Step E (PRD flow) |
813
+ | `.planning/CONTEXT.md` | Generated from PRD | Step E (PRD flow) |
814
+ | `.planning/ROADMAP.md` | Generated by planner subagent | Step F (PRD flow) |
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pbr",
3
- "version": "2.60.0",
3
+ "version": "2.61.0",
4
4
  "description": "Plan-Build-Run — Structured development workflow for Claude Code. Solves context rot through disciplined subagent delegation, structured planning, atomic execution, and goal-backward verification.",
5
5
  "author": {
6
6
  "name": "SienkLogic",
@@ -175,6 +175,18 @@
175
175
  },
176
176
  "additionalProperties": false
177
177
  },
178
+ "prd": {
179
+ "type": "object",
180
+ "description": "Settings for PRD import via /pbr:import --prd.",
181
+ "properties": {
182
+ "auto_extract": {
183
+ "type": "boolean",
184
+ "default": false,
185
+ "description": "When true, skip the confirmation gate during PRD import and write files immediately. Default: false (confirm-first)."
186
+ }
187
+ },
188
+ "additionalProperties": false
189
+ },
178
190
  "depth_profiles": {
179
191
  "type": "object",
180
192
  "description": "Depth profile overrides. Each profile maps depth value to effective feature/gate settings.",
@@ -2,7 +2,7 @@
2
2
  name: import
3
3
  description: "Import external plans. Validates context, detects conflicts, generates PLAN.md."
4
4
  allowed-tools: Read, Write, Bash, Glob, Grep, Task, AskUserQuestion
5
- argument-hint: "<phase-number> [--from <filepath>] [--skip-checker]"
5
+ argument-hint: "<phase-number> [--from <filepath>] [--skip-checker] | --prd <filepath>"
6
6
  ---
7
7
 
8
8
  **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.**
@@ -51,7 +51,15 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
51
51
  1. Parse `$ARGUMENTS` for phase number
52
52
  2. Parse optional `--from <filepath>` flag (path to the external document to import)
53
53
  3. Parse optional `--skip-checker` flag (skip plan validation step)
54
+ 3b. Parse optional `--prd <filepath>` flag.
55
+ - If `--prd` is present: **branch into PRD Import Flow (Steps A–G below)** immediately after writing `.active-skill`.
56
+ - Do NOT proceed to Step 2 (standard import flow). The --prd branch is a completely separate execution path.
57
+ - If both `--prd` and `--from` are present: treat `--prd` as the primary flag; `--from` is ignored with an [INFO] note.
58
+ - If `--prd` is present but no filepath follows: display error "Missing filepath for --prd flag." and stop.
54
59
  4. **CRITICAL: Write .active-skill NOW.** Write the text "import" to `.planning/.active-skill` using the Write tool.
60
+
61
+ **→ If --prd flag was set: jump to PRD Import Flow (Step A). Do not continue to Step 2.**
62
+
55
63
  5. Validate:
56
64
  - Phase exists in ROADMAP.md
57
65
  - Phase directory exists at `.planning/phases/{NN}-{slug}/`
@@ -63,6 +71,253 @@ Reference: `skills/shared/config-loading.md` for the tooling shortcut and config
63
71
 
64
72
  ---
65
73
 
74
+ ## PRD Import Flow
75
+
76
+ > **Entered when `--prd <filepath>` is present in $ARGUMENTS. Steps A–G replace Steps 2–11 entirely for this path.**
77
+
78
+ ---
79
+
80
+ ### Step A: Read and Validate PRD File
81
+
82
+ 1. Read the file at the `--prd <filepath>` path.
83
+ 2. If the file does not exist: display the "Import file not found" error from the Error Handling section and stop.
84
+ 3. If the file is empty or < 100 characters: display error "PRD file appears empty or too short to extract meaningful content." and stop.
85
+ 4. Store the full PRD content for use in Steps B–E.
86
+
87
+ ---
88
+
89
+ ### Step B: Gap Detection — Identify Missing Sections (inline)
90
+
91
+ Analyze the PRD content for the presence of these six required sections:
92
+
93
+ | Section | What to look for |
94
+ |---------|-----------------|
95
+ | Project name / title | A clear product name or title |
96
+ | Problem statement | What problem the product solves, who it's for |
97
+ | Goals / success criteria | Measurable outcomes, KPIs, or acceptance tests |
98
+ | Functional requirements | Feature list, user stories, or capabilities |
99
+ | Non-functional requirements | Performance, security, reliability constraints |
100
+ | Out of scope / deferred | Explicitly excluded features |
101
+
102
+ For each section that is **absent or ambiguous**, record it as a gap.
103
+
104
+ **If 1–3 gaps found:** Batch all gaps into ≤ 3 AskUserQuestion calls (max 4 options each). Ask the user to supply the missing info:
105
+
106
+ - If 1 gap: one AskUserQuestion with a freeform prompt.
107
+ - If 2–3 gaps: group into 2 AskUserQuestion calls of related topics (e.g., "Requirements" and "Constraints/Scope").
108
+ - If > 3 gaps: group all into exactly 3 AskUserQuestion calls. Do NOT exceed 3 calls.
109
+
110
+ Example AskUserQuestion for missing requirements:
111
+
112
+ ```
113
+ Use AskUserQuestion:
114
+ question: "The PRD doesn't clearly specify functional requirements. Please describe the main features or capabilities this product must have."
115
+ header: "Fill Gap"
116
+ options: [] ← freeform (no options means free text input)
117
+ multiSelect: false
118
+ ```
119
+
120
+ **If 0 gaps:** proceed directly to Step C with no prompts.
121
+
122
+ Incorporate user answers into the extraction context used in Step C.
123
+
124
+ ---
125
+
126
+ ### Step C: Extract 3 Files Inline (PROJECT.md, REQUIREMENTS.md, CONTEXT.md)
127
+
128
+ Using the PRD content (plus any gap-fill answers from Step B), generate the content for three files. Do this inline in your context — no subagents for these three files.
129
+
130
+ **C1. Generate PROJECT.md content** using `templates/PROJECT.md.tmpl` as the structure:
131
+
132
+ - `{project_name}`: extract from PRD title/header
133
+ - `{ONE sentence core value statement}`: extract from problem statement / vision
134
+ - Vision section: 2-3 sentences from PRD problem statement
135
+ - Scope — In Scope: features from functional requirements section
136
+ - Scope — Out of Scope: features from "out of scope" section (or mark "None specified" if absent)
137
+ - Success Criteria: from goals/KPIs section
138
+ - Stakeholders: extract if present; default to "Primary user: end users of the product"
139
+ - Milestones line: leave as "Planned in {N} phases across 1 milestone — see .planning/ROADMAP.md"
140
+
141
+ **C2. Generate REQUIREMENTS.md content** using `templates/REQUIREMENTS.md.tmpl` as the structure:
142
+
143
+ - Functional Requirements: each feature/capability from PRD becomes one REQ-F-xxx row
144
+ - Number from REQ-F-001 sequentially
145
+ - Priority: "Must" for core features, "Should" for nice-to-haves (infer from PRD language)
146
+ - Non-Functional Requirements: from performance/security/reliability section if present
147
+ - Deferred Requirements: items from "out of scope" section
148
+ - Traceability table: leave "Implemented In" and "Verified In" columns as "—"
149
+
150
+ **C3. Generate CONTEXT.md content** using `templates/project-CONTEXT.md.tmpl` as the structure:
151
+
152
+ - Locked Decisions: extract any explicit technology choices or constraints from PRD
153
+ - User Constraints: extract deployment, team size, budget, timeline if mentioned
154
+ - Deferred Ideas: items from "out of scope" section
155
+ - Claude's Discretion Areas: leave empty (executor will fill as they work)
156
+
157
+ ---
158
+
159
+ ### Step D: Confirmation Gate
160
+
161
+ **Check config:** Read `.planning/config.json`. If `prd.auto_extract` is `true`, skip this step entirely and proceed directly to Step E.
162
+
163
+ **If prd.auto_extract is false (default):**
164
+
165
+ Display a preview of the three generated files (show first 10 lines of each with a `...` truncation).
166
+
167
+ Then present the confirmation gate using the **approve-revise-abort** pattern from `skills/shared/gate-prompts.md`:
168
+
169
+ ```
170
+ Use AskUserQuestion:
171
+ question: "Approve these extracted files? (PROJECT.md, REQUIREMENTS.md, CONTEXT.md — ROADMAP.md will be generated next)"
172
+ header: "Approve?"
173
+ options:
174
+ - label: "Approve" description: "Write files and generate ROADMAP.md"
175
+ - label: "Request changes" description: "Describe what to adjust before writing"
176
+ - label: "Abort" description: "Cancel PRD import"
177
+ multiSelect: false
178
+ ```
179
+
180
+ - **Approve**: proceed to Step E.
181
+ - **Request changes**: ask user what to change (AskUserQuestion freeform), revise the affected file(s) inline, and re-display the gate. Repeat until Approve or Abort.
182
+ - **Abort**: delete `.planning/.active-skill` and stop with message: "PRD import cancelled."
183
+
184
+ ---
185
+
186
+ ### Step E: Check for Existing Files and Write PROJECT.md, REQUIREMENTS.md, CONTEXT.md
187
+
188
+ For each of the three files (`PROJECT.md`, `REQUIREMENTS.md`, `CONTEXT.md` in `.planning/`):
189
+
190
+ 1. Check if the file already exists (Glob `.planning/PROJECT.md`, etc.).
191
+ 2. If it exists: use AskUserQuestion yes-no pattern:
192
+ ```
193
+ question: ".planning/{filename} already exists. Overwrite it?"
194
+ header: "Overwrite?"
195
+ options:
196
+ - label: "Yes" description: "Replace existing file"
197
+ - label: "No" description: "Keep existing, skip this file"
198
+ ```
199
+ - If No: skip writing that file.
200
+ 3. Write approved content to:
201
+ - `.planning/PROJECT.md`
202
+ - `.planning/REQUIREMENTS.md`
203
+ - `.planning/CONTEXT.md`
204
+
205
+ ---
206
+
207
+ ### Step F: Delegate ROADMAP.md Generation to pbr:planner
208
+
209
+ Display: `◐ Generating ROADMAP.md via planner...`
210
+
211
+ Spawn the planner subagent:
212
+
213
+ ```
214
+ Task({
215
+ subagent_type: "pbr:planner",
216
+ prompt: "
217
+ You are the planner agent in Roadmap Mode.
218
+
219
+ <files_to_read>
220
+ CRITICAL: Read these files BEFORE any other action:
221
+ 1. .planning/PROJECT.md
222
+ 2. .planning/REQUIREMENTS.md
223
+ 3. .planning/CONTEXT.md
224
+ </files_to_read>
225
+
226
+ Generate `.planning/ROADMAP.md` from the project files above.
227
+
228
+ Use the roadmap template at `${CLAUDE_PLUGIN_ROOT}/templates/ROADMAP.md.tmpl`.
229
+ Apply Requirement Coverage Validation: every requirement in REQUIREMENTS.md must appear in at least one phase.
230
+ Apply the Dual Format requirement: Quick-scan checklist at top + detailed phase descriptions.
231
+ Wrap all phases in a Milestone section named after the project.
232
+
233
+ Write ROADMAP.md to `.planning/ROADMAP.md`.
234
+ Output your completion marker when done: ## PLANNING COMPLETE
235
+ "
236
+ })
237
+ ```
238
+
239
+ After the Task() completes:
240
+
241
+ - Confirm `.planning/ROADMAP.md` exists (Glob check).
242
+ - If missing: display error "Planner failed to generate ROADMAP.md. Run /pbr:plan to retry." and proceed to Step G anyway (the other 3 files are already written).
243
+
244
+ ---
245
+
246
+ ### Step G: State Updates, Commit, and Summary
247
+
248
+ **G1. Initialize STATE.md** (if it does not already exist):
249
+
250
+ - Run: `node ${CLAUDE_PLUGIN_ROOT}/scripts/pbr-tools.js state load`
251
+ - If STATE.md does not exist: create `.planning/STATE.md` with frontmatter fields:
252
+ ```
253
+ project: {project_name from PROJECT.md}
254
+ current_phase: 1
255
+ status: planning
256
+ source: prd-import
257
+ prd_file: {filepath}
258
+ ```
259
+
260
+ **G2. Update STATE.md** with PRD import status:
261
+
262
+ - Set `status: planning`
263
+ - Note `source: prd-import` and `prd_file: {filepath}`
264
+
265
+ **G3. Commit (if planning.commit_docs is true in config):**
266
+
267
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
268
+
269
+ ```
270
+ docs(planning): init project docs from PRD import
271
+ ```
272
+
273
+ Stage: `.planning/PROJECT.md`, `.planning/REQUIREMENTS.md`, `.planning/CONTEXT.md`, `.planning/ROADMAP.md` (if generated), `.planning/STATE.md`.
274
+
275
+ **G4. Delete `.planning/.active-skill`.**
276
+
277
+ **G5. Display completion banner:**
278
+
279
+ ```
280
+ ╔══════════════════════════════════════════════════════════════╗
281
+ ║ PLAN-BUILD-RUN ► PRD IMPORT COMPLETE ✓ ║
282
+ ╚══════════════════════════════════════════════════════════════╝
283
+
284
+ **Project**: {project_name}
285
+ **Source**: {prd_filepath}
286
+
287
+ Files generated:
288
+ ✓ .planning/PROJECT.md
289
+ ✓ .planning/REQUIREMENTS.md
290
+ ✓ .planning/CONTEXT.md
291
+ {✓ or ✗} .planning/ROADMAP.md
292
+
293
+ Requirements extracted: {count} REQ-IDs
294
+ Gaps filled: {count} (via interactive prompts)
295
+
296
+
297
+
298
+ ╔══════════════════════════════════════════════════════════════╗
299
+ ║ ▶ NEXT UP ║
300
+ ╚══════════════════════════════════════════════════════════════╝
301
+
302
+ **Plan Phase 1** — generate execution plans for the first phase
303
+
304
+ `/pbr:plan 1`
305
+
306
+ <sub>`/clear` first → fresh context window</sub>
307
+
308
+
309
+
310
+ **Also available:**
311
+ - `/pbr:discuss` — review and refine decisions before planning
312
+ - `/pbr:status` — see full project overview
313
+ ```
314
+
315
+ ---
316
+
317
+ > **End of PRD Import Flow. Steps 2–11 below apply only to the standard --from flow.**
318
+
319
+ ---
320
+
66
321
  ### Step 2: Load Full Project Context (inline)
67
322
 
68
323
  Read all relevant context files. This context is used for conflict detection in Step 4.
@@ -502,6 +757,22 @@ File not found: {filepath}
502
757
  **To fix:** Check the path and try again.
503
758
  ```
504
759
 
760
+ ### PRD file too short
761
+ If the PRD file is < 100 characters:
762
+ ```
763
+ ╔══════════════════════════════════════════════════════════════╗
764
+ ║ ERROR ║
765
+ ╚══════════════════════════════════════════════════════════════╝
766
+
767
+ PRD file appears empty or too short to extract meaningful content.
768
+
769
+ **To fix:** Provide a more complete PRD document (minimum ~100 characters).
770
+ ```
771
+
772
+ ### PRD import cancelled
773
+ If user selects "Abort" at the confirmation gate (Step D):
774
+ Display: "PRD import cancelled." and delete `.planning/.active-skill`.
775
+
505
776
  ### Import document too vague
506
777
  If the imported document contains no actionable tasks, display:
507
778
  ```
@@ -538,3 +809,7 @@ Present remaining issues and ask user to decide: proceed or intervene.
538
809
  | `.planning/ROADMAP.md` | Plans Complete + Status updated to `planned` | Step 8a |
539
810
  | `.planning/STATE.md` | Updated with plan status and import source | Step 8b |
540
811
  | `.planning/CONTEXT.md` | Updated if blockers surfaced new locked decisions | Step 8d |
812
+ | `.planning/PROJECT.md` | Generated from PRD | Step E (PRD flow) |
813
+ | `.planning/REQUIREMENTS.md` | Generated from PRD | Step E (PRD flow) |
814
+ | `.planning/CONTEXT.md` | Generated from PRD | Step E (PRD flow) |
815
+ | `.planning/ROADMAP.md` | Generated by planner subagent | Step F (PRD flow) |