The workflow execution engine is governed by: {project-root}/{bmad_folder}/core/tasks/workflow.xml
You MUST have already loaded and processed: {installed_path}/workflow.yaml
Communicate all responses in {communication_language} and generate all documents in {document_output_language}
🔥 CRITICAL MISSION: You are creating the ULTIMATE story context engine that prevents LLM developer mistakes, omissions or
disasters! 🔥
Your purpose is NOT to copy from epics - it's to create a comprehensive, optimized story file that gives the DEV agent
EVERYTHING needed for flawless implementation
COMMON LLM MISTAKES TO PREVENT: reinventing wheels, wrong libraries, wrong file locations, breaking regressions, ignoring UX,
vague implementations, lying about completion, not learning from past work
🚨 EXHAUSTIVE ANALYSIS REQUIRED: You must thoroughly analyze ALL artifacts to extract critical context - do NOT be lazy or skim!
This is the most important function in the entire development process!
🔬 UTILIZE SUBPROCESSES AND SUBAGENTS: Use research subagents, subprocesses or parallel processing if available to thoroughly
analyze different artifacts simultaneously and thoroughly
❓ SAVE QUESTIONS: If you think of questions or clarifications during analysis, save them for the end after the complete story is
written
🎯 ZERO USER INTERVENTION: Process should be fully automated except for initial epic/story selection or missing documents
Parse user-provided story path: extract epic_num, story_num, story_title from format like "1-2-user-auth"
Set {{epic_num}}, {{story_num}}, {{story_key}} from user input
GOTO step 2a
Check if {{sprint_status}} file exists for auto discover
Choose option [1], provide epic-story number, path to story docs, or [q] to quit:
HALT - No work needed
HALT - User needs to run sprint-planning
Parse user input: extract epic_num, story_num, story_title
Set {{epic_num}}, {{story_num}}, {{story_key}} from user input
GOTO step 2a
Use user-provided path for story documents
GOTO step 2a
MUST read COMPLETE {sprint_status} file from start to end to preserve order
Load the FULL file: {{sprint_status}}
Read ALL lines from beginning to end - do not skip any content
Parse the development_status section completely
Find the FIRST story (by reading in order from top to bottom) where:
- Key matches pattern: number-number-name (e.g., "1-2-user-auth")
- NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
- Status value equals "backlog"
HALT
Extract from found story key (e.g., "1-2-user-authentication"):
- epic_num: first number before dash (e.g., "1")
- story_num: second number after first dash (e.g., "2")
- story_title: remainder after second dash (e.g., "user-authentication")
Set {{story_id}} = "{{epic_num}}.{{story_num}}"
Store story_key for later use (e.g., "1-2-user-authentication")
Check if this is the first story in epic {{epic_num}} by looking for {{epic_num}}-1-* pattern
Load {{sprint_status}} and check epic-{{epic_num}} status
If epic status is "backlog" → update to "in-progress"
If epic status is "contexted" (legacy status) → update to "in-progress" (backward compatibility)
If epic status is "in-progress" → no change needed
HALT - Cannot proceed
HALT - Cannot proceed
GOTO step 2a
Load the FULL file: {{sprint_status}}
Read ALL lines from beginning to end - do not skip any content
Parse the development_status section completely
Find the FIRST story (by reading in order from top to bottom) where:
- Key matches pattern: number-number-name (e.g., "1-2-user-auth")
- NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
- Status value equals "backlog"
HALT
Extract from found story key (e.g., "1-2-user-authentication"):
- epic_num: first number before dash (e.g., "1")
- story_num: second number after first dash (e.g., "2")
- story_title: remainder after second dash (e.g., "user-authentication")
Set {{story_id}} = "{{epic_num}}.{{story_num}}"
Store story_key for later use (e.g., "1-2-user-authentication")
Check if this is the first story in epic {{epic_num}} by looking for {{epic_num}}-1-* pattern
Load {{sprint_status}} and check epic-{{epic_num}} status
If epic status is "backlog" → update to "in-progress"
If epic status is "contexted" (legacy status) → update to "in-progress" (backward compatibility)
If epic status is "in-progress" → no change needed
HALT - Cannot proceed
HALT - Cannot proceed
GOTO step 2a
🔬 EXHAUSTIVE ARTIFACT ANALYSIS - This is where you prevent future developer fuckups!
Available content: {epics_content}, {prd_content}, {architecture_content}, {ux_content},
{project_context}
From {epics_content}, extract Epic {{epic_num}} complete context: **EPIC ANALYSIS:** - Epic
objectives and business value - ALL stories in this epic for cross-story context - Our specific story's requirements, user story
statement, acceptance criteria - Technical requirements and constraints - Dependencies on other stories/epics - Source hints pointing to
original documents
Extract our story ({{epic_num}}-{{story_num}}) details: **STORY FOUNDATION:** - User story statement
(As a, I want, so that) - Detailed acceptance criteria (already BDD formatted) - Technical requirements specific to this story -
Business context and value - Success criteria
Load previous story file: {{story_dir}}/{{epic_num}}-{{previous_story_num}}-*.md **PREVIOUS STORY INTELLIGENCE:** -
Dev notes and learnings from previous story - Review feedback and corrections needed - Files that were created/modified and their
patterns - Testing approaches that worked/didn't work - Problems encountered and solutions found - Code patterns established Extract
all learnings that could impact current story implementation
Get last 5 commit titles to understand recent work patterns
Analyze 1-5 most recent commits for relevance to current story:
- Files created/modified
- Code patterns and conventions used
- Library dependencies added/changed
- Architecture decisions implemented
- Testing approaches used
Extract actionable insights for current story implementation
🏗️ ARCHITECTURE INTELLIGENCE - Extract everything the developer MUST follow! **ARCHITECTURE DOCUMENT ANALYSIS:** Systematically
analyze architecture content for story-relevant requirements:
Load complete {architecture_content}
Load architecture index and scan all architecture files
**CRITICAL ARCHITECTURE EXTRACTION:** For
each architecture section, determine if relevant to this story: - **Technical Stack:** Languages, frameworks, libraries with
versions - **Code Structure:** Folder organization, naming conventions, file patterns - **API Patterns:** Service structure, endpoint
patterns, data contracts - **Database Schemas:** Tables, relationships, constraints relevant to story - **Security Requirements:**
Authentication patterns, authorization rules - **Performance Requirements:** Caching strategies, optimization patterns - **Testing
Standards:** Testing frameworks, coverage expectations, test patterns - **Deployment Patterns:** Environment configurations, build
processes - **Integration Patterns:** External service integrations, data flows Extract any story-specific requirements that the
developer MUST follow
Identify any architectural decisions that override previous patterns
🌐 ENSURE LATEST TECH KNOWLEDGE - Prevent outdated implementations! **WEB INTELLIGENCE:** Identify specific
technical areas that require latest version knowledge:
From architecture analysis, identify specific libraries, APIs, or
frameworks
For each critical technology, research latest stable version and key changes:
- Latest API documentation and breaking changes
- Security vulnerabilities or updates
- Performance improvements or deprecations
- Best practices for current version
**EXTERNAL CONTEXT INCLUSION:** Include in story any critical latest information the developer needs:
- Specific library versions and why chosen
- API endpoints with parameters and authentication
- Recent security patches or considerations
- Performance optimization techniques
- Migration considerations if upgrading
📝 CREATE ULTIMATE STORY FILE - The developer's master implementation guide!
Initialize from template.md:
{default_output_file}
story_header
story_requirements
developer_context_section **DEV AGENT GUARDRAILS:**
technical_requirements
architecture_compliance
library_framework_requirements
file_structure_requirements
testing_requirements
previous_story_intelligence
git_intelligence_summary
latest_tech_information
project_context_reference
story_completion_status
Set story Status to: "ready-for-dev"
Add completion note: "Ultimate
context engine analysis completed - comprehensive developer guide created"
Validate against checklist at {installed_path}/checklist.md using {bmad_folder}/core/tasks/validate-workflow.xml
Save story document unconditionally
Update {{sprint_status}}
Load the FULL file and read all development_status entries
Find development_status key matching {{story_key}}
Verify current status is "backlog" (expected previous state)
Update development_status[{{story_key}}] = "ready-for-dev"
Save file, preserving ALL comments and structure including STATUS DEFINITIONS
Report completion