agileflow 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +3 -3
  3. package/lib/api-server.js +3 -2
  4. package/lib/flag-detection.js +4 -2
  5. package/lib/git-operations.js +4 -2
  6. package/lib/process-executor.js +24 -9
  7. package/lib/skill-loader.js +11 -3
  8. package/package.json +1 -1
  9. package/scripts/agileflow-welcome.js +65 -25
  10. package/scripts/claude-tmux.sh +9 -3
  11. package/scripts/damage-control-multi-agent.js +14 -10
  12. package/scripts/lib/bus-utils.js +3 -1
  13. package/scripts/lib/configure-detect.js +12 -9
  14. package/scripts/lib/configure-features.js +12 -7
  15. package/scripts/lib/configure-repair.js +6 -5
  16. package/scripts/lib/context-formatter.js +13 -3
  17. package/scripts/lib/damage-control-utils.js +5 -1
  18. package/scripts/lib/lifecycle-detector.js +5 -3
  19. package/scripts/lib/process-cleanup.js +8 -4
  20. package/scripts/lib/scale-detector.js +47 -8
  21. package/scripts/lib/signal-detectors.js +117 -59
  22. package/scripts/lib/task-registry.js +5 -1
  23. package/scripts/lib/team-events.js +4 -4
  24. package/scripts/messaging-bridge.js +7 -1
  25. package/scripts/ralph-loop.js +10 -8
  26. package/scripts/smart-detect.js +32 -11
  27. package/scripts/team-manager.js +1 -1
  28. package/scripts/tmux-task-name.sh +75 -0
  29. package/scripts/tmux-task-watcher.sh +177 -0
  30. package/src/core/commands/babysit.md +75 -42
  31. package/src/core/commands/blockers.md +7 -7
  32. package/src/core/commands/configure.md +5 -36
  33. package/src/core/commands/discovery/brief.md +363 -0
  34. package/src/core/commands/discovery/new.md +395 -0
  35. package/src/core/commands/ideate/new.md +5 -5
  36. package/src/core/commands/logic/audit.md +5 -5
  37. package/src/core/commands/review.md +7 -1
  38. package/src/core/commands/rpi.md +61 -26
  39. package/src/core/commands/sprint.md +7 -6
  40. package/src/core/templates/product-brief.md +136 -0
  41. package/tools/cli/installers/ide/claude-code.js +67 -2
  42. package/src/core/agents/configuration/archival.md +0 -350
  43. package/src/core/agents/configuration/attribution.md +0 -343
  44. package/src/core/agents/configuration/ci.md +0 -1103
  45. package/src/core/agents/configuration/damage-control.md +0 -375
  46. package/src/core/agents/configuration/git-config.md +0 -537
  47. package/src/core/agents/configuration/hooks.md +0 -623
  48. package/src/core/agents/configuration/precompact.md +0 -302
  49. package/src/core/agents/configuration/status-line.md +0 -557
  50. package/src/core/agents/configuration/verify.md +0 -618
  51. package/src/core/agents/configuration-damage-control.md +0 -259
  52. package/src/core/agents/configuration-visual-e2e.md +0 -339
@@ -0,0 +1,395 @@
1
+ ---
2
+ description: Run structured discovery workflow - brainstorm, research, and generate a Product Brief
3
+ argument-hint: "TOPIC=<text> [DEPTH=quick|guided|deep]"
4
+ compact_context:
5
+ priority: critical
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:discovery:new - Discovery workflow orchestrator"
8
+ - "DEPTH modes: quick (skip research, auto-generate), guided (interactive, optional research), deep (comprehensive research + curation)"
9
+ - "Phase 1: Brainstorm via /agileflow:ideate:new SCOPE=all"
10
+ - "Phase 2: Research via /agileflow:research:ask (optional in quick mode)"
11
+ - "Phase 3: Generate Product Brief via /agileflow:discovery:brief"
12
+ - "Output: docs/08-project/briefs/{date}-{topic-slug}-brief.md"
13
+ - "MUST parse TOPIC (required) and DEPTH (default: guided)"
14
+ - "After brief generation, offer: create epic, refine brief, or done"
15
+ state_fields:
16
+ - topic
17
+ - depth
18
+ - brainstorm_complete
19
+ - research_complete
20
+ - brief_generated
21
+ - ideation_file
22
+ - research_files
23
+ ---
24
+
25
+ # /agileflow:discovery:new
26
+
27
+ Run a structured discovery workflow that produces a professional Product Brief. Chains brainstorming, optional research, and synthesis into a single orchestrated flow.
28
+
29
+ ---
30
+
31
+ ## Purpose
32
+
33
+ Bridge the gap between "vague idea" and "epic planning". This command validates product viability BEFORE decomposing into stories/epics.
34
+
35
+ ```
36
+ Vague Idea --> /discovery:new --> Product Brief --> /epic --> Stories --> Implementation
37
+ ```
38
+
39
+ ---
40
+
41
+ ## STEP 0: Gather Context
42
+
43
+ ```bash
44
+ node .agileflow/scripts/obtain-context.js discovery
45
+ ```
46
+
47
+ ---
48
+
49
+ <!-- COMPACT_SUMMARY_START -->
50
+
51
+ ## Compact Summary
52
+
53
+ **Command**: `/agileflow:discovery:new` - Orchestrate brainstorm + research + Product Brief generation
54
+
55
+ **Quick Usage**:
56
+ ```
57
+ /agileflow:discovery:new TOPIC="Mobile time tracking app"
58
+ /agileflow:discovery:new TOPIC="AI code review tool" DEPTH=deep
59
+ /agileflow:discovery:new TOPIC="Internal dashboard" DEPTH=quick
60
+ ```
61
+
62
+ **Phases**:
63
+ 1. Brainstorm (delegates to `/agileflow:ideate:new`)
64
+ 2. Research (delegates to `/agileflow:research:ask` - optional in quick mode)
65
+ 3. Brief Generation (delegates to `/agileflow:discovery:brief`)
66
+
67
+ **Depth Modes**:
68
+ - `quick`: Auto-run brainstorm, skip research, generate brief immediately (~5-10 min)
69
+ - `guided` (default): Interactive brainstorm, optional research, curate before brief (~30-45 min)
70
+ - `deep`: Comprehensive brainstorm + multi-stage research + detailed brief (~2+ hours)
71
+
72
+ **Output**: `docs/08-project/briefs/{YYYYMMDD}-{topic-slug}-brief.md`
73
+
74
+ ### Tool Usage Examples
75
+
76
+ **AskUserQuestion** (depth selection):
77
+ ```xml
78
+ <invoke name="AskUserQuestion">
79
+ <parameter name="questions">[{"question": "What depth of discovery do you want for this topic?", "header": "Depth", "multiSelect": false, "options": [{"label": "Guided (Recommended)", "description": "Interactive brainstorm + optional research + curated brief (30-45 min)"}, {"label": "Quick", "description": "Auto brainstorm, skip research, fast brief (5-10 min)"}, {"label": "Deep", "description": "Comprehensive brainstorm + multi-stage research + detailed brief (2+ hours)"}]}]</parameter>
80
+ </invoke>
81
+ ```
82
+
83
+ <!-- COMPACT_SUMMARY_END -->
84
+
85
+ ---
86
+
87
+ ## How It Works
88
+
89
+ ```
90
+ USER: /agileflow:discovery:new TOPIC="..." DEPTH=guided
91
+ |
92
+ v
93
+ +-------------------------------+
94
+ | STEP 1: PARSE ARGUMENTS |
95
+ | - TOPIC (required) |
96
+ | - DEPTH (quick/guided/deep) |
97
+ +-------------------------------+
98
+ |
99
+ v
100
+ +-------------------------------+
101
+ | STEP 2: BRAINSTORM |
102
+ | Delegate to ideate:new |
103
+ | Output: ideation report |
104
+ +-------------------------------+
105
+ |
106
+ v
107
+ +-------------------------------+
108
+ | STEP 3: RESEARCH (optional) |
109
+ | Delegate to research:ask |
110
+ | User runs externally |
111
+ | Import with research:import |
112
+ +-------------------------------+
113
+ |
114
+ v
115
+ +-------------------------------+
116
+ | STEP 4: GENERATE BRIEF |
117
+ | Delegate to discovery:brief |
118
+ | Synthesize all inputs |
119
+ | Output: Product Brief |
120
+ +-------------------------------+
121
+ |
122
+ v
123
+ +-------------------------------+
124
+ | STEP 5: NEXT STEPS |
125
+ | Create epic? Refine? Done? |
126
+ +-------------------------------+
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Prompt
132
+
133
+ ROLE: Discovery Workflow Orchestrator
134
+
135
+ You run a structured discovery workflow that takes a topic from idea to Product Brief. You chain existing AgileFlow commands together and guide the user through each phase.
136
+
137
+ ### STEP 1: PARSE ARGUMENTS
138
+
139
+ Parse the user's input:
140
+
141
+ | Argument | Required | Default | Description |
142
+ |----------|----------|---------|-------------|
143
+ | TOPIC | Yes | - | The product/feature idea to explore |
144
+ | DEPTH | No | guided | Discovery depth: quick, guided, or deep |
145
+
146
+ **If TOPIC is missing**, ask the user:
147
+
148
+ ```xml
149
+ <invoke name="AskUserQuestion">
150
+ <parameter name="questions">[{"question": "What product or feature idea do you want to explore?", "header": "Topic", "multiSelect": false, "options": [{"label": "I'll type it", "description": "Describe the idea you want to validate"}]}]</parameter>
151
+ </invoke>
152
+ ```
153
+
154
+ **If DEPTH is not provided**, use `guided` as the default.
155
+
156
+ **Normalize the topic** into a slug for filenames: lowercase, replace spaces with hyphens, remove special characters. Example: "AI Code Review Tool" becomes `ai-code-review-tool`.
157
+
158
+ ---
159
+
160
+ ### STEP 2: BRAINSTORM PHASE
161
+
162
+ **Purpose**: Generate creative ideas and approaches around the topic using multi-expert analysis.
163
+
164
+ **Tell the user what's happening:**
165
+ ```
166
+ Phase 1/3: Brainstorming
167
+ Deploying domain experts to explore "{TOPIC}" from multiple angles...
168
+ ```
169
+
170
+ **Execute brainstorming differently per depth:**
171
+
172
+ #### Quick Mode
173
+ Run brainstorming with minimal interaction. Deploy 3 experts in parallel using the Task tool:
174
+
175
+ 1. **Product expert** - analyze market fit, user needs, competitive landscape
176
+ 2. **API/Architecture expert** - evaluate technical feasibility, architecture options
177
+ 3. **UX/Design expert** - consider user experience, interaction patterns
178
+
179
+ Use this prompt template for each expert:
180
+
181
+ ```
182
+ TASK: Brainstorm ideas for a product/feature: "{TOPIC}"
183
+
184
+ From your {DOMAIN} perspective, generate 3-5 ideas covering:
185
+ 1. **Core Value Proposition**: What's the main value this delivers?
186
+ 2. **Key Features**: What are the essential features?
187
+ 3. **Target Users**: Who benefits most?
188
+ 4. **Risks**: What could go wrong?
189
+ 5. **Differentiation**: How is this different from alternatives?
190
+
191
+ Be specific and actionable. Reference real-world examples where helpful.
192
+ ```
193
+
194
+ Deploy all experts with `run_in_background: true`, then collect results with TaskOutput.
195
+
196
+ #### Guided Mode
197
+ Same as Quick, but after collecting results:
198
+
199
+ 1. **Present a summary** of the brainstorm findings to the user
200
+ 2. **Ask the user to curate**: Which ideas resonate? Which to drop?
201
+
202
+ ```xml
203
+ <invoke name="AskUserQuestion">
204
+ <parameter name="questions">[{"question": "Review the brainstorm results above. Which direction do you want to pursue?", "header": "Curate", "multiSelect": false, "options": [{"label": "Proceed with all ideas", "description": "Include everything in the brief"}, {"label": "Let me highlight the best ones", "description": "I'll tell you which ideas to focus on"}, {"label": "Re-brainstorm with different focus", "description": "Try again with adjusted scope"}]}]</parameter>
205
+ </invoke>
206
+ ```
207
+
208
+ #### Deep Mode
209
+ Deploy 5+ experts (add Security and Testing to the base 3). Use `DEPTH=deep` prompts asking for 5 ideas each. After collection, present findings and allow the user to curate, add their own ideas, and refine before proceeding.
210
+
211
+ **Save brainstorm output** to `docs/08-project/ideation/ideation-{YYYYMMDD}-{topic-slug}.md`
212
+
213
+ Record the ideation file path for Phase 3.
214
+
215
+ ---
216
+
217
+ ### STEP 3: RESEARCH PHASE
218
+
219
+ **Purpose**: Gather external context - competitive analysis, market data, best practices.
220
+
221
+ **Behavior varies by depth:**
222
+
223
+ #### Quick Mode
224
+ **Skip research entirely.** Tell the user:
225
+ ```
226
+ Phase 2/3: Research
227
+ Skipping external research (quick mode). Using brainstorm findings + internal knowledge only.
228
+ ```
229
+ Proceed directly to Step 4.
230
+
231
+ #### Guided Mode
232
+ **Offer optional research.** Ask the user:
233
+
234
+ ```xml
235
+ <invoke name="AskUserQuestion">
236
+ <parameter name="questions">[{"question": "Would you like to research this topic before generating the brief?", "header": "Research", "multiSelect": false, "options": [{"label": "Yes, generate research prompt (Recommended)", "description": "Creates a detailed prompt for ChatGPT/Perplexity to gather competitive + market data"}, {"label": "Skip research", "description": "Generate brief using brainstorm findings + internal knowledge only"}, {"label": "I already have research", "description": "I'll paste findings or point to existing docs/10-research/ files"}]}]</parameter>
237
+ </invoke>
238
+ ```
239
+
240
+ **If yes**: Generate a research prompt tailored to the topic. Focus on:
241
+ - Competitive analysis (top 3-5 alternatives)
242
+ - Target market validation
243
+ - Best practices and patterns
244
+
245
+ Use this approach - generate the prompt inline (don't delegate to `/research:ask` to avoid double-orchestration complexity):
246
+
247
+ ```markdown
248
+ # Research Request: {TOPIC} - Competitive & Market Analysis
249
+
250
+ ## Context
251
+ We're exploring building: {TOPIC}
252
+ Key ideas from brainstorming: {top 3-5 ideas from Phase 1}
253
+
254
+ ## Questions
255
+ 1. What are the top 3-5 existing solutions for {TOPIC}? Compare on: features, pricing, target audience, strengths/weaknesses.
256
+ 2. What is the target market size? Who are the primary user segments?
257
+ 3. What are current best practices and emerging trends in this space?
258
+ 4. What common pitfalls should we avoid?
259
+ 5. What technical approaches are most common (architecture, tech stack)?
260
+
261
+ ## Format
262
+ Provide structured analysis with tables for comparison. Include specific data points and sources where possible.
263
+ ```
264
+
265
+ Instruct the user to copy the prompt, run it externally, and paste results back. When results are returned, save them to `docs/10-research/{YYYYMMDD}-{topic-slug}-market-research.md`.
266
+
267
+ **If user has existing research**: Ask them to specify the file path(s). Read those files to incorporate into the brief.
268
+
269
+ #### Deep Mode
270
+ Run **multiple research stages**, each with a focused prompt:
271
+
272
+ 1. **Stage 1: Competitive Analysis** - Top 5 competitors, feature comparison, pricing
273
+ 2. **Stage 2: Market Sizing** - TAM/SAM/SOM, user segments, growth trends
274
+ 3. **Stage 3: Technical Landscape** - Common architectures, tech stacks, best practices
275
+
276
+ Each stage is optional (user can skip). For each completed stage, save research output to `docs/10-research/`.
277
+
278
+ Record all research file paths for Phase 3.
279
+
280
+ ---
281
+
282
+ ### STEP 4: GENERATE PRODUCT BRIEF
283
+
284
+ **Purpose**: Synthesize brainstorm findings + research into a structured Product Brief.
285
+
286
+ **Tell the user:**
287
+ ```
288
+ Phase 3/3: Generating Product Brief
289
+ Synthesizing brainstorm findings and research into a structured brief...
290
+ ```
291
+
292
+ **Read the inputs:**
293
+ 1. Read the ideation report from Step 2
294
+ 2. Read any research files from Step 3
295
+
296
+ **Generate the brief** by filling in the product-brief template. Apply these rules:
297
+
298
+ **MoSCoW Mapping from brainstorm confidence:**
299
+ - Ideas agreed by 2+ experts OR marked as core value = **MUST HAVE**
300
+ - Ideas from 1 expert with strong rationale = **SHOULD HAVE**
301
+ - Nice-to-have ideas or differentiators = **COULD HAVE**
302
+ - Explicitly rejected or out-of-scope ideas = **WON'T HAVE**
303
+
304
+ **Persona extraction:**
305
+ - From research: extract user segments and pain points
306
+ - From brainstorm: infer personas from "target users" sections
307
+ - If insufficient data: create 2 reasonable personas based on the topic
308
+
309
+ **Success metrics:**
310
+ - Derive from the problem statement and value proposition
311
+ - Include both quantitative (adoption rate, time saved) and qualitative (user satisfaction) metrics
312
+
313
+ **ROI estimation:**
314
+ - Effort: Based on feature count and complexity from MoSCoW
315
+ - Benefit: Based on target user pain points and market size
316
+ - Keep it simple - order-of-magnitude estimates, not financial modeling
317
+
318
+ **Competitive context:**
319
+ - From research findings if available
320
+ - From expert knowledge if research was skipped
321
+
322
+ **Save the brief** to: `docs/08-project/briefs/{YYYYMMDD}-{topic-slug}-brief.md`
323
+
324
+ Create the `docs/08-project/briefs/` directory if it doesn't exist.
325
+
326
+ ---
327
+
328
+ ### STEP 5: OFFER NEXT STEPS
329
+
330
+ Present the completed brief and ask what to do next:
331
+
332
+ ```xml
333
+ <invoke name="AskUserQuestion">
334
+ <parameter name="questions">[{"question": "Product Brief for '{TOPIC}' has been generated. What would you like to do next?", "header": "Next Steps", "multiSelect": false, "options": [{"label": "Create epic from this brief (Recommended)", "description": "Run /agileflow:epic to decompose into stories"}, {"label": "Refine the brief", "description": "Edit specific sections or add more detail"}, {"label": "Run deeper research", "description": "Generate research prompts for areas that need more data"}, {"label": "Done for now", "description": "Brief saved, come back to it later"}]}]</parameter>
335
+ </invoke>
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Arguments
341
+
342
+ | Argument | Values | Default | Description |
343
+ |----------|--------|---------|-------------|
344
+ | TOPIC | Free text | (required) | The product/feature idea to explore |
345
+ | DEPTH | quick, guided, deep | guided | Discovery depth level |
346
+
347
+ {{argument}}
348
+
349
+ ---
350
+
351
+ ## Expected Output
352
+
353
+ ### Success
354
+
355
+ ```
356
+ Discovery Workflow: "AI Code Review Tool"
357
+ Depth: guided
358
+ ============================================
359
+
360
+ Phase 1/3: Brainstorming
361
+ Deploying 3 domain experts...
362
+ Product Expert... done
363
+ Architecture Expert... done
364
+ UX Expert... done
365
+ Synthesized 12 ideas (4 high-confidence, 6 medium, 2 low)
366
+
367
+ Phase 2/3: Research
368
+ [User runs external research prompt]
369
+ Imported competitive analysis (3 competitors found)
370
+
371
+ Phase 3/3: Generating Product Brief
372
+ Executive Summary... done
373
+ User Personas... done
374
+ Features (MoSCoW)... done
375
+ Success Metrics... done
376
+ Business Case... done
377
+ Competitive Context... done
378
+ Risks... done
379
+
380
+ Brief saved to: docs/08-project/briefs/20260213-ai-code-review-tool-brief.md
381
+
382
+ What would you like to do next?
383
+ ```
384
+
385
+ ---
386
+
387
+ ## Related Commands
388
+
389
+ - `/agileflow:discovery:brief` - Generate a Product Brief from existing ideation + research
390
+ - `/agileflow:ideate:new` - Run multi-expert brainstorming
391
+ - `/agileflow:research:ask` - Generate external research prompts
392
+ - `/agileflow:research:import` - Import research results
393
+ - `/agileflow:epic` - Create epic from a brief
394
+ - `/agileflow:auto` - Auto-generate stories from an epic
395
+ - `/agileflow:council` - Get architectural advice on an idea
@@ -705,14 +705,14 @@ After generating output, present options:
705
705
  ```xml
706
706
  <invoke name="AskUserQuestion">
707
707
  <parameter name="questions">[{
708
- "question": "What would you like to do with these ideas?",
708
+ "question": "[total] ideas from [expert_count] experts ([high] HIGH confidence, [medium] MEDIUM). [new] new, [recurring] recurring.",
709
709
  "header": "Next Steps",
710
710
  "multiSelect": false,
711
711
  "options": [
712
- {"label": "Create stories for high-confidence items", "description": "Generate stories in docs/06-stories/"},
713
- {"label": "Create epic grouping all improvements", "description": "Bundle into EP-XXXX: Ideation Improvements"},
714
- {"label": "Run deeper analysis on specific category", "description": "Re-run with SCOPE={category} DEPTH=deep"},
715
- {"label": "Save report and done", "description": "Keep the report, no further action"}
712
+ {"label": "Create [high] stories for HIGH-confidence items (Recommended)", "description": "Top idea: [top_idea_title] ([impact] impact, agreed by [N] experts)"},
713
+ {"label": "Create epic: '[epic_title]'", "description": "Bundle all [high] HIGH + [medium] MEDIUM items into EP-XXXX"},
714
+ {"label": "Deep dive on [top_category] ([count] ideas)", "description": "Re-run SCOPE=[category] DEPTH=deep for more detail"},
715
+ {"label": "Save report and done", "description": "Report saved to docs/08-project/ideation/ideation-[date].md"}
716
716
  ]
717
717
  }]</parameter>
718
718
  </invoke>
@@ -239,14 +239,14 @@ After consensus completes, show the report summary and offer next steps:
239
239
  ```xml
240
240
  <invoke name="AskUserQuestion">
241
241
  <parameter name="questions">[{
242
- "question": "What would you like to do with the audit results?",
242
+ "question": "Logic audit: [N] findings ([critical] CONFIRMED, [likely] LIKELY). [files_count] files analyzed.",
243
243
  "header": "Next steps",
244
244
  "multiSelect": false,
245
245
  "options": [
246
- {"label": "Fix critical issues now (Recommended)", "description": "Address P0/P1 issues immediately"},
247
- {"label": "Create stories for findings", "description": "Add to backlog as user stories"},
248
- {"label": "Run deeper analysis", "description": "Re-run with DEPTH=deep for more coverage"},
249
- {"label": "Save report and done", "description": "Keep the report, no further action"}
246
+ {"label": "Fix [critical] CONFIRMED issues now (Recommended)", "description": "[top_issue_summary] at [file:line] - [fix_hint]"},
247
+ {"label": "Create [N] stories for all findings", "description": "Track [critical] critical + [high] high priority items in backlog"},
248
+ {"label": "Re-run with DEPTH=deep on [target]", "description": "Current was quick - deep adds P2 issues and comprehensive coverage"},
249
+ {"label": "Save report and done", "description": "Report saved to docs/08-project/logic-audits/"}
250
250
  ]
251
251
  }]</parameter>
252
252
  </invoke>
@@ -641,7 +641,13 @@ Analyzing 127 lines changed across 3 files...
641
641
  Summary: 1 critical, 3 warnings, 3 good
642
642
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
643
643
 
644
- Apply auto-fixes for non-critical issues? [Y/n]
644
+ AskUserQuestion:
645
+ question: "Review: 85/100 score. 1 critical (SQL injection at :45), 3 warnings. How to proceed?"
646
+ options:
647
+ - "Fix SQL injection at line 45 first (Recommended)" → "Critical - blocks merge"
648
+ - "Auto-fix 3 style warnings" → "Safe formatting fixes only"
649
+ - "View full diff of all fixes" → "Preview 4 changes before applying"
650
+ - "Skip fixes, save report only" → "Report saved to docs/08-project/code-reviews/"
645
651
  ```
646
652
 
647
653
  ### Success - Clean Review
@@ -392,7 +392,7 @@ Reading plan: `.claude/plans/[slug].md`
392
392
  Running tests to verify step 1...
393
393
  ```
394
394
 
395
- 4. **Complete implementation**:
395
+ 4. **Complete implementation** with smart AskUserQuestion:
396
396
  ```markdown
397
397
  ---
398
398
 
@@ -404,13 +404,23 @@ All [N] steps executed successfully.
404
404
  - [X] files modified
405
405
  - [Y] tests added/updated
406
406
  - [Z] tests passing
407
+ ```
407
408
 
408
- ### Next Actions
409
- - [ ] Run full test suite: `npm test`
410
- - [ ] Create PR: `/agileflow:pr-template`
411
- - [ ] Update story status: `/agileflow:status STORY=US-#### STATUS=in-review`
412
-
413
- ---
409
+ Then present smart next steps:
410
+ ```xml
411
+ <invoke name="AskUserQuestion">
412
+ <parameter name="questions">[{
413
+ "question": "Implementation complete: [N] steps done, [X] files modified, [Z] tests passing. What next?",
414
+ "header": "Next step",
415
+ "multiSelect": false,
416
+ "options": [
417
+ {"label": "Run full test suite (Recommended)", "description": "Verify all [Z] tests still pass after [X] file changes"},
418
+ {"label": "🔍 Run logic audit on [X] modified files", "description": "5 analyzers check for edge cases, race conditions, type bugs"},
419
+ {"label": "Create PR with /agileflow:pr", "description": "[X] files changed across [N] implementation steps"},
420
+ {"label": "Pause here", "description": "Implementation saved, tests can be run later"}
421
+ ]
422
+ }]</parameter>
423
+ </invoke>
414
424
  ```
415
425
 
416
426
  ### Step 4: Monitor Context Health
@@ -423,18 +433,22 @@ Throughout execution, monitor for signs of context degradation:
423
433
  - Heavy tool output (JSON, logs)
424
434
  - Repetitive or generic responses
425
435
 
426
- **If detected, warn**:
427
- ```markdown
428
- ⚠️ **Context Health Warning**
436
+ **If detected, use smart AskUserQuestion**:
429
437
 
430
- This conversation has grown significantly. We may be approaching the "dumb zone" where agent quality degrades.
431
-
432
- **Current phase**: [phase]
433
- **Recommendation**: [Complete phase and start fresh / Save progress and compact]
434
-
435
- Would you like to:
436
- 1. Complete current phase and save artifact now
437
- 2. Continue (understanding quality may degrade)
438
+ ```xml
439
+ <invoke name="AskUserQuestion">
440
+ <parameter name="questions">[{
441
+ "question": "⚠️ Context at ~[utilization]% ([phase] phase). [files_read] files read, [tool_calls] tool calls. Save progress?",
442
+ "header": "Context health",
443
+ "multiSelect": false,
444
+ "options": [
445
+ {"label": "Save [phase] artifact and start fresh (Recommended)", "description": "New conversation starts in smart zone (<40%). Artifact preserves all understanding."},
446
+ {"label": "Compact context and continue", "description": "Reduce utilization but may lose some nuance"},
447
+ {"label": "Continue without saving", "description": "⚠️ Quality may degrade - currently at [utilization]%"},
448
+ {"label": "Pause here", "description": "Progress saved to [artifact_path]"}
449
+ ]
450
+ }]</parameter>
451
+ </invoke>
438
452
  ```
439
453
 
440
454
  ---
@@ -525,7 +539,13 @@ Research Summary:
525
539
  - Patterns: Use existing middleware structure
526
540
  - Risks: Token storage, refresh logic
527
541
 
528
- Ready for planning phase? [Y/n]
542
+ AskUserQuestion:
543
+ question: "Research complete: 4 findings, 2 risks identified. Ready for planning phase?"
544
+ options:
545
+ - "Start planning in new conversation (Recommended)" → "Fresh context with research artifact compressed"
546
+ - "Continue planning in this conversation" → "Context at ~35% - still in smart zone"
547
+ - "Refine research first" → "4 findings may need deeper investigation"
548
+ - "Pause here" → "Research saved to docs/10-research/"
529
549
 
530
550
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
531
551
  Phase 2: PLAN
@@ -542,7 +562,13 @@ Files to modify: 4
542
562
  New files: 2
543
563
  Estimated complexity: Medium
544
564
 
545
- Approve plan and proceed to implement? [Y/n]
565
+ AskUserQuestion:
566
+ question: "Plan ready: 5 steps, 6 files, ~medium complexity. Approve and proceed?"
567
+ options:
568
+ - "Approve - start implementing in new conversation (Recommended)" → "Fresh context with plan artifact"
569
+ - "Approve - implement in this conversation" → "Context at ~50% - proceed with caution"
570
+ - "Revise step 3 (update login endpoint)" → "Adjust plan before implementing"
571
+ - "Pause here" → "Plan saved to .claude/plans/"
546
572
 
547
573
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
548
574
  Phase 3: IMPLEMENT
@@ -555,6 +581,14 @@ Implementing...
555
581
  ✓ Added 12 tests (all passing)
556
582
 
557
583
  🎉 Implementation complete!
584
+
585
+ AskUserQuestion:
586
+ question: "Implementation complete: 5 steps, 4 files modified, 12 tests passing. What next?"
587
+ options:
588
+ - "Run full test suite (Recommended)" → "Verify all 12 tests pass"
589
+ - "🔍 Run logic audit on 4 modified files" → "5 analyzers check for edge cases"
590
+ - "Create PR" → "4 files changed across 5 steps"
591
+ - "Pause here" → "Implementation saved"
558
592
  ```
559
593
 
560
594
  ### Success - Phase Transition
@@ -567,12 +601,13 @@ Current: RESEARCH → Next: PLAN
567
601
 
568
602
  ⚠️ Context Health: 65% (approaching threshold)
569
603
 
570
- Before transitioning:
571
- 1. Document key findings
572
- 2. Save research notes
573
- 3. Plan is LEVERAGE - quality > speed now
574
-
575
- Proceed with transition? [Y/n]
604
+ AskUserQuestion:
605
+ question: "Context at 65% - approaching dumb zone. Save artifact and transition?"
606
+ options:
607
+ - "Save artifact and start new conversation (Recommended)" → "Fresh context in smart zone (<40%)"
608
+ - "Continue in this conversation" → "⚠️ Quality may degrade past 70%"
609
+ - "Compact context first" → "Reduce utilization, then continue"
610
+ - "Pause here" → "Progress saved, resume later"
576
611
  ```
577
612
 
578
613
  ### Error - Wrong Phase
@@ -95,17 +95,18 @@ TaskCreate/TaskUpdate:
95
95
  </invoke>
96
96
  ```
97
97
 
98
- AskUserQuestion:
98
+ AskUserQuestion (use actual counts and data from analysis):
99
99
  ```xml
100
100
  <invoke name="AskUserQuestion">
101
101
  <parameter name="questions">[{
102
- "question": "Commit this sprint plan: 5 stories, 8.5 days?",
103
- "header": "Confirm Sprint Commitment",
102
+ "question": "Sprint [ID]: [N] stories, [X]d estimated ([Y]% of [Z]d capacity). [Risk level]. Commit?",
103
+ "header": "Sprint",
104
104
  "multiSelect": false,
105
105
  "options": [
106
- {"label": "Yes, commit plan", "description": "Update status.json and create milestone"},
107
- {"label": "No, adjust", "description": "Modify story selection"},
108
- {"label": "Cancel", "description": "Exit without changes"}
106
+ {"label": "Commit sprint plan (Recommended)", "description": "[N] stories across [agents] - [epic summary]. Starts today, ends [date]"},
107
+ {"label": "Adjust story selection", "description": "Currently at [Y]% capacity - add/remove stories before committing"},
108
+ {"label": "View dependency risks first", "description": "[risk_count] risks detected: [top risk summary]"},
109
+ {"label": "Cancel", "description": "Exit without changes to status.json"}
109
110
  ]
110
111
  }]</parameter>
111
112
  </invoke>