Agent skill
viz-c4-diagram
Generate C4 architecture diagrams using Mermaid syntax. Use when the user says "draw a C4 diagram", "architecture diagram", "system context diagram", "container diagram", "component diagram", or "visualize the architecture".
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/viz-c4-diagram
SKILL.md
Generate C4 Diagrams
Path Resolution
- Read
workflow.jsonin the project root - If it exists and
docsRepois".": this IS the docs repo — use local paths - If it exists and
docsRepois a repo name: resolve viapwsh .claude/skills/tool-worktree/scripts/resolve-repo.ps1 <docsRepo>to get the docs root path. Templates at<resolved>/templates/, output to<resolved>/architecture/ - If no
workflow.json: templates attemplates/, output todocs/architecture/
Instructions
- Resolve paths (see Path Resolution above)
- Read the template at
<templates>/c4-diagrams.mdfor Mermaid C4 syntax reference - Determine the scope:
- What system or subsystem to diagram?
- What level(s)? (Context, Container, Component, Code)
- If not specified, start with Context + Container
- Analyze the codebase if diagramming an existing system:
- Read project structure and key files
- Identify external dependencies and integrations
- Map internal components and their relationships
- Generate diagrams using Mermaid C4 syntax:
- Level 1 — Context:
C4Context— system and its environment - Level 2 — Container:
C4Container— high-level tech building blocks - Level 3 — Component:
C4Component— internals of a container - Level 4 — Code:
classDiagram— class/interface relationships
- Level 1 — Context:
- Save to the appropriate location:
- Standalone:
<output>/[system]-c4.md - As part of a design doc: embed in the design doc directly
- Standalone:
C4 Level Guide
Level 1: System Context
- Audience: Everyone (tech and non-tech)
- Shows: The system as a box, users, and external systems
- Elements:
Person,System,System_Ext,Rel
Level 2: Container
- Audience: Technical people
- Shows: Applications, databases, message queues, file systems
- Elements:
Container,ContainerDb,ContainerQueue,System_Ext,System_Boundary
Level 3: Component
- Audience: Developers
- Shows: Components inside a container (services, repositories, controllers)
- Elements:
Component,Container_Boundary,ContainerDb
Level 4: Code
- Audience: Developers working on the component
- Shows: Classes, interfaces, relationships
- Use: Standard Mermaid
classDiagram(not C4 syntax)
Quality Checklist
- Each diagram has a descriptive title
- Relationships have labels describing what flows between elements
- External systems are clearly distinguished (
_Extsuffix) - Technology choices are annotated (e.g., "ASP.NET Core", "PostgreSQL")
- Diagrams zoom in logically (Context → Container → Component)
- No diagram has more than ~15 elements (split if larger)
Tips
- Start broad (Context) and zoom in — don't jump to Component level
- Every relationship arrow should have a verb ("Calls", "Reads from", "Publishes to")
- Include the technology in element descriptions ("Angular", "REST/JSON", "gRPC")
- For deployment diagrams, use
C4DeploymentwithDeployment_Node
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?