// Generate comprehensive architecture documentation automatically from existing codebase analysis. This skill should be used when working with brownfield projects or updating outdated documentation.
| name | document-project |
| description | Generate comprehensive architecture documentation automatically from existing codebase analysis. This skill should be used when working with brownfield projects or updating outdated documentation. |
| acceptance | [{"documentation_generated":"All three documentation files created (architecture.md, standards.md, patterns.md)"},{"confidence_sufficient":"Overall confidence score ≥70% across all analyzed sections"},{"review_checklist_created":"Human review checklist generated identifying low-confidence areas"},{"configuration_updated":"Project configuration updated with documentation paths and brownfield flag"}] |
| inputs | {"codebase_path":{"type":"string","required":true,"description":"Path to codebase to analyze (e.g., src/)"},"existing_docs_mode":{"type":"enum","values":["merge","replace","supplement"],"default":"merge","description":"How to handle existing documentation"},"include_tests":{"type":"boolean","default":true,"description":"Include test file analysis in documentation"},"max_files":{"type":"number","default":1000,"description":"Maximum files to analyze (safety limit)"}} |
| outputs | {"documentation_files":{"type":"object","description":"Paths to generated documentation files"},"confidence_score":{"type":"number","description":"Overall confidence score (0-100%)"},"review_checklist":{"type":"string","description":"Path to human review checklist file"},"analysis_summary":{"type":"object","description":"Summary of analysis (files analyzed, patterns found, etc.)"}} |
| telemetry | {"emit":"skill.document-project.completed","track":["project_name","codebase_path","duration_ms","files_analyzed","lines_analyzed","confidence_score","patterns_identified"]} |
Generate comprehensive architecture documentation automatically by analyzing existing codebase structure, patterns, and conventions.
Analyze an existing codebase and generate three comprehensive documentation files:
This enables BMAD Enhanced to work with brownfield projects by reverse-engineering architecture from code.
This skill should be used when:
This skill should NOT be used when:
Well-Supported Languages:
Basic Support:
Optimal Codebase Size: 10K-100K lines
Execute steps in order - each builds on previous analysis:
Purpose: Verify project is suitable for automated documentation.
Actions:
.claude/config.yaml (codebasePath, existingDocs, includeTests, maxFiles)See: references/templates.md#step-0-configuration-and-validation-output for complete formats
Halt if:
Output: Validation confirmation (project type, lines, existing docs mode, scope, ready status)
Reference: See validation-criteria.md for detailed validation rules.
Purpose: Map file organization and module structure.
Actions:
Output: Project structure analysis with type, organization, directory structure (dirs + file counts + line counts), key patterns
See: references/templates.md#step-1-codebase-analysis-output for complete format
Reference: See analysis-techniques.md for detailed analysis methods.
Purpose: Identify languages, frameworks, and dependencies.
Actions:
Read package configuration:
Extract dependencies and identify frameworks:
Detect runtime/platform:
Output: Tech stack summary (runtime, backend/frontend frameworks, key libraries, testing tools, versions, confidence score)
See: references/templates.md#step-2-technology-stack-analysis for complete format
Purpose: Document data structures and validation rules.
Actions:
Locate data model files:
prisma/schema.prismasrc/types/*.ts, src/models/*.tsprisma/migrations/, migrations/Parse data models and extract validation rules
Analyze relationships:
Detect data flow:
Output: Data models summary (models with fields/types/constraints, validation rules, relationships, confidence score)
See: references/templates.md#complete-architecture-md-template for data model format
Reference: See analysis-techniques.md for model extraction patterns.
Purpose: Document API structure and conventions.
Actions:
Locate API definitions:
src/routes/**/*.tssrc/controllers/**/*.tsExtract endpoints and analyze request/response patterns:
Identify authentication:
Detect rate limiting and other middleware
Output: API specs summary (base URL, authentication type/headers/expiry, error/success response formats, confidence score)
See: references/templates.md#complete-architecture-md-template for API specification format
Purpose: Document implicit conventions and best practices.
Actions:
Analyze code style:
.eslintrc, .prettierrc, tsconfig.jsonIdentify architectural patterns:
Extract error handling patterns:
Detect testing patterns:
Output:
Coding Standards:
Code Style:
- Indentation: 2 spaces
- Quotes: Single quotes
- Naming: camelCase (variables), PascalCase (classes), kebab-case (files)
Architectural Patterns:
1. Layered Architecture
- Routes (presentation layer)
- Services (business logic layer)
- Repositories (data access layer)
2. Dependency Injection
3. Repository Pattern
Error Handling:
- Custom error classes (AppError, ValidationError)
- Centralized error handling middleware
- Never expose stack traces to clients
Confidence: High (90%)
Reference: See pattern-detection.md for pattern identification techniques.
Purpose: Create comprehensive architecture.md from findings.
Actions:
Load architecture template structure
Populate sections with analyzed data from Steps 1-5:
Generate diagrams (optional):
Add human review notes for medium/low confidence sections
Write documentation file:
docs/architecture.mdOutput:
✓ Architecture documentation generated
✓ File: docs/architecture.md (2,450 lines)
✓ Sections: 12
✓ Overall confidence: 85%
✓ Human review items: 5
Reference: See documentation-templates.md for template structures.
Purpose: Create standards.md from discovered patterns.
Actions:
Extract standards from code analysis:
Document best practices:
Create standards document with examples and consistency scores
Output:
✓ Standards documentation generated
✓ File: docs/standards.md (850 lines)
✓ Standards extracted: 18
✓ Consistency scores: 75-100%
Purpose: Document discovered design patterns and conventions.
Actions:
Extract design patterns:
Document usage examples:
Identify anti-patterns:
Create patterns document
Output:
✓ Patterns documentation generated
✓ File: docs/patterns.md (620 lines)
✓ Patterns identified: 8
✓ Anti-patterns noted: 3
Reference: See pattern-detection.md for pattern documentation templates.
Purpose: Score accuracy and identify areas needing human review.
Actions:
Output: Validation summary (overall confidence %, high/medium priority review item counts)
See: references/templates.md#review-checklist-template and references/confidence-scoring.md for formats
Reference: See confidence-scoring.md for scoring guidelines.
Purpose: Provide user with clear summary and action items.
Actions:
docs/REVIEW_CHECKLIST.mdOutput: Summary confirmation (report generated, checklist created, config updated, ready status)
See: references/templates.md for complete summary formats
High (85-100%): Explicit in code/config, consistent patterns, no conflicts | Medium (70-84%): Inferred from patterns, some inconsistencies, needs validation | Low (<70%): Missing/unclear info, conflicts, high uncertainty, MUST review
See: references/confidence-scoring.md for detailed scoring methodology
Cannot: Understand business logic without context, document deployment infrastructure, capture tribal knowledge, understand legacy decisions, document external integrations perfectly
Requires: Readable structured codebase, standard organization, supported language/framework, 10K-100K lines (optimal)
Run periodically (every 3-6 months) | Always review low-confidence sections | Supplement with manual docs (business context, deployment) | Use as starting point, enhance with team input
Brownfield: document-project → index-docs → create-task-spec (use generated docs) | Greenfield: Write docs manually first | Brownfield: Generate from code, then refine
Detailed documentation in references/: