bmad-method 4.14.0 → 4.15.0

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.
@@ -1333,385 +1333,313 @@ Generate comprehensive documentation for existing projects optimized for AI deve
1333
1333
 
1334
1334
  ### 1. Initial Project Analysis
1335
1335
 
1336
- [[LLM: Begin by conducting a comprehensive analysis of the existing project. Use available tools to:
1336
+ [[LLM: First, check if a PRD or requirements document exists in context. If yes, use it to focus your documentation efforts on relevant areas only.
1337
1337
 
1338
- 1. **Project Structure Discovery**: Examine the root directory structure, identify main folders, and understand the overall organization
1339
- 2. **Technology Stack Identification**: Look for package.json, requirements.txt, Cargo.toml, pom.xml, etc. to identify languages, frameworks, and dependencies
1340
- 3. **Build System Analysis**: Find build scripts, CI/CD configurations, and development commands
1341
- 4. **Existing Documentation Review**: Check for README files, docs folders, and any existing documentation
1342
- 5. **Code Pattern Analysis**: Sample key files to understand coding patterns, naming conventions, and architectural approaches
1338
+ **IF PRD EXISTS**:
1343
1339
 
1344
- Ask the user these elicitation questions to better understand their needs:
1340
+ - Review the PRD to understand what enhancement/feature is planned
1341
+ - Identify which modules, services, or areas will be affected
1342
+ - Focus documentation ONLY on these relevant areas
1343
+ - Skip unrelated parts of the codebase to keep docs lean
1345
1344
 
1346
- - What is the primary purpose of this project?
1347
- - Are there any specific areas of the codebase that are particularly complex or important for agents to understand?
1348
- - What types of tasks do you expect AI agents to perform on this project? (e.g., bug fixes, feature additions, refactoring, testing)
1349
- - Are there any existing documentation standards or formats you prefer?
1350
- - What level of technical detail should the documentation target? (junior developers, senior developers, mixed team)
1351
- ]]
1352
-
1353
- ### 2. Core Documentation Generation
1354
-
1355
- [[LLM: Based on your analysis, generate the following core documentation files. Adapt the content and structure to match the specific project type and context you discovered:
1356
-
1357
- **Core Documents (always generate):**
1358
-
1359
- 1. **docs/index.md** - Master documentation index
1360
- 2. **docs/architecture/index.md** - Architecture documentation index
1361
- 3. **docs/architecture/coding-standards.md** - Coding conventions and style guidelines
1362
- 4. **docs/architecture/tech-stack.md** - Technology stack and version constraints
1363
- 5. **docs/architecture/unified-project-structure.md** - Project structure and organization
1364
- 6. **docs/architecture/testing-strategy.md** - Testing approaches and requirements
1345
+ **IF NO PRD EXISTS**:
1346
+ Ask the user:
1365
1347
 
1366
- **Backend Documents (generate for backend/full-stack projects):**
1348
+ "I notice you haven't provided a PRD or requirements document. To create more focused and useful documentation, I recommend one of these options:
1367
1349
 
1368
- 7. **docs/architecture/backend-architecture.md** - Backend service patterns and structure
1369
- 8. **docs/architecture/rest-api-spec.md** - API endpoint specifications
1370
- 9. **docs/architecture/data-models.md** - Data structures and validation rules
1371
- 10. **docs/architecture/database-schema.md** - Database design and relationships
1372
- 11. **docs/architecture/external-apis.md** - Third-party integrations
1350
+ 1. **Create a PRD first** - Would you like me to help create a brownfield PRD before documenting? This helps focus documentation on relevant areas.
1373
1351
 
1374
- **Frontend Documents (generate for frontend/full-stack projects):**
1352
+ 2. **Provide existing requirements** - Do you have a requirements document, epic, or feature description you can share?
1375
1353
 
1376
- 12. **docs/architecture/frontend-architecture.md** - Frontend patterns and structure
1377
- 13. **docs/architecture/components.md** - UI component specifications
1378
- 14. **docs/architecture/core-workflows.md** - User interaction flows
1379
- 15. **docs/architecture/ui-ux-spec.md** - UI/UX specifications and guidelines
1354
+ 3. **Describe the focus** - Can you briefly describe what enhancement or feature you're planning? For example:
1355
+ - 'Adding payment processing to the user service'
1356
+ - 'Refactoring the authentication module'
1357
+ - 'Integrating with a new third-party API'
1380
1358
 
1381
- **Additional Documents (generate if applicable):**
1359
+ 4. **Document everything** - Or should I proceed with comprehensive documentation of the entire codebase? (Note: This may create excessive documentation for large projects)
1382
1360
 
1383
- 16. **docs/prd.md** - Product requirements document (if not exists)
1384
- 17. **docs/architecture/deployment-guide.md** - Deployment and operations info
1385
- 18. **docs/architecture/security-considerations.md** - Security patterns and requirements
1386
- 19. **docs/architecture/performance-guidelines.md** - Performance optimization patterns
1361
+ Please let me know your preference, or I can proceed with full documentation if you prefer."
1387
1362
 
1388
- **Optional Enhancement Documents:**
1363
+ Based on their response:
1389
1364
 
1390
- 20. **docs/architecture/troubleshooting-guide.md** - Common issues and solutions
1391
- 21. **docs/architecture/changelog-conventions.md** - Change management practices
1392
- 22. **docs/architecture/code-review-checklist.md** - Review standards and practices
1365
+ - If they choose option 1-3: Use that context to focus documentation
1366
+ - If they choose option 4 or decline: Proceed with comprehensive analysis below
1393
1367
 
1394
- Present each document section by section, using the advanced elicitation task after each major section.]]
1368
+ Begin by conducting analysis of the existing project. Use available tools to:
1395
1369
 
1396
- ### 3. Document Structure Template
1397
-
1398
- [[LLM: Use this standardized structure for each documentation file, adapting content as needed:
1399
-
1400
- ```markdown
1401
- # {{Document Title}}
1402
-
1403
- ## Overview
1404
-
1405
- {{Brief description of what this document covers and why it's important for AI agents}}
1406
-
1407
- ## Quick Reference
1408
-
1409
- {{Key points, commands, or patterns that agents need most frequently}}
1410
-
1411
- ## Detailed Information
1412
-
1413
- {{Comprehensive information organized into logical sections}}
1414
-
1415
- ## Examples
1416
-
1417
- {{Concrete examples showing proper usage or implementation}}
1418
-
1419
- ## Common Patterns
1420
-
1421
- {{Recurring patterns agents should recognize and follow}}
1422
-
1423
- ## Things to Avoid
1424
-
1425
- {{Anti-patterns, deprecated approaches, or common mistakes}}
1426
-
1427
- ## Related Resources
1428
-
1429
- {{Links to other relevant documentation or external resources}}
1430
- ```
1370
+ 1. **Project Structure Discovery**: Examine the root directory structure, identify main folders, and understand the overall organization
1371
+ 2. **Technology Stack Identification**: Look for package.json, requirements.txt, Cargo.toml, pom.xml, etc. to identify languages, frameworks, and dependencies
1372
+ 3. **Build System Analysis**: Find build scripts, CI/CD configurations, and development commands
1373
+ 4. **Existing Documentation Review**: Check for README files, docs folders, and any existing documentation
1374
+ 5. **Code Pattern Analysis**: Sample key files to understand coding patterns, naming conventions, and architectural approaches
1431
1375
 
1432
- Each document should be:
1376
+ Ask the user these elicitation questions to better understand their needs:
1433
1377
 
1434
- - **Concrete and actionable** - Focus on what agents need to do, not just concepts
1435
- - **Pattern-focused** - Highlight recurring patterns agents can recognize and replicate
1436
- - **Example-rich** - Include specific code examples and real file references
1437
- - **Context-aware** - Reference actual project files, folders, and conventions
1438
- - **Assumption-free** - Don't assume agents know project history or implicit knowledge
1378
+ - What is the primary purpose of this project?
1379
+ - Are there any specific areas of the codebase that are particularly complex or important for agents to understand?
1380
+ - What types of tasks do you expect AI agents to perform on this project? (e.g., bug fixes, feature additions, refactoring, testing)
1381
+ - Are there any existing documentation standards or formats you prefer?
1382
+ - What level of technical detail should the documentation target? (junior developers, senior developers, mixed team)
1383
+ - Is there a specific feature or enhancement you're planning? (This helps focus documentation)
1439
1384
  ]]
1440
1385
 
1441
- ### 4. Content Guidelines for Each Document Type
1442
-
1443
- #### Core Architecture Documents
1444
-
1445
- ##### docs/architecture/index.md
1446
-
1447
- [[LLM: Create a comprehensive index of all architecture documentation:
1448
-
1449
- - List all architecture documents with brief descriptions
1450
- - Group documents by category (backend, frontend, shared)
1451
- - Include quick links to key sections
1452
- - Provide reading order recommendations for different use cases]]
1453
-
1454
- ##### docs/architecture/unified-project-structure.md
1455
-
1456
- [[LLM: Document the complete project structure:
1457
-
1458
- - Root-level directory structure with explanations
1459
- - Where each type of code belongs (backend, frontend, tests, etc.)
1460
- - File naming conventions and patterns
1461
- - Module/package organization
1462
- - Generated vs. source file locations
1463
- - Build output locations]]
1464
-
1465
- ##### docs/architecture/coding-standards.md
1466
-
1467
- [[LLM: Capture project-wide coding conventions:
1468
-
1469
- - Language-specific style guidelines
1470
- - Naming conventions (variables, functions, classes, files)
1471
- - Code organization within files
1472
- - Import/export patterns
1473
- - Comment and documentation standards
1474
- - Linting and formatting tool configurations
1475
- - Git commit message conventions]]
1476
-
1477
- ##### docs/architecture/tech-stack.md
1478
-
1479
- [[LLM: Document all technologies and versions:
1480
-
1481
- - Primary languages and versions
1482
- - Frameworks and major libraries with versions
1483
- - Development tools and their versions
1484
- - Database systems and versions
1485
- - External services and APIs used
1486
- - Browser/runtime requirements]]
1487
-
1488
- ##### docs/architecture/testing-strategy.md
1489
-
1490
- [[LLM: Define testing approaches and requirements:
1491
-
1492
- - Test file locations and naming conventions
1493
- - Unit testing patterns and frameworks
1494
- - Integration testing approaches
1495
- - E2E testing setup (if applicable)
1496
- - Test coverage requirements
1497
- - Mocking strategies
1498
- - Test data management]]
1386
+ ### 2. Deep Codebase Analysis
1499
1387
 
1500
- #### Backend Architecture Documents
1388
+ [[LLM: Before generating documentation, conduct extensive analysis of the existing codebase:
1501
1389
 
1502
- ##### docs/architecture/backend-architecture.md
1390
+ 1. **Explore Key Areas**:
1391
+ - Entry points (main files, index files, app initializers)
1392
+ - Configuration files and environment setup
1393
+ - Package dependencies and versions
1394
+ - Build and deployment configurations
1395
+ - Test suites and coverage
1503
1396
 
1504
- [[LLM: Document backend service structure:
1397
+ 2. **Ask Clarifying Questions**:
1398
+ - "I see you're using [technology X]. Are there any custom patterns or conventions I should document?"
1399
+ - "What are the most critical/complex parts of this system that developers struggle with?"
1400
+ - "Are there any undocumented 'tribal knowledge' areas I should capture?"
1401
+ - "What technical debt or known issues should I document?"
1402
+ - "Which parts of the codebase change most frequently?"
1505
1403
 
1506
- - Service layer organization
1507
- - Controller/route patterns
1508
- - Middleware architecture
1509
- - Authentication/authorization patterns
1510
- - Request/response flow
1511
- - Background job processing
1512
- - Service communication patterns]]
1404
+ 3. **Map the Reality**:
1405
+ - Identify ACTUAL patterns used (not theoretical best practices)
1406
+ - Find where key business logic lives
1407
+ - Locate integration points and external dependencies
1408
+ - Document workarounds and technical debt
1409
+ - Note areas that differ from standard patterns
1513
1410
 
1514
- ##### docs/architecture/rest-api-spec.md
1411
+ **IF PRD PROVIDED**: Also analyze what would need to change for the enhancement]]
1515
1412
 
1516
- [[LLM: Specify all API endpoints:
1413
+ ### 3. Core Documentation Generation
1517
1414
 
1518
- - Base URL and versioning strategy
1519
- - Authentication methods
1520
- - Common headers and parameters
1521
- - Each endpoint with:
1522
- - HTTP method and path
1523
- - Request parameters/body
1524
- - Response format and status codes
1525
- - Error responses
1526
- - Rate limiting and quotas]]
1415
+ [[LLM: Generate a comprehensive BROWNFIELD architecture document that reflects the ACTUAL state of the codebase.
1527
1416
 
1528
- ##### docs/architecture/data-models.md
1417
+ **CRITICAL**: This is NOT an aspirational architecture document. Document what EXISTS, including:
1418
+ - Technical debt and workarounds
1419
+ - Inconsistent patterns between different parts
1420
+ - Legacy code that can't be changed
1421
+ - Integration constraints
1422
+ - Performance bottlenecks
1529
1423
 
1530
- [[LLM: Define data structures and validation:
1424
+ **Document Structure**:
1531
1425
 
1532
- - Core business entities
1533
- - Data validation rules
1534
- - Relationships between entities
1535
- - Computed fields and derivations
1536
- - Data transformation patterns
1537
- - Serialization formats]]
1426
+ # [Project Name] Brownfield Architecture Document
1538
1427
 
1539
- ##### docs/architecture/database-schema.md
1540
-
1541
- [[LLM: Document database design:
1542
-
1543
- - Database type and version
1544
- - Table/collection structures
1545
- - Indexes and constraints
1546
- - Relationships and foreign keys
1547
- - Migration patterns
1548
- - Seed data requirements
1549
- - Backup and recovery procedures]]
1550
-
1551
- ##### docs/architecture/external-apis.md
1552
-
1553
- [[LLM: Document third-party integrations:
1554
-
1555
- - List of external services used
1556
- - Authentication methods for each
1557
- - API endpoints and usage patterns
1558
- - Rate limits and quotas
1559
- - Error handling strategies
1560
- - Webhook configurations
1561
- - Data synchronization patterns]]
1428
+ ## Introduction
1429
+ This document captures the CURRENT STATE of the [Project Name] codebase, including technical debt, workarounds, and real-world patterns. It serves as a reference for AI agents working on enhancements.
1562
1430
 
1563
- #### Frontend Architecture Documents
1431
+ ### Document Scope
1432
+ [If PRD provided: "Focused on areas relevant to: {enhancement description}"]
1433
+ [If no PRD: "Comprehensive documentation of entire system"]
1564
1434
 
1565
- ##### docs/architecture/frontend-architecture.md
1435
+ ### Change Log
1436
+ | Date | Version | Description | Author |
1437
+ |------|---------|-------------|--------|
1438
+ | [Date] | 1.0 | Initial brownfield analysis | [Analyst] |
1566
1439
 
1567
- [[LLM: Document frontend application structure:
1440
+ ## Quick Reference - Key Files and Entry Points
1568
1441
 
1569
- - Component hierarchy and organization
1570
- - State management patterns
1571
- - Routing architecture
1572
- - Data fetching patterns
1573
- - Authentication flow
1574
- - Error boundary strategies
1575
- - Performance optimization patterns]]
1442
+ ### Critical Files for Understanding the System
1443
+ - **Main Entry**: `src/index.js` (or actual entry point)
1444
+ - **Configuration**: `config/app.config.js`, `.env.example`
1445
+ - **Core Business Logic**: `src/services/`, `src/domain/`
1446
+ - **API Definitions**: `src/routes/` or link to OpenAPI spec
1447
+ - **Database Models**: `src/models/` or link to schema files
1448
+ - **Key Algorithms**: [List specific files with complex logic]
1576
1449
 
1577
- ##### docs/architecture/components.md
1450
+ ### If PRD Provided - Enhancement Impact Areas
1451
+ [Highlight which files/modules will be affected by the planned enhancement]
1578
1452
 
1579
- [[LLM: Specify UI components:
1453
+ ## High Level Architecture
1580
1454
 
1581
- - Component library/design system used
1582
- - Custom component specifications
1583
- - Props and state for each component
1584
- - Component composition patterns
1585
- - Styling approaches
1586
- - Accessibility requirements
1587
- - Component testing patterns]]
1455
+ ### Technical Summary
1456
+ [Real assessment of architecture - mention if it's well-structured or has issues]
1588
1457
 
1589
- ##### docs/architecture/core-workflows.md
1458
+ ### Actual Tech Stack (from package.json/requirements.txt)
1459
+ | Category | Technology | Version | Notes |
1460
+ |----------|------------|---------|--------|
1461
+ | Runtime | Node.js | 16.x | [Any constraints] |
1462
+ | Framework | Express | 4.18.2 | [Custom middleware?] |
1463
+ | Database | PostgreSQL | 13 | [Connection pooling setup] |
1464
+ | [etc...] |
1590
1465
 
1591
- [[LLM: Document user interaction flows:
1466
+ ### Repository Structure Reality Check
1467
+ - Type: [Monorepo/Polyrepo/Hybrid]
1468
+ - Package Manager: [npm/yarn/pnpm]
1469
+ - Notable: [Any unusual structure decisions]
1592
1470
 
1593
- - Major user journeys
1594
- - Screen flow diagrams
1595
- - Form handling patterns
1596
- - Navigation patterns
1597
- - Data flow through workflows
1598
- - Error states and recovery
1599
- - Loading and transition states]]
1471
+ ## Source Tree and Module Organization
1600
1472
 
1601
- ##### docs/architecture/ui-ux-spec.md
1473
+ ### Project Structure (Actual)
1474
+ ```
1475
+ project-root/
1476
+ ├── src/
1477
+ │ ├── controllers/ # HTTP request handlers
1478
+ │ ├── services/ # Business logic (NOTE: inconsistent patterns between user and payment services)
1479
+ │ ├── models/ # Database models (Sequelize)
1480
+ │ ├── utils/ # Mixed bag - needs refactoring
1481
+ │ └── legacy/ # DO NOT MODIFY - old payment system still in use
1482
+ ├── tests/ # Jest tests (60% coverage)
1483
+ ├── scripts/ # Build and deployment scripts
1484
+ └── config/ # Environment configs
1485
+ ```
1602
1486
 
1603
- [[LLM: Define UI/UX guidelines:
1487
+ ### Key Modules and Their Purpose
1488
+ - **User Management**: `src/services/userService.js` - Handles all user operations
1489
+ - **Authentication**: `src/middleware/auth.js` - JWT-based, custom implementation
1490
+ - **Payment Processing**: `src/legacy/payment.js` - CRITICAL: Do not refactor, tightly coupled
1491
+ - **[List other key modules with their actual files]**
1604
1492
 
1605
- - Design system specifications
1606
- - Color palette and typography
1607
- - Spacing and layout grids
1608
- - Responsive breakpoints
1609
- - Animation and transition guidelines
1610
- - Accessibility standards
1611
- - Browser compatibility requirements]]
1493
+ ## Data Models and APIs
1612
1494
 
1613
- ### 5. Adaptive Content Strategy
1495
+ ### Data Models
1496
+ Instead of duplicating, reference actual model files:
1497
+ - **User Model**: See `src/models/User.js`
1498
+ - **Order Model**: See `src/models/Order.js`
1499
+ - **Related Types**: TypeScript definitions in `src/types/`
1614
1500
 
1615
- [[LLM: Adapt your documentation approach based on project characteristics:
1501
+ ### API Specifications
1502
+ - **OpenAPI Spec**: `docs/api/openapi.yaml` (if exists)
1503
+ - **Postman Collection**: `docs/api/postman-collection.json`
1504
+ - **Manual Endpoints**: [List any undocumented endpoints discovered]
1616
1505
 
1617
- **For Web Applications:**
1506
+ ## Technical Debt and Known Issues
1618
1507
 
1619
- - Focus on component patterns, routing, state management
1620
- - Include build processes, asset handling, and deployment
1621
- - Cover API integration patterns and data fetching
1508
+ ### Critical Technical Debt
1509
+ 1. **Payment Service**: Legacy code in `src/legacy/payment.js` - tightly coupled, no tests
1510
+ 2. **User Service**: Different pattern than other services, uses callbacks instead of promises
1511
+ 3. **Database Migrations**: Manually tracked, no proper migration tool
1512
+ 4. **[Other significant debt]**
1622
1513
 
1623
- **For Backend Services:**
1514
+ ### Workarounds and Gotchas
1515
+ - **Environment Variables**: Must set `NODE_ENV=production` even for staging (historical reason)
1516
+ - **Database Connections**: Connection pool hardcoded to 10, changing breaks payment service
1517
+ - **[Other workarounds developers need to know]**
1624
1518
 
1625
- - Emphasize service architecture, data models, and API design
1626
- - Include database interaction patterns and migration strategies
1627
- - Cover authentication, authorization, and security patterns
1519
+ ## Integration Points and External Dependencies
1628
1520
 
1629
- **For CLI Tools:**
1521
+ ### External Services
1522
+ | Service | Purpose | Integration Type | Key Files |
1523
+ |---------|---------|------------------|-----------|
1524
+ | Stripe | Payments | REST API | `src/integrations/stripe/` |
1525
+ | SendGrid | Emails | SDK | `src/services/emailService.js` |
1526
+ | [etc...] |
1630
1527
 
1631
- - Focus on command structure, argument parsing, and output formatting
1632
- - Include plugin/extension patterns if applicable
1633
- - Cover configuration file handling and user interaction patterns
1528
+ ### Internal Integration Points
1529
+ - **Frontend Communication**: REST API on port 3000, expects specific headers
1530
+ - **Background Jobs**: Redis queue, see `src/workers/`
1531
+ - **[Other integrations]**
1634
1532
 
1635
- **For Libraries/Frameworks:**
1533
+ ## Development and Deployment
1636
1534
 
1637
- - Emphasize public API design and usage patterns
1638
- - Include extension points and customization approaches
1639
- - Cover versioning, compatibility, and migration strategies
1535
+ ### Local Development Setup
1536
+ 1. Actual steps that work (not ideal steps)
1537
+ 2. Known issues with setup
1538
+ 3. Required environment variables (see `.env.example`)
1640
1539
 
1641
- **For Mobile Applications:**
1540
+ ### Build and Deployment Process
1541
+ - **Build Command**: `npm run build` (webpack config in `webpack.config.js`)
1542
+ - **Deployment**: Manual deployment via `scripts/deploy.sh`
1543
+ - **Environments**: Dev, Staging, Prod (see `config/environments/`)
1642
1544
 
1643
- - Focus on platform-specific patterns and navigation
1644
- - Include state management and data persistence approaches
1645
- - Cover platform integration and native feature usage
1545
+ ## Testing Reality
1646
1546
 
1647
- **For Data Science/ML Projects:**
1547
+ ### Current Test Coverage
1548
+ - Unit Tests: 60% coverage (Jest)
1549
+ - Integration Tests: Minimal, in `tests/integration/`
1550
+ - E2E Tests: None
1551
+ - Manual Testing: Primary QA method
1648
1552
 
1649
- - Emphasize data pipeline patterns and model organization
1650
- - Include experiment tracking and reproducibility approaches
1651
- - Cover data validation and model deployment patterns
1652
- ]]
1553
+ ### Running Tests
1554
+ ```bash
1555
+ npm test # Runs unit tests
1556
+ npm run test:integration # Runs integration tests (requires local DB)
1557
+ ```
1653
1558
 
1654
- ### 6. Quality Assurance
1559
+ ## If Enhancement PRD Provided - Impact Analysis
1655
1560
 
1656
- [[LLM: Before completing each document:
1561
+ ### Files That Will Need Modification
1562
+ Based on the enhancement requirements, these files will be affected:
1563
+ - `src/services/userService.js` - Add new user fields
1564
+ - `src/models/User.js` - Update schema
1565
+ - `src/routes/userRoutes.js` - New endpoints
1566
+ - [etc...]
1657
1567
 
1658
- 1. **Accuracy Check**: Verify all file paths, commands, and code examples work
1659
- 2. **Completeness Review**: Ensure the document covers the most important patterns an agent would encounter
1660
- 3. **Clarity Assessment**: Check that explanations are clear and actionable
1661
- 4. **Consistency Verification**: Ensure terminology and patterns align across all documents
1662
- 5. **Agent Perspective**: Review from the viewpoint of an AI agent that needs to contribute to this project
1568
+ ### New Files/Modules Needed
1569
+ - `src/services/newFeatureService.js` - New business logic
1570
+ - `src/models/NewFeature.js` - New data model
1571
+ - [etc...]
1663
1572
 
1664
- Ask the user to review each completed document and use the advanced elicitation task to refine based on their feedback.]]
1573
+ ### Integration Considerations
1574
+ - Will need to integrate with existing auth middleware
1575
+ - Must follow existing response format in `src/utils/responseFormatter.js`
1576
+ - [Other integration points]
1665
1577
 
1666
- ### 7. Final Integration
1578
+ ## Appendix - Useful Commands and Scripts
1667
1579
 
1668
- [[LLM: After all documents are completed:
1580
+ ### Frequently Used Commands
1581
+ ```bash
1582
+ npm run dev # Start development server
1583
+ npm run build # Production build
1584
+ npm run migrate # Run database migrations
1585
+ npm run seed # Seed test data
1586
+ ```
1669
1587
 
1670
- 1. Ensure all documents are created in the proper BMAD-expected locations:
1588
+ ### Debugging and Troubleshooting
1589
+ - **Logs**: Check `logs/app.log` for application logs
1590
+ - **Debug Mode**: Set `DEBUG=app:*` for verbose logging
1591
+ - **Common Issues**: See `docs/troubleshooting.md`]]
1671
1592
 
1672
- - Core docs in `docs/` (index.md, prd.md)
1673
- - Architecture shards in `docs/architecture/` subdirectory
1674
- - Create the `docs/architecture/` directory if it doesn't exist
1593
+ ### 4. Document Delivery
1675
1594
 
1676
- 2. Create/update the master index documents:
1595
+ [[LLM: After generating the complete architecture document:
1677
1596
 
1678
- - Update `docs/index.md` to reference all documentation
1679
- - Create `docs/architecture/index.md` listing all architecture shards
1597
+ 1. **In Web UI (Gemini, ChatGPT, Claude)**:
1598
+ - Present the entire document in one response (or multiple if too long)
1599
+ - Tell user to copy and save as `docs/brownfield-architecture.md` or `docs/project-architecture.md`
1600
+ - Mention it can be sharded later in IDE if needed
1680
1601
 
1681
- 3. Verify document cross-references:
1602
+ 2. **In IDE Environment**:
1603
+ - Create the document as `docs/brownfield-architecture.md`
1604
+ - Inform user this single document contains all architectural information
1605
+ - Can be sharded later using PO agent if desired
1682
1606
 
1683
- - Ensure all documents link to related documentation
1684
- - Check that file paths match the actual project structure
1685
- - Validate that examples reference real files in the project
1607
+ The document should be comprehensive enough that future agents can understand:
1608
+ - The actual state of the system (not idealized)
1609
+ - Where to find key files and logic
1610
+ - What technical debt exists
1611
+ - What constraints must be respected
1612
+ - If PRD provided: What needs to change for the enhancement]]
1686
1613
 
1687
- 4. Provide maintenance guidance:
1614
+ ### 5. Quality Assurance
1688
1615
 
1689
- - Document update triggers (when to update each doc)
1690
- - Create a simple checklist for keeping docs current
1691
- - Suggest automated validation approaches
1616
+ [[LLM: Before finalizing the document:
1692
1617
 
1693
- 5. Summary report including:
1694
- - List of all documents created with their paths
1695
- - Any gaps or areas needing human review
1696
- - Recommendations for project-specific additions
1697
- - Next steps for maintaining documentation accuracy
1618
+ 1. **Accuracy Check**: Verify all technical details match the actual codebase
1619
+ 2. **Completeness Review**: Ensure all major system components are documented
1620
+ 3. **Focus Validation**: If user provided scope, verify relevant areas are emphasized
1621
+ 4. **Clarity Assessment**: Check that explanations are clear for AI agents
1622
+ 5. **Navigation**: Ensure document has clear section structure for easy reference
1698
1623
 
1699
- Present a summary of what was created and ask if any additional documentation would be helpful for AI agents working on this specific project.]]
1624
+ Apply the advanced elicitation task after major sections to refine based on user feedback.]]
1700
1625
 
1701
1626
  ## Success Criteria
1702
1627
 
1703
- - Documentation enables AI agents to understand project context without additional explanation
1704
- - All major architectural patterns and coding conventions are captured
1705
- - Examples reference actual project files and demonstrate real usage
1706
- - Documentation is structured consistently and easy to navigate
1707
- - Content is actionable and focuses on what agents need to do, not just understand
1628
+ - Single comprehensive brownfield architecture document created
1629
+ - Document reflects REALITY including technical debt and workarounds
1630
+ - Key files and modules are referenced with actual paths
1631
+ - Models/APIs reference source files rather than duplicating content
1632
+ - If PRD provided: Clear impact analysis showing what needs to change
1633
+ - Document enables AI agents to navigate and understand the actual codebase
1634
+ - Technical constraints and "gotchas" are clearly documented
1708
1635
 
1709
1636
  ## Notes
1710
1637
 
1711
- - This task is designed to work with any project type, language, or framework
1712
- - The documentation should reflect the project as it actually is, not as it should be
1713
- - Focus on patterns that agents can recognize and replicate consistently
1714
- - Include both positive examples (what to do) and negative examples (what to avoid)
1638
+ - This task creates ONE document that captures the TRUE state of the system
1639
+ - References actual files rather than duplicating content when possible
1640
+ - Documents technical debt, workarounds, and constraints honestly
1641
+ - For brownfield projects with PRD: Provides clear enhancement impact analysis
1642
+ - The goal is PRACTICAL documentation for AI agents doing real work
1715
1643
  ==================== END: tasks#document-project ====================
1716
1644
 
1717
1645
  ==================== START: tasks#create-next-story ====================
@@ -8874,10 +8802,16 @@ This architecture enables seamless operation across environments while maintaini
8874
8802
 
8875
8803
  ## Complete Development Workflow
8876
8804
 
8877
- ### Planning Phase (Web UI Recommended)
8805
+ ### Planning Phase (Web UI Recommended - Especially Gemini!)
8806
+
8807
+ **Ideal for cost efficiency with Gemini's massive context:**
8878
8808
 
8879
- **Ideal for cost efficiency, especially with Gemini:**
8809
+ **For Brownfield Projects - Start Here!**:
8810
+ 1. **Upload entire project to Gemini Web** (GitHub URL, files, or zip)
8811
+ 2. **Document existing system**: `/analyst` → `*document-project`
8812
+ 3. **Creates comprehensive docs** from entire codebase analysis
8880
8813
 
8814
+ **For All Projects**:
8881
8815
  1. **Optional Analysis**: `/analyst` - Market research, competitive analysis
8882
8816
  2. **Project Brief**: Create foundation document (Analyst or user)
8883
8817
  3. **PRD Creation**: `/pm create-doc prd` - Comprehensive product requirements
@@ -8981,25 +8915,70 @@ Each status change requires user verification and approval before proceeding.
8981
8915
 
8982
8916
  #### Brownfield Enhancement (Existing Projects)
8983
8917
 
8984
- **Key Concept**: Brownfield development requires generating good documentation for agents to understand your existing project.
8985
-
8986
- **Recommended Approach**:
8987
- 1. **Analysis Phase**: Use Gemini Web or AI Studio with their 1M+ context windows
8988
- 2. **Document Generation**: Ask Architect agent to analyze your project and run `document-project` task
8989
- 3. **PRD Creation**: Even brownfield projects typically need a PRD unless:
8990
- - Very small, focused changes
8991
- - Using `brownfield-create-epic` for single epic without full PRD
8992
- 4. **Architecture Assessment**: Use brownfield-specific templates for complex enhancements
8993
-
8994
- **Brownfield Templates Available**:
8995
- - `brownfield-prd-tmpl.md`: For substantial enhancements requiring multiple stories
8996
- - `brownfield-architecture-tmpl.md`: For complex changes impacting system architecture
8997
- - Both templates emphasize compatibility and integration with existing systems
8998
-
8999
- **When to Skip PRD**:
9000
- - For focused, single-epic work, use `brownfield-create-epic` task with detailed guidance
9001
- - For one-off stories without larger context
9002
- - Note: These tasks will evolve to require some documentation (potentially from `document-project`)
8918
+ **Key Concept**: Brownfield development requires comprehensive documentation of your existing project for AI agents to understand context, patterns, and constraints.
8919
+
8920
+ **Complete Brownfield Workflow Options**:
8921
+
8922
+ **Option 1: PRD-First (Recommended for Large Codebases/Monorepos)**:
8923
+ 1. **Upload project to Gemini Web** (GitHub URL, files, or zip)
8924
+ 2. **Create PRD first**: `@pm` → `*create-doc brownfield-prd`
8925
+ 3. **Focused documentation**: `@analyst` → `*document-project`
8926
+ - Analyst asks for focus if no PRD provided
8927
+ - Choose "single document" format for Web UI
8928
+ - Uses PRD to document ONLY relevant areas
8929
+ - Creates one comprehensive markdown file
8930
+ - Avoids bloating docs with unused code
8931
+
8932
+ **Option 2: Document-First (Good for Smaller Projects)**:
8933
+ 1. **Upload project to Gemini Web**
8934
+ 2. **Document everything**: `@analyst` `*document-project`
8935
+ 3. **Then create PRD**: `@pm` `*create-doc brownfield-prd`
8936
+ - More thorough but can create excessive documentation
8937
+
8938
+ 2. **Requirements Gathering**:
8939
+ - **Brownfield PRD**: Use PM agent with `brownfield-prd-tmpl`
8940
+ - **Analyzes**: Existing system, constraints, integration points
8941
+ - **Defines**: Enhancement scope, compatibility requirements, risk assessment
8942
+ - **Creates**: Epic and story structure for changes
8943
+
8944
+ 3. **Architecture Planning**:
8945
+ - **Brownfield Architecture**: Use Architect agent with `brownfield-architecture-tmpl`
8946
+ - **Integration Strategy**: How new features integrate with existing system
8947
+ - **Migration Planning**: Gradual rollout and backwards compatibility
8948
+ - **Risk Mitigation**: Addressing potential breaking changes
8949
+
8950
+ **Brownfield-Specific Resources**:
8951
+
8952
+ **Templates**:
8953
+ - `brownfield-prd-tmpl.md`: Comprehensive enhancement planning with existing system analysis
8954
+ - `brownfield-architecture-tmpl.md`: Integration-focused architecture for existing systems
8955
+
8956
+ **Tasks**:
8957
+ - `document-project`: Generates comprehensive documentation from existing codebase
8958
+ - `brownfield-create-epic`: Creates single epic for focused enhancements (when full PRD is overkill)
8959
+ - `brownfield-create-story`: Creates individual story for small, isolated changes
8960
+
8961
+ **When to Use Each Approach**:
8962
+
8963
+ **Full Brownfield Workflow** (Recommended for):
8964
+ - Major feature additions
8965
+ - System modernization
8966
+ - Complex integrations
8967
+ - Multiple related changes
8968
+
8969
+ **Quick Epic/Story Creation** (Use when):
8970
+ - Single, focused enhancement
8971
+ - Isolated bug fixes
8972
+ - Small feature additions
8973
+ - Well-documented existing system
8974
+
8975
+ **Critical Success Factors**:
8976
+ 1. **Documentation First**: Always run `document-project` if docs are outdated/missing
8977
+ 2. **Context Matters**: Provide agents access to relevant code sections
8978
+ 3. **Integration Focus**: Emphasize compatibility and non-breaking changes
8979
+ 4. **Incremental Approach**: Plan for gradual rollout and testing
8980
+
8981
+ **For detailed guide**: See `docs/working-in-the-brownfield.md`
9003
8982
 
9004
8983
  ## Document Creation Best Practices
9005
8984