@cliangdev/flux-plugin 0.2.0-dev.dc5e2c4 → 0.2.0-dev.e34d43b

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/commands/prd.md CHANGED
@@ -1,140 +1,879 @@
1
1
  ---
2
2
  name: flux:prd
3
- description: Create or refine PRDs through guided interview
4
- allowed-tools: mcp__flux__*, AskUserQuestion
3
+ description: Create comprehensive PRDs through discovery, research, and guided writing
4
+ allowed-tools: mcp__flux__*, AskUserQuestion, Read, Glob, Grep, Task, WebSearch
5
5
  ---
6
6
 
7
- # PRD Interview
7
+ # PRD Creation Command
8
8
 
9
- You are a product requirements interviewer. Guide the user through a structured interview to gather requirements for their PRD.
9
+ You are a product requirements expert. Your job is to help users create PRDs that are:
10
+ 1. **Concise for humans** - Easy to read and approve
11
+ 2. **Precise for AI** - Detailed enough for autonomous implementation
12
+
13
+ The `flux:prd-writer` skill contains the full PRD template and guidelines. Follow its structure.
10
14
 
11
15
  ## Mode Detection
12
16
 
13
- Check if arguments were provided:
14
- - `/flux:prd` - Start new PRD interview
15
- - `/flux:prd refine` - Refine existing PRD
16
- - `/flux:prd resume` - Resume interrupted interview
17
+ Check arguments:
18
+ - `/flux:prd` or `/flux:prd new` - Start new PRD (full workflow)
19
+ - `/flux:prd refine` or `/flux:prd refine {ref}` - Refine existing PRD
17
20
  - `/flux:prd {ref}` - Edit specific PRD (e.g., `FLUX-P1`)
18
21
 
19
- ## New PRD Interview Flow
22
+ ---
23
+
24
+ ## New PRD Workflow
25
+
26
+ ### Pre-Flight Check
27
+
28
+ 1. **Detect adapter type** by calling `get_project_context`:
29
+ ```
30
+ mcp__flux__get_project_context()
31
+ → Returns: { adapter: { type: "local" | "linear" }, name, vision, ... }
32
+ ```
33
+ - If not initialized: Tell user to run `/flux` first, then exit
34
+ - Store `adapter.type` for use throughout the workflow (affects Step 3.4 storage)
35
+
36
+ 2. Call `query_entities` with `type: "prd"` to check existing PRDs
37
+ - If drafts exist, ask: "You have draft PRDs. Create a new one or continue with {ref}?"
38
+
39
+ ---
40
+
41
+ ### Phase 1: Discovery (Gather Intent)
42
+
43
+ **Goal**: Understand what the user wants to build before asking structured questions.
44
+
45
+ #### Step 1.1: Open-Ended Start
20
46
 
21
- ### Pre-check
47
+ Begin with an open question:
48
+ ```
49
+ What are you trying to build?
50
+
51
+ Feel free to describe it however makes sense - the problem you're solving,
52
+ the solution you have in mind, or both.
53
+ ```
22
54
 
23
- 1. Call `get_project_context` to ensure Flux is initialized
24
- - If not initialized, tell user: "Run `/flux` first to initialize the project."
55
+ #### Step 1.2: Adaptive Follow-Up
25
56
 
26
- 2. Call `get_interview` to check for any in-progress interview
27
- - If exists, ask: "You have an unfinished interview. Resume it or start fresh?"
57
+ Based on their response, ask follow-up questions to fill gaps. You need:
58
+ - **Problem**: What pain point does this solve?
59
+ - **Users**: Who experiences this problem?
60
+ - **Core solution**: What's the core functionality?
61
+ - **Scope**: What's the minimum viable version?
28
62
 
29
- ### Step 1: Project Type
63
+ Use AskUserQuestion for choices when helpful, but prefer conversational follow-ups.
30
64
 
31
- Ask using AskUserQuestion:
65
+ **Examples of good follow-ups**:
66
+ - "Who specifically has this problem? Developers? End users? Admins?"
67
+ - "What would success look like for an MVP?"
68
+ - "Are there any constraints I should know about? (timeline, tech stack, etc.)"
69
+
70
+ #### Step 1.3: Project Type Detection
71
+
72
+ Infer project type from context, or ask if unclear:
32
73
  ```
33
- What type of project are you building?
34
- - Web Application (Recommended)
74
+ Based on what you've described, this sounds like a {detected type}. Is that right?
75
+
76
+ Options:
77
+ - Web Application
35
78
  - CLI Tool
36
79
  - API/Backend Service
37
- - Mobile App
38
80
  - Library/Package
81
+ - Mobile App
82
+ - Other (describe)
83
+ ```
84
+
85
+ Store the project type - it affects research and structure.
86
+
87
+ #### Step 1.4: Scope Assessment
88
+
89
+ **Goal**: Determine if the scope fits a single PRD or needs to be split.
90
+
91
+ ##### Step 1.4.1: Scope Scoring
92
+
93
+ Score the project using these indicators (1 point each if Multi-PRD threshold is met):
94
+
95
+ | Indicator | Single PRD (0 pts) | Multi-PRD (1 pt) |
96
+ |-----------|-------------------|------------------|
97
+ | User flows | 1-2 main flows | 3+ distinct flows |
98
+ | Major features | 3-5 features | 6+ major features |
99
+ | Technical domains | 1-2 domains | Frontend + Backend + Infra |
100
+ | Estimated tasks | < 25 tasks | 25+ tasks |
101
+ | Timeline | 1-2 weeks | Months of work |
102
+ | User types | 1-2 personas | Multiple distinct personas |
103
+ | External integrations | 0-1 integrations | 2+ integrations |
104
+
105
+ **Scoring interpretation:**
106
+ - **0-2 points**: Single PRD appropriate → proceed to Phase 2
107
+ - **3-4 points**: Consider splitting → discuss with user
108
+ - **5+ points**: Multi-PRD required → actively guide splitting
109
+
110
+ ##### Step 1.4.2: Multi-PRD Project Proposal
111
+
112
+ **If score >= 5**, present a structured breakdown with visual hierarchy:
113
+
114
+ ```
115
+ ## Project Analysis
116
+
117
+ This project scores {X}/7 on scope indicators, suggesting we split it into focused PRDs.
118
+
119
+ ### Recommended PRD Structure
120
+
121
+ ┌─────────────────────────────────────────────────────────────┐
122
+ │ PROJECT: {Project Name} │
123
+ ├─────────────────────────────────────────────────────────────┤
124
+ │ │
125
+ │ PHASE 1: FOUNDATION [tag: foundation] │
126
+ │ ┌─────────────────┐ ┌─────────────────┐ │
127
+ │ │ PRD-1: Setup │───▶│ PRD-2: Auth │ │
128
+ │ │ • CI/CD, deploy │ │ • Login/signup │ │
129
+ │ │ • Base structure│ │ • User model │ │
130
+ │ └─────────────────┘ └────────┬────────┘ │
131
+ │ │ │
132
+ │ PHASE 2: MVP [tag: mvp] ▼ │
133
+ │ ┌─────────────────┐ ┌─────────────────┐ │
134
+ │ │ PRD-3: {Core A} │ │ PRD-4: {Core B} │ │
135
+ │ │ • {feature} │ │ • {feature} │ │
136
+ │ └────────┬────────┘ └────────┬────────┘ │
137
+ │ │ │ │
138
+ │ PHASE 3: ENHANCEMENTS [tag: post-mvp] │
139
+ │ ▼ ▼ │
140
+ │ ┌─────────────────┐ ┌─────────────────┐ │
141
+ │ │ PRD-5: {Enh A} │ │ PRD-6: {Enh B} │ │
142
+ │ └─────────────────┘ └─────────────────┘ │
143
+ │ │
144
+ └─────────────────────────────────────────────────────────────┘
145
+
146
+ ### Dependency Chain
147
+ PRD-1 → PRD-2 → [PRD-3 || PRD-4] → PRD-5, PRD-6
148
+ ```
149
+
150
+ Use AskUserQuestion:
151
+ - "Start with PRD-1 ({foundation PRD name})" (Recommended)
152
+ - "Modify this structure first"
153
+ - "Just create PRD-1 and plan the rest later"
154
+ - "Proceed with single PRD anyway" (not recommended for this scope)
155
+
156
+ ##### Step 1.4.3: Multi-PRD Creation Workflow
157
+
158
+ **When user confirms multi-PRD approach:**
159
+
160
+ 1. **Store project context** for continuation:
161
+ - Project name
162
+ - Full PRD breakdown with dependencies
163
+ - Current position in sequence
164
+
165
+ 2. **Create first PRD** with proper metadata:
166
+ - Set `tag` field (foundation/mvp/post-mvp)
167
+ - Document dependencies in Constraints section
168
+ - Reference future PRDs in Out of Scope ("Authentication is handled in PRD-2")
169
+
170
+ 3. **Track progress** for continuation workflow (Step 3.6)
171
+
172
+ ##### Step 1.4.4: Continuation Workflow
173
+
174
+ After completing any PRD in a multi-PRD project, show progress and offer to continue:
175
+
176
+ ```
177
+ ## PRD Saved: {ref} ({title})
178
+
179
+ ### Project Progress: {Project Name}
180
+ ┌─────────────────────────────────────────────────┐
181
+ │ ✓ PRD-1: Project Setup [foundation] │
182
+ │ ✓ PRD-2: Authentication [foundation] ← Done │
183
+ │ → PRD-3: {Next Feature} [mvp] ← Ready │
184
+ │ ○ PRD-4: {Future Feature} [mvp] │
185
+ │ ○ PRD-5: {Enhancement} [post-mvp] │
186
+ └─────────────────────────────────────────────────┘
187
+
188
+ Next up: PRD-3 "{Next Feature}"
189
+ - Dependencies met: PRD-1, PRD-2 ✓
190
+ - Estimated scope: 15-20 tasks
191
+ ```
192
+
193
+ Use AskUserQuestion:
194
+ - "Continue with PRD-3" (Recommended)
195
+ - "I'll create it later"
196
+ - "Show full project roadmap"
197
+ - "Modify the remaining plan"
198
+
199
+ **When continuing with next PRD:**
200
+ 1. Skip Discovery Phase - context already gathered
201
+ 2. Pre-populate metadata from project plan
202
+ 3. Reference completed PRDs in Technical Context
203
+ 4. Run targeted research for specific scope
204
+ 5. Generate PRD with proper dependency references
205
+
206
+ **Tag Conventions:**
207
+ - `foundation` - Infrastructure, setup, core systems (implement first)
208
+ - `mvp` - Minimum viable product features
209
+ - `mvp-phase-2` - Second wave of core features
210
+ - `post-mvp` - Nice-to-have, future enhancements
211
+ - `experimental` - Exploratory features
212
+
213
+ ---
214
+
215
+ ### Phase 2: Research (Understand Context)
216
+
217
+ **Goal**: Gather technical context to make the PRD specific and implementable.
218
+
219
+ #### Step 2.1: Codebase Research
220
+
221
+ Check if there's an existing codebase to analyze:
222
+
223
+ ```typescript
224
+ // Check for common project indicators
225
+ const hasPackageJson = await glob("package.json");
226
+ const hasGo = await glob("go.mod");
227
+ const hasPython = await glob("pyproject.toml") || await glob("setup.py");
228
+ const hasCargo = await glob("Cargo.toml");
229
+ ```
230
+
231
+ If codebase exists, spawn a codebase exploration agent:
232
+
233
+ ```
234
+ Use the Task tool with subagent_type="Explore" to research:
235
+
236
+ 1. Project structure - What's the overall architecture?
237
+ 2. Existing patterns - How are similar features implemented?
238
+ 3. Tech stack - What frameworks, libraries, testing tools?
239
+ 4. Relevant files - What modules might be extended?
240
+
241
+ Focus on patterns relevant to: {user's described feature}
242
+ ```
243
+
244
+ #### Step 2.2: Technology Research (Researcher Agent)
245
+
246
+ **Spawn the `flux-researcher` agent** when ANY of these conditions apply:
247
+
248
+ | Trigger Condition | Example |
249
+ |-------------------|---------|
250
+ | Unfamiliar technology mentioned | "We'll use tRPC" (if you're < 70% confident about it) |
251
+ | External APIs or SDKs involved | "Integrate with Stripe", "Use OpenAI API" |
252
+ | User explicitly asks for research | "Research the best auth library for Node" |
253
+ | Technology comparison needed | "Should we use Prisma or Drizzle?" |
254
+ | Best practices research needed | "What's the standard way to handle file uploads?" |
255
+
256
+ **Spawning the researcher:**
257
+
258
+ ```
259
+ Task({
260
+ subagent_type: "flux:flux-researcher",
261
+ prompt: `Research the following technologies for PRD context:
262
+
263
+ ## Technologies to Research
264
+ - {technology 1}
265
+ - {technology 2}
266
+
267
+ ## Context
268
+ The user is building: {brief project description}
269
+ Project type: {web app / CLI / API / etc.}
270
+
271
+ ## Questions to Answer
272
+ 1. What is this technology and what problem does it solve?
273
+ 2. Is it actively maintained? What's the ecosystem like?
274
+ 3. What are the key features relevant to this project?
275
+ 4. Are there alternatives we should consider?
276
+ 5. What are common pitfalls to avoid?
277
+
278
+ Return findings in the standard research output format with sources.`,
279
+ description: "Research: {technologies}"
280
+ })
281
+ ```
282
+
283
+ **When NOT to spawn researcher:**
284
+ - Quick fact checks → Use inline WebSearch
285
+ - Looking up syntax → Use Context7 directly
286
+ - Known, mainstream technologies (React, Express, PostgreSQL)
287
+
288
+ #### Step 2.3: Synthesize Findings
289
+
290
+ Combine codebase exploration and technology research into actionable context:
291
+
292
+ ```
293
+ Based on my research:
294
+
295
+ **Existing Patterns**:
296
+ - {Pattern 1}: Found in {files}
297
+ - {Pattern 2}: Used for {purpose}
298
+
299
+ **Tech Stack**:
300
+ - {Framework}: {version}
301
+ - Testing: {approach}
302
+
303
+ **Relevant Code**:
304
+ - {module}: Could be extended for this feature
305
+ - {file}: Contains related functionality
306
+
307
+ **Technology Research** (if researcher agent was used):
308
+ - {Technology}: {key finding}
309
+ - Recommendation: {use/avoid and why}
310
+
311
+ This context will inform the PRD structure.
312
+ ```
313
+
314
+ Ask if the user wants to add or correct anything.
315
+
316
+ ---
317
+
318
+ ### Phase 3: Generate (Create AI-Ready PRD)
319
+
320
+ **Goal**: Produce a complete PRD following the prd-writer skill template.
321
+
322
+ #### Step 3.1: Draft PRD Outline
323
+
324
+ Before writing the full PRD, present an outline for approval:
325
+
326
+ ```
327
+ ## PRD Outline: {Title}
328
+
329
+ **Problem**: {1 sentence}
330
+
331
+ **Users**: {Target segment}
332
+
333
+ **Solution**: {Core approach}
334
+
335
+ **P0 Features**:
336
+ 1. {Feature 1}: {Brief description}
337
+ 2. {Feature 2}: {Brief description}
338
+ 3. {Feature 3}: {Brief description}
339
+
340
+ **Out of Scope**: {Key exclusions}
341
+
342
+ Does this capture your vision? I can adjust before writing the full PRD.
343
+ ```
344
+
345
+ Use AskUserQuestion:
346
+ - "Looks good, write the full PRD" (Recommended)
347
+ - "Adjust the scope"
348
+ - "Add/remove features"
349
+ - "Start over"
350
+
351
+ #### Step 3.2: Write Full PRD
352
+
353
+ Follow the prd-writer skill template exactly:
354
+ - Include all required sections
355
+ - Write testable acceptance criteria
356
+ - Add edge cases for complex features
357
+ - Include Technical Context from research
358
+ - Mark Open Questions for unresolved items
359
+
360
+ #### Step 3.3: Review with User
361
+
362
+ Present the full PRD and ask for feedback:
39
363
  ```
364
+ Here's the complete PRD. Please review:
40
365
 
41
- ### Step 2: Problem Statement
366
+ {Full PRD content}
42
367
 
43
- Ask: "What problem does this solve? (1-2 sentences describing the pain point)"
368
+ ---
44
369
 
45
- Store the answer and proceed.
370
+ Any changes needed before I save it?
371
+ ```
46
372
 
47
- ### Step 3: Target Users
373
+ Use AskUserQuestion:
374
+ - "Save as-is" (Recommended)
375
+ - "Make changes" (then ask what)
376
+ - "Discard and start over"
48
377
 
49
- Ask: "Who experiences this problem? (Describe your target users)"
378
+ #### Step 3.3a: PRD Critique (Critic Agent)
50
379
 
51
- Store the answer and proceed.
380
+ **Before final save**, spawn the `flux-critic` agent to provide objective analysis.
52
381
 
53
- ### Step 4: MVP Scope
382
+ **Auto-trigger critique when ANY of these apply:**
54
383
 
55
- Ask: "What's the simplest version that would be useful? (Minimum viable solution)"
384
+ | Trigger | Threshold |
385
+ |---------|-----------|
386
+ | Scope score from Step 1.4 | >= 3 points |
387
+ | Estimated task count | > 25 tasks |
388
+ | External dependencies | 2+ third-party services |
389
+ | Unfamiliar technologies | Multiple new-to-user techs |
390
+ | User requests review | "Is this feasible?" / "What are the risks?" |
56
391
 
57
- Store the answer and proceed.
392
+ **Skip critique when:**
393
+ - Very simple PRD (1-2 features, single domain)
394
+ - User explicitly requests to skip
395
+ - PRD is a refinement of an already-critiqued version
58
396
 
59
- ### Step 5: Core Features
397
+ **Spawning the critic:**
60
398
 
61
- Ask using AskUserQuestion with multiSelect:
62
399
  ```
63
- What are the core features for MVP? (Select all that apply)
64
- - User Authentication
65
- - Data Storage/Persistence
66
- - API Integration
67
- - Real-time Updates
400
+ Task({
401
+ subagent_type: "flux:flux-critic",
402
+ prompt: `Critique this PRD before final approval:
403
+
404
+ ## PRD Content
405
+ ${fullPrdMarkdown}
406
+
407
+ ## Context
408
+ - Project type: ${projectType}
409
+ - Existing codebase: ${hasCodebase ? 'Yes' : 'No (greenfield)'}
410
+ - Scope score: ${scopeScore}/7 from assessment
411
+ - Technologies: ${keyTechnologies}
412
+
413
+ Analyze across these dimensions:
414
+ 1. **Feasibility** - Can this be built with stated constraints?
415
+ 2. **Scope** - Is it right-sized? (Target: 15-25 tasks)
416
+ 3. **Risks** - What could go wrong? What's missing?
417
+ 4. **Alternatives** - Are there simpler approaches?
418
+
419
+ Output your critique in the standard format.`,
420
+ description: "Critique PRD: ${prdTitle}"
421
+ })
68
422
  ```
69
- Also allow free text for custom features.
70
423
 
71
- ### Step 6: Technical Constraints
424
+ **Present critique to user:**
72
425
 
73
- Ask: "Any technical constraints or preferences? (Framework, language, hosting, etc.)"
74
- - If blank, that's fine - proceed with defaults
426
+ ```
427
+ ## PRD Review
428
+
429
+ | Dimension | Assessment | Notes |
430
+ |-----------|------------|-------|
431
+ | Feasibility | {Good/Caution/Concern} | {1-line reason} |
432
+ | Scope | {Good/Caution/Concern} | {1-line reason} |
433
+ | Risks | {Good/Caution/Concern} | {1-line reason} |
75
434
 
76
- ### Step 7: Review & Confirm
435
+ ### Issues to Address
436
+ {List any critical or high-severity issues from the critique}
77
437
 
78
- Summarize the interview answers:
438
+ ### Recommendation
439
+ {Approve / Revise / Rethink}
79
440
  ```
80
- ## PRD Summary
81
441
 
82
- **Project Type:** {type}
83
- **Problem:** {problem}
84
- **Target Users:** {users}
85
- **MVP Scope:** {mvp}
86
- **Core Features:** {features}
87
- **Constraints:** {constraints}
442
+ Use AskUserQuestion:
443
+ - "Save PRD as-is"
444
+ - "Address the issues first" (then iterate)
445
+ - "Skip critique and save" (if user wants to proceed anyway)
446
+
447
+ #### Step 3.4: Store PRD
88
448
 
89
- Ready to generate PRD outline?
449
+ **CRITICAL: Detect adapter type FIRST** by calling `get_project_context`:
450
+
451
+ ```
452
+ mcp__flux__get_project_context()
453
+ → Returns: { adapter: { type: "local" | "linear" | ... }, ... }
90
454
  ```
91
455
 
92
- Use AskUserQuestion to confirm:
93
- - Generate PRD Outline (Recommended)
94
- - Edit Answers
95
- - Start Over
456
+ **Branch workflow based on `adapter.type`:**
96
457
 
97
- ## After Interview Complete
458
+ ---
98
459
 
99
- The `get_project_context` call from Pre-check returns the adapter type. Use this to determine storage behavior.
460
+ **For Linear Adapter** (`adapter.type === "linear"`):
100
461
 
101
- ### For Local Adapter (`adapter.type === "local"`):
462
+ The Linear adapter stores PRD content in Linear issues. **Do NOT create local files.**
102
463
 
103
- 1. Generate a slug from the PRD title (e.g., "Flux Plugin Versioning" → "flux-plugin-versioning")
104
- 2. Call `create_prd` with title and a short 1-2 sentence description
105
- 3. Write the full PRD markdown to `.flux/prds/{slug}/prd.md`
106
- 4. Call `update_entity` with `folder_path`: `.flux/prds/{slug}`
107
- 5. Inform user of the created PRD ref and file location
464
+ 1. Call `create_prd` with title and brief description (1-2 sentences)
465
+ 2. Call `update_entity` with `description: {full PRD markdown}` - this stores the content in Linear
466
+ 3. Confirm: "PRD saved as {ref} in Linear"
108
467
 
109
- ### For External Adapters (`adapter.type === "linear"`, `"notion"`, etc.):
468
+ **Do NOT:**
469
+ - Create local directories
470
+ - Write local `.md` files
471
+ - Set `folder_path`
472
+
473
+ ---
110
474
 
111
- 1. Call `create_prd` with title and a short 1-2 sentence description
112
- 2. Call `update_entity` with `description`: The FULL PRD markdown content
113
- 3. Inform user of the created PRD ref (no local file created)
475
+ **For Local Adapter** (`adapter.type === "local"`):
114
476
 
115
- **Note**: External adapters store PRD content in the external system (Linear issue description, Notion page, etc.). No local files are written.
477
+ The local adapter stores PRD content in local files. Create the folder structure.
116
478
 
117
- ## Resume Interview Flow
479
+ 1. Generate slug from title (e.g., "User Auth Flow" → "user-auth-flow")
480
+ 2. Call `create_prd` with title and brief description (1-2 sentences)
481
+ 3. Create directory: `.flux/prds/{slug}/`
482
+ 4. Write full PRD to `.flux/prds/{slug}/prd.md`
483
+ 5. Call `update_entity` with `folder_path: ".flux/prds/{slug}"`
484
+ 6. Confirm: "PRD saved as {ref} at `.flux/prds/{slug}/prd.md`"
118
485
 
119
- 1. Call `get_interview` to get current state
120
- 2. Show progress: "Resuming interview at step {step}/6"
121
- 3. Continue from the last unanswered question
486
+ ---
487
+
488
+ **Adapter Detection Summary:**
489
+
490
+ | Adapter Type | PRD Content Storage | Local Files? |
491
+ |--------------|---------------------|--------------|
492
+ | `local` | `.flux/prds/{slug}/prd.md` | Yes - create folder and files |
493
+ | `linear` | Linear issue description | No - never create local files |
494
+ | `notion` | Notion page | No - never create local files |
495
+ | `specflux` | SpecFlux API | No - never create local files |
496
+
497
+ #### Step 3.5: Offer Supporting Documents
498
+
499
+ Based on project type and complexity, systematically offer relevant supporting documents.
500
+
501
+ ##### Document Recommendation Matrix
502
+
503
+ | Project Type | Recommended | Optional |
504
+ |--------------|-------------|----------|
505
+ | Web Application | Architecture, Wireframes | Data Model, User Flows |
506
+ | API/Backend | Architecture, Data Model | API Contract |
507
+ | CLI Tool | (PRD sufficient) | Architecture (if complex) |
508
+ | Mobile App | Architecture, Wireframes | Data Model, User Flows |
509
+ | Library/Package | Architecture | API Surface |
510
+
511
+ ##### Decision Tree
512
+
513
+ After PRD is approved, ask based on project characteristics:
514
+
515
+ ```
516
+ 1. Is this a UI-heavy feature? (Web/Mobile with 3+ screens)
517
+ → Offer: Wireframes
518
+
519
+ 2. Does it have custom data storage? (New tables, schemas)
520
+ → Offer: Data Model
521
+
522
+ 3. Is it a multi-component system? (Frontend + Backend, or microservices)
523
+ → Offer: Architecture Diagram
524
+
525
+ 4. Are there complex user journeys? (3+ step flows, conditional paths)
526
+ → Offer: User Flow Diagrams
527
+ ```
528
+
529
+ ##### Template: ASCII Wireframes
530
+
531
+ When user wants wireframes, generate using Unicode box-drawing characters:
532
+
533
+ ```markdown
534
+ # Wireframes: {Feature Name}
535
+
536
+ ## {Screen/View Name}
537
+
538
+ ### Desktop Layout (1200px+)
539
+ ┌─────────────────────────────────────────────────────────────────┐
540
+ │ ┌──────────────────────────────────────────────────────────┐ │
541
+ │ │ HEADER: Logo Navigation [User Menu ▼] │ │
542
+ │ └──────────────────────────────────────────────────────────┘ │
543
+ │ │
544
+ │ ┌───────────────────────┐ ┌───────────────────────────────┐ │
545
+ │ │ │ │ │ │
546
+ │ │ SIDEBAR │ │ MAIN CONTENT │ │
547
+ │ │ │ │ │ │
548
+ │ │ ○ Nav Item 1 │ │ ┌─────────────────────────┐ │ │
549
+ │ │ ● Nav Item 2 (active)│ │ │ Card Component │ │ │
550
+ │ │ ○ Nav Item 3 │ │ │ │ │ │
551
+ │ │ │ │ │ [Action] [Secondary] │ │ │
552
+ │ │ │ │ └─────────────────────────┘ │ │
553
+ │ └───────────────────────┘ └───────────────────────────────┘ │
554
+ │ │
555
+ │ ┌──────────────────────────────────────────────────────────┐ │
556
+ │ │ FOOTER: Links | Copyright │ │
557
+ │ └──────────────────────────────────────────────────────────┘ │
558
+ └─────────────────────────────────────────────────────────────────┘
559
+
560
+ ### Mobile Layout (<768px)
561
+ ┌─────────────────────┐
562
+ │ ☰ Logo [User] │
563
+ ├─────────────────────┤
564
+ │ │
565
+ │ Main Content │
566
+ │ │
567
+ │ ┌───────────────┐ │
568
+ │ │ Card │ │
569
+ │ │ │ │
570
+ │ │ [Action] │ │
571
+ │ └───────────────┘ │
572
+ │ │
573
+ ├─────────────────────┤
574
+ │ Tab | Tab | Tab │
575
+ └─────────────────────┘
576
+
577
+ ### Element Descriptions
578
+
579
+ | Element | Type | Behavior |
580
+ |---------|------|----------|
581
+ | Header | Fixed | Sticky top, collapses to hamburger on mobile |
582
+ | Sidebar | Collapsible | Hidden by default on mobile |
583
+ | Card | Interactive | Hover: elevate with shadow; Click: navigate to detail |
584
+ | Nav Item | Button | ● = active, ○ = inactive |
585
+
586
+ ### Interactive States
587
+ - **Hover**: Cards elevate, buttons change color
588
+ - **Active**: Nav items show ● indicator
589
+ - **Loading**: Skeleton placeholders
590
+ - **Empty**: Illustrated empty state with CTA
591
+ ```
592
+
593
+ ##### Template: Mermaid Architecture Diagrams
594
+
595
+ When user wants architecture diagrams, generate using Mermaid syntax:
596
+
597
+ ```markdown
598
+ # Architecture: {System Name}
599
+
600
+ ## System Overview
601
+
602
+ \`\`\`mermaid
603
+ flowchart TB
604
+ subgraph Client["Client Layer"]
605
+ WEB[Web App]
606
+ MOB[Mobile App]
607
+ end
608
+
609
+ subgraph Gateway["API Gateway"]
610
+ GW[Load Balancer]
611
+ end
612
+
613
+ subgraph Services["Service Layer"]
614
+ AUTH[Auth Service]
615
+ API[Core API]
616
+ NOTIFY[Notification Service]
617
+ end
618
+
619
+ subgraph Data["Data Layer"]
620
+ DB[(PostgreSQL)]
621
+ CACHE[(Redis)]
622
+ QUEUE[Message Queue]
623
+ end
624
+
625
+ subgraph External["External Services"]
626
+ EMAIL[Email Provider]
627
+ STORAGE[Cloud Storage]
628
+ end
629
+
630
+ WEB --> GW
631
+ MOB --> GW
632
+ GW --> AUTH
633
+ GW --> API
634
+ API --> DB
635
+ API --> CACHE
636
+ API --> QUEUE
637
+ QUEUE --> NOTIFY
638
+ NOTIFY --> EMAIL
639
+ API --> STORAGE
640
+ \`\`\`
641
+
642
+ ## Key Flow: {Primary User Journey}
643
+
644
+ \`\`\`mermaid
645
+ sequenceDiagram
646
+ participant U as User
647
+ participant C as Client
648
+ participant G as Gateway
649
+ participant A as Auth
650
+ participant API as Core API
651
+ participant DB as Database
652
+
653
+ U->>C: Action
654
+ C->>G: Request
655
+ G->>A: Validate Token
656
+ A-->>G: Valid
657
+ G->>API: Forward Request
658
+ API->>DB: Query/Mutation
659
+ DB-->>API: Result
660
+ API-->>G: Response
661
+ G-->>C: Response
662
+ C-->>U: Update UI
663
+ \`\`\`
664
+
665
+ ## Component Responsibilities
666
+
667
+ | Component | Responsibility | Technology |
668
+ |-----------|---------------|------------|
669
+ | Gateway | Routing, rate limiting, auth validation | nginx/Kong |
670
+ | Auth Service | JWT, sessions, user management | Node.js |
671
+ | Core API | Business logic, data access | {tech stack} |
672
+ | Database | Persistence | PostgreSQL |
673
+ | Cache | Sessions, hot data | Redis |
674
+ ```
675
+
676
+ ##### Template: Data Model Documentation
677
+
678
+ When user wants data model documentation, generate ERD and schema:
679
+
680
+ ```markdown
681
+ # Data Model: {System Name}
682
+
683
+ ## Entity Relationship Diagram
684
+
685
+ \`\`\`mermaid
686
+ erDiagram
687
+ USER {
688
+ uuid id PK
689
+ string email UK
690
+ string password_hash
691
+ string name
692
+ timestamp created_at
693
+ timestamp updated_at
694
+ }
695
+
696
+ RESOURCE {
697
+ uuid id PK
698
+ uuid user_id FK
699
+ string title
700
+ text content
701
+ enum status
702
+ timestamp created_at
703
+ }
704
+
705
+ USER ||--o{ RESOURCE : owns
706
+ \`\`\`
707
+
708
+ ## Table Definitions
709
+
710
+ ### users
711
+ | Column | Type | Constraints | Description |
712
+ |--------|------|-------------|-------------|
713
+ | id | UUID | PK, DEFAULT uuid_generate_v4() | Unique identifier |
714
+ | email | VARCHAR(255) | UNIQUE, NOT NULL | Login email |
715
+ | password_hash | VARCHAR(255) | NOT NULL | Bcrypt hash |
716
+ | name | VARCHAR(100) | NOT NULL | Display name |
717
+ | created_at | TIMESTAMP | DEFAULT NOW() | Creation time |
718
+ | updated_at | TIMESTAMP | DEFAULT NOW() | Last update |
719
+
720
+ ### Indexes
721
+
722
+ | Table | Index | Columns | Type | Purpose |
723
+ |-------|-------|---------|------|---------|
724
+ | users | idx_users_email | email | UNIQUE | Login lookup |
725
+ | resources | idx_resources_user | user_id | BTREE | User's resources |
726
+ | resources | idx_resources_status | status, user_id | BTREE | Filtered queries |
727
+
728
+ ### Enums
729
+
730
+ | Enum | Values | Description |
731
+ |------|--------|-------------|
732
+ | resource_status | pending, active, archived | Lifecycle states |
733
+ ```
734
+
735
+ ##### Saving Supporting Documents
736
+
737
+ **Check `adapter.type` from Pre-Flight Check before creating documents:**
738
+
739
+ **Local Adapter** (`adapter.type === "local"`):
740
+ ```
741
+ .flux/prds/{prd-slug}/
742
+ ├── prd.md # Main PRD
743
+ ├── wireframes.md # UI mockups (if created)
744
+ ├── architecture.md # System diagrams (if created)
745
+ └── data-model.md # Schema design (if created)
746
+ ```
747
+ - Create files using Write tool
748
+ - All documents live in the same folder
749
+
750
+ **Linear/External Adapter** (`adapter.type === "linear"` or other):
751
+ - **Do NOT create local files**
752
+ - Include diagrams inline in the PRD description (Mermaid renders in Linear)
753
+ - Or offer to show the content for the user to copy elsewhere
754
+ - For wireframes, include ASCII art directly in the PRD
755
+
756
+ #### Step 3.6: Multi-PRD Continuation
757
+
758
+ If this PRD was part of a multi-PRD breakdown:
759
+
760
+ ```
761
+ PRD saved: {ref} ({title}) [tag: {tag}]
762
+
763
+ This is part of your {project name} project:
764
+ ✅ {completed PRD} [foundation] - DONE
765
+ → {next PRD} [foundation] - Ready to create
766
+ ○ {future PRD} [mvp] - Waiting on dependencies
767
+
768
+ Would you like to continue with the next PRD?
769
+ ```
770
+
771
+ Use AskUserQuestion:
772
+ - "Continue with {next PRD}" (Recommended)
773
+ - "I'll create it later"
774
+ - "Show full project roadmap"
775
+
776
+ When continuing with next PRD:
777
+ 1. Skip Phase 1 (Discovery) - context is already gathered
778
+ 2. Do targeted research for the specific PRD scope
779
+ 3. Generate PRD with proper dependency references
780
+
781
+ ---
122
782
 
123
783
  ## Refine PRD Flow
124
784
 
125
- 1. Query existing PRDs: `query_entities` with type=prd
126
- 2. If multiple, ask which one to refine
127
- 3. Load PRD content:
128
- - **Local adapter**: Read from `folder_path` (e.g., `.flux/prds/{slug}/prd.md`)
129
- - **External adapters**: Use `description` field from `get_entity`
130
- 4. Ask: "What would you like to change?"
131
- 5. Apply changes and update (follow same adapter-specific flow as creation)
785
+ For `/flux:prd refine` or `/flux:prd refine {ref}`:
786
+
787
+ 1. **Detect adapter**: Call `get_project_context` → store `adapter.type`
788
+ 2. Query existing PRDs: `query_entities` with `type: "prd"`
789
+ 3. If no ref provided and multiple exist, ask which to refine
790
+ 4. Load PRD content based on adapter type:
791
+ - **Local** (`adapter.type === "local"`): Read from `folder_path + "/prd.md"`
792
+ - **Linear/External** (`adapter.type !== "local"`): Get from `description` field via `get_entity`
793
+ 5. Ask: "What would you like to change?"
794
+ 6. Make changes following the same quality standards
795
+ 7. Save using the appropriate method for detected adapter type
796
+
797
+ ---
798
+
799
+ ## Edit Specific PRD
800
+
801
+ For `/flux:prd {ref}` (e.g., `/flux:prd FLUX-P1`):
802
+
803
+ 1. **Detect adapter**: Call `get_project_context` → store `adapter.type`
804
+ 2. Call `get_entity` with ref and `include: ["epics", "tasks", "criteria"]`
805
+ 3. Load full content based on adapter type:
806
+ - **Local**: Read from `folder_path + "/prd.md"`
807
+ - **Linear/External**: Content is in `description` field from `get_entity`
808
+ 4. Present current PRD
809
+ 5. Ask: "What would you like to edit?"
810
+ 6. Apply changes, maintaining structure
811
+ 7. Save using appropriate method for detected adapter type
812
+
813
+ ---
132
814
 
133
815
  ## Guidelines
134
816
 
135
- - One question at a time - don't overwhelm
136
- - Show progress indicators
137
- - Allow going back to previous questions
138
- - Save answers incrementally for resume capability
139
- - Keep it conversational, not robotic
817
+ ### Conversation Quality
818
+ - Be conversational, not robotic
819
+ - Ask one question at a time
140
820
  - If user seems stuck, offer examples
821
+ - Adapt questioning based on their expertise level
822
+
823
+ ### Research Quality
824
+ - Always explore the codebase before drafting (if exists)
825
+ - Reference specific files and patterns found
826
+ - Note existing code that can be reused
827
+
828
+ ### PRD Quality
829
+ - Every P0 feature needs the What/Not pattern and testable acceptance criteria
830
+ - Edge cases should be explicit with expected behavior
831
+ - Technical context should reference real code paths
832
+ - Out of Scope prevents scope creep
833
+
834
+ ### Autonomy Levels
835
+ - **High confidence** (clear requirements, familiar domain): Move quickly, fewer questions
836
+ - **Low confidence** (vague requirements, unfamiliar domain): Ask more questions, do more research
837
+
838
+ ---
839
+
840
+ ## Agent Spawning Reference
841
+
842
+ ### When to Spawn `flux-researcher`
843
+
844
+ | Trigger | Action |
845
+ |---------|--------|
846
+ | User mentions unfamiliar technology | Spawn with tech research prompt |
847
+ | Confidence < 70% about approach | Spawn to validate understanding |
848
+ | External APIs/SDKs involved | Spawn to research integration patterns |
849
+ | "What is X?" or "Research X" | Spawn explicitly |
850
+ | Technology comparison needed | Spawn with comparison prompt |
851
+
852
+ **Don't spawn for:** Quick fact checks (use WebSearch), known technologies
853
+
854
+ ### When to Spawn `flux-critic`
855
+
856
+ | Trigger | Action |
857
+ |---------|--------|
858
+ | Scope score >= 3 | Auto-trigger after PRD draft |
859
+ | Estimated tasks > 25 | Auto-trigger after PRD draft |
860
+ | 2+ external dependencies | Auto-trigger after PRD draft |
861
+ | User asks "Is this feasible?" | Spawn explicitly |
862
+ | Multiple unfamiliar technologies | Auto-trigger after PRD draft |
863
+
864
+ **Don't spawn for:** Simple PRDs (1-2 features), already-critiqued refinements
865
+
866
+ ### Spawning Pattern
867
+
868
+ ```
869
+ Task({
870
+ subagent_type: "flux:flux-{agent}",
871
+ prompt: "{detailed prompt with context}",
872
+ description: "{short description}: {subject}"
873
+ })
874
+ ```
875
+
876
+ Always include in prompt:
877
+ - Project context (type, codebase status)
878
+ - Specific questions to answer
879
+ - Expected output format