---
name: c4-architecture
description: Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.
C4 Architecture Documentation Workflow
Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.
[Extended thinking: This workflow implements a complete C4 architecture documentation process following the C4 model (Context, Container, Component, Code). It uses a bottom-up approach, starting from the deepest code directories and working upward, ensuring every code element is documented before synthesizing into higher-level abstractions. The workflow coordinates four specialized C4 agents (Code, Component, Container, Context) to create a complete architectural documentation set that serves both technical and non-technical stakeholders.]
Overview
This workflow creates comprehensive C4 architecture documentation following the official C4 model by:
- Code Level: Analyzing every subdirectory bottom-up to create code-level documentation
- Component Level: Synthesizing code documentation into logical components within containers
- Container Level: Mapping components to deployment containers with API documentation (shows high-level technology choices)
- Context Level: Creating high-level system context with personas and user journeys (focuses on people and software systems, not technologies)
Note: According to the C4 model, you don't need to use all 4 levels of diagram - the system context and container diagrams are sufficient for most software development teams. This workflow generates all levels for completeness, but teams can choose which levels to use.
All documentation is written to a new C4-Documentation/ directory in the repository root.
Phase 1: Code-Level Documentation (Bottom-Up Analysis)
1.1 Discover All Subdirectories
- Use codebase search to identify all subdirectories in the repository
- Sort directories by depth (deepest first) for bottom-up processing
- Filter out common non-code directories (node_modules, .git, build, dist, etc.)
- Create list of directories to process
1.2 Process Each Directory (Bottom-Up)
For each directory, starting from the deepest:
Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-code).
Instruction: |
Analyze the code in directory: [directory_path]
Create comprehensive C4 Code-level documentation following this structure:
- Overview Section:
- Name: [Descriptive name for this code directory]
- Description: [Short description of what this code does]
- Location: [Link to actual directory path relative to repo root]
- Language: [Primary programming language(s) used]
- Purpose: [What this code accomplishes]
- Code Elements Section:
- Document all functions/methods with complete signatures:
- Function name, parameters (with types), return type
- Description of what each function does
- Location (file path and line numbers)
- Dependencies (what this function depends on)
- Document all classes/modules:
- Class name, description, location
- Methods and their signatures
- Dependencies
- Dependencies Section:
- Internal dependencies (other code in this repo)
- External dependencies (libraries, frameworks, services)
- Relationships Section:
- Optional Mermaid diagram if relationships are complex
Save the output as: C4-Documentation/c4-code-[directory-name].md
Use a sanitized directory name (replace / with -, remove special chars) for the filename.
Ensure the documentation includes:
- Complete function signatures with all parameters and types
- Links to actual source code locations
- All dependencies (internal and external)
- Clear, descriptive names and descriptions
Expected output: c4-code-.md file in C4-Documentation/
Context: All files in the directory and its subdirectories
Repeat for every subdirectory until all directories have corresponding c4-code-*.md files.
Phase 2: Component-Level Synthesis
2.1 Analyze All Code-Level Documentation
- Collect all c4-code-*.md files created in Phase 1
- Analyze code structure, dependencies, and relationships
- Identify logical component boundaries based on:
- Domain boundaries (related business functionality)
- Technical boundaries (shared frameworks, libraries)
- Organizational boundaries (team ownership, if evident)
2.2 Create Component Documentation
For each identified component:
Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-component).
Instruction: |
Synthesize the following C4 Code-level documentation files into a logical component:
Code files to analyze:
[List of c4-code-*.md file paths]
Create comprehensive C4 Component-level documentation following this structure:
- Overview Section:
- Name: [Component name - descriptive and meaningful]
- Description: [Short description of component purpose]
- Type: [Application, Service, Library, etc.]
- Technology: [Primary technologies used]
- Purpose Section:
- Detailed description of what this component does
- What problems it solves
- Its role in the system
- Software Features Section:
- List all software features provided by this component
- Each feature with a brief description
- Code Elements Section:
- List all c4-code-*.md files contained in this component
- Link to each file with a brief description
- Interfaces Section:
- Document all component interfaces:
- Interface name
- Protocol (REST, GraphQL, gRPC, Events, etc.)
- Description
- Operations (function signatures, endpoints, etc.)
- Dependencies Section:
- Components used (other components this depends on)
- External systems (databases, APIs, services)
- Component Diagram:
- Mermaid diagram showing this component and its relationships
Save the output as: C4-Documentation/c4-component-[component-name].md
Use a sanitized component name for the filename.
Expected output: c4-component-.md file for each component
Context: All relevant c4-code-*.md files for this component
2.3 Create Master Component Index
Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-component).
Instruction: |
Create a master component index that lists all components in the system.
Based on all c4-component-*.md files created, generate:
- System Components Section:
- List all components with:
- Component name
- Short description
- Link to component documentation
- Component Relationships Diagram:
- Mermaid diagram showing all components and their relationships
- Show dependencies between components
- Show external system dependencies
Save the output as: C4-Documentation/c4-component.md
Expected output: Master c4-component.md file
Context: All c4-component-*.md files
Phase 3: Container-Level Synthesis
3.1 Analyze Components and Deployment Definitions
- Review all c4-component-*.md files
- Search for deployment/infrastructure definitions:
- Dockerfiles
- Kubernetes manifests (deployments, services, etc.)
- Docker Compose files
- Terraform/CloudFormation configs
- Cloud service definitions (AWS Lambda, Azure Functions, etc.)
- CI/CD pipeline definitions
3.2 Map Components to Containers
Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-container).
Instruction: |
Synthesize components into containers based on deployment definitions.
Component documentation:
[List of all c4-component-*.md file paths]
Deployment definitions found:
[List of deployment config files: Dockerfiles, K8s manifests, etc.]
Create comprehensive C4 Container-level documentation following this structure:
- Containers Section (for each container):
- Name: [Container name]
- Description: [Short description of container purpose and deployment]
- Type: [Web Application, API, Database, Message Queue, etc.]
- Technology: [Primary technologies: Node.js, Python, PostgreSQL, etc.]
- Deployment: [Docker, Kubernetes, Cloud Service, etc.]
- Purpose Section (for each container):
- Detailed description of what this container does
- How it's deployed
- Its role in the system
- Components Section (for each container):
- List all components deployed in this container
- Link to component documentation
- Interfaces Section (for each container):
- Document all container APIs and interfaces:
- API/Interface name
- Protocol (REST, GraphQL, gRPC, Events, etc.)
- Description
- Link to OpenAPI/Swagger/API Spec file
- List of endpoints/operations
- API Specifications:
- For each container API, create an OpenAPI 3.1+ specification
- Save as: C4-Documentation/apis/[container-name]-api.yaml
- Include:
- All endpoints with methods (GET, POST, etc.)
- Request/response schemas
- Authentication requirements
- Error responses
- Dependencies Section (for each container):
- Containers used (other containers this depends on)
- External systems (databases, third-party APIs, etc.)
- Communication protocols
- Infrastructure Section (for each container):
- Link to deployment config (Dockerfile, K8s manifest, etc.)
- Scaling strategy
- Resource requirements (CPU, memory, storage)
- Container Diagram:
- Mermaid diagram showing all containers and their relationships
- Show communication protocols
- Show external system dependencies
Save the output as: C4-Documentation/c4-container.md
Expected output: c4-container.md with all containers and API specifications
Context: All component documentation and deployment definitions
Phase 4: Context-Level Documentation
4.1 Analyze System Documentation
- Review container and component documentation
- Search for system documentation:
- README files
- Architecture documentation
- Requirements documents
- Design documents
- Test files (to understand system behavior)
- API documentation
- User documentation
4.2 Create Context Documentation
Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-context).
Instruction: |
Create comprehensive C4 Context-level documentation for the system.
Container documentation: C4-Documentation/c4-container.md
Component documentation: C4-Documentation/c4-component.md
System documentation: [List of README, architecture docs, requirements, etc.]
Test files: [List of test files that show system behavior]
Create comprehensive C4 Context-level documentation following this structure:
- System Overview Section:
- Short Description: [One-sentence description of what the system does]
- Long Description: [Detailed description of system purpose, capabilities, problems solved]
- Personas Section:
- For each persona (human users and programmatic "users"):
- Persona name
- Type (Human User / Programmatic User / External System)
- Description (who they are, what they need)
- Goals (what they want to achieve)
- Key features used
- System Features Section:
- For each high-level feature:
- Feature name
- Description (what this feature does)
- Users (which personas use this feature)
- Link to user journey map
- User Journeys Section:
- For each key feature and persona:
- Journey name: [Feature Name] - [Persona Name] Journey
- Step-by-step journey:
- ...
- Include all system touchpoints
- For programmatic users (external systems, APIs):
- Integration journey with step-by-step process
- External Systems and Dependencies Section:
- For each external system:
- System name
- Type (Database, API, Service, Message Queue, etc.)
- Description (what it provides)
- Integration type (API, Events, File Transfer, etc.)
- Purpose (why the system depends on this)
- System Context Diagram:
- Mermaid C4Context diagram showing:
- The system (as a box in the center)
- All personas (users) around it
- All external systems around it
- Relationships and data flows
- Use C4Context notation for proper C4 diagram
- Related Documentation Section:
- Links to container documentation
- Links to component documentation
Save the output as: C4-Documentation/c4-context.md
Ensure the documentation is:
- Understandable by non-technical stakeholders
- Focuses on system purpose, users, and external relationships
- Includes comprehensive user journey maps
- Identifies all external systems and dependencies
Expected output: c4-context.md with complete system context
Context: All container, component, and system documentation
Configuration Options
target_directory: Root directory to analyze (default: current repository root)
exclude_patterns: Patterns to exclude (default: node_modules, .git, build, dist, etc.)
output_directory: Where to write C4 documentation (default: C4-Documentation/)
include_tests: Whether to analyze test files for context (default: true)
api_format: Format for API specs (default: openapi)
Success Criteria
- ✅ Every subdirectory has a corresponding c4-code-*.md file
- ✅ All code-level documentation includes complete function signatures
- ✅ Components are logically grouped with clear boundaries
- ✅ All components have interface documentation
- ✅ Master component index created with relationship diagram
- ✅ Containers map to actual deployment units
- ✅ All container APIs documented with OpenAPI/Swagger specs
- ✅ Container diagram shows deployment architecture
- ✅ System context includes all personas (human and programmatic)
- ✅ User journeys documented for all key features
- ✅ All external systems and dependencies identified
- ✅ Context diagram shows system, users, and external systems
- ✅ Documentation is organized in C4-Documentation/ directory
Output Structure
C4-Documentation/
├── c4-code-*.md # Code-level docs (one per directory)
├── c4-component-*.md # Component-level docs (one per component)
├── c4-component.md # Master component index
├── c4-container.md # Container-level docs
├── c4-context.md # Context-level docs
└── apis/ # API specifications
├── [container]-api.yaml # OpenAPI specs for each container
└── ...
Coordination Notes
- Bottom-up processing: Process directories from deepest to shallowest
- Incremental synthesis: Each level builds on the previous level's documentation
- Complete coverage: Every directory must have code-level documentation before synthesis
- Link consistency: All documentation files link to each other appropriately
- API documentation: Container APIs must have OpenAPI/Swagger specifications
- Stakeholder-friendly: Context documentation should be understandable by non-technical stakeholders
- Mermaid diagrams: Use proper C4 Mermaid notation for all diagrams
Example Usage
/c4-architecture:c4-architecture
This will:
- Walk through all subdirectories bottom-up
- Create c4-code-*.md for each directory
- Synthesize into components
- Map to containers with API docs
- Create system context with personas and journeys
All documentation written to: C4-Documentation/
Output Format
<result>
<analysis>Brief analysis</analysis>
<solution>Implementation</solution>
<considerations>Trade-offs and notes</considerations>
</result>
1---2name: c4-architecture3description: ---4---5---6name: c4-architecture7description: Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.8---9# C4 Architecture Documentation Workflow1011Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.1213[Extended thinking: This workflow implements a complete C4 architecture documentation process following the C4 model (Context, Container, Component, Code). It uses a bottom-up approach, starting from the deepest code directories and working upward, ensuring every code element is documented before synthesizing into higher-level abstractions. The workflow coordinates four specialized C4 agents (Code, Component, Container, Context) to create a complete architectural documentation set that serves both technical and non-technical stakeholders.]1415## Overview1617This workflow creates comprehensive C4 architecture documentation following the [official C4 model](https://c4model.com/diagrams) by:18191. **Code Level**: Analyzing every subdirectory bottom-up to create code-level documentation202. **Component Level**: Synthesizing code documentation into logical components within containers213. **Container Level**: Mapping components to deployment containers with API documentation (shows high-level technology choices)224. **Context Level**: Creating high-level system context with personas and user journeys (focuses on people and software systems, not technologies)2324**Note**: According to the [C4 model](https://c4model.com/diagrams), you don't need to use all 4 levels of diagram - the system context and container diagrams are sufficient for most software development teams. This workflow generates all levels for completeness, but teams can choose which levels to use.2526All documentation is written to a new `C4-Documentation/` directory in the repository root.2728## Phase 1: Code-Level Documentation (Bottom-Up Analysis)2930### 1.1 Discover All Subdirectories3132- Use codebase search to identify all subdirectories in the repository33- Sort directories by depth (deepest first) for bottom-up processing34- Filter out common non-code directories (node_modules, .git, build, dist, etc.)35- Create list of directories to process3637### 1.2 Process Each Directory (Bottom-Up)3839For each directory, starting from the deepest:4041- Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-code).42- Instruction: |43 Analyze the code in directory: [directory_path]4445 Create comprehensive C4 Code-level documentation following this structure:46 1. **Overview Section**:47 - Name: [Descriptive name for this code directory]48 - Description: [Short description of what this code does]49 - Location: [Link to actual directory path relative to repo root]50 - Language: [Primary programming language(s) used]51 - Purpose: [What this code accomplishes]52 2. **Code Elements Section**:53 - Document all functions/methods with complete signatures:54 - Function name, parameters (with types), return type55 - Description of what each function does56 - Location (file path and line numbers)57 - Dependencies (what this function depends on)58 - Document all classes/modules:59 - Class name, description, location60 - Methods and their signatures61 - Dependencies62 3. **Dependencies Section**:63 - Internal dependencies (other code in this repo)64 - External dependencies (libraries, frameworks, services)65 4. **Relationships Section**:66 - Optional Mermaid diagram if relationships are complex6768 Save the output as: C4-Documentation/c4-code-[directory-name].md69 Use a sanitized directory name (replace / with -, remove special chars) for the filename.7071 Ensure the documentation includes:72 - Complete function signatures with all parameters and types73 - Links to actual source code locations74 - All dependencies (internal and external)75 - Clear, descriptive names and descriptions7677- Expected output: c4-code-<directory-name>.md file in C4-Documentation/78- Context: All files in the directory and its subdirectories7980**Repeat for every subdirectory** until all directories have corresponding c4-code-\*.md files.8182## Phase 2: Component-Level Synthesis8384### 2.1 Analyze All Code-Level Documentation8586- Collect all c4-code-\*.md files created in Phase 187- Analyze code structure, dependencies, and relationships88- Identify logical component boundaries based on:89 - Domain boundaries (related business functionality)90 - Technical boundaries (shared frameworks, libraries)91 - Organizational boundaries (team ownership, if evident)9293### 2.2 Create Component Documentation9495For each identified component:9697- Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-component).98- Instruction: |99 Synthesize the following C4 Code-level documentation files into a logical component:100101 Code files to analyze:102 [List of c4-code-*.md file paths]103104 Create comprehensive C4 Component-level documentation following this structure:105 1. **Overview Section**:106 - Name: [Component name - descriptive and meaningful]107 - Description: [Short description of component purpose]108 - Type: [Application, Service, Library, etc.]109 - Technology: [Primary technologies used]110 2. **Purpose Section**:111 - Detailed description of what this component does112 - What problems it solves113 - Its role in the system114 3. **Software Features Section**:115 - List all software features provided by this component116 - Each feature with a brief description117 4. **Code Elements Section**:118 - List all c4-code-\*.md files contained in this component119 - Link to each file with a brief description120 5. **Interfaces Section**:121 - Document all component interfaces:122 - Interface name123 - Protocol (REST, GraphQL, gRPC, Events, etc.)124 - Description125 - Operations (function signatures, endpoints, etc.)126 6. **Dependencies Section**:127 - Components used (other components this depends on)128 - External systems (databases, APIs, services)129 7. **Component Diagram**:130 - Mermaid diagram showing this component and its relationships131132 Save the output as: C4-Documentation/c4-component-[component-name].md133 Use a sanitized component name for the filename.134135- Expected output: c4-component-<name>.md file for each component136- Context: All relevant c4-code-\*.md files for this component137138### 2.3 Create Master Component Index139140- Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-component).141- Instruction: |142 Create a master component index that lists all components in the system.143144 Based on all c4-component-\*.md files created, generate:145 1. **System Components Section**:146 - List all components with:147 - Component name148 - Short description149 - Link to component documentation150 2. **Component Relationships Diagram**:151 - Mermaid diagram showing all components and their relationships152 - Show dependencies between components153 - Show external system dependencies154155 Save the output as: C4-Documentation/c4-component.md156157- Expected output: Master c4-component.md file158- Context: All c4-component-\*.md files159160## Phase 3: Container-Level Synthesis161162### 3.1 Analyze Components and Deployment Definitions163164- Review all c4-component-\*.md files165- Search for deployment/infrastructure definitions:166 - Dockerfiles167 - Kubernetes manifests (deployments, services, etc.)168 - Docker Compose files169 - Terraform/CloudFormation configs170 - Cloud service definitions (AWS Lambda, Azure Functions, etc.)171 - CI/CD pipeline definitions172173### 3.2 Map Components to Containers174175- Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-container).176- Instruction: |177 Synthesize components into containers based on deployment definitions.178179 Component documentation:180 [List of all c4-component-*.md file paths]181182 Deployment definitions found:183 [List of deployment config files: Dockerfiles, K8s manifests, etc.]184185 Create comprehensive C4 Container-level documentation following this structure:186 1. **Containers Section** (for each container):187 - Name: [Container name]188 - Description: [Short description of container purpose and deployment]189 - Type: [Web Application, API, Database, Message Queue, etc.]190 - Technology: [Primary technologies: Node.js, Python, PostgreSQL, etc.]191 - Deployment: [Docker, Kubernetes, Cloud Service, etc.]192 2. **Purpose Section** (for each container):193 - Detailed description of what this container does194 - How it's deployed195 - Its role in the system196 3. **Components Section** (for each container):197 - List all components deployed in this container198 - Link to component documentation199 4. **Interfaces Section** (for each container):200 - Document all container APIs and interfaces:201 - API/Interface name202 - Protocol (REST, GraphQL, gRPC, Events, etc.)203 - Description204 - Link to OpenAPI/Swagger/API Spec file205 - List of endpoints/operations206 5. **API Specifications**:207 - For each container API, create an OpenAPI 3.1+ specification208 - Save as: C4-Documentation/apis/[container-name]-api.yaml209 - Include:210 - All endpoints with methods (GET, POST, etc.)211 - Request/response schemas212 - Authentication requirements213 - Error responses214 6. **Dependencies Section** (for each container):215 - Containers used (other containers this depends on)216 - External systems (databases, third-party APIs, etc.)217 - Communication protocols218 7. **Infrastructure Section** (for each container):219 - Link to deployment config (Dockerfile, K8s manifest, etc.)220 - Scaling strategy221 - Resource requirements (CPU, memory, storage)222 8. **Container Diagram**:223 - Mermaid diagram showing all containers and their relationships224 - Show communication protocols225 - Show external system dependencies226227 Save the output as: C4-Documentation/c4-container.md228229- Expected output: c4-container.md with all containers and API specifications230- Context: All component documentation and deployment definitions231232## Phase 4: Context-Level Documentation233234### 4.1 Analyze System Documentation235236- Review container and component documentation237- Search for system documentation:238 - README files239 - Architecture documentation240 - Requirements documents241 - Design documents242 - Test files (to understand system behavior)243 - API documentation244 - User documentation245246### 4.2 Create Context Documentation247248- Do this step directly in Codex CLI (legacy playbook referenced subagent: c4-architecture::c4-context).249- Instruction: |250 Create comprehensive C4 Context-level documentation for the system.251252 Container documentation: C4-Documentation/c4-container.md253 Component documentation: C4-Documentation/c4-component.md254 System documentation: [List of README, architecture docs, requirements, etc.]255 Test files: [List of test files that show system behavior]256257 Create comprehensive C4 Context-level documentation following this structure:258 1. **System Overview Section**:259 - Short Description: [One-sentence description of what the system does]260 - Long Description: [Detailed description of system purpose, capabilities, problems solved]261 2. **Personas Section**:262 - For each persona (human users and programmatic "users"):263 - Persona name264 - Type (Human User / Programmatic User / External System)265 - Description (who they are, what they need)266 - Goals (what they want to achieve)267 - Key features used268 3. **System Features Section**:269 - For each high-level feature:270 - Feature name271 - Description (what this feature does)272 - Users (which personas use this feature)273 - Link to user journey map274 4. **User Journeys Section**:275 - For each key feature and persona:276 - Journey name: [Feature Name] - [Persona Name] Journey277 - Step-by-step journey:278 1. [Step 1]: [Description]279 2. [Step 2]: [Description]280 ...281 - Include all system touchpoints282 - For programmatic users (external systems, APIs):283 - Integration journey with step-by-step process284 5. **External Systems and Dependencies Section**:285 - For each external system:286 - System name287 - Type (Database, API, Service, Message Queue, etc.)288 - Description (what it provides)289 - Integration type (API, Events, File Transfer, etc.)290 - Purpose (why the system depends on this)291 6. **System Context Diagram**:292 - Mermaid C4Context diagram showing:293 - The system (as a box in the center)294 - All personas (users) around it295 - All external systems around it296 - Relationships and data flows297 - Use C4Context notation for proper C4 diagram298 7. **Related Documentation Section**:299 - Links to container documentation300 - Links to component documentation301302 Save the output as: C4-Documentation/c4-context.md303304 Ensure the documentation is:305 - Understandable by non-technical stakeholders306 - Focuses on system purpose, users, and external relationships307 - Includes comprehensive user journey maps308 - Identifies all external systems and dependencies309310- Expected output: c4-context.md with complete system context311- Context: All container, component, and system documentation312313## Configuration Options314315- `target_directory`: Root directory to analyze (default: current repository root)316- `exclude_patterns`: Patterns to exclude (default: node_modules, .git, build, dist, etc.)317- `output_directory`: Where to write C4 documentation (default: C4-Documentation/)318- `include_tests`: Whether to analyze test files for context (default: true)319- `api_format`: Format for API specs (default: openapi)320321## Success Criteria322323- ✅ Every subdirectory has a corresponding c4-code-\*.md file324- ✅ All code-level documentation includes complete function signatures325- ✅ Components are logically grouped with clear boundaries326- ✅ All components have interface documentation327- ✅ Master component index created with relationship diagram328- ✅ Containers map to actual deployment units329- ✅ All container APIs documented with OpenAPI/Swagger specs330- ✅ Container diagram shows deployment architecture331- ✅ System context includes all personas (human and programmatic)332- ✅ User journeys documented for all key features333- ✅ All external systems and dependencies identified334- ✅ Context diagram shows system, users, and external systems335- ✅ Documentation is organized in C4-Documentation/ directory336337## Output Structure338339```340C4-Documentation/341├── c4-code-*.md # Code-level docs (one per directory)342├── c4-component-*.md # Component-level docs (one per component)343├── c4-component.md # Master component index344├── c4-container.md # Container-level docs345├── c4-context.md # Context-level docs346└── apis/ # API specifications347 ├── [container]-api.yaml # OpenAPI specs for each container348 └── ...349```350351## Coordination Notes352353- **Bottom-up processing**: Process directories from deepest to shallowest354- **Incremental synthesis**: Each level builds on the previous level's documentation355- **Complete coverage**: Every directory must have code-level documentation before synthesis356- **Link consistency**: All documentation files link to each other appropriately357- **API documentation**: Container APIs must have OpenAPI/Swagger specifications358- **Stakeholder-friendly**: Context documentation should be understandable by non-technical stakeholders359- **Mermaid diagrams**: Use proper C4 Mermaid notation for all diagrams360361## Example Usage362363```bash364/c4-architecture:c4-architecture365```366367This will:3683691. Walk through all subdirectories bottom-up3702. Create c4-code-\*.md for each directory3713. Synthesize into components3724. Map to containers with API docs3735. Create system context with personas and journeys374375All documentation written to: C4-Documentation/376## Output Format377378```xml379<result>380 <analysis>Brief analysis</analysis>381 <solution>Implementation</solution>382 <considerations>Trade-offs and notes</considerations>383</result>384```