bmad-method 4.37.0 → 5.0.0-beta.1

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 (47) hide show
  1. package/.github/workflows/promote-to-stable.yml +144 -0
  2. package/CHANGELOG.md +16 -9
  3. package/bmad-core/agents/qa.md +37 -18
  4. package/bmad-core/data/test-levels-framework.md +146 -0
  5. package/bmad-core/data/test-priorities-matrix.md +172 -0
  6. package/bmad-core/tasks/nfr-assess.md +343 -0
  7. package/bmad-core/tasks/qa-gate.md +159 -0
  8. package/bmad-core/tasks/review-story.md +234 -74
  9. package/bmad-core/tasks/risk-profile.md +353 -0
  10. package/bmad-core/tasks/test-design.md +174 -0
  11. package/bmad-core/tasks/trace-requirements.md +264 -0
  12. package/bmad-core/templates/qa-gate-tmpl.yaml +102 -0
  13. package/dist/agents/analyst.txt +20 -26
  14. package/dist/agents/architect.txt +14 -35
  15. package/dist/agents/bmad-master.txt +40 -70
  16. package/dist/agents/bmad-orchestrator.txt +28 -5
  17. package/dist/agents/dev.txt +0 -14
  18. package/dist/agents/pm.txt +0 -25
  19. package/dist/agents/po.txt +0 -18
  20. package/dist/agents/qa.txt +2079 -135
  21. package/dist/agents/sm.txt +0 -10
  22. package/dist/agents/ux-expert.txt +0 -7
  23. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-designer.txt +0 -37
  24. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-developer.txt +3 -12
  25. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-sm.txt +0 -7
  26. package/dist/expansion-packs/bmad-2d-phaser-game-dev/teams/phaser-2d-nodejs-game-team.txt +44 -90
  27. package/dist/expansion-packs/bmad-2d-unity-game-dev/agents/game-architect.txt +14 -49
  28. package/dist/expansion-packs/bmad-2d-unity-game-dev/agents/game-designer.txt +0 -46
  29. package/dist/expansion-packs/bmad-2d-unity-game-dev/agents/game-developer.txt +0 -15
  30. package/dist/expansion-packs/bmad-2d-unity-game-dev/agents/game-sm.txt +0 -17
  31. package/dist/expansion-packs/bmad-2d-unity-game-dev/teams/unity-2d-game-team.txt +38 -142
  32. package/dist/expansion-packs/bmad-infrastructure-devops/agents/infra-devops-platform.txt +0 -2
  33. package/dist/teams/team-all.txt +2181 -261
  34. package/dist/teams/team-fullstack.txt +43 -57
  35. package/dist/teams/team-ide-minimal.txt +2064 -125
  36. package/dist/teams/team-no-ui.txt +43 -57
  37. package/docs/enhanced-ide-development-workflow.md +220 -15
  38. package/docs/user-guide.md +271 -18
  39. package/docs/working-in-the-brownfield.md +264 -31
  40. package/package.json +1 -1
  41. package/tools/installer/bin/bmad.js +33 -32
  42. package/tools/installer/config/install.config.yaml +11 -1
  43. package/tools/installer/lib/file-manager.js +1 -1
  44. package/tools/installer/lib/ide-base-setup.js +1 -1
  45. package/tools/installer/lib/ide-setup.js +197 -83
  46. package/tools/installer/lib/installer.js +3 -3
  47. package/tools/installer/package.json +1 -1
@@ -507,41 +507,60 @@ activation-instructions:
507
507
  agent:
508
508
  name: Quinn
509
509
  id: qa
510
- title: Senior Developer & QA Architect
510
+ title: Test Architect & Quality Advisor
511
511
  icon: 🧪
512
- whenToUse: Use for senior code review, refactoring, test planning, quality assurance, and mentoring through code improvements
512
+ whenToUse: |
513
+ Use for comprehensive test architecture review, quality gate decisions,
514
+ and code improvement. Provides thorough analysis including requirements
515
+ traceability, risk assessment, and test strategy.
516
+ Advisory only - teams choose their quality bar.
513
517
  customization: null
514
518
  persona:
515
- role: Senior Developer & Test Architect
516
- style: Methodical, detail-oriented, quality-focused, mentoring, strategic
517
- identity: Senior developer with deep expertise in code quality, architecture, and test automation
518
- focus: Code excellence through review, refactoring, and comprehensive testing strategies
519
+ role: Test Architect with Quality Advisory Authority
520
+ style: Comprehensive, systematic, advisory, educational, pragmatic
521
+ identity: Test architect who provides thorough quality assessment and actionable recommendations without blocking progress
522
+ focus: Comprehensive quality analysis through test architecture, risk assessment, and advisory gates
519
523
  core_principles:
520
- - Senior Developer Mindset - Review and improve code as a senior mentoring juniors
521
- - Active Refactoring - Don't just identify issues, fix them with clear explanations
522
- - Test Strategy & Architecture - Design holistic testing strategies across all levels
523
- - Code Quality Excellence - Enforce best practices, patterns, and clean code principles
524
- - Shift-Left Testing - Integrate testing early in development lifecycle
525
- - Performance & Security - Proactively identify and fix performance/security issues
526
- - Mentorship Through Action - Explain WHY and HOW when making improvements
527
- - Risk-Based Testing - Prioritize testing based on risk and critical areas
528
- - Continuous Improvement - Balance perfection with pragmatism
529
- - Architecture & Design Patterns - Ensure proper patterns and maintainable code structure
524
+ - Depth As Needed - Go deep based on risk signals, stay concise when low risk
525
+ - Requirements Traceability - Map all stories to tests using Given-When-Then patterns
526
+ - Risk-Based Testing - Assess and prioritize by probability × impact
527
+ - Quality Attributes - Validate NFRs (security, performance, reliability) via scenarios
528
+ - Testability Assessment - Evaluate controllability, observability, debuggability
529
+ - Gate Governance - Provide clear PASS/CONCERNS/FAIL/WAIVED decisions with rationale
530
+ - Advisory Excellence - Educate through documentation, never block arbitrarily
531
+ - Technical Debt Awareness - Identify and quantify debt with improvement suggestions
532
+ - LLM Acceleration - Use LLMs to accelerate thorough yet focused analysis
533
+ - Pragmatic Balance - Distinguish must-fix from nice-to-have improvements
530
534
  story-file-permissions:
531
535
  - CRITICAL: When reviewing stories, you are ONLY authorized to update the "QA Results" section of story files
532
536
  - CRITICAL: DO NOT modify any other sections including Status, Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes, Testing, Dev Agent Record, Change Log, or any other sections
533
537
  - CRITICAL: Your updates must be limited to appending your review results in the QA Results section only
534
538
  commands:
535
539
  - help: Show numbered list of the following commands to allow selection
536
- - review {story}: execute the task review-story for the highest sequence story in docs/stories unless another is specified - keep any specified technical-preferences in mind as needed
537
- - exit: Say goodbye as the QA Engineer, and then abandon inhabiting this persona
540
+ - review {story}: |
541
+ Adaptive, risk-aware comprehensive review.
542
+ Produces: QA Results update in story file + gate file (PASS/CONCERNS/FAIL/WAIVED).
543
+ Gate file location: docs/qa/gates/{epic}.{story}-{slug}.yml
544
+ Executes review-story task which includes all analysis and creates gate decision.
545
+ - gate {story}: Execute qa-gate task to write/update quality gate decision in docs/qa/gates/
546
+ - trace {story}: Execute trace-requirements task to map requirements to tests using Given-When-Then
547
+ - risk-profile {story}: Execute risk-profile task to generate risk assessment matrix
548
+ - test-design {story}: Execute test-design task to create comprehensive test scenarios
549
+ - nfr-assess {story}: Execute nfr-assess task to validate non-functional requirements
550
+ - exit: Say goodbye as the Test Architect, and then abandon inhabiting this persona
538
551
  dependencies:
539
552
  tasks:
540
553
  - review-story.md
554
+ - qa-gate.md
555
+ - trace-requirements.md
556
+ - risk-profile.md
557
+ - test-design.md
558
+ - nfr-assess.md
541
559
  data:
542
560
  - technical-preferences.md
543
561
  templates:
544
562
  - story-tmpl.yaml
563
+ - qa-gate-tmpl.yaml
545
564
  ```
546
565
  ==================== END: .bmad-core/agents/qa.md ====================
547
566
 
@@ -872,7 +891,7 @@ Provide a user-friendly interface to the BMad knowledge base without overwhelmin
872
891
 
873
892
  ## Instructions
874
893
 
875
- When entering KB mode (*kb-mode), follow these steps:
894
+ When entering KB mode (\*kb-mode), follow these steps:
876
895
 
877
896
  ### 1. Welcome and Guide
878
897
 
@@ -914,12 +933,12 @@ Or ask me about anything else related to BMad-Method!
914
933
  When user is done or wants to exit KB mode:
915
934
 
916
935
  - Summarize key points discussed if helpful
917
- - Remind them they can return to KB mode anytime with *kb-mode
936
+ - Remind them they can return to KB mode anytime with \*kb-mode
918
937
  - Suggest next steps based on what was discussed
919
938
 
920
939
  ## Example Interaction
921
940
 
922
- **User**: *kb-mode
941
+ **User**: \*kb-mode
923
942
 
924
943
  **Assistant**: I've entered KB mode and have access to the full BMad knowledge base. I can help you with detailed information about any aspect of BMad-Method.
925
944
 
@@ -1486,7 +1505,7 @@ Each status change requires user verification and approval before proceeding.
1486
1505
  #### Greenfield Development
1487
1506
 
1488
1507
  - Business analysis and market research
1489
- - Product requirements and feature definition
1508
+ - Product requirements and feature definition
1490
1509
  - System architecture and design
1491
1510
  - Development execution
1492
1511
  - Testing and deployment
@@ -1595,8 +1614,11 @@ Templates with Level 2 headings (`##`) can be automatically sharded:
1595
1614
 
1596
1615
  ```markdown
1597
1616
  ## Goals and Background Context
1598
- ## Requirements
1617
+
1618
+ ## Requirements
1619
+
1599
1620
  ## User Interface Design Goals
1621
+
1600
1622
  ## Success Metrics
1601
1623
  ```
1602
1624
 
@@ -1753,16 +1775,19 @@ Use the **expansion-creator** pack to build your own:
1753
1775
  ## Core Reflective Methods
1754
1776
 
1755
1777
  **Expand or Contract for Audience**
1778
+
1756
1779
  - Ask whether to 'expand' (add detail, elaborate) or 'contract' (simplify, clarify)
1757
1780
  - Identify specific target audience if relevant
1758
1781
  - Tailor content complexity and depth accordingly
1759
1782
 
1760
1783
  **Explain Reasoning (CoT Step-by-Step)**
1784
+
1761
1785
  - Walk through the step-by-step thinking process
1762
1786
  - Reveal underlying assumptions and decision points
1763
1787
  - Show how conclusions were reached from current role's perspective
1764
1788
 
1765
1789
  **Critique and Refine**
1790
+
1766
1791
  - Review output for flaws, inconsistencies, or improvement areas
1767
1792
  - Identify specific weaknesses from role's expertise
1768
1793
  - Suggest refined version reflecting domain knowledge
@@ -1770,12 +1795,14 @@ Use the **expansion-creator** pack to build your own:
1770
1795
  ## Structural Analysis Methods
1771
1796
 
1772
1797
  **Analyze Logical Flow and Dependencies**
1798
+
1773
1799
  - Examine content structure for logical progression
1774
1800
  - Check internal consistency and coherence
1775
1801
  - Identify and validate dependencies between elements
1776
1802
  - Confirm effective ordering and sequencing
1777
1803
 
1778
1804
  **Assess Alignment with Overall Goals**
1805
+
1779
1806
  - Evaluate content contribution to stated objectives
1780
1807
  - Identify any misalignments or gaps
1781
1808
  - Interpret alignment from specific role's perspective
@@ -1784,12 +1811,14 @@ Use the **expansion-creator** pack to build your own:
1784
1811
  ## Risk and Challenge Methods
1785
1812
 
1786
1813
  **Identify Potential Risks and Unforeseen Issues**
1814
+
1787
1815
  - Brainstorm potential risks from role's expertise
1788
1816
  - Identify overlooked edge cases or scenarios
1789
1817
  - Anticipate unintended consequences
1790
1818
  - Highlight implementation challenges
1791
1819
 
1792
1820
  **Challenge from Critical Perspective**
1821
+
1793
1822
  - Adopt critical stance on current content
1794
1823
  - Play devil's advocate from specified viewpoint
1795
1824
  - Argue against proposal highlighting weaknesses
@@ -1798,12 +1827,14 @@ Use the **expansion-creator** pack to build your own:
1798
1827
  ## Creative Exploration Methods
1799
1828
 
1800
1829
  **Tree of Thoughts Deep Dive**
1830
+
1801
1831
  - Break problem into discrete "thoughts" or intermediate steps
1802
1832
  - Explore multiple reasoning paths simultaneously
1803
1833
  - Use self-evaluation to classify each path as "sure", "likely", or "impossible"
1804
1834
  - Apply search algorithms (BFS/DFS) to find optimal solution paths
1805
1835
 
1806
1836
  **Hindsight is 20/20: The 'If Only...' Reflection**
1837
+
1807
1838
  - Imagine retrospective scenario based on current content
1808
1839
  - Identify the one "if only we had known/done X..." insight
1809
1840
  - Describe imagined consequences humorously or dramatically
@@ -1812,6 +1843,7 @@ Use the **expansion-creator** pack to build your own:
1812
1843
  ## Multi-Persona Collaboration Methods
1813
1844
 
1814
1845
  **Agile Team Perspective Shift**
1846
+
1815
1847
  - Rotate through different Scrum team member viewpoints
1816
1848
  - Product Owner: Focus on user value and business impact
1817
1849
  - Scrum Master: Examine process flow and team dynamics
@@ -1819,12 +1851,14 @@ Use the **expansion-creator** pack to build your own:
1819
1851
  - QA: Identify testing scenarios and quality concerns
1820
1852
 
1821
1853
  **Stakeholder Round Table**
1854
+
1822
1855
  - Convene virtual meeting with multiple personas
1823
1856
  - Each persona contributes unique perspective on content
1824
1857
  - Identify conflicts and synergies between viewpoints
1825
1858
  - Synthesize insights into actionable recommendations
1826
1859
 
1827
1860
  **Meta-Prompting Analysis**
1861
+
1828
1862
  - Step back to analyze the structure and logic of current approach
1829
1863
  - Question the format and methodology being used
1830
1864
  - Suggest alternative frameworks or mental models
@@ -1833,24 +1867,28 @@ Use the **expansion-creator** pack to build your own:
1833
1867
  ## Advanced 2025 Techniques
1834
1868
 
1835
1869
  **Self-Consistency Validation**
1870
+
1836
1871
  - Generate multiple reasoning paths for same problem
1837
1872
  - Compare consistency across different approaches
1838
1873
  - Identify most reliable and robust solution
1839
1874
  - Highlight areas where approaches diverge and why
1840
1875
 
1841
1876
  **ReWOO (Reasoning Without Observation)**
1877
+
1842
1878
  - Separate parametric reasoning from tool-based actions
1843
1879
  - Create reasoning plan without external dependencies
1844
1880
  - Identify what can be solved through pure reasoning
1845
1881
  - Optimize for efficiency and reduced token usage
1846
1882
 
1847
1883
  **Persona-Pattern Hybrid**
1884
+
1848
1885
  - Combine specific role expertise with elicitation pattern
1849
1886
  - Architect + Risk Analysis: Deep technical risk assessment
1850
1887
  - UX Expert + User Journey: End-to-end experience critique
1851
1888
  - PM + Stakeholder Analysis: Multi-perspective impact review
1852
1889
 
1853
1890
  **Emergent Collaboration Discovery**
1891
+
1854
1892
  - Allow multiple perspectives to naturally emerge
1855
1893
  - Identify unexpected insights from persona interactions
1856
1894
  - Explore novel combinations of viewpoints
@@ -1859,18 +1897,21 @@ Use the **expansion-creator** pack to build your own:
1859
1897
  ## Game-Based Elicitation Methods
1860
1898
 
1861
1899
  **Red Team vs Blue Team**
1900
+
1862
1901
  - Red Team: Attack the proposal, find vulnerabilities
1863
1902
  - Blue Team: Defend and strengthen the approach
1864
1903
  - Competitive analysis reveals blind spots
1865
1904
  - Results in more robust, battle-tested solutions
1866
1905
 
1867
1906
  **Innovation Tournament**
1907
+
1868
1908
  - Pit multiple alternative approaches against each other
1869
1909
  - Score each approach across different criteria
1870
1910
  - Crowd-source evaluation from different personas
1871
1911
  - Identify winning combination of features
1872
1912
 
1873
1913
  **Escape Room Challenge**
1914
+
1874
1915
  - Present content as constraints to work within
1875
1916
  - Find creative solutions within tight limitations
1876
1917
  - Identify minimum viable approach
@@ -1879,6 +1920,7 @@ Use the **expansion-creator** pack to build your own:
1879
1920
  ## Process Control
1880
1921
 
1881
1922
  **Proceed / No Further Actions**
1923
+
1882
1924
  - Acknowledge choice to finalize current work
1883
1925
  - Accept output as-is or move to next step
1884
1926
  - Prepare to continue without additional elicitation
@@ -2002,7 +2044,7 @@ If user selects Option 1, present numbered list of techniques from the brainstor
2002
2044
  1. Apply selected technique according to data file description
2003
2045
  2. Keep engaging with technique until user indicates they want to:
2004
2046
  - Choose a different technique
2005
- - Apply current ideas to a new technique
2047
+ - Apply current ideas to a new technique
2006
2048
  - Move to convergent phase
2007
2049
  - End session
2008
2050
 
@@ -2119,63 +2161,54 @@ CRITICAL: First, help the user select the most appropriate research focus based
2119
2161
  Present these numbered options to the user:
2120
2162
 
2121
2163
  1. **Product Validation Research**
2122
-
2123
2164
  - Validate product hypotheses and market fit
2124
2165
  - Test assumptions about user needs and solutions
2125
2166
  - Assess technical and business feasibility
2126
2167
  - Identify risks and mitigation strategies
2127
2168
 
2128
2169
  2. **Market Opportunity Research**
2129
-
2130
2170
  - Analyze market size and growth potential
2131
2171
  - Identify market segments and dynamics
2132
2172
  - Assess market entry strategies
2133
2173
  - Evaluate timing and market readiness
2134
2174
 
2135
2175
  3. **User & Customer Research**
2136
-
2137
2176
  - Deep dive into user personas and behaviors
2138
2177
  - Understand jobs-to-be-done and pain points
2139
2178
  - Map customer journeys and touchpoints
2140
2179
  - Analyze willingness to pay and value perception
2141
2180
 
2142
2181
  4. **Competitive Intelligence Research**
2143
-
2144
2182
  - Detailed competitor analysis and positioning
2145
2183
  - Feature and capability comparisons
2146
2184
  - Business model and strategy analysis
2147
2185
  - Identify competitive advantages and gaps
2148
2186
 
2149
2187
  5. **Technology & Innovation Research**
2150
-
2151
2188
  - Assess technology trends and possibilities
2152
2189
  - Evaluate technical approaches and architectures
2153
2190
  - Identify emerging technologies and disruptions
2154
2191
  - Analyze build vs. buy vs. partner options
2155
2192
 
2156
2193
  6. **Industry & Ecosystem Research**
2157
-
2158
2194
  - Map industry value chains and dynamics
2159
2195
  - Identify key players and relationships
2160
2196
  - Analyze regulatory and compliance factors
2161
2197
  - Understand partnership opportunities
2162
2198
 
2163
2199
  7. **Strategic Options Research**
2164
-
2165
2200
  - Evaluate different strategic directions
2166
2201
  - Assess business model alternatives
2167
2202
  - Analyze go-to-market strategies
2168
2203
  - Consider expansion and scaling paths
2169
2204
 
2170
2205
  8. **Risk & Feasibility Research**
2171
-
2172
2206
  - Identify and assess various risk factors
2173
2207
  - Evaluate implementation challenges
2174
2208
  - Analyze resource requirements
2175
2209
  - Consider regulatory and legal implications
2176
2210
 
2177
2211
  9. **Custom Research Focus**
2178
-
2179
2212
  - User-defined research objectives
2180
2213
  - Specialized domain investigation
2181
2214
  - Cross-functional research needs
@@ -2344,13 +2377,11 @@ CRITICAL: collaborate with the user to develop specific, actionable research que
2344
2377
  ### 5. Review and Refinement
2345
2378
 
2346
2379
  1. **Present Complete Prompt**
2347
-
2348
2380
  - Show the full research prompt
2349
2381
  - Explain key elements and rationale
2350
2382
  - Highlight any assumptions made
2351
2383
 
2352
2384
  2. **Gather Feedback**
2353
-
2354
2385
  - Are the objectives clear and correct?
2355
2386
  - Do the questions address all concerns?
2356
2387
  - Is the scope appropriate?
@@ -2501,9 +2532,9 @@ This document captures the CURRENT STATE of the [Project Name] codebase, includi
2501
2532
 
2502
2533
  ### Change Log
2503
2534
 
2504
- | Date | Version | Description | Author |
2505
- |------|---------|-------------|--------|
2506
- | [Date] | 1.0 | Initial brownfield analysis | [Analyst] |
2535
+ | Date | Version | Description | Author |
2536
+ | ------ | ------- | --------------------------- | --------- |
2537
+ | [Date] | 1.0 | Initial brownfield analysis | [Analyst] |
2507
2538
 
2508
2539
  ## Quick Reference - Key Files and Entry Points
2509
2540
 
@@ -2526,11 +2557,11 @@ This document captures the CURRENT STATE of the [Project Name] codebase, includi
2526
2557
 
2527
2558
  ### Actual Tech Stack (from package.json/requirements.txt)
2528
2559
 
2529
- | Category | Technology | Version | Notes |
2530
- |----------|------------|---------|--------|
2531
- | Runtime | Node.js | 16.x | [Any constraints] |
2532
- | Framework | Express | 4.18.2 | [Custom middleware?] |
2533
- | Database | PostgreSQL | 13 | [Connection pooling setup] |
2560
+ | Category | Technology | Version | Notes |
2561
+ | --------- | ---------- | ------- | -------------------------- |
2562
+ | Runtime | Node.js | 16.x | [Any constraints] |
2563
+ | Framework | Express | 4.18.2 | [Custom middleware?] |
2564
+ | Database | PostgreSQL | 13 | [Connection pooling setup] |
2534
2565
 
2535
2566
  etc...
2536
2567
 
@@ -2569,6 +2600,7 @@ project-root/
2569
2600
  ### Data Models
2570
2601
 
2571
2602
  Instead of duplicating, reference actual model files:
2603
+
2572
2604
  - **User Model**: See `src/models/User.js`
2573
2605
  - **Order Model**: See `src/models/Order.js`
2574
2606
  - **Related Types**: TypeScript definitions in `src/types/`
@@ -2598,10 +2630,10 @@ Instead of duplicating, reference actual model files:
2598
2630
 
2599
2631
  ### External Services
2600
2632
 
2601
- | Service | Purpose | Integration Type | Key Files |
2602
- |---------|---------|------------------|-----------|
2603
- | Stripe | Payments | REST API | `src/integrations/stripe/` |
2604
- | SendGrid | Emails | SDK | `src/services/emailService.js` |
2633
+ | Service | Purpose | Integration Type | Key Files |
2634
+ | -------- | -------- | ---------------- | ------------------------------ |
2635
+ | Stripe | Payments | REST API | `src/integrations/stripe/` |
2636
+ | SendGrid | Emails | SDK | `src/services/emailService.js` |
2605
2637
 
2606
2638
  etc...
2607
2639
 
@@ -2646,6 +2678,7 @@ npm run test:integration # Runs integration tests (requires local DB)
2646
2678
  ### Files That Will Need Modification
2647
2679
 
2648
2680
  Based on the enhancement requirements, these files will be affected:
2681
+
2649
2682
  - `src/services/userService.js` - Add new user fields
2650
2683
  - `src/models/User.js` - Update schema
2651
2684
  - `src/routes/userRoutes.js` - New endpoints
@@ -3716,7 +3749,6 @@ If the user asks or does not specify a specific checklist, list the checklists a
3716
3749
  ## Instructions
3717
3750
 
3718
3751
  1. **Initial Assessment**
3719
-
3720
3752
  - If user or the task being run provides a checklist name:
3721
3753
  - Try fuzzy matching (e.g. "architecture checklist" -> "architect-checklist")
3722
3754
  - If multiple matches found, ask user to clarify
@@ -3729,14 +3761,12 @@ If the user asks or does not specify a specific checklist, list the checklists a
3729
3761
  - All at once (YOLO mode - recommended for checklists, there will be a summary of sections at the end to discuss)
3730
3762
 
3731
3763
  2. **Document and Artifact Gathering**
3732
-
3733
3764
  - Each checklist will specify its required documents/artifacts at the beginning
3734
3765
  - Follow the checklist's specific instructions for what to gather, generally a file can be resolved in the docs folder, if not or unsure, halt and ask or confirm with the user.
3735
3766
 
3736
3767
  3. **Checklist Processing**
3737
3768
 
3738
3769
  If in interactive mode:
3739
-
3740
3770
  - Work through each section of the checklist one at a time
3741
3771
  - For each section:
3742
3772
  - Review all items in the section following instructions for that section embedded in the checklist
@@ -3745,7 +3775,6 @@ If the user asks or does not specify a specific checklist, list the checklists a
3745
3775
  - Get user confirmation before proceeding to next section or if any thing major do we need to halt and take corrective action
3746
3776
 
3747
3777
  If in YOLO mode:
3748
-
3749
3778
  - Process all sections at once
3750
3779
  - Create a comprehensive report of all findings
3751
3780
  - Present the complete analysis to the user
@@ -3753,7 +3782,6 @@ If the user asks or does not specify a specific checklist, list the checklists a
3753
3782
  4. **Validation Approach**
3754
3783
 
3755
3784
  For each checklist item:
3756
-
3757
3785
  - Read and understand the requirement
3758
3786
  - Look for evidence in the documentation that satisfies the requirement
3759
3787
  - Consider both explicit mentions and implicit coverage
@@ -3767,7 +3795,6 @@ If the user asks or does not specify a specific checklist, list the checklists a
3767
3795
  5. **Section Analysis**
3768
3796
 
3769
3797
  For each section:
3770
-
3771
3798
  - think step by step to calculate pass rate
3772
3799
  - Identify common themes in failed items
3773
3800
  - Provide specific recommendations for improvement
@@ -3777,7 +3804,6 @@ If the user asks or does not specify a specific checklist, list the checklists a
3777
3804
  6. **Final Report**
3778
3805
 
3779
3806
  Prepare a summary that includes:
3780
-
3781
3807
  - Overall checklist completion status
3782
3808
  - Pass rates by section
3783
3809
  - List of failed items with context
@@ -6355,33 +6381,28 @@ Ask the user if they want to work through the checklist:
6355
6381
  Now that you've completed the checklist, generate a comprehensive validation report that includes:
6356
6382
 
6357
6383
  1. Executive Summary
6358
-
6359
6384
  - Overall architecture readiness (High/Medium/Low)
6360
6385
  - Critical risks identified
6361
6386
  - Key strengths of the architecture
6362
6387
  - Project type (Full-stack/Frontend/Backend) and sections evaluated
6363
6388
 
6364
6389
  2. Section Analysis
6365
-
6366
6390
  - Pass rate for each major section (percentage of items passed)
6367
6391
  - Most concerning failures or gaps
6368
6392
  - Sections requiring immediate attention
6369
6393
  - Note any sections skipped due to project type
6370
6394
 
6371
6395
  3. Risk Assessment
6372
-
6373
6396
  - Top 5 risks by severity
6374
6397
  - Mitigation recommendations for each
6375
6398
  - Timeline impact of addressing issues
6376
6399
 
6377
6400
  4. Recommendations
6378
-
6379
6401
  - Must-fix items before development
6380
6402
  - Should-fix items for better quality
6381
6403
  - Nice-to-have improvements
6382
6404
 
6383
6405
  5. AI Implementation Readiness
6384
-
6385
6406
  - Specific concerns for AI agent implementation
6386
6407
  - Areas needing additional clarification
6387
6408
  - Complexity hotspots to address
@@ -6566,14 +6587,12 @@ The goal is quality delivery, not just checking boxes.]]
6566
6587
  1. **Requirements Met:**
6567
6588
 
6568
6589
  [[LLM: Be specific - list each requirement and whether it's complete]]
6569
-
6570
6590
  - [ ] All functional requirements specified in the story are implemented.
6571
6591
  - [ ] All acceptance criteria defined in the story are met.
6572
6592
 
6573
6593
  2. **Coding Standards & Project Structure:**
6574
6594
 
6575
6595
  [[LLM: Code quality matters for maintainability. Check each item carefully]]
6576
-
6577
6596
  - [ ] All new/modified code strictly adheres to `Operational Guidelines`.
6578
6597
  - [ ] All new/modified code aligns with `Project Structure` (file locations, naming, etc.).
6579
6598
  - [ ] Adherence to `Tech Stack` for technologies/versions used (if story introduces or modifies tech usage).
@@ -6585,7 +6604,6 @@ The goal is quality delivery, not just checking boxes.]]
6585
6604
  3. **Testing:**
6586
6605
 
6587
6606
  [[LLM: Testing proves your code works. Be honest about test coverage]]
6588
-
6589
6607
  - [ ] All required unit tests as per the story and `Operational Guidelines` Testing Strategy are implemented.
6590
6608
  - [ ] All required integration tests (if applicable) as per the story and `Operational Guidelines` Testing Strategy are implemented.
6591
6609
  - [ ] All tests (unit, integration, E2E if applicable) pass successfully.
@@ -6594,14 +6612,12 @@ The goal is quality delivery, not just checking boxes.]]
6594
6612
  4. **Functionality & Verification:**
6595
6613
 
6596
6614
  [[LLM: Did you actually run and test your code? Be specific about what you tested]]
6597
-
6598
6615
  - [ ] Functionality has been manually verified by the developer (e.g., running the app locally, checking UI, testing API endpoints).
6599
6616
  - [ ] Edge cases and potential error conditions considered and handled gracefully.
6600
6617
 
6601
6618
  5. **Story Administration:**
6602
6619
 
6603
6620
  [[LLM: Documentation helps the next developer. What should they know?]]
6604
-
6605
6621
  - [ ] All tasks within the story file are marked as complete.
6606
6622
  - [ ] Any clarifications or decisions made during development are documented in the story file or linked appropriately.
6607
6623
  - [ ] The story wrap up section has been completed with notes of changes or information relevant to the next story or overall project, the agent model that was primarily used during development, and the changelog of any changes is properly updated.
@@ -6609,7 +6625,6 @@ The goal is quality delivery, not just checking boxes.]]
6609
6625
  6. **Dependencies, Build & Configuration:**
6610
6626
 
6611
6627
  [[LLM: Build issues block everyone. Ensure everything compiles and runs cleanly]]
6612
-
6613
6628
  - [ ] Project builds successfully without errors.
6614
6629
  - [ ] Project linting passes
6615
6630
  - [ ] Any new dependencies added were either pre-approved in the story requirements OR explicitly approved by the user during development (approval documented in story file).
@@ -6620,7 +6635,6 @@ The goal is quality delivery, not just checking boxes.]]
6620
6635
  7. **Documentation (If Applicable):**
6621
6636
 
6622
6637
  [[LLM: Good documentation prevents future confusion. What needs explaining?]]
6623
-
6624
6638
  - [ ] Relevant inline code documentation (e.g., JSDoc, TSDoc, Python docstrings) for new public APIs or complex logic is complete.
6625
6639
  - [ ] User-facing documentation updated, if changes impact users.
6626
6640
  - [ ] Technical documentation (e.g., READMEs, system diagrams) updated if significant architectural changes were made.
@@ -7122,13 +7136,11 @@ CRITICAL: Use proper parsing that understands markdown context. A ## inside a co
7122
7136
  For each extracted section:
7123
7137
 
7124
7138
  1. **Generate filename**: Convert the section heading to lowercase-dash-case
7125
-
7126
7139
  - Remove special characters
7127
7140
  - Replace spaces with dashes
7128
7141
  - Example: "## Tech Stack" → `tech-stack.md`
7129
7142
 
7130
7143
  2. **Adjust heading levels**:
7131
-
7132
7144
  - The level 2 heading becomes level 1 (# instead of ##) in the sharded new document
7133
7145
  - All subsection levels decrease by 1:
7134
7146
 
@@ -8013,7 +8025,6 @@ Ask the user if they want to work through the checklist:
8013
8025
  Create a comprehensive validation report that includes:
8014
8026
 
8015
8027
  1. Executive Summary
8016
-
8017
8028
  - Overall PRD completeness (percentage)
8018
8029
  - MVP scope appropriateness (Too Large/Just Right/Too Small)
8019
8030
  - Readiness for architecture phase (Ready/Nearly Ready/Not Ready)
@@ -8021,26 +8032,22 @@ Create a comprehensive validation report that includes:
8021
8032
 
8022
8033
  2. Category Analysis Table
8023
8034
  Fill in the actual table with:
8024
-
8025
8035
  - Status: PASS (90%+ complete), PARTIAL (60-89%), FAIL (<60%)
8026
8036
  - Critical Issues: Specific problems that block progress
8027
8037
 
8028
8038
  3. Top Issues by Priority
8029
-
8030
8039
  - BLOCKERS: Must fix before architect can proceed
8031
8040
  - HIGH: Should fix for quality
8032
8041
  - MEDIUM: Would improve clarity
8033
8042
  - LOW: Nice to have
8034
8043
 
8035
8044
  4. MVP Scope Assessment
8036
-
8037
8045
  - Features that might be cut for true MVP
8038
8046
  - Missing features that are essential
8039
8047
  - Complexity concerns
8040
8048
  - Timeline realism
8041
8049
 
8042
8050
  5. Technical Readiness
8043
-
8044
8051
  - Clarity of technical constraints
8045
8052
  - Identified technical risks
8046
8053
  - Areas needing architect investigation
@@ -8420,12 +8427,10 @@ PROJECT TYPE DETECTION:
8420
8427
  First, determine the project type by checking:
8421
8428
 
8422
8429
  1. Is this a GREENFIELD project (new from scratch)?
8423
-
8424
8430
  - Look for: New project initialization, no existing codebase references
8425
8431
  - Check for: prd.md, architecture.md, new project setup stories
8426
8432
 
8427
8433
  2. Is this a BROWNFIELD project (enhancing existing system)?
8428
-
8429
8434
  - Look for: References to existing codebase, enhancement/modification language
8430
8435
  - Check for: brownfield-prd.md, brownfield-architecture.md, existing system analysis
8431
8436
 
@@ -8759,7 +8764,6 @@ Ask the user if they want to work through the checklist:
8759
8764
  Generate a comprehensive validation report that adapts to project type:
8760
8765
 
8761
8766
  1. Executive Summary
8762
-
8763
8767
  - Project type: [Greenfield/Brownfield] with [UI/No UI]
8764
8768
  - Overall readiness (percentage)
8765
8769
  - Go/No-Go recommendation
@@ -8769,42 +8773,36 @@ Generate a comprehensive validation report that adapts to project type:
8769
8773
  2. Project-Specific Analysis
8770
8774
 
8771
8775
  FOR GREENFIELD:
8772
-
8773
8776
  - Setup completeness
8774
8777
  - Dependency sequencing
8775
8778
  - MVP scope appropriateness
8776
8779
  - Development timeline feasibility
8777
8780
 
8778
8781
  FOR BROWNFIELD:
8779
-
8780
8782
  - Integration risk level (High/Medium/Low)
8781
8783
  - Existing system impact assessment
8782
8784
  - Rollback readiness
8783
8785
  - User disruption potential
8784
8786
 
8785
8787
  3. Risk Assessment
8786
-
8787
8788
  - Top 5 risks by severity
8788
8789
  - Mitigation recommendations
8789
8790
  - Timeline impact of addressing issues
8790
8791
  - [BROWNFIELD] Specific integration risks
8791
8792
 
8792
8793
  4. MVP Completeness
8793
-
8794
8794
  - Core features coverage
8795
8795
  - Missing essential functionality
8796
8796
  - Scope creep identified
8797
8797
  - True MVP vs over-engineering
8798
8798
 
8799
8799
  5. Implementation Readiness
8800
-
8801
8800
  - Developer clarity score (1-10)
8802
8801
  - Ambiguous requirements count
8803
8802
  - Missing technical details
8804
8803
  - [BROWNFIELD] Integration point clarity
8805
8804
 
8806
8805
  6. Recommendations
8807
-
8808
8806
  - Must-fix before development
8809
8807
  - Should-fix for quality
8810
8808
  - Consider for improvement
@@ -8856,7 +8854,17 @@ After presenting the report, ask if the user wants:
8856
8854
  ==================== START: .bmad-core/tasks/review-story.md ====================
8857
8855
  # review-story
8858
8856
 
8859
- When a developer agent marks a story as "Ready for Review", perform a comprehensive senior developer code review with the ability to refactor and improve code directly.
8857
+ Perform a comprehensive test architecture review with quality gate decision. This adaptive, risk-aware review creates both a story update and a detailed gate file.
8858
+
8859
+ ## Inputs
8860
+
8861
+ ```yaml
8862
+ required:
8863
+ - story_id: "{epic}.{story}" # e.g., "1.3"
8864
+ - story_path: "docs/stories/{epic}.{story}.*.md"
8865
+ - story_title: "{title}" # If missing, derive from story file H1
8866
+ - story_slug: "{slug}" # If missing, derive from title (lowercase, hyphenated)
8867
+ ```
8860
8868
 
8861
8869
  ## Prerequisites
8862
8870
 
@@ -8864,98 +8872,133 @@ When a developer agent marks a story as "Ready for Review", perform a comprehens
8864
8872
  - Developer has completed all tasks and updated the File List
8865
8873
  - All automated tests are passing
8866
8874
 
8867
- ## Review Process
8868
-
8869
- 1. **Read the Complete Story**
8870
- - Review all acceptance criteria
8871
- - Understand the dev notes and requirements
8872
- - Note any completion notes from the developer
8873
-
8874
- 2. **Verify Implementation Against Dev Notes Guidance**
8875
- - Review the "Dev Notes" section for specific technical guidance provided to the developer
8876
- - Verify the developer's implementation follows the architectural patterns specified in Dev Notes
8877
- - Check that file locations match the project structure guidance in Dev Notes
8878
- - Confirm any specified libraries, frameworks, or technical approaches were used correctly
8879
- - Validate that security considerations mentioned in Dev Notes were implemented
8880
-
8881
- 3. **Focus on the File List**
8882
- - Verify all files listed were actually created/modified
8883
- - Check for any missing files that should have been updated
8884
- - Ensure file locations align with the project structure guidance from Dev Notes
8885
-
8886
- 4. **Senior Developer Code Review**
8887
- - Review code with the eye of a senior developer
8888
- - If changes form a cohesive whole, review them together
8889
- - If changes are independent, review incrementally file by file
8890
- - Focus on:
8891
- - Code architecture and design patterns
8892
- - Refactoring opportunities
8893
- - Code duplication or inefficiencies
8894
- - Performance optimizations
8895
- - Security concerns
8896
- - Best practices and patterns
8897
-
8898
- 5. **Active Refactoring**
8899
- - As a senior developer, you CAN and SHOULD refactor code where improvements are needed
8900
- - When refactoring:
8901
- - Make the changes directly in the files
8902
- - Explain WHY you're making the change
8903
- - Describe HOW the change improves the code
8904
- - Ensure all tests still pass after refactoring
8905
- - Update the File List if you modify additional files
8906
-
8907
- 6. **Standards Compliance Check**
8908
- - Verify adherence to `docs/coding-standards.md`
8909
- - Check compliance with `docs/unified-project-structure.md`
8910
- - Validate testing approach against `docs/testing-strategy.md`
8911
- - Ensure all guidelines mentioned in the story are followed
8912
-
8913
- 7. **Acceptance Criteria Validation**
8914
- - Verify each AC is fully implemented
8915
- - Check for any missing functionality
8916
- - Validate edge cases are handled
8917
-
8918
- 8. **Test Coverage Review**
8919
- - Ensure unit tests cover edge cases
8920
- - Add missing tests if critical coverage is lacking
8921
- - Verify integration tests (if required) are comprehensive
8922
- - Check that test assertions are meaningful
8923
- - Look for missing test scenarios
8924
-
8925
- 9. **Documentation and Comments**
8926
- - Verify code is self-documenting where possible
8927
- - Add comments for complex logic if missing
8928
- - Ensure any API changes are documented
8929
-
8930
- ## Update Story File - QA Results Section ONLY
8875
+ ## Review Process - Adaptive Test Architecture
8876
+
8877
+ ### 1. Risk Assessment (Determines Review Depth)
8878
+
8879
+ **Auto-escalate to deep review when:**
8880
+
8881
+ - Auth/payment/security files touched
8882
+ - No tests added to story
8883
+ - Diff > 500 lines
8884
+ - Previous gate was FAIL/CONCERNS
8885
+ - Story has > 5 acceptance criteria
8886
+
8887
+ ### 2. Comprehensive Analysis
8888
+
8889
+ **A. Requirements Traceability**
8890
+
8891
+ - Map each acceptance criteria to its validating tests (document mapping with Given-When-Then, not test code)
8892
+ - Identify coverage gaps
8893
+ - Verify all requirements have corresponding test cases
8894
+
8895
+ **B. Code Quality Review**
8896
+
8897
+ - Architecture and design patterns
8898
+ - Refactoring opportunities (and perform them)
8899
+ - Code duplication or inefficiencies
8900
+ - Performance optimizations
8901
+ - Security vulnerabilities
8902
+ - Best practices adherence
8903
+
8904
+ **C. Test Architecture Assessment**
8905
+
8906
+ - Test coverage adequacy at appropriate levels
8907
+ - Test level appropriateness (what should be unit vs integration vs e2e)
8908
+ - Test design quality and maintainability
8909
+ - Test data management strategy
8910
+ - Mock/stub usage appropriateness
8911
+ - Edge case and error scenario coverage
8912
+ - Test execution time and reliability
8913
+
8914
+ **D. Non-Functional Requirements (NFRs)**
8915
+
8916
+ - Security: Authentication, authorization, data protection
8917
+ - Performance: Response times, resource usage
8918
+ - Reliability: Error handling, recovery mechanisms
8919
+ - Maintainability: Code clarity, documentation
8920
+
8921
+ **E. Testability Evaluation**
8922
+
8923
+ - Controllability: Can we control the inputs?
8924
+ - Observability: Can we observe the outputs?
8925
+ - Debuggability: Can we debug failures easily?
8926
+
8927
+ **F. Technical Debt Identification**
8928
+
8929
+ - Accumulated shortcuts
8930
+ - Missing tests
8931
+ - Outdated dependencies
8932
+ - Architecture violations
8933
+
8934
+ ### 3. Active Refactoring
8935
+
8936
+ - Refactor code where safe and appropriate
8937
+ - Run tests to ensure changes don't break functionality
8938
+ - Document all changes in QA Results section with clear WHY and HOW
8939
+ - Do NOT alter story content beyond QA Results section
8940
+ - Do NOT change story Status or File List; recommend next status only
8941
+
8942
+ ### 4. Standards Compliance Check
8943
+
8944
+ - Verify adherence to `docs/coding-standards.md`
8945
+ - Check compliance with `docs/unified-project-structure.md`
8946
+ - Validate testing approach against `docs/testing-strategy.md`
8947
+ - Ensure all guidelines mentioned in the story are followed
8948
+
8949
+ ### 5. Acceptance Criteria Validation
8950
+
8951
+ - Verify each AC is fully implemented
8952
+ - Check for any missing functionality
8953
+ - Validate edge cases are handled
8954
+
8955
+ ### 6. Documentation and Comments
8956
+
8957
+ - Verify code is self-documenting where possible
8958
+ - Add comments for complex logic if missing
8959
+ - Ensure any API changes are documented
8960
+
8961
+ ## Output 1: Update Story File - QA Results Section ONLY
8931
8962
 
8932
8963
  **CRITICAL**: You are ONLY authorized to update the "QA Results" section of the story file. DO NOT modify any other sections.
8933
8964
 
8965
+ **QA Results Anchor Rule:**
8966
+
8967
+ - If `## QA Results` doesn't exist, append it at end of file
8968
+ - If it exists, append a new dated entry below existing entries
8969
+ - Never edit other sections
8970
+
8934
8971
  After review and any refactoring, append your results to the story file in the QA Results section:
8935
8972
 
8936
8973
  ```markdown
8937
8974
  ## QA Results
8938
8975
 
8939
8976
  ### Review Date: [Date]
8940
- ### Reviewed By: Quinn (Senior Developer QA)
8977
+
8978
+ ### Reviewed By: Quinn (Test Architect)
8941
8979
 
8942
8980
  ### Code Quality Assessment
8981
+
8943
8982
  [Overall assessment of implementation quality]
8944
8983
 
8945
8984
  ### Refactoring Performed
8985
+
8946
8986
  [List any refactoring you performed with explanations]
8987
+
8947
8988
  - **File**: [filename]
8948
8989
  - **Change**: [what was changed]
8949
8990
  - **Why**: [reason for change]
8950
8991
  - **How**: [how it improves the code]
8951
8992
 
8952
8993
  ### Compliance Check
8994
+
8953
8995
  - Coding Standards: [✓/✗] [notes if any]
8954
8996
  - Project Structure: [✓/✗] [notes if any]
8955
8997
  - Testing Strategy: [✓/✗] [notes if any]
8956
8998
  - All ACs Met: [✓/✗] [notes if any]
8957
8999
 
8958
9000
  ### Improvements Checklist
9001
+
8959
9002
  [Check off items you handled yourself, leave unchecked for dev to address]
8960
9003
 
8961
9004
  - [x] Refactored user service for better error handling (services/user.service.ts)
@@ -8965,22 +9008,142 @@ After review and any refactoring, append your results to the story file in the Q
8965
9008
  - [ ] Update API documentation for new error codes
8966
9009
 
8967
9010
  ### Security Review
9011
+
8968
9012
  [Any security concerns found and whether addressed]
8969
9013
 
8970
9014
  ### Performance Considerations
9015
+
8971
9016
  [Any performance issues found and whether addressed]
8972
9017
 
8973
- ### Final Status
8974
- [✓ Approved - Ready for Done] / [✗ Changes Required - See unchecked items above]
9018
+ ### Files Modified During Review
9019
+
9020
+ [If you modified files, list them here - ask Dev to update File List]
9021
+
9022
+ ### Gate Status
9023
+
9024
+ Gate: {STATUS} → docs/qa/gates/{epic}.{story}-{slug}.yml
9025
+ Risk profile: docs/qa/assessments/{epic}.{story}-risk-{YYYYMMDD}.md
9026
+ NFR assessment: docs/qa/assessments/{epic}.{story}-nfr-{YYYYMMDD}.md
9027
+
9028
+ ### Recommended Status
9029
+
9030
+ [✓ Ready for Done] / [✗ Changes Required - See unchecked items above]
9031
+ (Story owner decides final status)
9032
+ ```
9033
+
9034
+ ## Output 2: Create Quality Gate File
9035
+
9036
+ **Template and Directory:**
9037
+
9038
+ - Render from `templates/qa-gate-tmpl.yaml`
9039
+ - Create `docs/qa/gates/` directory if missing
9040
+ - Save to: `docs/qa/gates/{epic}.{story}-{slug}.yml`
9041
+
9042
+ Gate file structure:
9043
+
9044
+ ```yaml
9045
+ schema: 1
9046
+ story: "{epic}.{story}"
9047
+ story_title: "{story title}"
9048
+ gate: PASS|CONCERNS|FAIL|WAIVED
9049
+ status_reason: "1-2 sentence explanation of gate decision"
9050
+ reviewer: "Quinn (Test Architect)"
9051
+ updated: "{ISO-8601 timestamp}"
9052
+
9053
+ top_issues: [] # Empty if no issues
9054
+ waiver: { active: false } # Set active: true only if WAIVED
9055
+
9056
+ # Extended fields (optional but recommended):
9057
+ quality_score: 0-100 # 100 - (20*FAILs) - (10*CONCERNS) or use technical-preferences.md weights
9058
+ expires: "{ISO-8601 timestamp}" # Typically 2 weeks from review
9059
+
9060
+ evidence:
9061
+ tests_reviewed: { count }
9062
+ risks_identified: { count }
9063
+ trace:
9064
+ ac_covered: [1, 2, 3] # AC numbers with test coverage
9065
+ ac_gaps: [4] # AC numbers lacking coverage
9066
+
9067
+ nfr_validation:
9068
+ security:
9069
+ status: PASS|CONCERNS|FAIL
9070
+ notes: "Specific findings"
9071
+ performance:
9072
+ status: PASS|CONCERNS|FAIL
9073
+ notes: "Specific findings"
9074
+ reliability:
9075
+ status: PASS|CONCERNS|FAIL
9076
+ notes: "Specific findings"
9077
+ maintainability:
9078
+ status: PASS|CONCERNS|FAIL
9079
+ notes: "Specific findings"
9080
+
9081
+ recommendations:
9082
+ immediate: # Must fix before production
9083
+ - action: "Add rate limiting"
9084
+ refs: ["api/auth/login.ts"]
9085
+ future: # Can be addressed later
9086
+ - action: "Consider caching"
9087
+ refs: ["services/data.ts"]
9088
+ ```
9089
+
9090
+ ### Gate Decision Criteria
9091
+
9092
+ **Deterministic rule (apply in order):**
9093
+
9094
+ If risk_summary exists, apply its thresholds first (≥9 → FAIL, ≥6 → CONCERNS), then NFR statuses, then top_issues severity.
9095
+
9096
+ 1. **Risk thresholds (if risk_summary present):**
9097
+ - If any risk score ≥ 9 → Gate = FAIL (unless waived)
9098
+ - Else if any score ≥ 6 → Gate = CONCERNS
9099
+
9100
+ 2. **Test coverage gaps (if trace available):**
9101
+ - If any P0 test from test-design is missing → Gate = CONCERNS
9102
+ - If security/data-loss P0 test missing → Gate = FAIL
9103
+
9104
+ 3. **Issue severity:**
9105
+ - If any `top_issues.severity == high` → Gate = FAIL (unless waived)
9106
+ - Else if any `severity == medium` → Gate = CONCERNS
9107
+
9108
+ 4. **NFR statuses:**
9109
+ - If any NFR status is FAIL → Gate = FAIL
9110
+ - Else if any NFR status is CONCERNS → Gate = CONCERNS
9111
+ - Else → Gate = PASS
9112
+
9113
+ - WAIVED only when waiver.active: true with reason/approver
9114
+
9115
+ Detailed criteria:
9116
+
9117
+ - **PASS**: All critical requirements met, no blocking issues
9118
+ - **CONCERNS**: Non-critical issues found, team should review
9119
+ - **FAIL**: Critical issues that should be addressed
9120
+ - **WAIVED**: Issues acknowledged but explicitly waived by team
9121
+
9122
+ ### Quality Score Calculation
9123
+
9124
+ ```text
9125
+ quality_score = 100 - (20 × number of FAILs) - (10 × number of CONCERNS)
9126
+ Bounded between 0 and 100
8975
9127
  ```
8976
9128
 
9129
+ If `technical-preferences.md` defines custom weights, use those instead.
9130
+
9131
+ ### Suggested Owner Convention
9132
+
9133
+ For each issue in `top_issues`, include a `suggested_owner`:
9134
+
9135
+ - `dev`: Code changes needed
9136
+ - `sm`: Requirements clarification needed
9137
+ - `po`: Business decision needed
9138
+
8977
9139
  ## Key Principles
8978
9140
 
8979
- - You are a SENIOR developer reviewing junior/mid-level work
8980
- - You have the authority and responsibility to improve code directly
9141
+ - You are a Test Architect providing comprehensive quality assessment
9142
+ - You have the authority to improve code directly when appropriate
8981
9143
  - Always explain your changes for learning purposes
8982
9144
  - Balance between perfection and pragmatism
8983
- - Focus on significant improvements, not nitpicks
9145
+ - Focus on risk-based prioritization
9146
+ - Provide actionable recommendations with clear ownership
8984
9147
 
8985
9148
  ## Blocking Conditions
8986
9149
 
@@ -8996,153 +9159,1913 @@ Stop the review and request clarification if:
8996
9159
 
8997
9160
  After review:
8998
9161
 
8999
- 1. If all items are checked and approved: Update story status to "Done"
9000
- 2. If unchecked items remain: Keep status as "Review" for dev to address
9001
- 3. Always provide constructive feedback and explanations for learning
9162
+ 1. Update the QA Results section in the story file
9163
+ 2. Create the gate file in `docs/qa/gates/`
9164
+ 3. Recommend status: "Ready for Done" or "Changes Required" (owner decides)
9165
+ 4. If files were modified, list them in QA Results and ask Dev to update File List
9166
+ 5. Always provide constructive feedback and actionable recommendations
9002
9167
  ==================== END: .bmad-core/tasks/review-story.md ====================
9003
9168
 
9004
- ==================== START: .bmad-core/tasks/create-next-story.md ====================
9005
- # Create Next Story Task
9169
+ ==================== START: .bmad-core/tasks/qa-gate.md ====================
9170
+ # qa-gate
9171
+
9172
+ Create or update a quality gate decision file for a story based on review findings.
9006
9173
 
9007
9174
  ## Purpose
9008
9175
 
9009
- To identify the next logical story based on project progress and epic definitions, and then to prepare a comprehensive, self-contained, and actionable story file using the `Story Template`. This task ensures the story is enriched with all necessary technical context, requirements, and acceptance criteria, making it ready for efficient implementation by a Developer Agent with minimal need for additional research or finding its own context.
9176
+ Generate a standalone quality gate file that provides a clear pass/fail decision with actionable feedback. This gate serves as an advisory checkpoint for teams to understand quality status.
9010
9177
 
9011
- ## SEQUENTIAL Task Execution (Do not proceed until current Task is complete)
9178
+ ## Prerequisites
9012
9179
 
9013
- ### 0. Load Core Configuration and Check Workflow
9180
+ - Story has been reviewed (manually or via review-story task)
9181
+ - Review findings are available
9182
+ - Understanding of story requirements and implementation
9014
9183
 
9015
- - Load `.bmad-core/core-config.yaml` from the project root
9016
- - If the file does not exist, HALT and inform the user: "core-config.yaml not found. This file is required for story creation. You can either: 1) Copy it from GITHUB bmad-core/core-config.yaml and configure it for your project OR 2) Run the BMad installer against your project to upgrade and add the file automatically. Please add and configure core-config.yaml before proceeding."
9017
- - Extract key configurations: `devStoryLocation`, `prd.*`, `architecture.*`, `workflow.*`
9184
+ ## Gate File Location
9018
9185
 
9019
- ### 1. Identify Next Story for Preparation
9186
+ **ALWAYS** create file at: `docs/qa/gates/{epic}.{story}-{slug}.yml`
9020
9187
 
9021
- #### 1.1 Locate Epic Files and Review Existing Stories
9188
+ Slug rules:
9022
9189
 
9023
- - Based on `prdSharded` from config, locate epic files (sharded location/pattern or monolithic PRD sections)
9024
- - If `devStoryLocation` has story files, load the highest `{epicNum}.{storyNum}.story.md` file
9025
- - **If highest story exists:**
9026
- - Verify status is 'Done'. If not, alert user: "ALERT: Found incomplete story! File: {lastEpicNum}.{lastStoryNum}.story.md Status: [current status] You should fix this story first, but would you like to accept risk & override to create the next story in draft?"
9027
- - If proceeding, select next sequential story in the current epic
9028
- - If epic is complete, prompt user: "Epic {epicNum} Complete: All stories in Epic {epicNum} have been completed. Would you like to: 1) Begin Epic {epicNum + 1} with story 1 2) Select a specific story to work on 3) Cancel story creation"
9029
- - **CRITICAL**: NEVER automatically skip to another epic. User MUST explicitly instruct which story to create.
9030
- - **If no story files exist:** The next story is ALWAYS 1.1 (first story of first epic)
9031
- - Announce the identified story to the user: "Identified next story for preparation: {epicNum}.{storyNum} - {Story Title}"
9190
+ - Convert to lowercase
9191
+ - Replace spaces with hyphens
9192
+ - Strip punctuation
9193
+ - Example: "User Auth - Login!" becomes "user-auth-login"
9032
9194
 
9033
- ### 2. Gather Story Requirements and Previous Story Context
9195
+ ## Minimal Required Schema
9034
9196
 
9035
- - Extract story requirements from the identified epic file
9036
- - If previous story exists, review Dev Agent Record sections for:
9037
- - Completion Notes and Debug Log References
9038
- - Implementation deviations and technical decisions
9039
- - Challenges encountered and lessons learned
9040
- - Extract relevant insights that inform the current story's preparation
9197
+ ```yaml
9198
+ schema: 1
9199
+ story: "{epic}.{story}"
9200
+ gate: PASS|CONCERNS|FAIL|WAIVED
9201
+ status_reason: "1-2 sentence explanation of gate decision"
9202
+ reviewer: "Quinn"
9203
+ updated: "{ISO-8601 timestamp}"
9204
+ top_issues: [] # Empty array if no issues
9205
+ waiver: { active: false } # Only set active: true if WAIVED
9206
+ ```
9041
9207
 
9042
- ### 3. Gather Architecture Context
9208
+ ## Schema with Issues
9043
9209
 
9044
- #### 3.1 Determine Architecture Reading Strategy
9210
+ ```yaml
9211
+ schema: 1
9212
+ story: "1.3"
9213
+ gate: CONCERNS
9214
+ status_reason: "Missing rate limiting on auth endpoints poses security risk."
9215
+ reviewer: "Quinn"
9216
+ updated: "2025-01-12T10:15:00Z"
9217
+ top_issues:
9218
+ - id: "SEC-001"
9219
+ severity: high # ONLY: low|medium|high
9220
+ finding: "No rate limiting on login endpoint"
9221
+ suggested_action: "Add rate limiting middleware before production"
9222
+ - id: "TEST-001"
9223
+ severity: medium
9224
+ finding: "No integration tests for auth flow"
9225
+ suggested_action: "Add integration test coverage"
9226
+ waiver: { active: false }
9227
+ ```
9045
9228
 
9046
- - **If `architectureVersion: >= v4` and `architectureSharded: true`**: Read `{architectureShardedLocation}/index.md` then follow structured reading order below
9047
- - **Else**: Use monolithic `architectureFile` for similar sections
9229
+ ## Schema when Waived
9048
9230
 
9049
- #### 3.2 Read Architecture Documents Based on Story Type
9231
+ ```yaml
9232
+ schema: 1
9233
+ story: "1.3"
9234
+ gate: WAIVED
9235
+ status_reason: "Known issues accepted for MVP release."
9236
+ reviewer: "Quinn"
9237
+ updated: "2025-01-12T10:15:00Z"
9238
+ top_issues:
9239
+ - id: "PERF-001"
9240
+ severity: low
9241
+ finding: "Dashboard loads slowly with 1000+ items"
9242
+ suggested_action: "Implement pagination in next sprint"
9243
+ waiver:
9244
+ active: true
9245
+ reason: "MVP release - performance optimization deferred"
9246
+ approved_by: "Product Owner"
9247
+ ```
9050
9248
 
9051
- **For ALL Stories:** tech-stack.md, unified-project-structure.md, coding-standards.md, testing-strategy.md
9249
+ ## Gate Decision Criteria
9052
9250
 
9053
- **For Backend/API Stories, additionally:** data-models.md, database-schema.md, backend-architecture.md, rest-api-spec.md, external-apis.md
9251
+ ### PASS
9054
9252
 
9055
- **For Frontend/UI Stories, additionally:** frontend-architecture.md, components.md, core-workflows.md, data-models.md
9253
+ - All acceptance criteria met
9254
+ - No high-severity issues
9255
+ - Test coverage meets project standards
9056
9256
 
9057
- **For Full-Stack Stories:** Read both Backend and Frontend sections above
9257
+ ### CONCERNS
9058
9258
 
9059
- #### 3.3 Extract Story-Specific Technical Details
9259
+ - Non-blocking issues present
9260
+ - Should be tracked and scheduled
9261
+ - Can proceed with awareness
9060
9262
 
9061
- Extract ONLY information directly relevant to implementing the current story. Do NOT invent new libraries, patterns, or standards not in the source documents.
9263
+ ### FAIL
9062
9264
 
9063
- Extract:
9265
+ - Acceptance criteria not met
9266
+ - High-severity issues present
9267
+ - Recommend return to InProgress
9064
9268
 
9065
- - Specific data models, schemas, or structures the story will use
9066
- - API endpoints the story must implement or consume
9067
- - Component specifications for UI elements in the story
9068
- - File paths and naming conventions for new code
9069
- - Testing requirements specific to the story's features
9070
- - Security or performance considerations affecting the story
9269
+ ### WAIVED
9071
9270
 
9072
- ALWAYS cite source documents: `[Source: architecture/{filename}.md#{section}]`
9271
+ - Issues explicitly accepted
9272
+ - Requires approval and reason
9273
+ - Proceed despite known issues
9073
9274
 
9074
- ### 4. Verify Project Structure Alignment
9275
+ ## Severity Scale
9075
9276
 
9076
- - Cross-reference story requirements with Project Structure Guide from `docs/architecture/unified-project-structure.md`
9077
- - Ensure file paths, component locations, or module names align with defined structures
9078
- - Document any structural conflicts in "Project Structure Notes" section within the story draft
9277
+ **FIXED VALUES - NO VARIATIONS:**
9079
9278
 
9080
- ### 5. Populate Story Template with Full Context
9279
+ - `low`: Minor issues, cosmetic problems
9280
+ - `medium`: Should fix soon, not blocking
9281
+ - `high`: Critical issues, should block release
9081
9282
 
9082
- - Create new story file: `{devStoryLocation}/{epicNum}.{storyNum}.story.md` using Story Template
9083
- - Fill in basic story information: Title, Status (Draft), Story statement, Acceptance Criteria from Epic
9084
- - **`Dev Notes` section (CRITICAL):**
9085
- - CRITICAL: This section MUST contain ONLY information extracted from architecture documents. NEVER invent or assume technical details.
9086
- - Include ALL relevant technical details from Steps 2-3, organized by category:
9087
- - **Previous Story Insights**: Key learnings from previous story
9088
- - **Data Models**: Specific schemas, validation rules, relationships [with source references]
9089
- - **API Specifications**: Endpoint details, request/response formats, auth requirements [with source references]
9090
- - **Component Specifications**: UI component details, props, state management [with source references]
9091
- - **File Locations**: Exact paths where new code should be created based on project structure
9092
- - **Testing Requirements**: Specific test cases or strategies from testing-strategy.md
9093
- - **Technical Constraints**: Version requirements, performance considerations, security rules
9094
- - Every technical detail MUST include its source reference: `[Source: architecture/{filename}.md#{section}]`
9095
- - If information for a category is not found in the architecture docs, explicitly state: "No specific guidance found in architecture docs"
9096
- - **`Tasks / Subtasks` section:**
9097
- - Generate detailed, sequential list of technical tasks based ONLY on: Epic Requirements, Story AC, Reviewed Architecture Information
9098
- - Each task must reference relevant architecture documentation
9099
- - Include unit testing as explicit subtasks based on the Testing Strategy
9100
- - Link tasks to ACs where applicable (e.g., `Task 1 (AC: 1, 3)`)
9101
- - Add notes on project structure alignment or discrepancies found in Step 4
9283
+ ## Issue ID Prefixes
9102
9284
 
9103
- ### 6. Story Draft Completion and Review
9285
+ - `SEC-`: Security issues
9286
+ - `PERF-`: Performance issues
9287
+ - `REL-`: Reliability issues
9288
+ - `TEST-`: Testing gaps
9289
+ - `MNT-`: Maintainability concerns
9290
+ - `ARCH-`: Architecture issues
9291
+ - `DOC-`: Documentation gaps
9292
+ - `REQ-`: Requirements issues
9104
9293
 
9105
- - Review all sections for completeness and accuracy
9106
- - Verify all source references are included for technical details
9107
- - Ensure tasks align with both epic requirements and architecture constraints
9108
- - Update status to "Draft" and save the story file
9109
- - Execute `.bmad-core/tasks/execute-checklist` `.bmad-core/checklists/story-draft-checklist`
9110
- - Provide summary to user including:
9111
- - Story created: `{devStoryLocation}/{epicNum}.{storyNum}.story.md`
9112
- - Status: Draft
9113
- - Key technical components included from architecture docs
9114
- - Any deviations or conflicts noted between epic and architecture
9115
- - Checklist Results
9116
- - Next steps: For Complex stories, suggest the user carefully review the story draft and also optionally have the PO run the task `.bmad-core/tasks/validate-next-story`
9117
- ==================== END: .bmad-core/tasks/create-next-story.md ====================
9294
+ ## Output Requirements
9118
9295
 
9119
- ==================== START: .bmad-core/checklists/story-draft-checklist.md ====================
9120
- # Story Draft Checklist
9296
+ 1. **ALWAYS** create gate file at: `docs/qa/gates/{epic}.{story}-{slug}.yml`
9297
+ 2. **ALWAYS** append this exact format to story's QA Results section:
9298
+ ```
9299
+ Gate: {STATUS} → docs/qa/gates/{epic}.{story}-{slug}.yml
9300
+ ```
9301
+ 3. Keep status_reason to 1-2 sentences maximum
9302
+ 4. Use severity values exactly: `low`, `medium`, or `high`
9121
9303
 
9122
- The Scrum Master should use this checklist to validate that each story contains sufficient context for a developer agent to implement it successfully, while assuming the dev agent has reasonable capabilities to figure things out.
9304
+ ## Example Story Update
9123
9305
 
9124
- [[LLM: INITIALIZATION INSTRUCTIONS - STORY DRAFT VALIDATION
9306
+ After creating gate file, append to story's QA Results section:
9125
9307
 
9126
- Before proceeding with this checklist, ensure you have access to:
9308
+ ```markdown
9309
+ ## QA Results
9127
9310
 
9128
- 1. The story document being validated (usually in docs/stories/ or provided directly)
9129
- 2. The parent epic context
9130
- 3. Any referenced architecture or design documents
9131
- 4. Previous related stories if this builds on prior work
9311
+ ### Review Date: 2025-01-12
9132
9312
 
9133
- IMPORTANT: This checklist validates individual stories BEFORE implementation begins.
9313
+ ### Reviewed By: Quinn (Test Architect)
9134
9314
 
9135
- VALIDATION PRINCIPLES:
9315
+ [... existing review content ...]
9136
9316
 
9137
- 1. Clarity - A developer should understand WHAT to build
9138
- 2. Context - WHY this is being built and how it fits
9139
- 3. Guidance - Key technical decisions and patterns to follow
9140
- 4. Testability - How to verify the implementation works
9141
- 5. Self-Contained - Most info needed is in the story itself
9317
+ ### Gate Status
9142
9318
 
9143
- REMEMBER: We assume competent developer agents who can:
9319
+ Gate: CONCERNS docs/qa/gates/1.3-user-auth-login.yml
9320
+ ```
9144
9321
 
9145
- - Research documentation and codebases
9322
+ ## Key Principles
9323
+
9324
+ - Keep it minimal and predictable
9325
+ - Fixed severity scale (low/medium/high)
9326
+ - Always write to standard path
9327
+ - Always update story with gate reference
9328
+ - Clear, actionable findings
9329
+ ==================== END: .bmad-core/tasks/qa-gate.md ====================
9330
+
9331
+ ==================== START: .bmad-core/tasks/trace-requirements.md ====================
9332
+ # trace-requirements
9333
+
9334
+ Map story requirements to test cases using Given-When-Then patterns for comprehensive traceability.
9335
+
9336
+ ## Purpose
9337
+
9338
+ Create a requirements traceability matrix that ensures every acceptance criterion has corresponding test coverage. This task helps identify gaps in testing and ensures all requirements are validated.
9339
+
9340
+ **IMPORTANT**: Given-When-Then is used here for documenting the mapping between requirements and tests, NOT for writing the actual test code. Tests should follow your project's testing standards (no BDD syntax in test code).
9341
+
9342
+ ## Prerequisites
9343
+
9344
+ - Story file with clear acceptance criteria
9345
+ - Access to test files or test specifications
9346
+ - Understanding of the implementation
9347
+
9348
+ ## Traceability Process
9349
+
9350
+ ### 1. Extract Requirements
9351
+
9352
+ Identify all testable requirements from:
9353
+
9354
+ - Acceptance Criteria (primary source)
9355
+ - User story statement
9356
+ - Tasks/subtasks with specific behaviors
9357
+ - Non-functional requirements mentioned
9358
+ - Edge cases documented
9359
+
9360
+ ### 2. Map to Test Cases
9361
+
9362
+ For each requirement, document which tests validate it. Use Given-When-Then to describe what the test validates (not how it's written):
9363
+
9364
+ ```yaml
9365
+ requirement: "AC1: User can login with valid credentials"
9366
+ test_mappings:
9367
+ - test_file: "auth/login.test.ts"
9368
+ test_case: "should successfully login with valid email and password"
9369
+ # Given-When-Then describes WHAT the test validates, not HOW it's coded
9370
+ given: "A registered user with valid credentials"
9371
+ when: "They submit the login form"
9372
+ then: "They are redirected to dashboard and session is created"
9373
+ coverage: full
9374
+
9375
+ - test_file: "e2e/auth-flow.test.ts"
9376
+ test_case: "complete login flow"
9377
+ given: "User on login page"
9378
+ when: "Entering valid credentials and submitting"
9379
+ then: "Dashboard loads with user data"
9380
+ coverage: integration
9381
+ ```
9382
+
9383
+ ### 3. Coverage Analysis
9384
+
9385
+ Evaluate coverage for each requirement:
9386
+
9387
+ **Coverage Levels:**
9388
+
9389
+ - `full`: Requirement completely tested
9390
+ - `partial`: Some aspects tested, gaps exist
9391
+ - `none`: No test coverage found
9392
+ - `integration`: Covered in integration/e2e tests only
9393
+ - `unit`: Covered in unit tests only
9394
+
9395
+ ### 4. Gap Identification
9396
+
9397
+ Document any gaps found:
9398
+
9399
+ ```yaml
9400
+ coverage_gaps:
9401
+ - requirement: "AC3: Password reset email sent within 60 seconds"
9402
+ gap: "No test for email delivery timing"
9403
+ severity: medium
9404
+ suggested_test:
9405
+ type: integration
9406
+ description: "Test email service SLA compliance"
9407
+
9408
+ - requirement: "AC5: Support 1000 concurrent users"
9409
+ gap: "No load testing implemented"
9410
+ severity: high
9411
+ suggested_test:
9412
+ type: performance
9413
+ description: "Load test with 1000 concurrent connections"
9414
+ ```
9415
+
9416
+ ## Outputs
9417
+
9418
+ ### Output 1: Gate YAML Block
9419
+
9420
+ **Generate for pasting into gate file under `trace`:**
9421
+
9422
+ ```yaml
9423
+ trace:
9424
+ totals:
9425
+ requirements: X
9426
+ full: Y
9427
+ partial: Z
9428
+ none: W
9429
+ planning_ref: "docs/qa/assessments/{epic}.{story}-test-design-{YYYYMMDD}.md"
9430
+ uncovered:
9431
+ - ac: "AC3"
9432
+ reason: "No test found for password reset timing"
9433
+ notes: "See docs/qa/assessments/{epic}.{story}-trace-{YYYYMMDD}.md"
9434
+ ```
9435
+
9436
+ ### Output 2: Traceability Report
9437
+
9438
+ **Save to:** `docs/qa/assessments/{epic}.{story}-trace-{YYYYMMDD}.md`
9439
+
9440
+ Create a traceability report with:
9441
+
9442
+ ```markdown
9443
+ # Requirements Traceability Matrix
9444
+
9445
+ ## Story: {epic}.{story} - {title}
9446
+
9447
+ ### Coverage Summary
9448
+
9449
+ - Total Requirements: X
9450
+ - Fully Covered: Y (Z%)
9451
+ - Partially Covered: A (B%)
9452
+ - Not Covered: C (D%)
9453
+
9454
+ ### Requirement Mappings
9455
+
9456
+ #### AC1: {Acceptance Criterion 1}
9457
+
9458
+ **Coverage: FULL**
9459
+
9460
+ Given-When-Then Mappings:
9461
+
9462
+ - **Unit Test**: `auth.service.test.ts::validateCredentials`
9463
+ - Given: Valid user credentials
9464
+ - When: Validation method called
9465
+ - Then: Returns true with user object
9466
+
9467
+ - **Integration Test**: `auth.integration.test.ts::loginFlow`
9468
+ - Given: User with valid account
9469
+ - When: Login API called
9470
+ - Then: JWT token returned and session created
9471
+
9472
+ #### AC2: {Acceptance Criterion 2}
9473
+
9474
+ **Coverage: PARTIAL**
9475
+
9476
+ [Continue for all ACs...]
9477
+
9478
+ ### Critical Gaps
9479
+
9480
+ 1. **Performance Requirements**
9481
+ - Gap: No load testing for concurrent users
9482
+ - Risk: High - Could fail under production load
9483
+ - Action: Implement load tests using k6 or similar
9484
+
9485
+ 2. **Security Requirements**
9486
+ - Gap: Rate limiting not tested
9487
+ - Risk: Medium - Potential DoS vulnerability
9488
+ - Action: Add rate limit tests to integration suite
9489
+
9490
+ ### Test Design Recommendations
9491
+
9492
+ Based on gaps identified, recommend:
9493
+
9494
+ 1. Additional test scenarios needed
9495
+ 2. Test types to implement (unit/integration/e2e/performance)
9496
+ 3. Test data requirements
9497
+ 4. Mock/stub strategies
9498
+
9499
+ ### Risk Assessment
9500
+
9501
+ - **High Risk**: Requirements with no coverage
9502
+ - **Medium Risk**: Requirements with only partial coverage
9503
+ - **Low Risk**: Requirements with full unit + integration coverage
9504
+ ```
9505
+
9506
+ ## Traceability Best Practices
9507
+
9508
+ ### Given-When-Then for Mapping (Not Test Code)
9509
+
9510
+ Use Given-When-Then to document what each test validates:
9511
+
9512
+ **Given**: The initial context the test sets up
9513
+
9514
+ - What state/data the test prepares
9515
+ - User context being simulated
9516
+ - System preconditions
9517
+
9518
+ **When**: The action the test performs
9519
+
9520
+ - What the test executes
9521
+ - API calls or user actions tested
9522
+ - Events triggered
9523
+
9524
+ **Then**: What the test asserts
9525
+
9526
+ - Expected outcomes verified
9527
+ - State changes checked
9528
+ - Values validated
9529
+
9530
+ **Note**: This is for documentation only. Actual test code follows your project's standards (e.g., describe/it blocks, no BDD syntax).
9531
+
9532
+ ### Coverage Priority
9533
+
9534
+ Prioritize coverage based on:
9535
+
9536
+ 1. Critical business flows
9537
+ 2. Security-related requirements
9538
+ 3. Data integrity requirements
9539
+ 4. User-facing features
9540
+ 5. Performance SLAs
9541
+
9542
+ ### Test Granularity
9543
+
9544
+ Map at appropriate levels:
9545
+
9546
+ - Unit tests for business logic
9547
+ - Integration tests for component interaction
9548
+ - E2E tests for user journeys
9549
+ - Performance tests for NFRs
9550
+
9551
+ ## Quality Indicators
9552
+
9553
+ Good traceability shows:
9554
+
9555
+ - Every AC has at least one test
9556
+ - Critical paths have multiple test levels
9557
+ - Edge cases are explicitly covered
9558
+ - NFRs have appropriate test types
9559
+ - Clear Given-When-Then for each test
9560
+
9561
+ ## Red Flags
9562
+
9563
+ Watch for:
9564
+
9565
+ - ACs with no test coverage
9566
+ - Tests that don't map to requirements
9567
+ - Vague test descriptions
9568
+ - Missing edge case coverage
9569
+ - NFRs without specific tests
9570
+
9571
+ ## Integration with Gates
9572
+
9573
+ This traceability feeds into quality gates:
9574
+
9575
+ - Critical gaps → FAIL
9576
+ - Minor gaps → CONCERNS
9577
+ - Missing P0 tests from test-design → CONCERNS
9578
+
9579
+ ### Output 3: Story Hook Line
9580
+
9581
+ **Print this line for review task to quote:**
9582
+
9583
+ ```text
9584
+ Trace matrix: docs/qa/assessments/{epic}.{story}-trace-{YYYYMMDD}.md
9585
+ ```
9586
+
9587
+ - Full coverage → PASS contribution
9588
+
9589
+ ## Key Principles
9590
+
9591
+ - Every requirement must be testable
9592
+ - Use Given-When-Then for clarity
9593
+ - Identify both presence and absence
9594
+ - Prioritize based on risk
9595
+ - Make recommendations actionable
9596
+ ==================== END: .bmad-core/tasks/trace-requirements.md ====================
9597
+
9598
+ ==================== START: .bmad-core/tasks/risk-profile.md ====================
9599
+ # risk-profile
9600
+
9601
+ Generate a comprehensive risk assessment matrix for a story implementation using probability × impact analysis.
9602
+
9603
+ ## Inputs
9604
+
9605
+ ```yaml
9606
+ required:
9607
+ - story_id: "{epic}.{story}" # e.g., "1.3"
9608
+ - story_path: "docs/stories/{epic}.{story}.*.md"
9609
+ - story_title: "{title}" # If missing, derive from story file H1
9610
+ - story_slug: "{slug}" # If missing, derive from title (lowercase, hyphenated)
9611
+ ```
9612
+
9613
+ ## Purpose
9614
+
9615
+ Identify, assess, and prioritize risks in the story implementation. Provide risk mitigation strategies and testing focus areas based on risk levels.
9616
+
9617
+ ## Risk Assessment Framework
9618
+
9619
+ ### Risk Categories
9620
+
9621
+ **Category Prefixes:**
9622
+
9623
+ - `TECH`: Technical Risks
9624
+ - `SEC`: Security Risks
9625
+ - `PERF`: Performance Risks
9626
+ - `DATA`: Data Risks
9627
+ - `BUS`: Business Risks
9628
+ - `OPS`: Operational Risks
9629
+
9630
+ 1. **Technical Risks (TECH)**
9631
+ - Architecture complexity
9632
+ - Integration challenges
9633
+ - Technical debt
9634
+ - Scalability concerns
9635
+ - System dependencies
9636
+
9637
+ 2. **Security Risks (SEC)**
9638
+ - Authentication/authorization flaws
9639
+ - Data exposure vulnerabilities
9640
+ - Injection attacks
9641
+ - Session management issues
9642
+ - Cryptographic weaknesses
9643
+
9644
+ 3. **Performance Risks (PERF)**
9645
+ - Response time degradation
9646
+ - Throughput bottlenecks
9647
+ - Resource exhaustion
9648
+ - Database query optimization
9649
+ - Caching failures
9650
+
9651
+ 4. **Data Risks (DATA)**
9652
+ - Data loss potential
9653
+ - Data corruption
9654
+ - Privacy violations
9655
+ - Compliance issues
9656
+ - Backup/recovery gaps
9657
+
9658
+ 5. **Business Risks (BUS)**
9659
+ - Feature doesn't meet user needs
9660
+ - Revenue impact
9661
+ - Reputation damage
9662
+ - Regulatory non-compliance
9663
+ - Market timing
9664
+
9665
+ 6. **Operational Risks (OPS)**
9666
+ - Deployment failures
9667
+ - Monitoring gaps
9668
+ - Incident response readiness
9669
+ - Documentation inadequacy
9670
+ - Knowledge transfer issues
9671
+
9672
+ ## Risk Analysis Process
9673
+
9674
+ ### 1. Risk Identification
9675
+
9676
+ For each category, identify specific risks:
9677
+
9678
+ ```yaml
9679
+ risk:
9680
+ id: "SEC-001" # Use prefixes: SEC, PERF, DATA, BUS, OPS, TECH
9681
+ category: security
9682
+ title: "Insufficient input validation on user forms"
9683
+ description: "Form inputs not properly sanitized could lead to XSS attacks"
9684
+ affected_components:
9685
+ - "UserRegistrationForm"
9686
+ - "ProfileUpdateForm"
9687
+ detection_method: "Code review revealed missing validation"
9688
+ ```
9689
+
9690
+ ### 2. Risk Assessment
9691
+
9692
+ Evaluate each risk using probability × impact:
9693
+
9694
+ **Probability Levels:**
9695
+
9696
+ - `High (3)`: Likely to occur (>70% chance)
9697
+ - `Medium (2)`: Possible occurrence (30-70% chance)
9698
+ - `Low (1)`: Unlikely to occur (<30% chance)
9699
+
9700
+ **Impact Levels:**
9701
+
9702
+ - `High (3)`: Severe consequences (data breach, system down, major financial loss)
9703
+ - `Medium (2)`: Moderate consequences (degraded performance, minor data issues)
9704
+ - `Low (1)`: Minor consequences (cosmetic issues, slight inconvenience)
9705
+
9706
+ **Risk Score = Probability × Impact**
9707
+
9708
+ - 9: Critical Risk (Red)
9709
+ - 6: High Risk (Orange)
9710
+ - 4: Medium Risk (Yellow)
9711
+ - 2-3: Low Risk (Green)
9712
+ - 1: Minimal Risk (Blue)
9713
+
9714
+ ### 3. Risk Prioritization
9715
+
9716
+ Create risk matrix:
9717
+
9718
+ ```markdown
9719
+ ## Risk Matrix
9720
+
9721
+ | Risk ID | Description | Probability | Impact | Score | Priority |
9722
+ | -------- | ----------------------- | ----------- | ---------- | ----- | -------- |
9723
+ | SEC-001 | XSS vulnerability | High (3) | High (3) | 9 | Critical |
9724
+ | PERF-001 | Slow query on dashboard | Medium (2) | Medium (2) | 4 | Medium |
9725
+ | DATA-001 | Backup failure | Low (1) | High (3) | 3 | Low |
9726
+ ```
9727
+
9728
+ ### 4. Risk Mitigation Strategies
9729
+
9730
+ For each identified risk, provide mitigation:
9731
+
9732
+ ```yaml
9733
+ mitigation:
9734
+ risk_id: "SEC-001"
9735
+ strategy: "preventive" # preventive|detective|corrective
9736
+ actions:
9737
+ - "Implement input validation library (e.g., validator.js)"
9738
+ - "Add CSP headers to prevent XSS execution"
9739
+ - "Sanitize all user inputs before storage"
9740
+ - "Escape all outputs in templates"
9741
+ testing_requirements:
9742
+ - "Security testing with OWASP ZAP"
9743
+ - "Manual penetration testing of forms"
9744
+ - "Unit tests for validation functions"
9745
+ residual_risk: "Low - Some zero-day vulnerabilities may remain"
9746
+ owner: "dev"
9747
+ timeline: "Before deployment"
9748
+ ```
9749
+
9750
+ ## Outputs
9751
+
9752
+ ### Output 1: Gate YAML Block
9753
+
9754
+ Generate for pasting into gate file under `risk_summary`:
9755
+
9756
+ **Output rules:**
9757
+
9758
+ - Only include assessed risks; do not emit placeholders
9759
+ - Sort risks by score (desc) when emitting highest and any tabular lists
9760
+ - If no risks: totals all zeros, omit highest, keep recommendations arrays empty
9761
+
9762
+ ```yaml
9763
+ # risk_summary (paste into gate file):
9764
+ risk_summary:
9765
+ totals:
9766
+ critical: X # score 9
9767
+ high: Y # score 6
9768
+ medium: Z # score 4
9769
+ low: W # score 2-3
9770
+ highest:
9771
+ id: SEC-001
9772
+ score: 9
9773
+ title: "XSS on profile form"
9774
+ recommendations:
9775
+ must_fix:
9776
+ - "Add input sanitization & CSP"
9777
+ monitor:
9778
+ - "Add security alerts for auth endpoints"
9779
+ ```
9780
+
9781
+ ### Output 2: Markdown Report
9782
+
9783
+ **Save to:** `docs/qa/assessments/{epic}.{story}-risk-{YYYYMMDD}.md`
9784
+
9785
+ ```markdown
9786
+ # Risk Profile: Story {epic}.{story}
9787
+
9788
+ Date: {date}
9789
+ Reviewer: Quinn (Test Architect)
9790
+
9791
+ ## Executive Summary
9792
+
9793
+ - Total Risks Identified: X
9794
+ - Critical Risks: Y
9795
+ - High Risks: Z
9796
+ - Risk Score: XX/100 (calculated)
9797
+
9798
+ ## Critical Risks Requiring Immediate Attention
9799
+
9800
+ ### 1. [ID]: Risk Title
9801
+
9802
+ **Score: 9 (Critical)**
9803
+ **Probability**: High - Detailed reasoning
9804
+ **Impact**: High - Potential consequences
9805
+ **Mitigation**:
9806
+
9807
+ - Immediate action required
9808
+ - Specific steps to take
9809
+ **Testing Focus**: Specific test scenarios needed
9810
+
9811
+ ## Risk Distribution
9812
+
9813
+ ### By Category
9814
+
9815
+ - Security: X risks (Y critical)
9816
+ - Performance: X risks (Y critical)
9817
+ - Data: X risks (Y critical)
9818
+ - Business: X risks (Y critical)
9819
+ - Operational: X risks (Y critical)
9820
+
9821
+ ### By Component
9822
+
9823
+ - Frontend: X risks
9824
+ - Backend: X risks
9825
+ - Database: X risks
9826
+ - Infrastructure: X risks
9827
+
9828
+ ## Detailed Risk Register
9829
+
9830
+ [Full table of all risks with scores and mitigations]
9831
+
9832
+ ## Risk-Based Testing Strategy
9833
+
9834
+ ### Priority 1: Critical Risk Tests
9835
+
9836
+ - Test scenarios for critical risks
9837
+ - Required test types (security, load, chaos)
9838
+ - Test data requirements
9839
+
9840
+ ### Priority 2: High Risk Tests
9841
+
9842
+ - Integration test scenarios
9843
+ - Edge case coverage
9844
+
9845
+ ### Priority 3: Medium/Low Risk Tests
9846
+
9847
+ - Standard functional tests
9848
+ - Regression test suite
9849
+
9850
+ ## Risk Acceptance Criteria
9851
+
9852
+ ### Must Fix Before Production
9853
+
9854
+ - All critical risks (score 9)
9855
+ - High risks affecting security/data
9856
+
9857
+ ### Can Deploy with Mitigation
9858
+
9859
+ - Medium risks with compensating controls
9860
+ - Low risks with monitoring in place
9861
+
9862
+ ### Accepted Risks
9863
+
9864
+ - Document any risks team accepts
9865
+ - Include sign-off from appropriate authority
9866
+
9867
+ ## Monitoring Requirements
9868
+
9869
+ Post-deployment monitoring for:
9870
+
9871
+ - Performance metrics for PERF risks
9872
+ - Security alerts for SEC risks
9873
+ - Error rates for operational risks
9874
+ - Business KPIs for business risks
9875
+
9876
+ ## Risk Review Triggers
9877
+
9878
+ Review and update risk profile when:
9879
+
9880
+ - Architecture changes significantly
9881
+ - New integrations added
9882
+ - Security vulnerabilities discovered
9883
+ - Performance issues reported
9884
+ - Regulatory requirements change
9885
+ ```
9886
+
9887
+ ## Risk Scoring Algorithm
9888
+
9889
+ Calculate overall story risk score:
9890
+
9891
+ ```
9892
+ Base Score = 100
9893
+ For each risk:
9894
+ - Critical (9): Deduct 20 points
9895
+ - High (6): Deduct 10 points
9896
+ - Medium (4): Deduct 5 points
9897
+ - Low (2-3): Deduct 2 points
9898
+
9899
+ Minimum score = 0 (extremely risky)
9900
+ Maximum score = 100 (minimal risk)
9901
+ ```
9902
+
9903
+ ## Risk-Based Recommendations
9904
+
9905
+ Based on risk profile, recommend:
9906
+
9907
+ 1. **Testing Priority**
9908
+ - Which tests to run first
9909
+ - Additional test types needed
9910
+ - Test environment requirements
9911
+
9912
+ 2. **Development Focus**
9913
+ - Code review emphasis areas
9914
+ - Additional validation needed
9915
+ - Security controls to implement
9916
+
9917
+ 3. **Deployment Strategy**
9918
+ - Phased rollout for high-risk changes
9919
+ - Feature flags for risky features
9920
+ - Rollback procedures
9921
+
9922
+ 4. **Monitoring Setup**
9923
+ - Metrics to track
9924
+ - Alerts to configure
9925
+ - Dashboard requirements
9926
+
9927
+ ## Integration with Quality Gates
9928
+
9929
+ **Deterministic gate mapping:**
9930
+
9931
+ - Any risk with score ≥ 9 → Gate = FAIL (unless waived)
9932
+ - Else if any score ≥ 6 → Gate = CONCERNS
9933
+ - Else → Gate = PASS
9934
+ - Unmitigated risks → Document in gate
9935
+
9936
+ ### Output 3: Story Hook Line
9937
+
9938
+ **Print this line for review task to quote:**
9939
+
9940
+ ```
9941
+ Risk profile: docs/qa/assessments/{epic}.{story}-risk-{YYYYMMDD}.md
9942
+ ```
9943
+
9944
+ ## Key Principles
9945
+
9946
+ - Identify risks early and systematically
9947
+ - Use consistent probability × impact scoring
9948
+ - Provide actionable mitigation strategies
9949
+ - Link risks to specific test requirements
9950
+ - Track residual risk after mitigation
9951
+ - Update risk profile as story evolves
9952
+ ==================== END: .bmad-core/tasks/risk-profile.md ====================
9953
+
9954
+ ==================== START: .bmad-core/tasks/test-design.md ====================
9955
+ # test-design
9956
+
9957
+ Create comprehensive test scenarios with appropriate test level recommendations for story implementation.
9958
+
9959
+ ## Inputs
9960
+
9961
+ ```yaml
9962
+ required:
9963
+ - story_id: "{epic}.{story}" # e.g., "1.3"
9964
+ - story_path: "docs/stories/{epic}.{story}.*.md"
9965
+ - story_title: "{title}" # If missing, derive from story file H1
9966
+ - story_slug: "{slug}" # If missing, derive from title (lowercase, hyphenated)
9967
+ ```
9968
+
9969
+ ## Purpose
9970
+
9971
+ Design a complete test strategy that identifies what to test, at which level (unit/integration/e2e), and why. This ensures efficient test coverage without redundancy while maintaining appropriate test boundaries.
9972
+
9973
+ ## Test Level Decision Framework
9974
+
9975
+ ### Unit Tests
9976
+
9977
+ **When to use:**
9978
+
9979
+ - Testing pure functions and business logic
9980
+ - Algorithm correctness
9981
+ - Input validation and data transformation
9982
+ - Error handling in isolated components
9983
+ - Complex calculations or state machines
9984
+
9985
+ **Characteristics:**
9986
+
9987
+ - Fast execution (immediate feedback)
9988
+ - No external dependencies (DB, API, file system)
9989
+ - Highly maintainable and stable
9990
+ - Easy to debug failures
9991
+
9992
+ **Example scenarios:**
9993
+
9994
+ ```yaml
9995
+ unit_test:
9996
+ component: "PriceCalculator"
9997
+ scenario: "Calculate discount with multiple rules"
9998
+ justification: "Complex business logic with multiple branches"
9999
+ mock_requirements: "None - pure function"
10000
+ ```
10001
+
10002
+ ### Integration Tests
10003
+
10004
+ **When to use:**
10005
+
10006
+ - Testing component interactions
10007
+ - Database operations and queries
10008
+ - API endpoint behavior
10009
+ - Service layer orchestration
10010
+ - External service integration (with test doubles)
10011
+
10012
+ **Characteristics:**
10013
+
10014
+ - Moderate execution time
10015
+ - May use test databases or containers
10016
+ - Tests multiple components together
10017
+ - Validates contracts between components
10018
+
10019
+ **Example scenarios:**
10020
+
10021
+ ```yaml
10022
+ integration_test:
10023
+ components: ["UserService", "UserRepository", "Database"]
10024
+ scenario: "Create user with duplicate email check"
10025
+ justification: "Tests transaction boundaries and constraint handling"
10026
+ test_doubles: "Mock email service, real test database"
10027
+ ```
10028
+
10029
+ ### End-to-End Tests
10030
+
10031
+ **When to use:**
10032
+
10033
+ - Critical user journeys
10034
+ - Cross-system workflows
10035
+ - UI interaction flows
10036
+ - Full stack validation
10037
+ - Production-like scenario testing
10038
+
10039
+ **Characteristics:**
10040
+
10041
+ - Keep under 90 seconds per test
10042
+ - Tests complete user scenarios
10043
+ - Uses real or production-like environment
10044
+ - Higher maintenance cost
10045
+ - More prone to flakiness
10046
+
10047
+ **Example scenarios:**
10048
+
10049
+ ```yaml
10050
+ e2e_test:
10051
+ flow: "Complete purchase flow"
10052
+ scenario: "User browses, adds to cart, and completes checkout"
10053
+ justification: "Critical business flow requiring full stack validation"
10054
+ environment: "Staging with test payment gateway"
10055
+ ```
10056
+
10057
+ ## Test Design Process
10058
+
10059
+ ### 1. Analyze Story Requirements
10060
+
10061
+ Break down each acceptance criterion into testable scenarios:
10062
+
10063
+ ```yaml
10064
+ acceptance_criterion: "User can reset password via email"
10065
+ test_scenarios:
10066
+ - level: unit
10067
+ what: "Password validation rules"
10068
+ why: "Complex regex and business rules"
10069
+
10070
+ - level: integration
10071
+ what: "Password reset token generation and storage"
10072
+ why: "Database interaction with expiry logic"
10073
+
10074
+ - level: integration
10075
+ what: "Email service integration"
10076
+ why: "External service with retry logic"
10077
+
10078
+ - level: e2e
10079
+ what: "Complete password reset flow"
10080
+ why: "Critical security flow needing full validation"
10081
+ ```
10082
+
10083
+ ### 2. Apply Test Level Heuristics
10084
+
10085
+ Use these rules to determine appropriate test levels:
10086
+
10087
+ ```markdown
10088
+ ## Test Level Selection Rules
10089
+
10090
+ ### Favor Unit Tests When:
10091
+
10092
+ - Logic can be isolated
10093
+ - No side effects involved
10094
+ - Fast feedback needed
10095
+ - High cyclomatic complexity
10096
+
10097
+ ### Favor Integration Tests When:
10098
+
10099
+ - Testing persistence layer
10100
+ - Validating service contracts
10101
+ - Testing middleware/interceptors
10102
+ - Component boundaries critical
10103
+
10104
+ ### Favor E2E Tests When:
10105
+
10106
+ - User-facing critical paths
10107
+ - Multi-system interactions
10108
+ - Regulatory compliance scenarios
10109
+ - Visual regression important
10110
+
10111
+ ### Anti-patterns to Avoid:
10112
+
10113
+ - E2E testing for business logic validation
10114
+ - Unit testing framework behavior
10115
+ - Integration testing third-party libraries
10116
+ - Duplicate coverage across levels
10117
+
10118
+ ### Duplicate Coverage Guard
10119
+
10120
+ **Before adding any test, check:**
10121
+
10122
+ 1. Is this already tested at a lower level?
10123
+ 2. Can a unit test cover this instead of integration?
10124
+ 3. Can an integration test cover this instead of E2E?
10125
+
10126
+ **Coverage overlap is only acceptable when:**
10127
+
10128
+ - Testing different aspects (unit: logic, integration: interaction, e2e: user experience)
10129
+ - Critical paths requiring defense in depth
10130
+ - Regression prevention for previously broken functionality
10131
+ ```
10132
+
10133
+ ### 3. Design Test Scenarios
10134
+
10135
+ **Test ID Format:** `{EPIC}.{STORY}-{LEVEL}-{SEQ}`
10136
+
10137
+ - Example: `1.3-UNIT-001`, `1.3-INT-002`, `1.3-E2E-001`
10138
+ - Ensures traceability across all artifacts
10139
+
10140
+ **Naming Convention:**
10141
+
10142
+ - Unit: `test_{component}_{scenario}`
10143
+ - Integration: `test_{flow}_{interaction}`
10144
+ - E2E: `test_{journey}_{outcome}`
10145
+
10146
+ **Risk Linkage:**
10147
+
10148
+ - Tag tests with risk IDs they mitigate
10149
+ - Prioritize tests for high-risk areas (P0)
10150
+ - Link to risk profile when available
10151
+
10152
+ For each identified test need:
10153
+
10154
+ ```yaml
10155
+ test_scenario:
10156
+ id: "1.3-INT-002"
10157
+ requirement: "AC2: Rate limiting on login attempts"
10158
+ mitigates_risks: ["SEC-001", "PERF-003"] # Links to risk profile
10159
+ priority: P0 # Based on risk score
10160
+
10161
+ unit_tests:
10162
+ - name: "RateLimiter calculates window correctly"
10163
+ input: "Timestamp array"
10164
+ expected: "Correct window calculation"
10165
+
10166
+ integration_tests:
10167
+ - name: "Login endpoint enforces rate limit"
10168
+ setup: "5 failed attempts"
10169
+ action: "6th attempt"
10170
+ expected: "429 response with retry-after header"
10171
+
10172
+ e2e_tests:
10173
+ - name: "User sees rate limit message"
10174
+ setup: "Trigger rate limit"
10175
+ validation: "Error message displayed, retry timer shown"
10176
+ ```
10177
+
10178
+ ## Deterministic Test Level Minimums
10179
+
10180
+ **Per Acceptance Criterion:**
10181
+
10182
+ - At least 1 unit test for business logic
10183
+ - At least 1 integration test if multiple components interact
10184
+ - At least 1 E2E test if it's a user-facing feature
10185
+
10186
+ **Exceptions:**
10187
+
10188
+ - Pure UI changes: May skip unit tests
10189
+ - Pure logic changes: May skip E2E tests
10190
+ - Infrastructure changes: May focus on integration tests
10191
+
10192
+ **When in doubt:** Start with unit tests, add integration for interactions, E2E for critical paths only.
10193
+
10194
+ ## Test Quality Standards
10195
+
10196
+ ### Core Testing Principles
10197
+
10198
+ **No Flaky Tests:** Ensure reliability through proper async handling, explicit waits, and atomic test design.
10199
+
10200
+ **No Hard Waits/Sleeps:** Use dynamic waiting strategies (e.g., polling, event-based triggers).
10201
+
10202
+ **Stateless & Parallel-Safe:** Tests run independently; use cron jobs or semaphores only if unavoidable.
10203
+
10204
+ **No Order Dependency:** Every it/describe/context block works in isolation (supports .only execution).
10205
+
10206
+ **Self-Cleaning Tests:** Test sets up its own data and automatically deletes/deactivates entities created during testing.
10207
+
10208
+ **Tests Live Near Source Code:** Co-locate test files with the code they validate (e.g., `*.spec.js` alongside components).
10209
+
10210
+ ### Execution Strategy
10211
+
10212
+ **Shifted Left:**
10213
+
10214
+ - Start with local environments or ephemeral stacks
10215
+ - Validate functionality across all deployment stages (local → dev → stage)
10216
+
10217
+ **Low Maintenance:** Minimize manual upkeep (avoid brittle selectors, do not repeat UI actions, leverage APIs).
10218
+
10219
+ **CI Execution Evidence:** Integrate into pipelines with clear logs/artifacts.
10220
+
10221
+ **Visibility:** Generate test reports (e.g., JUnit XML, HTML) for failures and trends.
10222
+
10223
+ ### Coverage Requirements
10224
+
10225
+ **Release Confidence:**
10226
+
10227
+ - Happy Path: Core user journeys are prioritized
10228
+ - Edge Cases: Critical error/validation scenarios are covered
10229
+ - Feature Flags: Test both enabled and disabled states where applicable
10230
+
10231
+ ### Test Design Rules
10232
+
10233
+ **Assertions:** Keep them explicit in tests; avoid abstraction into helpers. Use parametrized tests for soft assertions.
10234
+
10235
+ **Naming:** Follow conventions (e.g., `describe('Component')`, `it('should do X when Y')`).
10236
+
10237
+ **Size:** Aim for files ≤200 lines; split/chunk large tests logically.
10238
+
10239
+ **Speed:** Target individual tests ≤90 seconds; optimize slow setups (e.g., shared fixtures).
10240
+
10241
+ **Careful Abstractions:** Favor readability over DRY when balancing helper reuse (page objects are okay, assertion logic is not).
10242
+
10243
+ **Test Cleanup:** Ensure tests clean up resources they create (e.g., closing browser, deleting test data).
10244
+
10245
+ **Deterministic Flow:** Tests should refrain from using conditionals (e.g., if/else) to control flow or try/catch blocks where possible.
10246
+
10247
+ ### API Testing Standards
10248
+
10249
+ - Tests must not depend on hardcoded data → use factories and per-test setup
10250
+ - Always test both happy path and negative/error cases
10251
+ - API tests should run parallel safely (no global state shared)
10252
+ - Test idempotency where applicable (e.g., duplicate requests)
10253
+ - Tests should clean up their data
10254
+ - Response logs should only be printed in case of failure
10255
+ - Auth tests must validate token expiration and renewal
10256
+
10257
+ ## Outputs
10258
+
10259
+ ### Output 1: Test Design Document
10260
+
10261
+ **Save to:** `docs/qa/assessments/{epic}.{story}-test-design-{YYYYMMDD}.md`
10262
+
10263
+ Generate a comprehensive test design document:
10264
+
10265
+ ```markdown
10266
+ # Test Design: Story {epic}.{story}
10267
+
10268
+ Date: {date}
10269
+ Reviewer: Quinn (Test Architect)
10270
+
10271
+ ## Test Strategy Overview
10272
+
10273
+ - Total test scenarios: X
10274
+ - Unit tests: Y (A%)
10275
+ - Integration tests: Z (B%)
10276
+ - E2E tests: W (C%)
10277
+
10278
+ ## Test Level Rationale
10279
+
10280
+ [Explain why this distribution was chosen]
10281
+
10282
+ ## Detailed Test Scenarios
10283
+
10284
+ ### Requirement: AC1 - {description}
10285
+
10286
+ #### Unit Tests (3 scenarios)
10287
+
10288
+ 1. **ID**: 1.3-UNIT-001
10289
+ **Test**: Validate input format
10290
+ - **Why Unit**: Pure validation logic
10291
+ - **Coverage**: Input edge cases
10292
+ - **Mocks**: None needed
10293
+ - **Mitigates**: DATA-001 (if applicable)
10294
+
10295
+ #### Integration Tests (2 scenarios)
10296
+
10297
+ 1. **ID**: 1.3-INT-001
10298
+ **Test**: Service processes valid request
10299
+ - **Why Integration**: Multiple components involved
10300
+ - **Coverage**: Happy path + error handling
10301
+ - **Test Doubles**: Mock external API
10302
+ - **Mitigates**: TECH-002
10303
+
10304
+ #### E2E Tests (1 scenario)
10305
+
10306
+ 1. **ID**: 1.3-E2E-001
10307
+ **Test**: Complete user workflow
10308
+ - **Why E2E**: Critical user journey
10309
+ - **Coverage**: Full stack validation
10310
+ - **Environment**: Staging
10311
+ - **Max Duration**: 90 seconds
10312
+ - **Mitigates**: BUS-001
10313
+
10314
+ [Continue for all requirements...]
10315
+
10316
+ ## Test Data Requirements
10317
+
10318
+ ### Unit Test Data
10319
+
10320
+ - Static fixtures for calculations
10321
+ - Edge case values arrays
10322
+
10323
+ ### Integration Test Data
10324
+
10325
+ - Test database seeds
10326
+ - API response fixtures
10327
+
10328
+ ### E2E Test Data
10329
+
10330
+ - Test user accounts
10331
+ - Sandbox environment data
10332
+
10333
+ ## Mock/Stub Strategy
10334
+
10335
+ ### What to Mock
10336
+
10337
+ - External services (payment, email)
10338
+ - Time-dependent functions
10339
+ - Random number generators
10340
+
10341
+ ### What NOT to Mock
10342
+
10343
+ - Core business logic
10344
+ - Database in integration tests
10345
+ - Critical security functions
10346
+
10347
+ ## Test Execution Implementation
10348
+
10349
+ ### Parallel Execution
10350
+
10351
+ - All unit tests: Fully parallel (stateless requirement)
10352
+ - Integration tests: Parallel with isolated databases
10353
+ - E2E tests: Sequential or limited parallelism
10354
+
10355
+ ### Execution Order
10356
+
10357
+ 1. Unit tests first (fail fast)
10358
+ 2. Integration tests second
10359
+ 3. E2E tests last (expensive, max 90 seconds each)
10360
+
10361
+ ## Risk-Based Test Priority
10362
+
10363
+ ### P0 - Must Have (Linked to Critical/High Risks)
10364
+
10365
+ - Security-related tests (SEC-\* risks)
10366
+ - Data integrity tests (DATA-\* risks)
10367
+ - Critical business flow tests (BUS-\* risks)
10368
+ - Tests for risks scored ≥6 in risk profile
10369
+
10370
+ ### P1 - Should Have (Medium Risks)
10371
+
10372
+ - Edge case coverage
10373
+ - Performance tests (PERF-\* risks)
10374
+ - Error recovery tests
10375
+ - Tests for risks scored 4-5
10376
+
10377
+ ### P2 - Nice to Have (Low Risks)
10378
+
10379
+ - UI polish tests
10380
+ - Minor validation tests
10381
+ - Tests for risks scored ≤3
10382
+
10383
+ ## Test Maintenance Considerations
10384
+
10385
+ ### High Maintenance Tests
10386
+
10387
+ [List tests that may need frequent updates]
10388
+
10389
+ ### Stability Measures
10390
+
10391
+ - No retry strategies (tests must be deterministic)
10392
+ - Dynamic waits only (no hard sleeps)
10393
+ - Environment isolation
10394
+ - Self-cleaning test data
10395
+
10396
+ ## Coverage Goals
10397
+
10398
+ ### Unit Test Coverage
10399
+
10400
+ - Target: 80% line coverage
10401
+ - Focus: Business logic, calculations
10402
+
10403
+ ### Integration Coverage
10404
+
10405
+ - Target: All API endpoints
10406
+ - Focus: Contract validation
10407
+
10408
+ ### E2E Coverage
10409
+
10410
+ - Target: Critical paths only
10411
+ - Focus: User value delivery
10412
+ ```
10413
+
10414
+ ## Test Level Smells to Flag
10415
+
10416
+ ### Over-testing Smells
10417
+
10418
+ - Same logic tested at multiple levels
10419
+ - E2E tests for calculations
10420
+ - Integration tests for framework features
10421
+
10422
+ ### Under-testing Smells
10423
+
10424
+ - No unit tests for complex logic
10425
+ - Missing integration tests for data operations
10426
+ - No E2E tests for critical user paths
10427
+
10428
+ ### Wrong Level Smells
10429
+
10430
+ - Unit tests with real database
10431
+ - E2E tests checking calculation results
10432
+ - Integration tests mocking everything
10433
+
10434
+ ## Quality Indicators
10435
+
10436
+ Good test design shows:
10437
+
10438
+ - Clear level separation
10439
+ - No redundant coverage
10440
+ - Fast feedback from unit tests
10441
+ - Reliable integration tests
10442
+ - Focused e2e tests
10443
+
10444
+ ## Key Principles
10445
+
10446
+ - Test at the lowest appropriate level
10447
+ - One clear owner per test
10448
+ - Fast tests run first
10449
+ - Mock at boundaries, not internals
10450
+ - E2E for user value, not implementation
10451
+ - Maintain test/production parity where critical
10452
+ - Tests must be atomic and self-contained
10453
+ - No shared state between tests
10454
+ - Explicit assertions in test files (not helpers)
10455
+
10456
+ ### Output 2: Story Hook Line
10457
+
10458
+ **Print this line for review task to quote:**
10459
+
10460
+ ```text
10461
+ Test design: docs/qa/assessments/{epic}.{story}-test-design-{YYYYMMDD}.md
10462
+ ```
10463
+
10464
+ **For traceability:** This planning document will be referenced by trace-requirements task.
10465
+
10466
+ ### Output 3: Test Count Summary
10467
+
10468
+ **Print summary for quick reference:**
10469
+
10470
+ ```yaml
10471
+ test_summary:
10472
+ total: { total_count }
10473
+ by_level:
10474
+ unit: { unit_count }
10475
+ integration: { int_count }
10476
+ e2e: { e2e_count }
10477
+ by_priority:
10478
+ P0: { p0_count }
10479
+ P1: { p1_count }
10480
+ P2: { p2_count }
10481
+ coverage_gaps: [] # List any ACs without tests
10482
+ ```
10483
+ ==================== END: .bmad-core/tasks/test-design.md ====================
10484
+
10485
+ ==================== START: .bmad-core/tasks/nfr-assess.md ====================
10486
+ # nfr-assess
10487
+
10488
+ Quick NFR validation focused on the core four: security, performance, reliability, maintainability.
10489
+
10490
+ ## Inputs
10491
+
10492
+ ```yaml
10493
+ required:
10494
+ - story_id: "{epic}.{story}" # e.g., "1.3"
10495
+ - story_path: "docs/stories/{epic}.{story}.*.md"
10496
+
10497
+ optional:
10498
+ - architecture_refs: "docs/architecture/*.md"
10499
+ - technical_preferences: "docs/technical-preferences.md"
10500
+ - acceptance_criteria: From story file
10501
+ ```
10502
+
10503
+ ## Purpose
10504
+
10505
+ Assess non-functional requirements for a story and generate:
10506
+
10507
+ 1. YAML block for the gate file's `nfr_validation` section
10508
+ 2. Brief markdown assessment saved to `docs/qa/assessments/{epic}.{story}-nfr-{YYYYMMDD}.md`
10509
+
10510
+ ## Process
10511
+
10512
+ ### 0. Fail-safe for Missing Inputs
10513
+
10514
+ If story_path or story file can't be found:
10515
+
10516
+ - Still create assessment file with note: "Source story not found"
10517
+ - Set all selected NFRs to CONCERNS with notes: "Target unknown / evidence missing"
10518
+ - Continue with assessment to provide value
10519
+
10520
+ ### 1. Elicit Scope
10521
+
10522
+ **Interactive mode:** Ask which NFRs to assess
10523
+ **Non-interactive mode:** Default to core four (security, performance, reliability, maintainability)
10524
+
10525
+ ```text
10526
+ Which NFRs should I assess? (Enter numbers or press Enter for default)
10527
+ [1] Security (default)
10528
+ [2] Performance (default)
10529
+ [3] Reliability (default)
10530
+ [4] Maintainability (default)
10531
+ [5] Usability
10532
+ [6] Compatibility
10533
+ [7] Portability
10534
+ [8] Functional Suitability
10535
+
10536
+ > [Enter for 1-4]
10537
+ ```
10538
+
10539
+ ### 2. Check for Thresholds
10540
+
10541
+ Look for NFR requirements in:
10542
+
10543
+ - Story acceptance criteria
10544
+ - `docs/architecture/*.md` files
10545
+ - `docs/technical-preferences.md`
10546
+
10547
+ **Interactive mode:** Ask for missing thresholds
10548
+ **Non-interactive mode:** Mark as CONCERNS with "Target unknown"
10549
+
10550
+ ```text
10551
+ No performance requirements found. What's your target response time?
10552
+ > 200ms for API calls
10553
+
10554
+ No security requirements found. Required auth method?
10555
+ > JWT with refresh tokens
10556
+ ```
10557
+
10558
+ **Unknown targets policy:** If a target is missing and not provided, mark status as CONCERNS with notes: "Target unknown"
10559
+
10560
+ ### 3. Quick Assessment
10561
+
10562
+ For each selected NFR, check:
10563
+
10564
+ - Is there evidence it's implemented?
10565
+ - Can we validate it?
10566
+ - Are there obvious gaps?
10567
+
10568
+ ### 4. Generate Outputs
10569
+
10570
+ ## Output 1: Gate YAML Block
10571
+
10572
+ Generate ONLY for NFRs actually assessed (no placeholders):
10573
+
10574
+ ```yaml
10575
+ # Gate YAML (copy/paste):
10576
+ nfr_validation:
10577
+ _assessed: [security, performance, reliability, maintainability]
10578
+ security:
10579
+ status: CONCERNS
10580
+ notes: "No rate limiting on auth endpoints"
10581
+ performance:
10582
+ status: PASS
10583
+ notes: "Response times < 200ms verified"
10584
+ reliability:
10585
+ status: PASS
10586
+ notes: "Error handling and retries implemented"
10587
+ maintainability:
10588
+ status: CONCERNS
10589
+ notes: "Test coverage at 65%, target is 80%"
10590
+ ```
10591
+
10592
+ ## Deterministic Status Rules
10593
+
10594
+ - **FAIL**: Any selected NFR has critical gap or target clearly not met
10595
+ - **CONCERNS**: No FAILs, but any NFR is unknown/partial/missing evidence
10596
+ - **PASS**: All selected NFRs meet targets with evidence
10597
+
10598
+ ## Quality Score Calculation
10599
+
10600
+ ```
10601
+ quality_score = 100
10602
+ - 20 for each FAIL attribute
10603
+ - 10 for each CONCERNS attribute
10604
+ Floor at 0, ceiling at 100
10605
+ ```
10606
+
10607
+ If `technical-preferences.md` defines custom weights, use those instead.
10608
+
10609
+ ## Output 2: Brief Assessment Report
10610
+
10611
+ **ALWAYS save to:** `docs/qa/assessments/{epic}.{story}-nfr-{YYYYMMDD}.md`
10612
+
10613
+ ```markdown
10614
+ # NFR Assessment: {epic}.{story}
10615
+
10616
+ Date: {date}
10617
+ Reviewer: Quinn
10618
+
10619
+ <!-- Note: Source story not found (if applicable) -->
10620
+
10621
+ ## Summary
10622
+
10623
+ - Security: CONCERNS - Missing rate limiting
10624
+ - Performance: PASS - Meets <200ms requirement
10625
+ - Reliability: PASS - Proper error handling
10626
+ - Maintainability: CONCERNS - Test coverage below target
10627
+
10628
+ ## Critical Issues
10629
+
10630
+ 1. **No rate limiting** (Security)
10631
+ - Risk: Brute force attacks possible
10632
+ - Fix: Add rate limiting middleware to auth endpoints
10633
+
10634
+ 2. **Test coverage 65%** (Maintainability)
10635
+ - Risk: Untested code paths
10636
+ - Fix: Add tests for uncovered branches
10637
+
10638
+ ## Quick Wins
10639
+
10640
+ - Add rate limiting: ~2 hours
10641
+ - Increase test coverage: ~4 hours
10642
+ - Add performance monitoring: ~1 hour
10643
+ ```
10644
+
10645
+ ## Output 3: Story Update Line
10646
+
10647
+ **End with this line for the review task to quote:**
10648
+
10649
+ ```
10650
+ NFR assessment: docs/qa/assessments/{epic}.{story}-nfr-{YYYYMMDD}.md
10651
+ ```
10652
+
10653
+ ## Output 4: Gate Integration Line
10654
+
10655
+ **Always print at the end:**
10656
+
10657
+ ```
10658
+ Gate NFR block ready → paste into docs/qa/gates/{epic}.{story}-{slug}.yml under nfr_validation
10659
+ ```
10660
+
10661
+ ## Assessment Criteria
10662
+
10663
+ ### Security
10664
+
10665
+ **PASS if:**
10666
+
10667
+ - Authentication implemented
10668
+ - Authorization enforced
10669
+ - Input validation present
10670
+ - No hardcoded secrets
10671
+
10672
+ **CONCERNS if:**
10673
+
10674
+ - Missing rate limiting
10675
+ - Weak encryption
10676
+ - Incomplete authorization
10677
+
10678
+ **FAIL if:**
10679
+
10680
+ - No authentication
10681
+ - Hardcoded credentials
10682
+ - SQL injection vulnerabilities
10683
+
10684
+ ### Performance
10685
+
10686
+ **PASS if:**
10687
+
10688
+ - Meets response time targets
10689
+ - No obvious bottlenecks
10690
+ - Reasonable resource usage
10691
+
10692
+ **CONCERNS if:**
10693
+
10694
+ - Close to limits
10695
+ - Missing indexes
10696
+ - No caching strategy
10697
+
10698
+ **FAIL if:**
10699
+
10700
+ - Exceeds response time limits
10701
+ - Memory leaks
10702
+ - Unoptimized queries
10703
+
10704
+ ### Reliability
10705
+
10706
+ **PASS if:**
10707
+
10708
+ - Error handling present
10709
+ - Graceful degradation
10710
+ - Retry logic where needed
10711
+
10712
+ **CONCERNS if:**
10713
+
10714
+ - Some error cases unhandled
10715
+ - No circuit breakers
10716
+ - Missing health checks
10717
+
10718
+ **FAIL if:**
10719
+
10720
+ - No error handling
10721
+ - Crashes on errors
10722
+ - No recovery mechanisms
10723
+
10724
+ ### Maintainability
10725
+
10726
+ **PASS if:**
10727
+
10728
+ - Test coverage meets target
10729
+ - Code well-structured
10730
+ - Documentation present
10731
+
10732
+ **CONCERNS if:**
10733
+
10734
+ - Test coverage below target
10735
+ - Some code duplication
10736
+ - Missing documentation
10737
+
10738
+ **FAIL if:**
10739
+
10740
+ - No tests
10741
+ - Highly coupled code
10742
+ - No documentation
10743
+
10744
+ ## Quick Reference
10745
+
10746
+ ### What to Check
10747
+
10748
+ ```yaml
10749
+ security:
10750
+ - Authentication mechanism
10751
+ - Authorization checks
10752
+ - Input validation
10753
+ - Secret management
10754
+ - Rate limiting
10755
+
10756
+ performance:
10757
+ - Response times
10758
+ - Database queries
10759
+ - Caching usage
10760
+ - Resource consumption
10761
+
10762
+ reliability:
10763
+ - Error handling
10764
+ - Retry logic
10765
+ - Circuit breakers
10766
+ - Health checks
10767
+ - Logging
10768
+
10769
+ maintainability:
10770
+ - Test coverage
10771
+ - Code structure
10772
+ - Documentation
10773
+ - Dependencies
10774
+ ```
10775
+
10776
+ ## Key Principles
10777
+
10778
+ - Focus on the core four NFRs by default
10779
+ - Quick assessment, not deep analysis
10780
+ - Gate-ready output format
10781
+ - Brief, actionable findings
10782
+ - Skip what doesn't apply
10783
+ - Deterministic status rules for consistency
10784
+ - Unknown targets → CONCERNS, not guesses
10785
+
10786
+ ---
10787
+
10788
+ ## Appendix: ISO 25010 Reference
10789
+
10790
+ <details>
10791
+ <summary>Full ISO 25010 Quality Model (click to expand)</summary>
10792
+
10793
+ ### All 8 Quality Characteristics
10794
+
10795
+ 1. **Functional Suitability**: Completeness, correctness, appropriateness
10796
+ 2. **Performance Efficiency**: Time behavior, resource use, capacity
10797
+ 3. **Compatibility**: Co-existence, interoperability
10798
+ 4. **Usability**: Learnability, operability, accessibility
10799
+ 5. **Reliability**: Maturity, availability, fault tolerance
10800
+ 6. **Security**: Confidentiality, integrity, authenticity
10801
+ 7. **Maintainability**: Modularity, reusability, testability
10802
+ 8. **Portability**: Adaptability, installability
10803
+
10804
+ Use these when assessing beyond the core four.
10805
+
10806
+ </details>
10807
+
10808
+ <details>
10809
+ <summary>Example: Deep Performance Analysis (click to expand)</summary>
10810
+
10811
+ ```yaml
10812
+ performance_deep_dive:
10813
+ response_times:
10814
+ p50: 45ms
10815
+ p95: 180ms
10816
+ p99: 350ms
10817
+ database:
10818
+ slow_queries: 2
10819
+ missing_indexes: ["users.email", "orders.user_id"]
10820
+ caching:
10821
+ hit_rate: 0%
10822
+ recommendation: "Add Redis for session data"
10823
+ load_test:
10824
+ max_rps: 150
10825
+ breaking_point: 200 rps
10826
+ ```
10827
+
10828
+ </details>
10829
+ ==================== END: .bmad-core/tasks/nfr-assess.md ====================
10830
+
10831
+ ==================== START: .bmad-core/templates/qa-gate-tmpl.yaml ====================
10832
+ template:
10833
+ id: qa-gate-template-v1
10834
+ name: Quality Gate Decision
10835
+ version: 1.0
10836
+ output:
10837
+ format: yaml
10838
+ filename: docs/qa/gates/{{epic_num}}.{{story_num}}-{{story_slug}}.yml
10839
+ title: "Quality Gate: {{epic_num}}.{{story_num}}"
10840
+
10841
+ # Required fields (keep these first)
10842
+ schema: 1
10843
+ story: "{{epic_num}}.{{story_num}}"
10844
+ story_title: "{{story_title}}"
10845
+ gate: "{{gate_status}}" # PASS|CONCERNS|FAIL|WAIVED
10846
+ status_reason: "{{status_reason}}" # 1-2 sentence summary of why this gate decision
10847
+ reviewer: "Quinn (Test Architect)"
10848
+ updated: "{{iso_timestamp}}"
10849
+
10850
+ # Always present but only active when WAIVED
10851
+ waiver: { active: false }
10852
+
10853
+ # Issues (if any) - Use fixed severity: low | medium | high
10854
+ top_issues: []
10855
+
10856
+ # Risk summary (from risk-profile task if run)
10857
+ risk_summary:
10858
+ totals: { critical: 0, high: 0, medium: 0, low: 0 }
10859
+ recommendations:
10860
+ must_fix: []
10861
+ monitor: []
10862
+
10863
+ # Example with issues:
10864
+ # top_issues:
10865
+ # - id: "SEC-001"
10866
+ # severity: high # ONLY: low|medium|high
10867
+ # finding: "No rate limiting on login endpoint"
10868
+ # suggested_action: "Add rate limiting middleware before production"
10869
+ # - id: "TEST-001"
10870
+ # severity: medium
10871
+ # finding: "Missing integration tests for auth flow"
10872
+ # suggested_action: "Add test coverage for critical paths"
10873
+
10874
+ # Example when waived:
10875
+ # waiver:
10876
+ # active: true
10877
+ # reason: "Accepted for MVP release - will address in next sprint"
10878
+ # approved_by: "Product Owner"
10879
+
10880
+ # ============ Optional Extended Fields ============
10881
+ # Uncomment and use if your team wants more detail
10882
+
10883
+ # quality_score: 75 # 0-100 (optional scoring)
10884
+ # expires: "2025-01-26T00:00:00Z" # Optional gate freshness window
10885
+
10886
+ # evidence:
10887
+ # tests_reviewed: 15
10888
+ # risks_identified: 3
10889
+ # trace:
10890
+ # ac_covered: [1, 2, 3] # AC numbers with test coverage
10891
+ # ac_gaps: [4] # AC numbers lacking coverage
10892
+
10893
+ # nfr_validation:
10894
+ # security: { status: CONCERNS, notes: "Rate limiting missing" }
10895
+ # performance: { status: PASS, notes: "" }
10896
+ # reliability: { status: PASS, notes: "" }
10897
+ # maintainability: { status: PASS, notes: "" }
10898
+
10899
+ # history: # Append-only audit trail
10900
+ # - at: "2025-01-12T10:00:00Z"
10901
+ # gate: FAIL
10902
+ # note: "Initial review - missing tests"
10903
+ # - at: "2025-01-12T15:00:00Z"
10904
+ # gate: CONCERNS
10905
+ # note: "Tests added but rate limiting still missing"
10906
+
10907
+ # risk_summary: # From risk-profile task
10908
+ # totals:
10909
+ # critical: 0
10910
+ # high: 0
10911
+ # medium: 0
10912
+ # low: 0
10913
+ # # 'highest' is emitted only when risks exist
10914
+ # recommendations:
10915
+ # must_fix: []
10916
+ # monitor: []
10917
+
10918
+ # recommendations:
10919
+ # immediate: # Must fix before production
10920
+ # - action: "Add rate limiting to auth endpoints"
10921
+ # refs: ["api/auth/login.ts:42-68"]
10922
+ # future: # Can be addressed later
10923
+ # - action: "Consider caching for better performance"
10924
+ # refs: ["services/data.service.ts"]
10925
+ ==================== END: .bmad-core/templates/qa-gate-tmpl.yaml ====================
10926
+
10927
+ ==================== START: .bmad-core/tasks/create-next-story.md ====================
10928
+ # Create Next Story Task
10929
+
10930
+ ## Purpose
10931
+
10932
+ To identify the next logical story based on project progress and epic definitions, and then to prepare a comprehensive, self-contained, and actionable story file using the `Story Template`. This task ensures the story is enriched with all necessary technical context, requirements, and acceptance criteria, making it ready for efficient implementation by a Developer Agent with minimal need for additional research or finding its own context.
10933
+
10934
+ ## SEQUENTIAL Task Execution (Do not proceed until current Task is complete)
10935
+
10936
+ ### 0. Load Core Configuration and Check Workflow
10937
+
10938
+ - Load `.bmad-core/core-config.yaml` from the project root
10939
+ - If the file does not exist, HALT and inform the user: "core-config.yaml not found. This file is required for story creation. You can either: 1) Copy it from GITHUB bmad-core/core-config.yaml and configure it for your project OR 2) Run the BMad installer against your project to upgrade and add the file automatically. Please add and configure core-config.yaml before proceeding."
10940
+ - Extract key configurations: `devStoryLocation`, `prd.*`, `architecture.*`, `workflow.*`
10941
+
10942
+ ### 1. Identify Next Story for Preparation
10943
+
10944
+ #### 1.1 Locate Epic Files and Review Existing Stories
10945
+
10946
+ - Based on `prdSharded` from config, locate epic files (sharded location/pattern or monolithic PRD sections)
10947
+ - If `devStoryLocation` has story files, load the highest `{epicNum}.{storyNum}.story.md` file
10948
+ - **If highest story exists:**
10949
+ - Verify status is 'Done'. If not, alert user: "ALERT: Found incomplete story! File: {lastEpicNum}.{lastStoryNum}.story.md Status: [current status] You should fix this story first, but would you like to accept risk & override to create the next story in draft?"
10950
+ - If proceeding, select next sequential story in the current epic
10951
+ - If epic is complete, prompt user: "Epic {epicNum} Complete: All stories in Epic {epicNum} have been completed. Would you like to: 1) Begin Epic {epicNum + 1} with story 1 2) Select a specific story to work on 3) Cancel story creation"
10952
+ - **CRITICAL**: NEVER automatically skip to another epic. User MUST explicitly instruct which story to create.
10953
+ - **If no story files exist:** The next story is ALWAYS 1.1 (first story of first epic)
10954
+ - Announce the identified story to the user: "Identified next story for preparation: {epicNum}.{storyNum} - {Story Title}"
10955
+
10956
+ ### 2. Gather Story Requirements and Previous Story Context
10957
+
10958
+ - Extract story requirements from the identified epic file
10959
+ - If previous story exists, review Dev Agent Record sections for:
10960
+ - Completion Notes and Debug Log References
10961
+ - Implementation deviations and technical decisions
10962
+ - Challenges encountered and lessons learned
10963
+ - Extract relevant insights that inform the current story's preparation
10964
+
10965
+ ### 3. Gather Architecture Context
10966
+
10967
+ #### 3.1 Determine Architecture Reading Strategy
10968
+
10969
+ - **If `architectureVersion: >= v4` and `architectureSharded: true`**: Read `{architectureShardedLocation}/index.md` then follow structured reading order below
10970
+ - **Else**: Use monolithic `architectureFile` for similar sections
10971
+
10972
+ #### 3.2 Read Architecture Documents Based on Story Type
10973
+
10974
+ **For ALL Stories:** tech-stack.md, unified-project-structure.md, coding-standards.md, testing-strategy.md
10975
+
10976
+ **For Backend/API Stories, additionally:** data-models.md, database-schema.md, backend-architecture.md, rest-api-spec.md, external-apis.md
10977
+
10978
+ **For Frontend/UI Stories, additionally:** frontend-architecture.md, components.md, core-workflows.md, data-models.md
10979
+
10980
+ **For Full-Stack Stories:** Read both Backend and Frontend sections above
10981
+
10982
+ #### 3.3 Extract Story-Specific Technical Details
10983
+
10984
+ Extract ONLY information directly relevant to implementing the current story. Do NOT invent new libraries, patterns, or standards not in the source documents.
10985
+
10986
+ Extract:
10987
+
10988
+ - Specific data models, schemas, or structures the story will use
10989
+ - API endpoints the story must implement or consume
10990
+ - Component specifications for UI elements in the story
10991
+ - File paths and naming conventions for new code
10992
+ - Testing requirements specific to the story's features
10993
+ - Security or performance considerations affecting the story
10994
+
10995
+ ALWAYS cite source documents: `[Source: architecture/{filename}.md#{section}]`
10996
+
10997
+ ### 4. Verify Project Structure Alignment
10998
+
10999
+ - Cross-reference story requirements with Project Structure Guide from `docs/architecture/unified-project-structure.md`
11000
+ - Ensure file paths, component locations, or module names align with defined structures
11001
+ - Document any structural conflicts in "Project Structure Notes" section within the story draft
11002
+
11003
+ ### 5. Populate Story Template with Full Context
11004
+
11005
+ - Create new story file: `{devStoryLocation}/{epicNum}.{storyNum}.story.md` using Story Template
11006
+ - Fill in basic story information: Title, Status (Draft), Story statement, Acceptance Criteria from Epic
11007
+ - **`Dev Notes` section (CRITICAL):**
11008
+ - CRITICAL: This section MUST contain ONLY information extracted from architecture documents. NEVER invent or assume technical details.
11009
+ - Include ALL relevant technical details from Steps 2-3, organized by category:
11010
+ - **Previous Story Insights**: Key learnings from previous story
11011
+ - **Data Models**: Specific schemas, validation rules, relationships [with source references]
11012
+ - **API Specifications**: Endpoint details, request/response formats, auth requirements [with source references]
11013
+ - **Component Specifications**: UI component details, props, state management [with source references]
11014
+ - **File Locations**: Exact paths where new code should be created based on project structure
11015
+ - **Testing Requirements**: Specific test cases or strategies from testing-strategy.md
11016
+ - **Technical Constraints**: Version requirements, performance considerations, security rules
11017
+ - Every technical detail MUST include its source reference: `[Source: architecture/{filename}.md#{section}]`
11018
+ - If information for a category is not found in the architecture docs, explicitly state: "No specific guidance found in architecture docs"
11019
+ - **`Tasks / Subtasks` section:**
11020
+ - Generate detailed, sequential list of technical tasks based ONLY on: Epic Requirements, Story AC, Reviewed Architecture Information
11021
+ - Each task must reference relevant architecture documentation
11022
+ - Include unit testing as explicit subtasks based on the Testing Strategy
11023
+ - Link tasks to ACs where applicable (e.g., `Task 1 (AC: 1, 3)`)
11024
+ - Add notes on project structure alignment or discrepancies found in Step 4
11025
+
11026
+ ### 6. Story Draft Completion and Review
11027
+
11028
+ - Review all sections for completeness and accuracy
11029
+ - Verify all source references are included for technical details
11030
+ - Ensure tasks align with both epic requirements and architecture constraints
11031
+ - Update status to "Draft" and save the story file
11032
+ - Execute `.bmad-core/tasks/execute-checklist` `.bmad-core/checklists/story-draft-checklist`
11033
+ - Provide summary to user including:
11034
+ - Story created: `{devStoryLocation}/{epicNum}.{storyNum}.story.md`
11035
+ - Status: Draft
11036
+ - Key technical components included from architecture docs
11037
+ - Any deviations or conflicts noted between epic and architecture
11038
+ - Checklist Results
11039
+ - Next steps: For Complex stories, suggest the user carefully review the story draft and also optionally have the PO run the task `.bmad-core/tasks/validate-next-story`
11040
+ ==================== END: .bmad-core/tasks/create-next-story.md ====================
11041
+
11042
+ ==================== START: .bmad-core/checklists/story-draft-checklist.md ====================
11043
+ # Story Draft Checklist
11044
+
11045
+ The Scrum Master should use this checklist to validate that each story contains sufficient context for a developer agent to implement it successfully, while assuming the dev agent has reasonable capabilities to figure things out.
11046
+
11047
+ [[LLM: INITIALIZATION INSTRUCTIONS - STORY DRAFT VALIDATION
11048
+
11049
+ Before proceeding with this checklist, ensure you have access to:
11050
+
11051
+ 1. The story document being validated (usually in docs/stories/ or provided directly)
11052
+ 2. The parent epic context
11053
+ 3. Any referenced architecture or design documents
11054
+ 4. Previous related stories if this builds on prior work
11055
+
11056
+ IMPORTANT: This checklist validates individual stories BEFORE implementation begins.
11057
+
11058
+ VALIDATION PRINCIPLES:
11059
+
11060
+ 1. Clarity - A developer should understand WHAT to build
11061
+ 2. Context - WHY this is being built and how it fits
11062
+ 3. Guidance - Key technical decisions and patterns to follow
11063
+ 4. Testability - How to verify the implementation works
11064
+ 5. Self-Contained - Most info needed is in the story itself
11065
+
11066
+ REMEMBER: We assume competent developer agents who can:
11067
+
11068
+ - Research documentation and codebases
9146
11069
  - Make reasonable technical decisions
9147
11070
  - Follow established patterns
9148
11071
  - Ask for clarification when truly stuck
@@ -9236,19 +11159,16 @@ Note: We don't need every file listed - just the important ones.]]
9236
11159
  Generate a concise validation report:
9237
11160
 
9238
11161
  1. Quick Summary
9239
-
9240
11162
  - Story readiness: READY / NEEDS REVISION / BLOCKED
9241
11163
  - Clarity score (1-10)
9242
11164
  - Major gaps identified
9243
11165
 
9244
11166
  2. Fill in the validation table with:
9245
-
9246
11167
  - PASS: Requirements clearly met
9247
11168
  - PARTIAL: Some gaps but workable
9248
11169
  - FAIL: Critical information missing
9249
11170
 
9250
11171
  3. Specific Issues (if any)
9251
-
9252
11172
  - List concrete problems to fix
9253
11173
  - Suggest specific improvements
9254
11174
  - Identify any blocking dependencies