Agent skill

C4 Architecture Diagrams

by lexler in lexler/skill-factory

Creates C4 model diagrams at every zoom level, from system landscape to code, in ASCII, Mermaid or Structurizr, for designing or documenting software architecture.

Apache-2.0Auto-check passedDevelopment

Install C4 Architecture Diagrams

skills CLI
$ npx skills add lexler/skill-factory --skill c4-diagrams -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install lexler/skill-factory c4-diagrams --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/lexler/skill-factory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/output_skills/design/c4-diagrams .claude/skills/c4-diagrams && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
c4-diagrams
GitHub stars
239
Token cost
~2.3k tokens
SKILL.md length
1,106 words
Files
13 (incl. scripts, references)
Skills in repo
25
Repo updated
First seen
Licence
Apache-2.0

At a glance

Creates C4 model diagrams at every zoom level, from system landscape to code, in ASCII, Mermaid or Structurizr, for designing or documenting software architecture.

  • Works in 6 steps: Explore the codebase to identify the… → Start at System Context level — identify… → Zoom into Container level — identify… → …
  • Sketching the system context and containers for a new design
  • SKILL.md covers C4 Model, Core Abstractions, Choosing the Diagram Type and Choosing the Output Format, plus 4 more sections
  • Runs Python scripts from its folder; calls uv

What it does

The skill teaches the C4 approach, a hierarchy of four views: System Context, Container, Component and Code. Three more diagram types round it out: System Landscape for all systems in an organization, Dynamic for the runtime behavior of one use case, and Deployment for how containers map onto infrastructure. It defines the building blocks, namely person, software system, container, component and relationship, and stresses that a container here means any deployable unit, not a Docker container.

The agent picks the level that fits the conversation, loads the matching reference for that diagram type and chooses an output format from the ASCII, Mermaid and Structurizr references. A script, `check_ascii_alignment.py`, checks that ASCII diagrams line up, and an evals file is included. Component and code views are suggested only when they add understanding.

When your agent uses it

  • Sketching the system context and containers for a new design
  • Mapping an existing codebase into an architecture diagram
  • Documenting deployment or runtime flow for one use case
  • Producing a Mermaid or Structurizr version of an architecture diagram

Example prompts

  • “Draw a C4 container diagram for our checkout service, its database and the payment provider.”
  • “Map this repository into a component diagram of the API container.”
  • “Give me a Mermaid system landscape of all our internal platforms.”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Explore the codebase to identify the system boundary, external dependencies, and internal structure
  2. Start at System Context level — identify users and external systems
  3. Zoom into Container level — identify deployable units, data stores, and inter-container communication
  4. Ask the user if deeper levels (Component, Code) are needed before going further
  5. For large systems, create multiple focused views by domain area or user journey rather than one giant diagram
  6. Verify the diagram against actual code — don't guess at relationships

What it can do on your machine

Read from SKILL.md and the folder at commit e262032. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

C4 Architecture Diagrams loads about 2.3k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 64 tokens; SKILL.md has 1,106 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~64
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~11k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from lexler/skill-factory at commit e262032, republished under its Apache-2.0 licence (© lexler). 1,106 words, ~2,260 tokens.

Download SKILL.mdSave it as .claude/skills/c4-diagrams/SKILL.md (or your agent's skills folder). This skill also uses 12 other files; get the full folder from GitHub.
name
c4-diagrams
description
Creates C4 architecture diagrams for designing, documenting, or understanding software architecture. Use when working through system design, mapping existing codebases, or visualizing structure at any level from system landscape down to code.

STARTER_CHARACTER = 🏗️

C4 Model

C4 is a hierarchical approach to diagramming software architecture. Four core levels of zoom, each showing more detail:

System Context (one system + its users and external dependencies)
  └── Container (deployable units inside the system)
        └── Component (logical groupings inside a container)
              └── Code (classes, interfaces, functions inside a component)

Three supplementary diagram types complement this hierarchy:

  • System Landscape — zooms out wider than Context, shows all systems in an org
  • Dynamic — shows runtime behavior for a specific use case
  • Deployment — shows how containers map to infrastructure

Core Abstractions

  • Person — a user, actor, or role that interacts with software systems
  • Software System — the highest level of abstraction; a thing that delivers value to users. Can be yours (in scope) or external
  • Container — a separately deployable/runnable unit within a system. Web apps, APIs, databases, message queues, file systems, serverless functions. NOT Docker containers — "container" here means "thing that runs code or stores data"
  • Component — a logical grouping within a container. In practice: a module, package, namespace, or set of related classes
  • Relationship — a unidirectional dependency or data flow between elements

Choosing the Diagram Type

Pick the level that matches the conversation. Load the reference for the type you're creating.

Static structure (the zoom hierarchy):

  • System Context — starting point for any architecture discussion. One system, its users, external dependencies. Both technical and non-technical audiences. → system-context.md
  • Container — inside one system. Shows major technology choices, how deployable units communicate. Technical audience. → container.md
  • Component — inside one container. Shows logical structure. Only when it adds value for understanding. → component.md
  • Code — inside one component. Classes, interfaces, relationships. For understanding a specific component's internals, or when the user requests it. → code.md

Wider or orthogonal views:

  • System Landscape — all systems in an org/department. Like System Context but without focus on one system. For portfolio views. → system-landscape.md
  • Dynamic — how elements interact at runtime for a specific use case. Numbered interactions. Use sparingly, for complex or non-obvious flows. → dynamic.md
  • Deployment — how containers map to infrastructure (servers, cloud, Docker). Per environment. → deployment.md

Most teams need only System Context + Container. Add others when they earn their place.

Choosing the Output Format

Ask the user which format they prefer. If no preference stated, choose based on context:

  • ASCII — works everywhere: inline docs, chat, code review comments. No tooling needed. → ascii.md
  • Structurizr DSL — architecture as code. Model once, generate multiple views. Render at structurizr.com/dsl or locally. Best for living documentation. → structurizr.md
  • Mermaid — renders natively in GitHub, GitLab, many markdown tools. Good for embedding in docs/READMEs. → mermaid.md

Notation Rules

Every diagram must have:

  • A title stating the diagram type and scope (e.g., "Container diagram for Payment Service")

Every element must have:

  • A name
  • Its type explicitly stated (Person, Software System, Container, Component)

Every container and component must also have:

  • Technology explicitly stated (e.g., "Spring Boot", "PostgreSQL", "React SPA")

Every relationship must:

  • Be unidirectional (one arrow direction)
  • Have a label describing the intent, not just "Uses" — say what it does ("Sends orders to", "Reads credentials from", "Queries customer data via")
  • Include technology/protocol for inter-container communication ("JSON/HTTPS", "JDBC", "gRPC")

Descriptions and legends are format-dependent:

  • Structurizr DSL — descriptions go in element definitions, render as tooltips
  • Mermaid — descriptions go in element parameters, render below the name
  • ASCII — keep boxes minimal (name + technology only). No descriptions inside boxes, no legend block. The conventions are simple enough to be self-evident.

Review Checklist

After creating any diagram, verify:

  • Title present, states diagram type and scope
  • Every element has name and type (descriptions where the format supports them — see Notation Rules)
  • Technology labeled on containers, components, and inter-container relationships
  • Relationship labels describe intent and match arrow direction
  • No vague labels ("Uses", "Connects to") — be specific about what flows
  • Acronyms either universally understood or explained
  • Notation consistent (colors, shapes, line styles mean the same thing across the diagram)
  • For ASCII diagrams: run uv run ${CLAUDE_SKILL_DIR}/scripts/check_ascii_alignment.py <file> to validate box alignment. Fix any issues before presenting.

Anti-Patterns

One giant diagram — if a Container diagram has 20+ containers, split into focused views by domain area or user journey. Each view should tell one story.

Mixing abstraction levels — don't show components and software systems on the same diagram. Each diagram operates at one zoom level.

Missing technology labels — "Web App" tells the reader nothing. "React SPA" or "Spring Boot API" tells them what stack they're looking at.

Vague relationship labels — "Uses" between every element makes the diagram useless. Be specific: "Authenticates via", "Publishes events to", "Reads from".

Deployment details in Container diagrams — clustering, load balancers, replication belong in Deployment diagrams, not Container diagrams.

Show full SKILL.md (391 more words)Show less

Workflows

From Existing Code

When analyzing a codebase to generate diagrams:

  1. Explore the codebase to identify the system boundary, external dependencies, and internal structure
  2. Start at System Context level — identify users and external systems
  3. Zoom into Container level — identify deployable units, data stores, and inter-container communication
  4. Ask the user if deeper levels (Component, Code) are needed before going further
  5. For large systems, create multiple focused views by domain area or user journey rather than one giant diagram
  6. Verify the diagram against actual code — don't guess at relationships

Recognizing C4 elements in code:

  • Separately deployed processes, services, or apps → Containers
  • Databases, message brokers, file stores with their own process/lifecycle → Containers
  • Modules, packages, or namespaces within one deployable → Components
  • External APIs, third-party SaaS, systems you don't control → External Software Systems
  • A monolith is one Container with many Components inside — don't split it into multiple Containers unless the parts deploy independently
From Designs Being Planned

When the user wants to work through architecture for a system that doesn't exist yet — or only partially exists — first figure out where they are in the design process:

  1. Look for existing design artifacts before asking. Check docs/, architecture/, design/, ADRs, RFCs, README files, anywhere design might already be captured. If you find them, read them and base the diagrams on what's there.
  2. If partial designs exist, draft diagrams from them and ask the user only about gaps.
  3. If no design exists, interview the user: what is the system, who uses it, what does it integrate with, what are the major moving parts.
  4. Draft a System Context diagram and validate with the user before going deeper
  5. Discuss containers — what tech, what responsibilities, how they communicate
  6. Draft a Container diagram
  7. Go deeper only if the user wants to explore a specific container's internals

The diagrams are a tool for thinking, not just documentation. Surface architectural decisions as you draft — "I'm assuming the queue decouples ingestion from processing — is that intentional?" — rather than just transcribing what the user said.

After the First Draft
  • Does any single view have too many elements? Split by domain area or user journey
  • Are the abstraction levels consistent? Don't mix containers and components in one diagram
  • Are relationship labels specific or vague?
  • Would someone unfamiliar with the system understand the diagram without narration?

© lexler, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 12 other files (scripts, references) in output_skills/design/c4-diagrams of lexler/skill-factory.

  • SKILL.md
  • evals/evals.json
  • references/diagrams/code.md
  • references/diagrams/component.md
  • references/diagrams/container.md
  • references/diagrams/deployment.md
  • references/diagrams/dynamic.md
  • references/diagrams/system-context.md
  • references/diagrams/system-landscape.md
  • references/formats/ascii.md
  • references/formats/mermaid.md
  • references/formats/structurizr.md
  • scripts/check_ascii_alignment.py

Open the folder on GitHubat commit e262032

Compare with similar skills

C4 Architecture Diagrams next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

C4 Architecture Diagrams compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
C4 Architecture Diagrams this skilllexler/skill-factory239—~2.3kAutomated safety check: PassApache-2.0
Mermaid Diagramsjjmartres/opencode1336 repos~1.9kAutomated safety check: PassMIT
Archify Diagramstt-a1i/archify81k—~2.9kAutomated safety check: PassMIT
Diagram Designcathrynlavery/diagram-design48k1 repos~7.6kAutomated safety check: PassMIT
Draw.io Diagram StudioAgents365-ai/drawio-skill10k—~2.4kAutomated safety check: NotesMIT
Dark Architecture Diagram BuilderCocoon-AI/architecture-diagram-generator7.4k1 repos~2.1kAutomated safety check: PassMIT

Similar skills

  • Mermaid Diagrams

    jjmartres/opencode

    Helps an agent pick the right Mermaid diagram type and write the syntax for class, sequence, flow, ER, C4, state and other software diagrams.

    133 GitHub starsUsed in 6 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Archify Diagrams

    tt-a1i/archify

    Creates interactive architecture, workflow, sequence, data-flow and lifecycle diagrams as standalone HTML with inline SVG, themes and image or video export.

    81k GitHub stars~2.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Diagram Design

    cathrynlavery/diagram-design

    Creates branded diagrams, from architecture, flowchart and sequence to charts and maps, as self-contained HTML with inline SVG, with import from draw.io, Mermaid and Excalidraw.

    48k GitHub starsUsed in 1 repo~7.6k tokens
    DevelopmentAuto-check passed
  • Draw.io Diagram Studio

    Agents365-ai/drawio-skill

    Creates and edits editable draw.io diagrams from descriptions, code, infrastructure files, SQL and API schemas, with sync, review, test and export tools.

    10k GitHub stars~2.4k tokensUpdated 8 days ago
    DevelopmentAuto-check: notes
  • Dark Architecture Diagram Builder

    Cocoon-AI/architecture-diagram-generator

    Creates dark-themed system, cloud, security and network architecture diagrams as self-contained HTML files with inline SVG and CSS.

    7.4k GitHub starsUsed in 1 repo~2.1k tokens
    DevelopmentAuto-check passed
  • Pretty Mermaid Renderer

    imxv/Pretty-mermaid-skills

    Writes and renders Mermaid diagrams as themed SVG, PNG or terminal ASCII and Unicode art with a bundled Node.js CLI that needs no browser.

    1.5k GitHub stars~2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from lexler/skill-factory

All 25 skills in this repo
  • Launching Agent Teams

    lexler/skill-factory

    Plans and launches Claude Code agent teams with distinct roles, right-sized tasks and detailed spawn prompts, and says when subagents or worktrees fit better.

    239 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Claude Code Statusline Writer

    lexler/skill-factory

    Guides writing and debugging Claude Code status line scripts that read session JSON from stdin and print one line of text.

    239 GitHub stars~872 tokensUpdated today
    Auto-check passed
  • Catalog of obstacles, anti-patterns and patterns for working with AI coding agents, covering context management and reliability, from a published patterns collection.

    239 GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Approval Testing Toolkit

    lexler/skill-factory

    Writes snapshot-style approval tests in Python, JavaScript, TypeScript or Java, comparing output against an approved file instead of writing individual assertions.

    239 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Hotspots

    lexler/skill-factory

    Find where a codebase actually costs time by mining its git history (Tornhill hotspot analysis).

    239 GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Nullables Testing Pattern

    lexler/skill-factory

    Teaches the Nullables pattern for testing without mocking libraries: production classes with an off switch, stubbed only at the third-party edge.

    239 GitHub stars~2.2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about C4 Architecture Diagrams

What does C4 Architecture Diagrams do?

Creates C4 model diagrams at every zoom level, from system landscape to code, in ASCII, Mermaid or Structurizr, for designing or documenting software architecture. The skill teaches the C4 approach, a hierarchy of four views: System Context, Container, Component and Code. Three more diagram types round it out: System Landscape for all systems in an organization, Dynamic for the runtime behavior of one use case, and Deployment for how containers map onto infrastructure.

When should I use C4 Architecture Diagrams?

C4 Architecture Diagrams fits situations like: sketching the system context and containers for a new design; mapping an existing codebase into an architecture diagram; documenting deployment or runtime flow for one use case; producing a Mermaid or Structurizr version of an architecture diagram.

How do I install C4 Architecture Diagrams in Claude Code?

Run `npx skills add lexler/skill-factory --skill c4-diagrams -a claude-code`. Or copy the skill folder (output_skills/design/c4-diagrams in lexler/skill-factory) into .claude/skills/c4-diagrams in your project. Claude Code loads it when a task matches its description.

How do I install C4 Architecture Diagrams in Codex?

Run `npx skills add lexler/skill-factory --skill c4-diagrams -a codex`. Or copy the skill folder (output_skills/design/c4-diagrams in lexler/skill-factory) into .agents/skills/c4-diagrams in your project. Codex loads it when a task matches its description.

Can I use C4 Architecture Diagrams in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add lexler/skill-factory --skill c4-diagrams -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/c4-diagrams, .gemini/skills/c4-diagrams, .github/skills/c4-diagrams and .opencode/skills/c4-diagrams in your project.

What does C4 Architecture Diagrams need to run?

Going by SKILL.md and its folder, C4 Architecture Diagrams needs Python for the scripts in its folder and the command-line tools its instructions call (uv).

Does C4 Architecture Diagrams access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is C4 Architecture Diagrams safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does C4 Architecture Diagrams use?

C4 Architecture Diagrams is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does C4 Architecture Diagrams use?

About 2.3k tokens (SKILL.md is roughly 9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 9.1k tokens, read only when the agent opens those files.

What are the alternatives to C4 Architecture Diagrams?

Skills that share tags, products or a category with C4 Architecture Diagrams: Mermaid Diagrams (jjmartres/opencode, 133 stars), Archify Diagrams (tt-a1i/archify, 81k stars), Diagram Design (cathrynlavery/diagram-design, 48k stars) and Draw.io Diagram Studio (Agents365-ai/drawio-skill, 10k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains C4 Architecture Diagrams?

lexler (a GitHub user) maintains it in lexler/skill-factory, which has 239 GitHub stars. The repository holds 25 skills in this directory. The repository was last updated on October 10, 2026.

Source: lexler/skill-factory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.