Antigravity c4 architecture c4 architecture

From boisenoise/skills-collections · View interactive version

Antigravity c4 architecture c4 architecture is an AI agent skill from the GitHub repository boisenoise/skills-collections. Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.

How to use this skill

Skill file

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

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 C4 applications/data stores 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. 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

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:

2. Code Elements Section:

3. Dependencies Section:

4. Relationships Section:

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:

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:

2. Purpose Section:

3. Software Features Section:

4. Code Elements Section:

5. Interfaces Section:

6. Dependencies Section:

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

2. 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):

2. Purpose Section (for each container):

3. Components Section (for each container):

4. Interfaces Section (for each container):

5. API Specifications:

6. Dependencies Section (for each container):

7. Infrastructure Section (for each container):

8. 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:

2. Personas Section:

3. System Features Section:

4. User Journeys Section:

1. [Step 1]: [Description]

2. [Step 2]: [Description]

...

5. External Systems and Dependencies Section:

6. System Context Diagram:

7. Related Documentation Section:

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

Ensure the documentation is:

Configuration Options

Do not infer users, journeys, scaling or CPU/memory requirements from naming alone; link source evidence or label an assumption/open question. Review diagrams against code/deployment owners, check links and IDs, and distinguish static source interpretation from actual runtime topology.

Success Criteria

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

Example Usage

Document this repository’s context and containers at the specified commit.
Include source links and open questions; omit detailed code views unless they add value.

This will:

  1. Walk through all subdirectories bottom-up
  2. Create c4-code-\*.md for each directory
  3. Synthesize into components
  4. Map to containers with API docs
  5. Create system context with personas and journeys

All documentation written to: C4-Documentation/

Limitations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.