Codebase Architecture Documentation Guide
Overview
This skill performs a comprehensive analysis of a codebase to generate architectural documentation that helps developers understand the project structure, organization, technologies, data flows, and areas of active development. The analysis is read-only and produces a detailed architectural overview document.
Scope
By default, analyze the current directory as the project root. Users can specify a different directory if needed.
Output
Generate architectural documentation and write it to @docs/project-overview.md in the project directory.
Analysis Areas
1. Technologies & Frameworks
Identify and document:
- Programming languages used (primary and secondary)
- Frameworks and libraries (web frameworks, UI libraries, etc.)
- Build tools and package managers (npm, Maven, Gradle, etc.)
- Testing frameworks and test runners
- CI/CD tools and deployment configurations
- Database technologies and ORMs
- Development tooling (linters, formatters, type checkers)
- Runtime environments (Node.js version, JVM version, etc.)
2. High-Level Data Flows
Document how data moves through the system:
- Input sources: Where data enters the system (user input, APIs, files, databases)
- Processing layers: Major data transformation steps
- Output destinations: Where data goes (responses, storage, external systems)
- Key data transformations: Critical business logic that transforms data
- State management: How application state is managed and flows
- Data validation points: Where and how data is validated
- Error handling flows: How errors propagate through the system
3. Functional Components
Identify and describe major system components:
- Component structure: Main modules, packages, or logical groupings
- Component responsibilities: What each major component does
- Component relationships: How components interact and depend on each other
- Layer architecture: Presentation, business logic, data access layers
- Design patterns: Observable patterns (MVC, Repository, Factory, etc.)
- Module boundaries: Clear separation points between components
- Shared utilities: Common code used across components
4. Public APIs Consumed
Document external APIs and services the project depends on:
- Third-party APIs: External services consumed (payment, auth, etc.)
- API purpose: Why each external API is used
- Integration points: Where in the code external APIs are called
- Authentication methods: How the project authenticates with external services
- Rate limits or quotas: Known limitations of external APIs
- Fallback strategies: How the system handles API failures
5. Public APIs Exposed
Document APIs or interfaces the project provides:
- REST/GraphQL endpoints: Public API routes and their purposes
- Library interfaces: If it's a library, what public APIs does it expose
- CLI commands: If it's a CLI tool, what commands are available
- Event interfaces: Webhooks, event emitters, or pub/sub interfaces
- Authentication/Authorization: How consumers authenticate
- API versioning: How API versions are managed
- Documentation: Where API docs are located (Swagger, JSDoc, etc.)
6. External System Dependencies
Identify dependencies on external systems:
- Databases: Type, purpose, and connection details (without credentials)
- Message queues: RabbitMQ, Kafka, SQS, etc.
- Caching layers: Redis, Memcached, etc.
- Storage systems: S3, file systems, blob storage
- Authentication providers: OAuth, SAML, LDAP
- Monitoring and logging: Datadog, Sentry, CloudWatch, etc.
- Email services: SendGrid, SES, etc.
- Payment processors: Stripe, PayPal, etc.
7. Commit History Analysis (Last 30 Commits)
Analyze recent development activity with moderate detail:
- Most frequently changed files: Which files are modified most often
- Active development areas: Which components/modules are seeing the most work
- Change patterns: Types of changes (features, bugs, refactoring)
- Commit message themes: Common topics in recent commits
- File change statistics: Additions, deletions per file/area
- Development velocity: Pace of changes over time
- Key contributors: Who is working on what (if git history available)
8. Complexity & Problem Areas
Identify areas that may be difficult to work with:
- High complexity files: Large files, high cyclomatic complexity
- Deep nesting: Functions/files with deep nesting levels
- Unclear abstractions: Areas where code intent is hard to understand
- Frequent bug fixes: Areas with many bug-related commits
- Missing documentation: Critical areas without comments or docs
- Tight coupling: Components that are overly dependent on each other
- Technical debt indicators: TODOs, FIXMEs, or known workarounds
- Configuration complexity: Complex or hard-to-understand config
Inspection Process
Step 1: Project Discovery
- Identify the root directory of the project
- Look for configuration files (package.json, pom.xml, Cargo.toml, etc.)
- Examine directory structure to understand organization
- Check for README files or existing documentation
- Identify the primary programming language(s)
Step 2: Technology Stack Analysis
- Read package manager files to identify dependencies
- Look for framework-specific files (next.config.js, vite.config.ts, etc.)
- Identify build and test configurations
- Check for Docker, CI/CD configurations
- Note development tooling (ESLint, Prettier, etc.)
Step 3: Code Structure Analysis
- Map out the directory structure
- Identify main entry points (main.ts, index.js, App.tsx, etc.)
- Locate core business logic directories
- Find configuration and utility directories
- Identify test directories and test organization
Step 4: Data Flow Analysis
- Trace how requests/inputs enter the system
- Follow data through major processing steps
- Identify state management approaches
- Note validation and error handling patterns
- Map data persistence points
Step 5: API and Integration Analysis
- Search for API client code (fetch, axios, SDK usage)
- Identify API route definitions (Express routes, controllers, etc.)
- Look for authentication/authorization code
- Find webhook or event handler definitions
- Check for API documentation files
Step 6: External Dependencies Analysis
- Identify database connection code
- Look for cloud service integrations (AWS, GCP, Azure)
- Find message queue or event bus usage
- Identify third-party service integrations
- Note monitoring and observability tools
Step 7: Git History Analysis
- Run
git log --oneline -30 to get last 30 commits
- Run
git log -30 --name-only --pretty=format: to see changed files
- Analyze which files appear most frequently
- Group changes by directory/component
- Identify patterns in commit messages
- Calculate change velocity and patterns
Step 8: Complexity Analysis
- Use file size as a proxy for complexity (find large files)
- Look for deeply nested code structures
- Identify files with many dependencies
- Search for TODO, FIXME, HACK comments
- Find frequently fixed files (many "fix" commits)
- Note areas with sparse documentation
Step 9: Generate Documentation
Compile all findings into a comprehensive, well-structured markdown document.
Report Format
Structure the output document (@docs/project-overview.md) as follows:
# Project Architecture Overview
Generated: [Date]
Project: [Project Name/Directory]
## Executive Summary
[2-3 paragraph overview of the project, its purpose, tech stack, and architecture]
## Technology Stack
### Languages
- [Primary language and version]
- [Secondary languages if applicable]
### Frameworks & Libraries
- **[Category]**: [Framework/library name and version]
- Purpose: [Why it's used]
### Build & Development Tools
- [Build tool]: [Version/config]
- [Testing framework]
- [Linters/formatters]
### Infrastructure & Runtime
- [Runtime environment]
- [Container/orchestration tools]
- [CI/CD platform]
## Architecture Overview
### High-Level Architecture
[Describe the overall architecture pattern - monolith, microservices, serverless, etc.]
### Directory Structure
[Key directories with brief descriptions]
### Core Components
#### [Component Name]
- **Location**: `path/to/component`
- **Responsibility**: [What it does]
- **Dependencies**: [What it depends on]
- **Key Files**: [Important files in this component]
[Repeat for each major component]
### Component Relationships
[Describe how major components interact with each other]
## Data Flows
### Input Sources
- [Source]: [Description of how data enters]
### Key Processing Flows
1. **[Flow Name]**: [Description of data transformation]
- Input: [What goes in]
- Processing: [What happens]
- Output: [What comes out]
### State Management
[Describe how application state is managed]
### Error Handling
[Describe error handling strategy]
## APIs Consumed
### External Services
| Service | Purpose | Integration Point | Auth Method |
|---------|---------|-------------------|-------------|
| [Service name] | [Why used] | [Where in code] | [How auth] |
### Key Dependencies
- [Dependency]: [Purpose and usage]
## APIs Exposed
### Endpoints
| Method | Path | Purpose | Auth Required |
|--------|------|---------|---------------|
| [GET/POST] | [/api/path] | [What it does] | [Yes/No] |
### Public Interfaces
[Describe public API, library exports, or CLI commands]
### API Documentation
[Location of API docs, if any]
## External System Dependencies
### Databases
- **[Database type]**: [Purpose and schema notes]
### Cloud Services
- **[Service name]**: [Purpose and usage]
### Third-Party Integrations
- **[Integration name]**: [Purpose and configuration]
### Monitoring & Observability
- **[Tool name]**: [What it monitors]
## Development Activity Analysis
Last 30 Commits
### Most Active Areas
| Area/Component | Number of Changes | Change Type |
|----------------|-------------------|-------------|
| [Directory/file] | [Count] | [features/fixes/refactor] |
### Recent Development Themes
- **[Theme]**: [Number of commits] - [Description]
### Frequently Modified Files
1. `[file path]` - [number] changes - [Pattern of changes]
2. `[file path]` - [number] changes - [Pattern of changes]
### Change Velocity
[Describe pace and pattern of recent changes]
### Key Recent Changes
- [Commit summary with key changes or features added]
## Complexity & Challenge Areas
### High-Complexity Components
1. **[Component/File]** (`path/to/file`)
- **Why Complex**: [File size, nesting, many dependencies]
- **Improvement Suggestions**: [How to make it easier]
### Areas Requiring Attention
- **[Area]**: [Why it's problematic and what could help]
### Technical Debt Indicators
- [Location]: [Issue description]
### Documentation Gaps
- [Area lacking documentation]
## Recommendations
### For New Developers
[Key areas to understand first, where to start reading code]
### For Maintenance
[Areas that need refactoring or better documentation]
### For Feature Development
[Which components are easiest to extend, which need caution]
## Additional Resources
- [Link to other docs]
- [Link to wiki or confluence]
- [Link to API docs]
## Notes
- This document is auto-generated and should be updated as the project evolves
- For questions about specific components, see [relevant documentation]
Important Notes
- Read-Only Operation: This skill MUST NOT modify any code files
- No State Changes: Do not run builds, tests, or any commands that modify the project
- Document Only: All output goes to the project overview document
- Be Accurate: Verify findings by reading actual code, not assumptions
- Be Specific: Include exact file paths when referencing code
- Be Comprehensive: Cover all 8 analysis areas thoroughly
- Respect Privacy: Do not include credentials, API keys, or sensitive data
- Git Available: Assume git is available for commit history analysis
- Handle Missing Info: If certain information isn't available, note it in the document
Completion Criteria
- All 8 analysis areas have been thoroughly examined
- Technology stack is completely documented
- Major components and their relationships are clearly described
- Data flows are mapped out
- External APIs and dependencies are cataloged
- Last 30 commits have been analyzed with moderate detail
- Complexity areas have been identified
- Report is written to
@docs/project-overview.md
- User is notified that the architectural analysis is complete
1---2name: codearchitect3description: Analyzes a codebase to generate comprehensive architectural documentation including technologies used, data flows, functional components, APIs, external dependencies, commit history analysis, and complexity hotspots.4---5
6# Codebase Architecture Documentation Guide
7
8## Overview
9This skill performs a comprehensive analysis of a codebase to generate architectural documentation that helps developers understand the project structure, organization, technologies, data flows, and areas of active development. The analysis is read-only and produces a detailed architectural overview document.
10
11## Scope
12By default, analyze the current directory as the project root. Users can specify a different directory if needed.
13
14## Output
15Generate architectural documentation and write it to `@docs/project-overview.md` in the project directory.
16
17## Analysis Areas
18
19### 1. Technologies & Frameworks
20Identify and document:
21- **Programming languages** used (primary and secondary)
22- **Frameworks and libraries** (web frameworks, UI libraries, etc.)
23- **Build tools and package managers** (npm, Maven, Gradle, etc.)
24- **Testing frameworks** and test runners
25- **CI/CD tools** and deployment configurations
26- **Database technologies** and ORMs
27- **Development tooling** (linters, formatters, type checkers)
28- **Runtime environments** (Node.js version, JVM version, etc.)
29
30### 2. High-Level Data Flows
31Document how data moves through the system:
32- **Input sources**: Where data enters the system (user input, APIs, files, databases)
33- **Processing layers**: Major data transformation steps
34- **Output destinations**: Where data goes (responses, storage, external systems)
35- **Key data transformations**: Critical business logic that transforms data
36- **State management**: How application state is managed and flows
37- **Data validation points**: Where and how data is validated
38- **Error handling flows**: How errors propagate through the system
39
40### 3. Functional Components
41Identify and describe major system components:
42- **Component structure**: Main modules, packages, or logical groupings
43- **Component responsibilities**: What each major component does
44- **Component relationships**: How components interact and depend on each other
45- **Layer architecture**: Presentation, business logic, data access layers
46- **Design patterns**: Observable patterns (MVC, Repository, Factory, etc.)
47- **Module boundaries**: Clear separation points between components
48- **Shared utilities**: Common code used across components
49
50### 4. Public APIs Consumed
51Document external APIs and services the project depends on:
52- **Third-party APIs**: External services consumed (payment, auth, etc.)
53- **API purpose**: Why each external API is used
54- **Integration points**: Where in the code external APIs are called
55- **Authentication methods**: How the project authenticates with external services
56- **Rate limits or quotas**: Known limitations of external APIs
57- **Fallback strategies**: How the system handles API failures
58
59### 5. Public APIs Exposed
60Document APIs or interfaces the project provides:
61- **REST/GraphQL endpoints**: Public API routes and their purposes
62- **Library interfaces**: If it's a library, what public APIs does it expose
63- **CLI commands**: If it's a CLI tool, what commands are available
64- **Event interfaces**: Webhooks, event emitters, or pub/sub interfaces
65- **Authentication/Authorization**: How consumers authenticate
66- **API versioning**: How API versions are managed
67- **Documentation**: Where API docs are located (Swagger, JSDoc, etc.)
68
69### 6. External System Dependencies
70Identify dependencies on external systems:
71- **Databases**: Type, purpose, and connection details (without credentials)
72- **Message queues**: RabbitMQ, Kafka, SQS, etc.
73- **Caching layers**: Redis, Memcached, etc.
74- **Storage systems**: S3, file systems, blob storage
75- **Authentication providers**: OAuth, SAML, LDAP
76- **Monitoring and logging**: Datadog, Sentry, CloudWatch, etc.
77- **Email services**: SendGrid, SES, etc.
78- **Payment processors**: Stripe, PayPal, etc.
79
80### 7. Commit History Analysis (Last 30 Commits)
81Analyze recent development activity with moderate detail:
82- **Most frequently changed files**: Which files are modified most often
83- **Active development areas**: Which components/modules are seeing the most work
84- **Change patterns**: Types of changes (features, bugs, refactoring)
85- **Commit message themes**: Common topics in recent commits
86- **File change statistics**: Additions, deletions per file/area
87- **Development velocity**: Pace of changes over time
88- **Key contributors**: Who is working on what (if git history available)
89
90### 8. Complexity & Problem Areas
91Identify areas that may be difficult to work with:
92- **High complexity files**: Large files, high cyclomatic complexity
93- **Deep nesting**: Functions/files with deep nesting levels
94- **Unclear abstractions**: Areas where code intent is hard to understand
95- **Frequent bug fixes**: Areas with many bug-related commits
96- **Missing documentation**: Critical areas without comments or docs
97- **Tight coupling**: Components that are overly dependent on each other
98- **Technical debt indicators**: TODOs, FIXMEs, or known workarounds
99- **Configuration complexity**: Complex or hard-to-understand config
100
101## Inspection Process
102
103### Step 1: Project Discovery
1041. Identify the root directory of the project
1052. Look for configuration files (package.json, pom.xml, Cargo.toml, etc.)
1063. Examine directory structure to understand organization
1074. Check for README files or existing documentation
1085. Identify the primary programming language(s)
109
110### Step 2: Technology Stack Analysis
1111. Read package manager files to identify dependencies
1122. Look for framework-specific files (next.config.js, vite.config.ts, etc.)
1133. Identify build and test configurations
1144. Check for Docker, CI/CD configurations
1155. Note development tooling (ESLint, Prettier, etc.)
116
117### Step 3: Code Structure Analysis
1181. Map out the directory structure
1192. Identify main entry points (main.ts, index.js, App.tsx, etc.)
1203. Locate core business logic directories
1214. Find configuration and utility directories
1225. Identify test directories and test organization
123
124### Step 4: Data Flow Analysis
1251. Trace how requests/inputs enter the system
1262. Follow data through major processing steps
1273. Identify state management approaches
1284. Note validation and error handling patterns
1295. Map data persistence points
130
131### Step 5: API and Integration Analysis
1321. Search for API client code (fetch, axios, SDK usage)
1332. Identify API route definitions (Express routes, controllers, etc.)
1343. Look for authentication/authorization code
1354. Find webhook or event handler definitions
1365. Check for API documentation files
137
138### Step 6: External Dependencies Analysis
1391. Identify database connection code
1402. Look for cloud service integrations (AWS, GCP, Azure)
1413. Find message queue or event bus usage
1424. Identify third-party service integrations
1435. Note monitoring and observability tools
144
145### Step 7: Git History Analysis
1461. Run `git log --oneline -30` to get last 30 commits
1472. Run `git log -30 --name-only --pretty=format:` to see changed files
1483. Analyze which files appear most frequently
1494. Group changes by directory/component
1505. Identify patterns in commit messages
1516. Calculate change velocity and patterns
152
153### Step 8: Complexity Analysis
1541. Use file size as a proxy for complexity (find large files)
1552. Look for deeply nested code structures
1563. Identify files with many dependencies
1574. Search for TODO, FIXME, HACK comments
1585. Find frequently fixed files (many "fix" commits)
1596. Note areas with sparse documentation
160
161### Step 9: Generate Documentation
162Compile all findings into a comprehensive, well-structured markdown document.
163
164## Report Format
165
166Structure the output document (`@docs/project-overview.md`) as follows:
167
168```markdown
169# Project Architecture Overview
170Generated: [Date]
171Project: [Project Name/Directory]
172
173## Executive Summary
174[2-3 paragraph overview of the project, its purpose, tech stack, and architecture]
175
176## Technology Stack
177
178### Languages
179- [Primary language and version]
180- [Secondary languages if applicable]
181
182### Frameworks & Libraries
183- **[Category]**: [Framework/library name and version]
184 - Purpose: [Why it's used]
185
186### Build & Development Tools
187- [Build tool]: [Version/config]
188- [Testing framework]
189- [Linters/formatters]
190
191### Infrastructure & Runtime
192- [Runtime environment]
193- [Container/orchestration tools]
194- [CI/CD platform]
195
196## Architecture Overview
197
198### High-Level Architecture
199[Describe the overall architecture pattern - monolith, microservices, serverless, etc.]
200
201### Directory Structure
202```
203[Key directories with brief descriptions]
204```
205
206### Core Components
207
208#### [Component Name]
209- **Location**: `path/to/component`
210- **Responsibility**: [What it does]
211- **Dependencies**: [What it depends on]
212- **Key Files**: [Important files in this component]
213
214[Repeat for each major component]
215
216### Component Relationships
217[Describe how major components interact with each other]
218
219## Data Flows
220
221### Input Sources
222- [Source]: [Description of how data enters]
223
224### Key Processing Flows
2251. **[Flow Name]**: [Description of data transformation]
226 - Input: [What goes in]
227 - Processing: [What happens]
228 - Output: [What comes out]
229
230### State Management
231[Describe how application state is managed]
232
233### Error Handling
234[Describe error handling strategy]
235
236## APIs Consumed
237
238### External Services
239| Service | Purpose | Integration Point | Auth Method |
240|---------|---------|-------------------|-------------|
241| [Service name] | [Why used] | [Where in code] | [How auth] |
242
243### Key Dependencies
244- [Dependency]: [Purpose and usage]
245
246## APIs Exposed
247
248### Endpoints
249| Method | Path | Purpose | Auth Required |
250|--------|------|---------|---------------|
251| [GET/POST] | [/api/path] | [What it does] | [Yes/No] |
252
253### Public Interfaces
254[Describe public API, library exports, or CLI commands]
255
256### API Documentation
257[Location of API docs, if any]
258
259## External System Dependencies
260
261### Databases
262- **[Database type]**: [Purpose and schema notes]
263
264### Cloud Services
265- **[Service name]**: [Purpose and usage]
266
267### Third-Party Integrations
268- **[Integration name]**: [Purpose and configuration]
269
270### Monitoring & Observability
271- **[Tool name]**: [What it monitors]
272
273## Development Activity Analysis
274Last 30 Commits
275
276### Most Active Areas
277| Area/Component | Number of Changes | Change Type |
278|----------------|-------------------|-------------|
279| [Directory/file] | [Count] | [features/fixes/refactor] |
280
281### Recent Development Themes
282- **[Theme]**: [Number of commits] - [Description]
283
284### Frequently Modified Files
2851. `[file path]` - [number] changes - [Pattern of changes]
2862. `[file path]` - [number] changes - [Pattern of changes]
287
288### Change Velocity
289[Describe pace and pattern of recent changes]
290
291### Key Recent Changes
292- [Commit summary with key changes or features added]
293
294## Complexity & Challenge Areas
295
296### High-Complexity Components
2971. **[Component/File]** (`path/to/file`)
298 - **Why Complex**: [File size, nesting, many dependencies]
299 - **Improvement Suggestions**: [How to make it easier]
300
301### Areas Requiring Attention
302- **[Area]**: [Why it's problematic and what could help]
303
304### Technical Debt Indicators
305- [Location]: [Issue description]
306
307### Documentation Gaps
308- [Area lacking documentation]
309
310## Recommendations
311
312### For New Developers
313[Key areas to understand first, where to start reading code]
314
315### For Maintenance
316[Areas that need refactoring or better documentation]
317
318### For Feature Development
319[Which components are easiest to extend, which need caution]
320
321## Additional Resources
322- [Link to other docs]
323- [Link to wiki or confluence]
324- [Link to API docs]
325
326## Notes
327- This document is auto-generated and should be updated as the project evolves
328- For questions about specific components, see [relevant documentation]
329```
330
331## Important Notes
332
333- **Read-Only Operation**: This skill MUST NOT modify any code files
334- **No State Changes**: Do not run builds, tests, or any commands that modify the project
335- **Document Only**: All output goes to the project overview document
336- **Be Accurate**: Verify findings by reading actual code, not assumptions
337- **Be Specific**: Include exact file paths when referencing code
338- **Be Comprehensive**: Cover all 8 analysis areas thoroughly
339- **Respect Privacy**: Do not include credentials, API keys, or sensitive data
340- **Git Available**: Assume git is available for commit history analysis
341- **Handle Missing Info**: If certain information isn't available, note it in the document
342
343## Completion Criteria
344- All 8 analysis areas have been thoroughly examined
345- Technology stack is completely documented
346- Major components and their relationships are clearly described
347- Data flows are mapped out
348- External APIs and dependencies are cataloged
349- Last 30 commits have been analyzed with moderate detail
350- Complexity areas have been identified
351- Report is written to `@docs/project-overview.md`
352- User is notified that the architectural analysis is complete