How to Implement a Story
Use the dev-story workflow to implement a story with tests following the architecture and conventions.
When to Use This
Section titled âWhen to Use Thisâ- After create-story has prepared the story file
- When ready to write code for a story
- Story dependencies are marked DONE
Prerequisites
Section titled âPrerequisitesâ- BMad Method installed
- DEV agent available
- Story file created by create-story
- Architecture and tech-spec available for context
1. Load the DEV Agent
Section titled â1. Load the DEV AgentâStart a fresh chat and load the DEV agent.
2. Run the Workflow
Section titled â2. Run the Workflowâ*dev-story3. Provide Story Context
Section titled â3. Provide Story ContextâPoint the agent to the story file created by create-story.
4. Implement with Guidance
Section titled â4. Implement with GuidanceâThe DEV agent:
- Reads the story file and acceptance criteria
- References architecture decisions
- Follows existing code patterns
- Implements with tests
5. Complete Implementation
Section titled â5. Complete ImplementationâWork with the agent until all acceptance criteria are met.
What Happens
Section titled âWhat HappensâThe dev-story workflow:
- Reads context - Story file, architecture, existing patterns
- Plans implementation - Identifies files to create/modify
- Writes code - Following conventions and patterns
- Writes tests - Unit, integration, or E2E as appropriate
- Validates - Runs tests and checks acceptance criteria
Key Principles
Section titled âKey PrinciplesâOne Story at a Time
Section titled âOne Story at a TimeâComplete each storyâs full lifecycle before starting the next. This prevents context switching and ensures quality.
Follow Architecture
Section titled âFollow ArchitectureâThe DEV agent references:
- ADRs for technology decisions
- Standards for naming and structure
- Existing patterns in the codebase
Write Tests
Section titled âWrite TestsâEvery story includes appropriate tests:
- Unit tests for business logic
- Integration tests for API endpoints
- E2E tests for critical flows
After Implementation
Section titled âAfter Implementationâ- Update sprint-status.yaml - Mark story as READY FOR REVIEW
- Run code-review - Quality assurance
- Address feedback - If code review finds issues
- Mark DONE - After code review passes
- Keep the story file open for reference
- Ask the agent to explain decisions
- Run tests frequently during implementation
- Donât skip tests for âsimpleâ changes
Troubleshooting
Section titled âTroubleshootingâQ: Story needs significant changes mid-implementation?
A: Run correct-course to analyze impact and route appropriately.
Q: Can I work on multiple stories in parallel? A: Not recommended. Complete one storyâs full lifecycle first.
Q: What if implementation reveals the story is too large? A: Split the story and document the change.
Related
Section titled âRelatedâ- Create Story - Prepare the story first
- Run Code Review - After implementation
- Run Sprint Planning - Sprint organization