C4 Architecture Documentation Workflow
Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.
Use a bottom-up source inventory to support C4 views, while selecting only levels useful to the audience. Specialized agents are optional execution helpers, not bundled tools or evidence that source was reviewed.
Use this skill when
- Working on c4 architecture documentation workflow tasks or workflows
- Needing guidance, best practices, or checklists for c4 architecture documentation workflow
Do not use this skill when
- The task is unrelated to c4 architecture documentation workflow
- You need a different domain or tool outside this scope
Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
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 C4 applications/data stores 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. Select useful levels first; code-level diagrams are optional and are not a function catalog for every directory. Preserve a source inventory even when detailed diagrams are omitted.
Use the user’s requested location, otherwise propose a new C4-Documentation/ directory in the repository root.
Before writing, record repository/head, audience, system boundary and files actually inspected. Protect secrets/internal infrastructure details and follow existing docs conventions. C4 containers are applications or data stores, not synonymous with Docker containers or one deployment replica. Components belong inside one container; code directories do not by themselves establish component boundaries.
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:
If an authorized compatible subagent exists, delegate this bounded analysis; otherwise perform it directly. c4-architecture::c4-code is an example role name, not a bundled tool.
Prompt: |
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 stable collision-free path mapping: a/b and a-b must not overwrite each other. Prefer matching output subdirectories or append a short path hash, and record the map.
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: Only files directly owned by this inventory unit; link previously reviewed child inventories instead of repeatedly claiming the same files
Repeat for every subdirectory until all directories have corresponding c4-code-*.md
1---2name: c4-architecture-c4-architecture3description: Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach. 4category: Document Processing5source: antigravity6tags: [python, node, api, ai, agent, workflow, template, design, document, docker]7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/c4-architecture-c4-architecture8metadata:9 source: https://skillmd.com/skills/ranbot-ai/c4-architecture-c4-architecture10---111213# C4 Architecture Documentation Workflow1415Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.1617Use a bottom-up source inventory to support C4 views, while selecting only levels useful to the audience. Specialized agents are optional execution helpers, not bundled tools or evidence that source was reviewed.1819## Use this skill when2021- Working on c4 architecture documentation workflow tasks or workflows22- Needing guidance, best practices, or checklists for c4 architecture documentation workflow2324## Do not use this skill when2526- The task is unrelated to c4 architecture documentation workflow27- You need a different domain or tool outside this scope2829## Instructions3031- Clarify goals, constraints, and required inputs.32- Apply relevant best practices and validate outcomes.33- Provide actionable steps and verification.3435## Overview3637This workflow creates comprehensive C4 architecture documentation following the [official C4 model](https://c4model.com/diagrams) by:38391. **Code Level**: Analyzing every subdirectory bottom-up to create code-level documentation402. **Component Level**: Synthesizing code documentation into logical components within containers413. **Container Level**: Mapping components to C4 applications/data stores with API documentation (shows high-level technology choices)424. **Context Level**: Creating high-level system context with personas and user journeys (focuses on people and software systems, not technologies)4344**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. Select useful levels first; code-level diagrams are optional and are not a function catalog for every directory. Preserve a source inventory even when detailed diagrams are omitted.4546Use the user’s requested location, otherwise propose a new `C4-Documentation/` directory in the repository root.4748Before writing, record repository/head, audience, system boundary and files actually inspected. Protect secrets/internal infrastructure details and follow existing docs conventions. C4 containers are applications or data stores, not synonymous with Docker containers or one deployment replica. Components belong inside one container; code directories do not by themselves establish component boundaries.4950## Phase 1: Code-Level Documentation (Bottom-Up Analysis)5152### 1.1 Discover All Subdirectories5354- Use codebase search to identify all subdirectories in the repository55- Sort directories by depth (deepest first) for bottom-up processing56- Filter out common non-code directories (node_modules, .git, build, dist, etc.)57- Create list of directories to process5859### 1.2 Process Each Directory (Bottom-Up)6061For each directory, starting from the deepest:6263- If an authorized compatible subagent exists, delegate this bounded analysis; otherwise perform it directly. c4-architecture::c4-code is an example role name, not a bundled tool.64- Prompt: |65 Analyze the code in directory: [directory_path]6667 Create comprehensive C4 Code-level documentation following this structure:68 1. **Overview Section**:69 - Name: [Descriptive name for this code directory]70 - Description: [Short description of what this code does]71 - Location: [Link to actual directory path relative to repo root]72 - Language: [Primary programming language(s) used]73 - Purpose: [What this code accomplishes]74 2. **Code Elements Section**:75 - Document all functions/methods with complete signatures:76 - Function name, parameters (with types), return type77 - Description of what each function does78 - Location (file path and line numbers)79 - Dependencies (what this function depends on)80 - Document all classes/modules:81 - Class name, description, location82 - Methods and their signatures83 - Dependencies84 3. **Dependencies Section**:85 - Internal dependencies (other code in this repo)86 - External dependencies (libraries, frameworks, services)87 4. **Relationships Section**:88 - Optional Mermaid diagram if relationships are complex8990 Save the output as: C4-Documentation/c4-code-[directory-name].md91 Use a stable collision-free path mapping: a/b and a-b must not overwrite each other. Prefer matching output subdirectories or append a short path hash, and record the map.9293 Ensure the documentation includes:94 - Complete function signatures with all parameters and types95 - Links to actual source code locations96 - All dependencies (internal and external)97 - Clear, descriptive names and descriptions9899- Expected output: c4-code-<directory-name>.md file in C4-Documentation/100- Context: Only files directly owned by this inventory unit; link previously reviewed child inventories instead of repeatedly claiming the same files101102**Repeat for every subdirectory** until all directories have corresponding c4-code-\*.md