Guide for working with existing codebases using BMad Method. Learn how to extend, enhance, and modernize legacy systems safely.
Brownfield workflows adapt BMad Method for existing projects. Key differences from greenfield:
Use when: Adding significant features, 2+ weeks work, multiple epics
Process: Document → Plan → Develop (same as greenfield but with brownfield templates)
Use when: Adding features, 3-10 days work, single epic
Process: Create brownfield epic → Create stories → Develop
Use when: Small additions, < 4 hours, single story
Process: Create single brownfield story → Develop immediately
npx bmad-method flatten -i . -o project-complete.xmlWhat it does:
.gitignore patternsOutput: project-complete.xml (use this as reference for planning)
Load Planning Team:
web-bundles/teams/team-fullstack.txtweb-bundles/teams/team-no-ui.txt*agent pm
*create-prdPM uses brownfield-prd-tmpl.yaml which focuses on:
Reference: project-complete.xml when PM asks about existing system
Output: docs/brownfield-prd.md
*agent architect
*create-architectureArchitect uses brownfield-architecture-tmpl.yaml which includes:
Output: docs/brownfield-architecture.md
*agent po
*shard-docOutput: docs/prd/ and docs/architecture/ directories
Same as greenfield development with additional safety:
*agent sm
*draftSM uses create-brownfield-story task which includes:
Brownfield Story Additions:
## Integration Context
[Source: project-complete.xml#existing-auth]
Existing authentication uses Passport.js with JWT strategy.
New OAuth integration must coexist with existing JWT auth.
## Safety Checks
- Existing JWT authentication must continue working
- No breaking changes to /api/auth/* endpoints
- Maintain backward compatibility with mobile apps
## Rollback Plan
1. Revert src/auth/oauth.js
2. Remove OAuth routes from src/app.js
3. Restore previous package.json dependencies
4. Run `npm install`
## Risk Assessment
**Medium Risk**: OAuth integration may conflict with existing JWT middleware
**Mitigation**: Test both auth methods thoroughly, use feature flag*agent dev
*develop-storyDev follows same process but with extra caution:
Output: Code changes with safety checks
For medium enhancements (single epic), skip full documents:
*agent sm
*draftUse brownfield-create-epic task:
Output: docs/epics/brownfield-{feature}.md and story files
Same as full brownfield development above.
For very small changes (< 4 hours):
*agent pm
*create-brownfield-storyPM uses brownfield-create-story task to create single story:
Story includes:
Output: Single story file
*agent dev
*develop-storyImplement immediately.
Always flatten codebase before planning:
npx bmad-method flatten -i . -o project.xmlApproach: Single-story workflow
*agent pm
*create-brownfield-storyStory includes:
Approach: Medium enhancement (epic with 2-3 stories)
*agent sm
*draftCreates brownfield epic:
Approach: Full brownfield workflow
Document system → Create PRD → Create Architecture → Develop stories
Problem: Don't understand existing codebase Solution: Review flattened XML, ask clarifying questions in planning
Problem: New code breaks existing functionality Solution: Increase test coverage for existing features, use feature flags
Problem: Integration points unclear
Solution: Use create-brownfield-story task with interactive context gathering
Problem: Can't follow existing patterns Solution: Document deviation in story, get stakeholder approval