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.
@@ -811,10 +811,16 @@ This architecture enables seamless operation across environments while maintaini
811
811
 
812
812
  ## Complete Development Workflow
813
813
 
814
- ### Planning Phase (Web UI Recommended)
814
+ ### Planning Phase (Web UI Recommended - Especially Gemini!)
815
815
 
816
- **Ideal for cost efficiency, especially with Gemini:**
816
+ **Ideal for cost efficiency with Gemini's massive context:**
817
817
 
818
+ **For Brownfield Projects - Start Here!**:
819
+ 1. **Upload entire project to Gemini Web** (GitHub URL, files, or zip)
820
+ 2. **Document existing system**: `/analyst` → `*document-project`
821
+ 3. **Creates comprehensive docs** from entire codebase analysis
822
+
823
+ **For All Projects**:
818
824
  1. **Optional Analysis**: `/analyst` - Market research, competitive analysis
819
825
  2. **Project Brief**: Create foundation document (Analyst or user)
820
826
  3. **PRD Creation**: `/pm create-doc prd` - Comprehensive product requirements
@@ -918,25 +924,70 @@ Each status change requires user verification and approval before proceeding.
918
924
 
919
925
  #### Brownfield Enhancement (Existing Projects)
920
926
 
921
- **Key Concept**: Brownfield development requires generating good documentation for agents to understand your existing project.
922
-
923
- **Recommended Approach**:
924
- 1. **Analysis Phase**: Use Gemini Web or AI Studio with their 1M+ context windows
925
- 2. **Document Generation**: Ask Architect agent to analyze your project and run `document-project` task
926
- 3. **PRD Creation**: Even brownfield projects typically need a PRD unless:
927
- - Very small, focused changes
928
- - Using `brownfield-create-epic` for single epic without full PRD
929
- 4. **Architecture Assessment**: Use brownfield-specific templates for complex enhancements
930
-
931
- **Brownfield Templates Available**:
932
- - `brownfield-prd-tmpl.md`: For substantial enhancements requiring multiple stories
933
- - `brownfield-architecture-tmpl.md`: For complex changes impacting system architecture
934
- - Both templates emphasize compatibility and integration with existing systems
935
-
936
- **When to Skip PRD**:
937
- - For focused, single-epic work, use `brownfield-create-epic` task with detailed guidance
938
- - For one-off stories without larger context
939
- - Note: These tasks will evolve to require some documentation (potentially from `document-project`)
927
+ **Key Concept**: Brownfield development requires comprehensive documentation of your existing project for AI agents to understand context, patterns, and constraints.
928
+
929
+ **Complete Brownfield Workflow Options**:
930
+
931
+ **Option 1: PRD-First (Recommended for Large Codebases/Monorepos)**:
932
+ 1. **Upload project to Gemini Web** (GitHub URL, files, or zip)
933
+ 2. **Create PRD first**: `@pm` → `*create-doc brownfield-prd`
934
+ 3. **Focused documentation**: `@analyst` → `*document-project`
935
+ - Analyst asks for focus if no PRD provided
936
+ - Choose "single document" format for Web UI
937
+ - Uses PRD to document ONLY relevant areas
938
+ - Creates one comprehensive markdown file
939
+ - Avoids bloating docs with unused code
940
+
941
+ **Option 2: Document-First (Good for Smaller Projects)**:
942
+ 1. **Upload project to Gemini Web**
943
+ 2. **Document everything**: `@analyst` `*document-project`
944
+ 3. **Then create PRD**: `@pm` `*create-doc brownfield-prd`
945
+ - More thorough but can create excessive documentation
946
+
947
+ 2. **Requirements Gathering**:
948
+ - **Brownfield PRD**: Use PM agent with `brownfield-prd-tmpl`
949
+ - **Analyzes**: Existing system, constraints, integration points
950
+ - **Defines**: Enhancement scope, compatibility requirements, risk assessment
951
+ - **Creates**: Epic and story structure for changes
952
+
953
+ 3. **Architecture Planning**:
954
+ - **Brownfield Architecture**: Use Architect agent with `brownfield-architecture-tmpl`
955
+ - **Integration Strategy**: How new features integrate with existing system
956
+ - **Migration Planning**: Gradual rollout and backwards compatibility
957
+ - **Risk Mitigation**: Addressing potential breaking changes
958
+
959
+ **Brownfield-Specific Resources**:
960
+
961
+ **Templates**:
962
+ - `brownfield-prd-tmpl.md`: Comprehensive enhancement planning with existing system analysis
963
+ - `brownfield-architecture-tmpl.md`: Integration-focused architecture for existing systems
964
+
965
+ **Tasks**:
966
+ - `document-project`: Generates comprehensive documentation from existing codebase
967
+ - `brownfield-create-epic`: Creates single epic for focused enhancements (when full PRD is overkill)
968
+ - `brownfield-create-story`: Creates individual story for small, isolated changes
969
+
970
+ **When to Use Each Approach**:
971
+
972
+ **Full Brownfield Workflow** (Recommended for):
973
+ - Major feature additions
974
+ - System modernization
975
+ - Complex integrations
976
+ - Multiple related changes
977
+
978
+ **Quick Epic/Story Creation** (Use when):
979
+ - Single, focused enhancement
980
+ - Isolated bug fixes
981
+ - Small feature additions
982
+ - Well-documented existing system
983
+
984
+ **Critical Success Factors**:
985
+ 1. **Documentation First**: Always run `document-project` if docs are outdated/missing
986
+ 2. **Context Matters**: Provide agents access to relevant code sections
987
+ 3. **Integration Focus**: Emphasize compatibility and non-breaking changes
988
+ 4. **Incremental Approach**: Plan for gradual rollout and testing
989
+
990
+ **For detailed guide**: See `docs/working-in-the-brownfield.md`
940
991
 
941
992
  ## Document Creation Best Practices
942
993
 
@@ -70,7 +70,7 @@ agent:
70
70
  id: analyst
71
71
  title: Business Analyst
72
72
  icon: 📊
73
- whenToUse: Use for market research, brainstorming, competitive analysis, creating project briefs, and initial project discovery
73
+ whenToUse: Use for market research, brainstorming, competitive analysis, creating project briefs, initial project discovery, and documenting existing projects (brownfield)
74
74
  customization: null
75
75
  persona:
76
76
  role: Insightful Analyst & Strategic Ideation Partner
@@ -98,6 +98,7 @@ commands:
98
98
  - brainstorm {topic}: Facilitate structured brainstorming session
99
99
  - research {topic}: Generate deep research prompt for investigation
100
100
  - elicit: Run advanced elicitation to clarify requirements
101
+ - document-project: Analyze and document existing project structure comprehensively
101
102
  - exit: Say goodbye as the Business Analyst, and then abandon inhabiting this persona
102
103
  dependencies:
103
104
  tasks:
@@ -105,6 +106,7 @@ dependencies:
105
106
  - create-deep-research-prompt
106
107
  - create-doc
107
108
  - advanced-elicitation
109
+ - document-project
108
110
  templates:
109
111
  - project-brief-tmpl
110
112
  - market-research-tmpl
@@ -1161,6 +1163,326 @@ The questions and perspectives offered should always consider:
1161
1163
  - Game development best practices and common pitfalls
1162
1164
  ==================== END: tasks#advanced-elicitation ====================
1163
1165
 
1166
+ ==================== START: tasks#document-project ====================
1167
+ # Document an Existing Project
1168
+
1169
+ ## Purpose
1170
+
1171
+ Generate comprehensive documentation for existing projects optimized for AI development agents. This task creates structured reference materials that enable AI agents to understand project context, conventions, and patterns for effective contribution to any codebase.
1172
+
1173
+ ## Task Instructions
1174
+
1175
+ ### 1. Initial Project Analysis
1176
+
1177
+ [[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.
1178
+
1179
+ **IF PRD EXISTS**:
1180
+
1181
+ - Review the PRD to understand what enhancement/feature is planned
1182
+ - Identify which modules, services, or areas will be affected
1183
+ - Focus documentation ONLY on these relevant areas
1184
+ - Skip unrelated parts of the codebase to keep docs lean
1185
+
1186
+ **IF NO PRD EXISTS**:
1187
+ Ask the user:
1188
+
1189
+ "I notice you haven't provided a PRD or requirements document. To create more focused and useful documentation, I recommend one of these options:
1190
+
1191
+ 1. **Create a PRD first** - Would you like me to help create a brownfield PRD before documenting? This helps focus documentation on relevant areas.
1192
+
1193
+ 2. **Provide existing requirements** - Do you have a requirements document, epic, or feature description you can share?
1194
+
1195
+ 3. **Describe the focus** - Can you briefly describe what enhancement or feature you're planning? For example:
1196
+ - 'Adding payment processing to the user service'
1197
+ - 'Refactoring the authentication module'
1198
+ - 'Integrating with a new third-party API'
1199
+
1200
+ 4. **Document everything** - Or should I proceed with comprehensive documentation of the entire codebase? (Note: This may create excessive documentation for large projects)
1201
+
1202
+ Please let me know your preference, or I can proceed with full documentation if you prefer."
1203
+
1204
+ Based on their response:
1205
+
1206
+ - If they choose option 1-3: Use that context to focus documentation
1207
+ - If they choose option 4 or decline: Proceed with comprehensive analysis below
1208
+
1209
+ Begin by conducting analysis of the existing project. Use available tools to:
1210
+
1211
+ 1. **Project Structure Discovery**: Examine the root directory structure, identify main folders, and understand the overall organization
1212
+ 2. **Technology Stack Identification**: Look for package.json, requirements.txt, Cargo.toml, pom.xml, etc. to identify languages, frameworks, and dependencies
1213
+ 3. **Build System Analysis**: Find build scripts, CI/CD configurations, and development commands
1214
+ 4. **Existing Documentation Review**: Check for README files, docs folders, and any existing documentation
1215
+ 5. **Code Pattern Analysis**: Sample key files to understand coding patterns, naming conventions, and architectural approaches
1216
+
1217
+ Ask the user these elicitation questions to better understand their needs:
1218
+
1219
+ - What is the primary purpose of this project?
1220
+ - Are there any specific areas of the codebase that are particularly complex or important for agents to understand?
1221
+ - What types of tasks do you expect AI agents to perform on this project? (e.g., bug fixes, feature additions, refactoring, testing)
1222
+ - Are there any existing documentation standards or formats you prefer?
1223
+ - What level of technical detail should the documentation target? (junior developers, senior developers, mixed team)
1224
+ - Is there a specific feature or enhancement you're planning? (This helps focus documentation)
1225
+ ]]
1226
+
1227
+ ### 2. Deep Codebase Analysis
1228
+
1229
+ [[LLM: Before generating documentation, conduct extensive analysis of the existing codebase:
1230
+
1231
+ 1. **Explore Key Areas**:
1232
+ - Entry points (main files, index files, app initializers)
1233
+ - Configuration files and environment setup
1234
+ - Package dependencies and versions
1235
+ - Build and deployment configurations
1236
+ - Test suites and coverage
1237
+
1238
+ 2. **Ask Clarifying Questions**:
1239
+ - "I see you're using [technology X]. Are there any custom patterns or conventions I should document?"
1240
+ - "What are the most critical/complex parts of this system that developers struggle with?"
1241
+ - "Are there any undocumented 'tribal knowledge' areas I should capture?"
1242
+ - "What technical debt or known issues should I document?"
1243
+ - "Which parts of the codebase change most frequently?"
1244
+
1245
+ 3. **Map the Reality**:
1246
+ - Identify ACTUAL patterns used (not theoretical best practices)
1247
+ - Find where key business logic lives
1248
+ - Locate integration points and external dependencies
1249
+ - Document workarounds and technical debt
1250
+ - Note areas that differ from standard patterns
1251
+
1252
+ **IF PRD PROVIDED**: Also analyze what would need to change for the enhancement]]
1253
+
1254
+ ### 3. Core Documentation Generation
1255
+
1256
+ [[LLM: Generate a comprehensive BROWNFIELD architecture document that reflects the ACTUAL state of the codebase.
1257
+
1258
+ **CRITICAL**: This is NOT an aspirational architecture document. Document what EXISTS, including:
1259
+ - Technical debt and workarounds
1260
+ - Inconsistent patterns between different parts
1261
+ - Legacy code that can't be changed
1262
+ - Integration constraints
1263
+ - Performance bottlenecks
1264
+
1265
+ **Document Structure**:
1266
+
1267
+ # [Project Name] Brownfield Architecture Document
1268
+
1269
+ ## Introduction
1270
+ 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.
1271
+
1272
+ ### Document Scope
1273
+ [If PRD provided: "Focused on areas relevant to: {enhancement description}"]
1274
+ [If no PRD: "Comprehensive documentation of entire system"]
1275
+
1276
+ ### Change Log
1277
+ | Date | Version | Description | Author |
1278
+ |------|---------|-------------|--------|
1279
+ | [Date] | 1.0 | Initial brownfield analysis | [Analyst] |
1280
+
1281
+ ## Quick Reference - Key Files and Entry Points
1282
+
1283
+ ### Critical Files for Understanding the System
1284
+ - **Main Entry**: `src/index.js` (or actual entry point)
1285
+ - **Configuration**: `config/app.config.js`, `.env.example`
1286
+ - **Core Business Logic**: `src/services/`, `src/domain/`
1287
+ - **API Definitions**: `src/routes/` or link to OpenAPI spec
1288
+ - **Database Models**: `src/models/` or link to schema files
1289
+ - **Key Algorithms**: [List specific files with complex logic]
1290
+
1291
+ ### If PRD Provided - Enhancement Impact Areas
1292
+ [Highlight which files/modules will be affected by the planned enhancement]
1293
+
1294
+ ## High Level Architecture
1295
+
1296
+ ### Technical Summary
1297
+ [Real assessment of architecture - mention if it's well-structured or has issues]
1298
+
1299
+ ### Actual Tech Stack (from package.json/requirements.txt)
1300
+ | Category | Technology | Version | Notes |
1301
+ |----------|------------|---------|--------|
1302
+ | Runtime | Node.js | 16.x | [Any constraints] |
1303
+ | Framework | Express | 4.18.2 | [Custom middleware?] |
1304
+ | Database | PostgreSQL | 13 | [Connection pooling setup] |
1305
+ | [etc...] |
1306
+
1307
+ ### Repository Structure Reality Check
1308
+ - Type: [Monorepo/Polyrepo/Hybrid]
1309
+ - Package Manager: [npm/yarn/pnpm]
1310
+ - Notable: [Any unusual structure decisions]
1311
+
1312
+ ## Source Tree and Module Organization
1313
+
1314
+ ### Project Structure (Actual)
1315
+ ```
1316
+ project-root/
1317
+ ├── src/
1318
+ │ ├── controllers/ # HTTP request handlers
1319
+ │ ├── services/ # Business logic (NOTE: inconsistent patterns between user and payment services)
1320
+ │ ├── models/ # Database models (Sequelize)
1321
+ │ ├── utils/ # Mixed bag - needs refactoring
1322
+ │ └── legacy/ # DO NOT MODIFY - old payment system still in use
1323
+ ├── tests/ # Jest tests (60% coverage)
1324
+ ├── scripts/ # Build and deployment scripts
1325
+ └── config/ # Environment configs
1326
+ ```
1327
+
1328
+ ### Key Modules and Their Purpose
1329
+ - **User Management**: `src/services/userService.js` - Handles all user operations
1330
+ - **Authentication**: `src/middleware/auth.js` - JWT-based, custom implementation
1331
+ - **Payment Processing**: `src/legacy/payment.js` - CRITICAL: Do not refactor, tightly coupled
1332
+ - **[List other key modules with their actual files]**
1333
+
1334
+ ## Data Models and APIs
1335
+
1336
+ ### Data Models
1337
+ Instead of duplicating, reference actual model files:
1338
+ - **User Model**: See `src/models/User.js`
1339
+ - **Order Model**: See `src/models/Order.js`
1340
+ - **Related Types**: TypeScript definitions in `src/types/`
1341
+
1342
+ ### API Specifications
1343
+ - **OpenAPI Spec**: `docs/api/openapi.yaml` (if exists)
1344
+ - **Postman Collection**: `docs/api/postman-collection.json`
1345
+ - **Manual Endpoints**: [List any undocumented endpoints discovered]
1346
+
1347
+ ## Technical Debt and Known Issues
1348
+
1349
+ ### Critical Technical Debt
1350
+ 1. **Payment Service**: Legacy code in `src/legacy/payment.js` - tightly coupled, no tests
1351
+ 2. **User Service**: Different pattern than other services, uses callbacks instead of promises
1352
+ 3. **Database Migrations**: Manually tracked, no proper migration tool
1353
+ 4. **[Other significant debt]**
1354
+
1355
+ ### Workarounds and Gotchas
1356
+ - **Environment Variables**: Must set `NODE_ENV=production` even for staging (historical reason)
1357
+ - **Database Connections**: Connection pool hardcoded to 10, changing breaks payment service
1358
+ - **[Other workarounds developers need to know]**
1359
+
1360
+ ## Integration Points and External Dependencies
1361
+
1362
+ ### External Services
1363
+ | Service | Purpose | Integration Type | Key Files |
1364
+ |---------|---------|------------------|-----------|
1365
+ | Stripe | Payments | REST API | `src/integrations/stripe/` |
1366
+ | SendGrid | Emails | SDK | `src/services/emailService.js` |
1367
+ | [etc...] |
1368
+
1369
+ ### Internal Integration Points
1370
+ - **Frontend Communication**: REST API on port 3000, expects specific headers
1371
+ - **Background Jobs**: Redis queue, see `src/workers/`
1372
+ - **[Other integrations]**
1373
+
1374
+ ## Development and Deployment
1375
+
1376
+ ### Local Development Setup
1377
+ 1. Actual steps that work (not ideal steps)
1378
+ 2. Known issues with setup
1379
+ 3. Required environment variables (see `.env.example`)
1380
+
1381
+ ### Build and Deployment Process
1382
+ - **Build Command**: `npm run build` (webpack config in `webpack.config.js`)
1383
+ - **Deployment**: Manual deployment via `scripts/deploy.sh`
1384
+ - **Environments**: Dev, Staging, Prod (see `config/environments/`)
1385
+
1386
+ ## Testing Reality
1387
+
1388
+ ### Current Test Coverage
1389
+ - Unit Tests: 60% coverage (Jest)
1390
+ - Integration Tests: Minimal, in `tests/integration/`
1391
+ - E2E Tests: None
1392
+ - Manual Testing: Primary QA method
1393
+
1394
+ ### Running Tests
1395
+ ```bash
1396
+ npm test # Runs unit tests
1397
+ npm run test:integration # Runs integration tests (requires local DB)
1398
+ ```
1399
+
1400
+ ## If Enhancement PRD Provided - Impact Analysis
1401
+
1402
+ ### Files That Will Need Modification
1403
+ Based on the enhancement requirements, these files will be affected:
1404
+ - `src/services/userService.js` - Add new user fields
1405
+ - `src/models/User.js` - Update schema
1406
+ - `src/routes/userRoutes.js` - New endpoints
1407
+ - [etc...]
1408
+
1409
+ ### New Files/Modules Needed
1410
+ - `src/services/newFeatureService.js` - New business logic
1411
+ - `src/models/NewFeature.js` - New data model
1412
+ - [etc...]
1413
+
1414
+ ### Integration Considerations
1415
+ - Will need to integrate with existing auth middleware
1416
+ - Must follow existing response format in `src/utils/responseFormatter.js`
1417
+ - [Other integration points]
1418
+
1419
+ ## Appendix - Useful Commands and Scripts
1420
+
1421
+ ### Frequently Used Commands
1422
+ ```bash
1423
+ npm run dev # Start development server
1424
+ npm run build # Production build
1425
+ npm run migrate # Run database migrations
1426
+ npm run seed # Seed test data
1427
+ ```
1428
+
1429
+ ### Debugging and Troubleshooting
1430
+ - **Logs**: Check `logs/app.log` for application logs
1431
+ - **Debug Mode**: Set `DEBUG=app:*` for verbose logging
1432
+ - **Common Issues**: See `docs/troubleshooting.md`]]
1433
+
1434
+ ### 4. Document Delivery
1435
+
1436
+ [[LLM: After generating the complete architecture document:
1437
+
1438
+ 1. **In Web UI (Gemini, ChatGPT, Claude)**:
1439
+ - Present the entire document in one response (or multiple if too long)
1440
+ - Tell user to copy and save as `docs/brownfield-architecture.md` or `docs/project-architecture.md`
1441
+ - Mention it can be sharded later in IDE if needed
1442
+
1443
+ 2. **In IDE Environment**:
1444
+ - Create the document as `docs/brownfield-architecture.md`
1445
+ - Inform user this single document contains all architectural information
1446
+ - Can be sharded later using PO agent if desired
1447
+
1448
+ The document should be comprehensive enough that future agents can understand:
1449
+ - The actual state of the system (not idealized)
1450
+ - Where to find key files and logic
1451
+ - What technical debt exists
1452
+ - What constraints must be respected
1453
+ - If PRD provided: What needs to change for the enhancement]]
1454
+
1455
+ ### 5. Quality Assurance
1456
+
1457
+ [[LLM: Before finalizing the document:
1458
+
1459
+ 1. **Accuracy Check**: Verify all technical details match the actual codebase
1460
+ 2. **Completeness Review**: Ensure all major system components are documented
1461
+ 3. **Focus Validation**: If user provided scope, verify relevant areas are emphasized
1462
+ 4. **Clarity Assessment**: Check that explanations are clear for AI agents
1463
+ 5. **Navigation**: Ensure document has clear section structure for easy reference
1464
+
1465
+ Apply the advanced elicitation task after major sections to refine based on user feedback.]]
1466
+
1467
+ ## Success Criteria
1468
+
1469
+ - Single comprehensive brownfield architecture document created
1470
+ - Document reflects REALITY including technical debt and workarounds
1471
+ - Key files and modules are referenced with actual paths
1472
+ - Models/APIs reference source files rather than duplicating content
1473
+ - If PRD provided: Clear impact analysis showing what needs to change
1474
+ - Document enables AI agents to navigate and understand the actual codebase
1475
+ - Technical constraints and "gotchas" are clearly documented
1476
+
1477
+ ## Notes
1478
+
1479
+ - This task creates ONE document that captures the TRUE state of the system
1480
+ - References actual files rather than duplicating content when possible
1481
+ - Documents technical debt, workarounds, and constraints honestly
1482
+ - For brownfield projects with PRD: Provides clear enhancement impact analysis
1483
+ - The goal is PRACTICAL documentation for AI agents doing real work
1484
+ ==================== END: tasks#document-project ====================
1485
+
1164
1486
  ==================== START: templates#project-brief-tmpl ====================
1165
1487
  # Project Brief: {{Project Name}}
1166
1488