c4-diagram
Skill1 starsChanged 6 months agoMITView on GitHub
Produce C4 software architecture diagrams in Mermaid notation (flowchart + subgraphs, not experimental C4* syntax). Handles system context, container, component, deployment, dynamic, and landscape views. Use when the user needs architecture diagrams, wants to visualize system structure, or mentions C4, Mermaid, or software architecture communication. Validates output syntax.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- bsene/skillstheir own version, first seen Oct 25, 2026
- mccc8/claude-skillstheir own version, first seen Oct 13, 2026
- dougmotshell/mathematics-studiestheir own version, first seen Aug 1, 2026
- aleksnikolaev/c4-diagram-skilltheir own version, first seen Mar 29, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- aleksnikolaev/c4-diagram-skill★ 15same name
- bsene/skills★ 7same name
- dougmotshell/mathematics-studies★ 0same name
- mccc8/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- distill-knowledgeSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 131
Before drawing anything, map the architecture to C4 vocabulary:
- Very specific: line 161
Use flowchart TB for hierarchical views, flowchart LR for pipelines/flows
- Distinctive: line 162
Keep under 25 nodes — split into focused sub-views if larger
- Very specific: line 163
Use click NodeID "url" "tooltip" for drill-down links between diagrams
- Very specific: line 195
NEVER: use C4Context, C4Container, C4Component, C4Deployment, C4Dynamic — experimental, breaks across versions.
- Very specific: line 196
ALWAYS: use flowchart + subgraph for structural diagrams, sequenceDiagram for temporal interactions.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C4 Architecture Diagrams → Mermaid
Emit valid Mermaid flowchart code blocks that follow C4 methodology. Never use experimental C4Context/C4Container/C4Component/C4Deployment syntax — it breaks across Mermaid versions.
References (load on demand): abstractions · diagram selection · anti-patterns · mermaid gotchas · templates: context · container · component · deployment · dynamic · landscape
Validation: node scripts/validate_mermaid.mjs <file>. On first use run npm install in scripts/.
Rendering Primitives
Node label formula
["<b>Name</b><br/><i>[Stereotype: Technology]</i><br/>One-line responsibility"]Shapes → C4 element types
| C4 Element | Shape | Example |
| Person | (["..."]) | User(["<b>User</b><br/><i>[Person]</i><br/>Uses the system"]) |
| Software System | ["..."] | IBS["<b>IBS</b><br/><i>[Software System]</i><br/>Online banking"] |
| Container | ["..."] | API["<b>API</b><br/><i>[Container: Go]</i><br/>Serves REST endpoints"] |
| Component | ["..."] | Auth["<b>Auth</b><br/><i>[Component: Spring Bean]</i><br/>Handles login"] |
| Database | [("...")] | DB[("<b>DB</b><br/><i>[Container: PostgreSQL]</i><br/>Stores accounts")] |
| External system | ["..."]:::external | Mail["<b>Mailgun</b><br/><i>[External System]</i><br/>Sends emails"]:::external |
Boundaries = subgraphs
subgraph systemName ["System Name — [Software System]"]
direction TB
Container1["..."]
Container2["..."]
endNest subgraphs for deployment nodes, trust boundaries, or container internals.
Edges
| Style | Syntax | Use for |
| Solid | --> | Runtime interaction |
| Dashed | .-> | Static dependency / ownership / non-runtime |
| Bidirectional | <--> | Only when both directions are semantically meaningful |
Label every edge with purpose, not protocol:
A -- "sends commands to" --> B
A -. "reads config from" .-> CProtocol belongs one level down (container edges show tech on container diagrams, not on context diagrams).
Title (mandatory)
---
title: System Name — View Type
---
flowchart TB
...Legend (mandatory on structural diagrams)
subgraph Legend["Legend"]
direction LR
LP(["Person"]):::person
LS["Internal System"]:::system
LE["External System"]:::external
LP ~~~ LS ~~~ LE
end
classDef person fill:#08427b,color:#fff,stroke:#052e56
classDef system fill:#1168bd,color:#fff,stroke:#0b4884
classDef external fill:#999999,color:#fff,stroke:#6b6b6bAdapt legend entries to match what appears in the diagram. Use ~~~ (invisible link) for layout.
Colors
| Class | Use for | Default |
person | People / actors | #08427b dark blue |
system | Internal systems / containers | #1168bd blue |
external | External systems / services | #999999 grey |
container | Containers (when distinguishing from system) | #438dd5 lighter blue |
component | Components | #85bbf0 lightest blue |
database | Data stores | #438dd5 with cylinder shape |
Colors are not prescribed by C4 — adapt to context. Be consistent within and across diagrams.
Workflow
Step 0 — Intake
Ask:
- What system (or landscape) are we diagramming?
- Who is the audience? (everyone / technical / architects+devs)
- What's the goal? (communicate to stakeholders / onboard devs / design review / document current state)
- Do you already have named abstractions (systems, containers, components) or should we identify them together?
Sensible defaults if user skips fields. Proceed once enough context exists.
Step 1 — Identify Abstractions
Before drawing anything, map the architecture to C4 vocabulary:
- Software system — what a single team owns. The team boundary = system boundary.
- Container — a running application or data store. Not Docker (though often maps to Docker).
- Component — a grouping of related code behind an interface, inside a container. Not separately deployable.
Load references/abstractions.md for:
- Microservice decision: same team → containers; different team → separate system
- Queues/topics: model as individual containers (data stores), not a single "message bus"
- Shared libraries: not containers — show as component copies with color coding
Step 2 — Select Diagram Type
| Audience | Goal | Diagram type |
| Everyone | Big picture | System Context |
| Everyone | Enterprise overview | System Landscape |
| Technical | Architecture shape | Container |
| Architects + devs | Internal structure | Component |
| Technical | Runtime behavior | Dynamic (sequence) |
| Ops / infra | Where it runs | Deployment |
Load references/diagram-selection.md for detail. Confirm choice with user.
Most teams need only System Context + Container. Don't over-diagram.
Step 3 — Produce Diagram
- Load the template for the chosen type from
assets/templates/ - Apply the rendering primitives from this file
- Use
flowchart TBfor hierarchical views,flowchart LRfor pipelines/flows - Keep under 25 nodes — split into focused sub-views if larger
- Use
click NodeID "url" "tooltip"for drill-down links between diagrams
Step 4 — Validate Syntax
node scripts/validate_mermaid.mjs diagram.mmdOr pipe directly:
echo '<mermaid code>' | node scripts/validate_mermaid.mjs --strict -Fix errors. Re-run until ✓ Valid. Use --strict to also reject banned C4* keywords.
Step 5 — Self-Check (notation quality)
- Title present (YAML frontmatter in the mermaid block)
- Every element has
[Stereotype]in label - Every element has one-line responsibility description
- Every container/component has technology stated
- Every edge is labeled with purpose
- Every edge is unidirectional (bidirectional only when both directions meaningful)
- Legend subgraph present (structural diagrams)
- Diagram has ≤ 25 nodes
- No
C4Context/C4Container/C4Component/C4Deploymentkeywords - Labels with HTML or special chars are quoted
Hard Rules
- NEVER use
C4Context,C4Container,C4Component,C4Deployment,C4Dynamic— experimental, breaks across versions. - ALWAYS use
flowchart+subgraphfor structural diagrams,sequenceDiagramfor temporal interactions. - ALWAYS quote labels containing HTML (
<b>,<i>,<br/>) or special chars. - ALWAYS include Legend subgraph in structural diagrams.
- ALWAYS validate with
scripts/validate_mermaid.mjsbefore delivering. - Purpose on edges, not protocol. Protocol belongs one level down.
- Abstraction labels (
[Person],[Software System],[Container: Tech],[Component: Tech]) are mandatory — they tell the reader what level they are looking at.
Anti-Patterns (top 5)
- Hub-and-spoke message bus — modeling RabbitMQ/Kafka as one container. Model each queue/topic as its own container instead. See anti-patterns.
- Microservice as component — a microservice is a container (or group of containers), never a component. Components are not separately deployable.
- Mixing abstraction levels — a context diagram showing containers, or a container diagram showing components from other systems. Each diagram has one scope.
- Unlabeled edges — every arrow must say what it does. "Uses" is too vague. Be specific: "sends payment requests to", "reads user profiles from".
- Missing boundaries — if your container diagram doesn't have a subgraph showing the system boundary, the reader can't tell what's inside vs. outside.
Full catalog: references/anti-patterns.md
Mermaid Syntax Pitfalls
| Error | Fix |
Unescaped ()[] in labels | Quote entire label: ["label with (parens)"] |
| Missing quotes on HTML labels | Always: ["<b>Name</b><br/>desc"] |
subgraph without end | Every subgraph needs matching end |
| Empty subgraph | Must contain at least one node |
| HTML stripped at render time | Renderer needs securityLevel: 'loose' — note in output |
Full list: references/mermaid-gotchas.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

