HIGHLY RECOMMENDED: Use Gemini Web or Gemini CLI for Brownfield Documentation Generation!
Gemini Web's 1M+ token context window or Gemini CLI (when it's working) can analyze your ENTIRE codebase, or critical sections of it, all at once (obviously within reason):
- Upload via GitHub URL or use gemini cli in the project folder
- If working in the web: use
npx bmad-method flattento flatten your project into a single file, then upload that file to your web agent.
Brownfield development refers to adding features, fixing bugs, or modernizing existing software projects. Unlike greenfield (new) projects, brownfield work requires understanding existing code, respecting constraints, and ensuring new changes integrate seamlessly without breaking existing functionality.
- Add significant new features to existing applications
- Modernize legacy codebases
- Integrate new technologies or services
- Refactor complex systems
- Fix bugs that require architectural understanding
- Document undocumented systems
If you have just completed an MVP with BMad, and you want to continue with post-MVP, its easier to just talk to the PM and ask it to work with you to create a new epic to add into the PRD, shard out the epic, update any architecture documents with the architect, and just go from there.
- Follow the User Guide - Installation steps to setup your agent in the web.
- Generate a 'flattened' single file of your entire codebase run:
npx bmad-method flatten
Approach A: PRD-First (Recommended if adding very large and complex new features, single or multiple epics or massive changes)
Best for: Large codebases, monorepos, or when you know exactly what you want to build
- Create PRD First to define requirements
- Document only relevant areas based on PRD needs
- More efficient - avoids documenting unused code
Best for: Smaller codebases, unknown systems, or exploratory changes
- Document entire system first
- Create PRD with full context
- More thorough - captures everything
In Gemini Web (with your flattened-codebase.xml uploaded):
@pm
*create-brownfield-prdThe PM will:
- Ask about your enhancement requirements
- Explore the codebase to understand current state
- Identify affected areas that need documentation
- Create focused PRD with clear scope
Key Advantage: The PRD identifies which parts of your monorepo/large codebase actually need documentation!
Still in Gemini Web, now with PRD context:
@architect
*document-projectThe architect will:
- Ask about your focus if no PRD was provided
- Offer options: Create PRD, provide requirements, or describe the enhancement
- Reference the PRD/description to understand scope
- Focus on relevant modules identified in PRD or your description
- Skip unrelated areas to keep docs lean
- Generate ONE architecture document for all environments
The architect creates:
- One comprehensive architecture document following fullstack-architecture template
- Covers all system aspects in a single file
- Easy to copy and save as
docs/architecture.md - Can be sharded later in IDE if desired
For example, if you say "Add payment processing to user service":
- Documents only: user service, API endpoints, database schemas, payment integrations
- Creates focused source tree showing only payment-related code paths
- Skips: admin panels, reporting modules, unrelated microservices
Best Approach - Gemini Web with 1M+ Context:
- Go to Gemini Web (gemini.google.com)
- Upload your project:
- Option A: Paste your GitHub repository URL directly
- Option B: Upload your flattened-codebase.xml file
- Load the architect agent: Upload
dist/agents/architect.txt - Run documentation: Type
*document-project
The architect will generate comprehensive documentation of everything.
1. Create Brownfield PRD:
@pm
*create-brownfield-prdThe PM agent will:
- Analyze existing documentation from Phase 1
- Request specific enhancement details from you
- Assess complexity and recommend approach
- Create epic/story structure for the enhancement
- Identify risks and integration points
How PM Agent Gets Project Context:
- In Gemini Web: Already has full project context from Phase 1 documentation
- In IDE: Will ask "Please provide the path to your existing project documentation"
Key Prompts You'll Encounter:
- "What specific enhancement or feature do you want to add?"
- "Are there any existing systems or APIs this needs to integrate with?"
- "What are the critical constraints we must respect?"
- "What is your timeline and team size?"
2. Create Brownfield Architecture:
@architect
*create-brownfield-architectureThe architect will:
- Review the brownfield PRD
- Design integration strategy
- Plan migration approach if needed
- Identify technical risks
- Define compatibility requirements
For Single Epic Without Full PRD:
@pm
*create-brownfield-epicUse when:
- Enhancement is well-defined and isolated
- Existing documentation is comprehensive
- Changes don't impact multiple systems
- You need quick turnaround
For Single Story:
@pm
*create-brownfield-storyUse when:
- Bug fix or tiny feature
- Very isolated change
- No architectural impact
- Clear implementation path
@po
*execute-checklist-poThe PO ensures:
- Compatibility with existing system
- No breaking changes planned
- Risk mitigation strategies in place
- Clear integration approach
-
Save your PRD and Architecture as: docs/prd.md docs/architecture.md (Note: You can optionally prefix with 'brownfield-' if managing multiple versions)
-
Shard your docs: In your IDE
@po shard docs/prd.md
@po shard docs/architecture.md
Follow the Enhanced IDE Development Workflow
Even if you think you know the codebase:
- Run
document-projectto capture current state - AI agents need this context
- Discovers undocumented patterns
The brownfield templates specifically look for:
- Current coding conventions
- Existing architectural patterns
- Technology constraints
- Team preferences
Brownfield changes should:
- Support feature flags
- Plan rollback strategies
- Include migration scripts
- Maintain backwards compatibility
In brownfield projects, the Test Architect (Quinn) becomes your safety net against breaking existing functionality. Unlike greenfield where you're building fresh, brownfield requires careful validation that new changes don't destabilize what already works.
The Test Architect addresses unique brownfield complexities:
| Challenge | How Test Architect Helps | Command |
|---|---|---|
| Regression Risks | Identifies which existing features might break | *risk |
| Legacy Dependencies | Maps integration points and hidden dependencies | *trace |
| Performance Degradation | Validates no slowdown in existing flows | *nfr |
| Coverage Gaps | Finds untested legacy code that new changes touch | *design |
| Breaking Changes | Detects API/contract violations | *review |
| Migration Safety | Validates data transformations and rollback plans | *risk + *review |
CRITICAL FOR BROWNFIELD - Run These First:
# 1. RISK ASSESSMENT (Run IMMEDIATELY after story creation)
@qa *risk {brownfield-story}
# Identifies: Legacy dependencies, breaking changes, integration points
# Output: docs/qa/assessments/{epic}.{story}-risk-{YYYYMMDD}.md
# Brownfield Focus:
# - Regression probability scoring
# - Affected downstream systems
# - Data migration risks
# - Rollback complexity
# 2. TEST DESIGN (After risk assessment)
@qa *design {brownfield-story}
# Creates: Regression test strategy + new feature tests
# Output: docs/qa/assessments/{epic}.{story}-test-design-{YYYYMMDD}.md
# Brownfield Focus:
# - Existing functionality that needs regression tests
# - Integration test requirements
# - Performance benchmarks to maintain
# - Feature flag test scenariosMonitor Integration Health While Coding:
# 3. REQUIREMENTS TRACING (Mid-development checkpoint)
@qa *trace {brownfield-story}
# Maps: New requirements + existing functionality preservation
# Output: docs/qa/assessments/{epic}.{story}-trace-{YYYYMMDD}.md
# Brownfield Focus:
# - Existing features that must still work
# - New/old feature interactions
# - API contract preservation
# - Missing regression test coverage
# 4. NFR VALIDATION (Before considering "done")
@qa *nfr {brownfield-story}
# Validates: Performance, security, reliability unchanged
# Output: docs/qa/assessments/{epic}.{story}-nfr-{YYYYMMDD}.md
# Brownfield Focus:
# - Performance regression detection
# - Security implications of integrations
# - Backward compatibility validation
# - Load/stress on legacy componentsComprehensive Brownfield Review:
# 5. FULL REVIEW (When development complete)
@qa *review {brownfield-story}
# Performs: Deep analysis + active refactoring
# Outputs:
# - QA Results in story file
# - Gate file: docs/qa/gates/{epic}.{story}-{slug}.ymlThe review specifically analyzes:
- API Breaking Changes: Validates all existing contracts maintained
- Data Migration Safety: Checks transformation logic and rollback procedures
- Performance Regression: Compares against baseline metrics
- Integration Points: Validates all touchpoints with legacy code
- Feature Flag Logic: Ensures proper toggle behavior
- Dependency Impacts: Maps affected downstream systems
# 6. GATE STATUS UPDATE (After addressing issues)
@qa *gate {brownfield-story}
# Updates: Quality gate decision after fixes
# Output: docs/qa/gates/{epic}.{story}-{slug}.yml
# Brownfield Considerations:
# - May WAIVE certain legacy code issues
# - Documents technical debt acceptance
# - Tracks migration progressThe Test Architect uses enhanced risk scoring for brownfield:
| Risk Category | Brownfield Factors | Impact on Gate |
|---|---|---|
| Regression Risk | Number of integration points × Age of code | Score ≥9 = FAIL |
| Data Risk | Migration complexity × Data volume | Score ≥6 = CONCERNS |
| Performance Risk | Current load × Added complexity | Score ≥6 = CONCERNS |
| Compatibility Risk | API consumers × Contract changes | Score ≥9 = FAIL |
Quinn enforces additional standards for brownfield:
- Regression Test Coverage: Every touched legacy module needs tests
- Performance Baselines: Must maintain or improve current metrics
- Rollback Procedures: Every change needs a rollback plan
- Feature Flags: All risky changes behind toggles
- Integration Tests: Cover all legacy touchpoints
- Contract Tests: Validate API compatibility
- Data Validation: Migration correctness checks
| Scenario | Commands to Run | Order | Why Critical |
|---|---|---|---|
| Adding Feature to Legacy Code | *risk → *design → *trace → *review |
Sequential | Map all dependencies first |
| API Modification | *risk → *design → *nfr → *review |
Sequential | Prevent breaking consumers |
| Performance-Critical Change | *nfr early and often → *review |
Continuous | Catch degradation immediately |
| Data Migration | *risk → *design → *trace → *review → *gate |
Full cycle | Ensure data integrity |
| Bug Fix in Complex System | *risk → *trace → *review |
Focused | Prevent side effects |
Scenario-Specific Guidance:
-
Legacy Code Modernization
- Start with
*riskto map all dependencies - Use
*designto plan strangler fig approach - Run
*tracefrequently to ensure nothing breaks *reviewwith focus on gradual migration
- Start with
-
Adding Features to Monolith
*riskidentifies integration complexity*designplans isolation strategies*nfrmonitors performance impact*reviewvalidates no monolith degradation
-
Microservice Extraction
*riskmaps service boundaries*traceensures functionality preservation*nfrvalidates network overhead acceptable*gatedocuments accepted trade-offs
-
Database Schema Changes
*riskassesses migration complexity*designplans backward-compatible approach*tracemaps all affected queries*reviewvalidates migration safety
Document:
- What changed and why
- Migration instructions
- New patterns introduced
- Deprecation notices
- Document existing system
- Create brownfield PRD focusing on integration
- Test Architect Early Involvement:
- Run
@qa *riskon draft stories to identify integration risks - Use
@qa *designto plan regression test strategy
- Run
- Architecture emphasizes compatibility
- Stories include integration tasks with test requirements
- During Development:
- Developer runs
@qa *traceto verify coverage - Use
@qa *nfrto monitor performance impact
- Developer runs
- Review Stage:
@qa *reviewvalidates integration safety
- Extensive documentation phase
- PRD includes migration strategy
- Test Architect Strategy Planning:
@qa *riskassesses modernization complexity@qa *designplans parallel testing approach
- Architecture plans gradual transition (strangler fig pattern)
- Stories follow incremental modernization with:
- Regression tests for untouched legacy code
- Integration tests for new/old boundaries
- Performance benchmarks at each stage
- Continuous Validation: Run
@qa *traceafter each increment - Gate Management: Use
@qa *gateto track technical debt acceptance
- Document relevant subsystems
- Use
create-brownfield-storyfor focused fix - Test Architect Risk Assessment: Run
@qa *riskto identify side effect potential - Include regression test requirements from
@qa *designoutput - During Fix: Use
@qa *traceto map affected functionality - Before Commit: Run
@qa *reviewfor comprehensive validation - Test Architect validates no side effects using:
- Risk profiling for side effect analysis (probability × impact scoring)
- Trace matrix to ensure fix doesn't break related features
- NFR assessment to verify performance/security unchanged
- Gate decision documents fix safety
- Document existing API patterns
- PRD defines integration requirements
- Test Architect Contract Analysis:
@qa *riskidentifies breaking change potential@qa *designcreates contract test strategy
- Architecture ensures consistent patterns
- API Testing Focus:
- Contract tests for backward compatibility
- Integration tests for new endpoints
- Performance tests for added load
- Stories include API documentation updates
- Validation Checkpoints:
@qa *tracemaps all API consumers@qa *nfrvalidates response times@qa *reviewensures no breaking changes
- Gate Decision: Document any accepted breaking changes with migration path
Solution: Re-run document-project with more specific paths to critical files
Solution: Update generated documentation with your specific conventions before planning phase
Solution: Use create-brownfield-story instead of full workflow
Solution: Provide more context during PRD creation, specifically highlighting integration systems
# Document existing project
@architect *document-project
# Create enhancement PRD
@pm *create-brownfield-prd
# Create architecture with integration focus
@architect *create-brownfield-architecture
# Quick epic creation
@pm *create-brownfield-epic
# Single story creation
@pm *create-brownfield-storyNote: Short forms shown below. Full commands: *risk-profile, *test-design, *nfr-assess, *trace-requirements
# BEFORE DEVELOPMENT (Planning)
@qa *risk {story} # Assess regression & integration risks
@qa *design {story} # Plan regression + new feature tests
# DURING DEVELOPMENT (Validation)
@qa *trace {story} # Verify coverage of old + new
@qa *nfr {story} # Check performance degradation
# AFTER DEVELOPMENT (Review)
@qa *review {story} # Deep integration analysis
@qa *gate {story} # Update quality decisionDo you have a large codebase or monorepo?
├─ Yes → PRD-First Approach
│ └─ Create PRD → Document only affected areas
└─ No → Is the codebase well-known to you?
├─ Yes → PRD-First Approach
└─ No → Document-First Approach
Is this a major enhancement affecting multiple systems?
├─ Yes → Full Brownfield Workflow
│ └─ ALWAYS run Test Architect *risk + *design first
└─ No → Is this more than a simple bug fix?
├─ Yes → *create-brownfield-epic
│ └─ Run Test Architect *risk for integration points
└─ No → *create-brownfield-story
└─ Still run *risk if touching critical paths
Does the change touch legacy code?
├─ Yes → Test Architect is MANDATORY
│ ├─ *risk → Identify regression potential
│ ├─ *design → Plan test coverage
│ └─ *review → Validate no breakage
└─ No → Test Architect is RECOMMENDED
└─ *review → Ensure quality standards
Brownfield development with BMad Method provides structure and safety when modifying existing systems. The Test Architect becomes your critical safety net, using risk assessment, regression testing, and continuous validation to ensure new changes don't destabilize existing functionality.
The Brownfield Success Formula:
- Document First - Understand what exists
- Assess Risk Early - Use Test Architect
*riskbefore coding - Plan Test Strategy - Design regression + new feature tests
- Validate Continuously - Check integration health during development
- Review Comprehensively - Deep analysis before committing
- Gate Decisively - Document quality decisions
Remember: In brownfield, the Test Architect isn't optional - it's your insurance policy against breaking production.