// Analyzes existing codebases to document architecture OR helps design architecture for new projects. Creates comprehensive architecture.md with tech stack, components, data flow, and architectural decisions.
| name | Architecture Documentation |
| description | Analyzes existing codebases to document architecture OR helps design architecture for new projects. Creates comprehensive architecture.md with tech stack, components, data flow, and architectural decisions. |
Autonomous Architecture Documentation Skill
This skill documents existing architecture OR helps define architecture for new projects. It creates comprehensive architecture documentation that other skills can reference.
docs/architecture.md doesn't exist or is outdateddocs/architecture.mdYou are now operating as Architecture Analyst & Designer. Your role is to document existing architecture OR help design new architecture.
The workflow branches based on whether this is an existing or new project.
src/, app/, lib/)If substantial code exists → Existing Project Path If minimal/no code → New Project Path
Create docs/architecture.md:
# Architecture Documentation
> Auto-generated by Architecture Skill on {date}
> Based on analysis of existing codebase
## Executive Summary
**Project**: {name}
**Type**: {monorepo|single-app|library|etc}
**Primary Stack**: {tech stack summary}
**Architecture Pattern**: {pattern identified}
## System Overview
{1-2 paragraph overview of what the system does and how it's organized}
## High-Level Architecture
```mermaid
graph TB
Client[Client Applications]
API[API Layer]
DB[(Database)]
Auth[Authentication]
Storage[File Storage]
Client -->|HTTP/WebSocket| API
API --> DB
API --> Auth
API --> Storage
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Frontend | {framework} | {version} | {purpose} |
| Backend | {framework} | {version} | {purpose} |
| Database | {database} | {version} | {purpose} |
| Auth | {service} | {version} | {purpose} |
| Hosting | {platform} | - | {purpose} |
{directory tree}
{dir}/: {purpose}{dir}/: {purpose}Location: {path}
Purpose: {description}
Dependencies: {list}
Location: {path}
Purpose: {description}
Dependencies: {list}
graph LR
A[Component A] --> B[Component B]
A --> C[Component C]
B --> D[Shared Utils]
C --> D
{If identifiable from code, migrations, or types}
Tables/Collections:
{table}: {purpose and key fields}{table}: {purpose and key fields}sequenceDiagram
participant User
participant UI
participant API
participant DB
User->>UI: Action
UI->>API: Request
API->>DB: Query
DB-->>API: Data
API-->>UI: Response
UI-->>User: Update
Server State: {approach - React Query, SWR, etc.} Client State: {approach - Zustand, Redux, Context, etc.}
Pattern: {description of how state is managed}
{REST|GraphQL|tRPC|mixed}
{observed patterns}
Method: {JWT|Session|OAuth|etc} Implementation: {library/service used}
{approach - RBAC, RLS, etc.}
{React|Vue|Svelte|etc} with {routing approach}
{CSR|SSR|SSG|Mixed}
Component Structure: {observed pattern}
Data Fetching: {approach - loaders, useEffect, hooks, etc.}
Routing: {file-based|configured|etc}
{If applicable}
{serverless|traditional server|BaaS|etc}
{framework and pattern}
{ORM|query builder|direct SQL|etc}
| Service | Purpose | Integration Point |
|---|---|---|
| {service} | {purpose} | {where integrated} |
{description}
{Any observable performance patterns}
{pattern observed}
{If observable from config files}
{description}
{approach if determinable}
{how environments are managed}
Context: {why the decision was needed} Decision: {what was chosen} Rationale: {why this was chosen} Consequences: {trade-offs}
Context: {why the decision was needed} Decision: {what was chosen} Rationale: {why this was chosen} Consequences: {trade-offs}
{Observable from code comments, TODO comments, or patterns}
{Based on TODO comments, feature flags, or incomplete implementations}
This document was generated by analyzing the existing codebase. Update as architecture evolves.
---
### Path B: New Project Architecture Design
#### Step 1: Requirements Gathering
Ask user about:
1. **Project Type**: Web app, mobile app, API, library, etc.
2. **User Base**: Scale expectations, user types
3. **Key Features**: Core functionality needed
4. **Technical Preferences**: Any tech stack preferences or constraints
5. **Team Size**: Solo, small team, large team
6. **Timeline**: MVP timeline, long-term goals
#### Step 2: Architecture Recommendations
Based on requirements, recommend:
1. **Architecture Pattern**: MVC, Clean Architecture, Layered, Microservices, etc.
2. **Technology Stack**: Languages, frameworks, databases
3. **Hosting/Deployment**: Platform recommendations
4. **Third-Party Services**: Auth, storage, etc.
#### Step 3: Generate Architecture Document
Create `docs/architecture.md`:
```markdown
# Architecture Design
> Created by Architecture Skill on {date}
> Architecture design for new project
## Project Overview
**Name**: {project name}
**Type**: {type}
**Target Users**: {description}
**Scale**: {expected scale}
## Requirements Summary
### Functional Requirements
- {requirement 1}
- {requirement 2}
### Non-Functional Requirements
- **Performance**: {target}
- **Scalability**: {target}
- **Security**: {requirements}
- **Availability**: {target}
## Recommended Architecture
### Architecture Pattern
**Pattern**: {pattern name}
**Rationale**: {why this pattern fits the requirements}
### High-Level Architecture
```mermaid
graph TB
Client[Client]
Server[Application Server]
DB[(Database)]
Cache[(Cache)]
Storage[Object Storage]
Auth[Auth Service]
Client --> Server
Server --> DB
Server --> Cache
Server --> Storage
Server --> Auth
| Layer | Recommended Technology | Rationale |
|---|---|---|
| Frontend | {tech} | {why} |
| Backend | {tech} | {why} |
| Database | {tech} | {why} |
| Cache | {tech} | {why} |
| Auth | {tech} | {why} |
| Hosting | {platform} | {why} |
Frontend Alternatives:
Backend Alternatives:
project-name/
├── src/
│ ├── components/
│ ├── pages/
│ ├── services/
│ ├── utils/
│ └── types/
├── tests/
├── docs/
└── config/
Purpose: {description} Responsibilities:
Purpose: {description} Responsibilities:
{Initial schema design based on requirements}
Server State: {recommended approach} Client State: {recommended approach}
Recommendation: {REST|GraphQL|tRPC}
Rationale: {why}
{guidelines for endpoints}
Method: {JWT|Session|OAuth}
Rationale: {why}
Recommendation: {framework}
Rationale: {why this framework for the requirements}
Recommendation: {CSR|SSR|SSG|hybrid}
Rationale: {why}
Recommendation: {approach}
Rationale: {why}
{proposed approach}
{proposed approach - RBAC, policies, etc.}
{proposed pipeline}
Recommendation: {platform}
Rationale: {why}
{approach - continuous deployment, staging, etc.}
{approach}
{approach}
{initial strategies}
Status: Proposed Context: {why decision needed} Decision: {what's proposed} Rationale: {why} Consequences: {trade-offs}
Status: Proposed Context: {why decision needed} Decision: {what's proposed} Rationale: {why} Consequences: {trade-offs}
Goal: {core functionality} Timeline: {estimate} Components:
Goal: {additional features} Timeline: {estimate} Components:
| Risk | Impact | Probability | Mitigation |
|---|---|---|---|
| {risk} | {H/M/L} | {H/M/L} | {strategy} |
This is a proposed architecture. Refine based on implementation learnings.
---
### Step 5: Return JSON Summary
```json
{
"status": "completed",
"mode": "existing|new",
"architecture_doc": {
"path": "/full/path/to/docs/architecture.md",
"generated_at": "{ISO timestamp}"
},
"summary": {
"project_type": "{type}",
"architecture_pattern": "{pattern}",
"primary_stack": {
"frontend": "{tech}",
"backend": "{tech}",
"database": "{tech}",
"auth": "{tech}"
},
"key_decisions": [
{
"title": "{decision}",
"choice": "{what was chosen}"
}
]
}
}
For Existing Projects:
For New Projects:
If analysis fails:
If user requirements are unclear: