Home / Market / c4 architecture c4 architecture

c4 architecture c4 architecture

Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.

skill★ 509030 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: c4-architecture-c4-architecture description: "Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach." risk: critical source: community date_added: "2026-02-27"

---

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.]

Use this skill when

Do not use this skill when

Instructions

Overview

This workflow creates comprehensive C4 architecture documentation following the official C4 model by:

  1. Code Level: Analyzing every subdirectory bottom-up to create code-level documentation
  2. Component Level: Synthesizing code documentation into logical components within containers
  3. Container Level: Mapping components to deployment containers with API documentation (shows high-level technology choices)
  4. 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

1.2 Process Each Directory (Bottom-Up)

For each directory, starting from the deepest:

Analyze the code in directory: [directory_path]

Create comprehensive C4 Code-level documentation following this structure:

  1. Overview Section:
  1. Code Elements Section:
  1. Dependencies Section:
  1. Relationships Section:

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:

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

2.2 Create Component Documentation

For each identified component:

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:

  1. Overview Section:
  1. Purpose Section:
  1. Software Features Section:
  1. Code Elements Section:
  1. Interfaces Section:
  1. Dependencies Section:
  1. Component Diagram:

Save the output as: C4-Documentation/c4-component-[component-name].md Use a sanitized component name for the filename.

2.3 Create Master Component Index

Create a master component index that lists all components in the system.

Based on all c4-component-\*.md files created, generate:

  1. System Components Section:
  1. Component Relationships Diagram:

Save the output as: C4-Documentation/c4-component.md

Phase 3: Container-Level Synthesis

3.1 Analyze Components and Deployment Definitions

3.2 Map Components to Containers

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:

  1. Containers Section (for each container):
  1. Purpose Section (for each container):
  1. Components Section (for each container):
  1. Interfaces Section (for each container):
  1. API Specifications:
  1. Dependencies Section (for each container):
  1. Infrastructure Section (for each container):
  1. Container Diagram:

Save the output as: C4-Documentation/c4-container.md

Phase 4: Context-Level Documentation

4.1 Analyze System Documentation

4.2 Create Context Documentation

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:

  1. System Overview Section:
  1. Personas Section: