Automates generation of C4 system context and container diagrams from project code. Includes Structurizr DSL for advanced modeling.

Install

mkdir -p .claude/skills/c4 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17321" && unzip -o skill.zip -d .claude/skills/c4 && rm skill.zip

Installs to .claude/skills/c4

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Generate C4 L1 (Context) + L2 (Container) Mermaid diagrams from a project's codebase. Structurizr DSL escape hatch (--dsl) for L3+ component precision.
151 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Generate C4 Level 1 (System Context) diagrams
  • Generate C4 Level 2 (Container) diagrams
  • Produce Mermaid markdown diagrams from codebase analysis
  • Generate Structurizr DSL for L3+ component precision
  • Detect containers based on various codebase signals
  • Resolve project paths using `_lib-portfolio-paths.sh`

How it works

The skill analyzes a project's codebase to detect deployable units and relationships, then generates C4 Level 1 and Level 2 diagrams in Mermaid markdown format. It can also output Structurizr DSL for more detailed L3+ component precision.

Inputs & outputs

You give it
A project name or current working directory, with optional level and format arguments
You get back
Mermaid markdown files (`{context,container}.md`) or a Structurizr DSL file (`workspace.dsl`)

When to use c4

  • Generate system architecture diagrams
  • Visualize project container structure
  • Create documentation for new features

About this skill

/c4 — Generate C4 Architecture Diagrams

Reads the target project's codebase and produces filled-in Level 1 (System Context) and Level 2 (Container) diagrams as Mermaid markdown. Saves the slog of filling in the templates by hand for a repo you already understand structurally.

This skill complements /handover (which seeds a stub L2 once at onboarding). Use /c4 whenever the architecture changes substantially and the diagrams need a refresh — or for a project that wasn't onboarded via /handover.

For projects that hit Mermaid's ceiling — L3 (component) precision, auto-zoom across levels, tags/perspectives — pass --dsl to emit a Structurizr DSL workspace instead. See "Escape hatch: Structurizr DSL (L3+)" below.

Path resolution

Read the registry path via portfolio_registry, the per-project docs dir via portfolio_projects_dir, and the ideas backlog via portfolio_ideas_backlog — all from .claude/hooks/_lib-portfolio-paths.sh. Source the helper at the top of any bash block that touches those paths:

source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-read-config.sh"
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-portfolio-paths.sh"
registry=$(portfolio_registry)

Defaults match today's single-fork layout (./apexyard.projects.yaml, ./projects, ./projects/ideas-backlog.md). Adopters in split-portfolio mode override the portfolio.{registry, projects_dir, ideas_backlog} keys in .claude/project-config.json. Don't hardcode literal apexyard.projects.yaml or projects/ paths in bash blocks — the helper resolves whichever mode the adopter is in. See docs/multi-project.md.

Usage

/c4                                    # current cwd, both levels
/c4 curios-dog                         # registered project, both levels
/c4 curios-dog --level=1               # only the L1 system-context diagram
/c4 . --level=2                        # only the L2 container diagram for cwd
/c4 curios-dog --force                 # overwrite existing diagrams
/c4 curios-dog --dsl                   # Structurizr DSL escape hatch (L3+), instead of Mermaid
/c4 curios-dog --dsl --force           # overwrite an existing workspace.dsl

Output location

Where the files land depends on where the skill is invoked from and what argument is passed:

Invoked fromArgOutput
workspace/<name>/ (project clone)none<project>/docs/architecture/{context,container}.md (inside the project's own repo)
Ops fork root<name> (registered project)projects/<name>/architecture/{context,container}.md (ops view)
Ops fork rootnonedocs/architecture/{name}-{context,container}.md (framework-wide)
Anywhere.Treat cwd as the project; write to docs/architecture/{context,container}.md
Any of the above--dsl addedSame directory as the Mermaid output would use, but a single workspace.dsl file instead of {context,container}.md

The split mirrors the existing convention from docs/multi-project.md § "Architecture diagrams".

Process

1. Resolve the target

  • If <project-name> is . → use cwd.
  • If <project-name> is given and the registry has it → use workspace/<name>/ if it exists, otherwise fall back to ops-view-only mode (no codebase to scan; ask the user to clone or to provide a path).
  • If no arg → use cwd; if cwd is the ops fork root, ask whether the diagram is framework-wide or for a registered project.

If the cwd / target doesn't have any of the detection signals listed below (no package.json, no Dockerfile, no template.yaml, etc.), stop and tell the user — there's nothing to scan.

2. Detect

Run these in parallel; collect findings into a structured proposal.

2a. Containers (L2)

A "container" in C4 is a deployable / runnable unit — a frontend, an API, a database, a queue, a worker, a CDN. Not a Docker container (confusing but standard).

Detection sources:

SignalContainer inferred
web/, frontend/, client/ with package.jsonWeb App (label by framework: detect Next.js / Vite / CRA from dependencies)
backend/, api/, server/ with package.jsonAPI
admin/ with package.jsonAdmin App
Top-level Dockerfile (no monorepo split)Single containerised service (label by base image)
template.yaml (SAM)Each AWS::Serverless::Function → potentially a container, but collapse to one logical "Lambda functions" container unless there are clear domain boundaries (auth-functions vs api-functions). One box per domain, max 5–9 containers total.
serverless.ymlSame pattern as SAM — one container per logical service
Terraform module names (infrastructure/modules/*)Each module that creates a runtime resource (DynamoDB, S3 bucket, CloudFront distribution, Cognito user pool, RDS instance) → infra container. Skip pure-policy / pure-IAM modules.
prisma/schema.prisma or migrations dirDatabase container (label by provider in schema)
package.json deps containing bullmq, bee-queue, agendaBackground Worker container
package.json deps containing @aws-sdk/client-s3, aws-sdk (S3 usage)S3 / object storage as a container if the project owns the bucket
Cron / EventBridge rules in IaCScheduler container

Hard cap: 9 containers max. If detection yields more, collapse the most-similar pair into a single container with a combined label, and surface the collapse to the user during step 3.

2b. External actors and systems (L1)

External actors fall into three buckets — Person (humans), System_Ext (third-party SaaS / APIs), and the System (the box being modelled).

Detection sources:

SignalActor typeInferred name
Auth code present (Cognito / Auth0 / Clerk / Supabase Auth)System_ExtThe auth provider
@aws-sdk/client-bedrock, openai, @anthropic-ai/sdkSystem_ExtThe AI provider
stripe, paddle, lemonsqueezySystem_ExtPayment processor
posthog-js, @amplitude/analytics-browser, mixpanel-browser, react-ga4System_ExtAnalytics provider
@sentry/*, @datadog/*, bugsnag-jsSystem_ExtError / monitoring provider
nodemailer, @sendgrid/mail, postmark, resend, AWS SES useSystem_ExtEmail provider
twilio, vonageSystem_ExtSMS / telephony
algoliasearch, meilisearch, @elastic/elasticsearchSystem_ExtSearch provider
dicebear, image CDNs, fonts CDN (fonts.googleapis.com)System_ExtAsset CDN
Public-facing pages / /[username] style routesPersonPublic visitor
Admin routes (/admin/)PersonAdmin
Auth + non-admin routesPersonEnd user

If a signal could match multiple personas (e.g., the API serves both end users and admins), surface both; the user can collapse during confirm.

Detection should also pull the project's one-sentence description from:

  • The README's first non-heading paragraph
  • The description field in package.json
  • An existing projects/<name>/README.md if the registry has the project

If none of those exist, ask the user for one sentence in step 3.

3. Confirm with the user

Show the detected proposal in a compact table:

For <project>:

External actors (L1):
  [Person] End user — uses the public profile pages
  [Person] Admin — manages reports and users
  [Ext] AWS Cognito — authentication
  [Ext] Amazon Bedrock — text embeddings for similarity
  [Ext] PostHog EU — product analytics
  [Ext] DiceBear — avatar generation

Containers (L2, inside the system boundary):
  Web App         Next.js 16        — public profile pages, sign-in, dashboard
  Backend API     AWS Lambda + SAM  — Q&A endpoints, profiles, likes, search
  Admin App       Next.js + Cognito — moderation console
  DynamoDB        single-table      — questions, answers, profiles, likes
  S3 (uploads)    public-read       — avatar + answer-attachment storage
  CloudFront      asset CDN         — public-asset distribution

One-sentence description:
  "Public Q&A platform — anonymous askers, public answers, share-driven growth."

Edit? (a) accept · (e) edit list · (d) edit description · (q) quit
>

On e: open an interactive add/remove flow — one item per prompt, accept by Enter, or type add: <new item> / remove: <name>. On d: prompt for a one-sentence replacement description. On q: exit without writing. On a: proceed to step 4 (or step 4b if --dsl was passed).

4. Generate the Mermaid (skip if --dsl was passed — go to step 4b)

Resolve the C4 templates via the portfolio helper so adopter overrides win when present:

source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-read-config.sh"
source "$(git rev-parse --show-toplevel)/.claude/hooks/_lib-portfolio-paths.sh"
context_template=$(portfolio_resolve_template architecture/c4-context.md)     # L1 skeleton
container_template=$(portfolio_resolve_template architecture/c4-container.md) # L2 skeleton

Single-fork adopters (no portfolio block) and adopters with no override fall straight through to templates/architecture/c4-{context,container}.md. Adopters who want a customised C4 shape drop their versions at <private_repo>/custom-templates/architecture/c4-{context,container}.md. See templates/README.md for the path-mirroring convention.

Keep the surrounding markdown sections from the resolved templates ("How to use this template" can be trimmed in the generated file since these are real diagrams, not templates).

For L1:

C4Context
    title System Context for {Project Name}

    Person(<id>, "<Display>", "<Description>")
    ...
    System(main, "{Project Name}", "<one-sentence description>")
    System_Ext(<id>, "<Name>", "<Tech / role>")
    ...
    Rel(<from>, <to>, "<Verb>", "<Protocol>")
    ...

For L2:

C4Container
    title Container Diagram for {Project Name}

    Pe

---

*Content truncated.*

When not to use it

  • When drawing sequence diagrams or per-class diagrams
  • When L4 (Code) precision is required
  • When auto-diff against existing diagrams is needed

Limitations

  • The skill does not generate L4 (Code) diagrams
  • The skill does not auto-detect L3 components; `--dsl` provides the model and view
  • The skill has a hard cap of 9 containers in the generated diagram

How it compares

This skill automates the creation of C4 architectural diagrams directly from codebase analysis, providing a structured and up-to-date visualization of system context and containers, unlike manual diagramming which can be time-consuming and

Compared to similar skills

c4 side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
c4 (this skill)018dReviewIntermediate
mermaid-diagrams86moNo flagsBeginner
c4-container13moNo flagsIntermediate
c4-architecture-documentation05moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

mermaid-diagrams

davila7

Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts, gantt charts, or any other diagram type. Triggers include requests to "diagram", "visualize", "model", "map out", "show the flow", or when explaining system architecture, database design, code structure, or user/application flows.

827

c4-container

sickn33

Expert C4 Container-level documentation specialist. Synthesizes Component-level documentation into Container-level architecture, mapping components to deployment units, documenting container interfaces as APIs, and creating container diagrams. Use when synthesizing components into deployment containers and documenting system deployment architecture.

11

c4-architecture-documentation

Hack23

Document system architecture using C4 model with context, container, component views and Mermaid diagrams

00

architecture-blueprint

jayeshthadani19

Comprehensive project architecture blueprint generator. Use when: generate architecture docs, create architectural blueprint, analyze codebase architecture, document tech stack, create Mermaid diagrams, map component dependencies, document API surface, detect architectural patterns, reverse-engineer

00

deepwiki-rs

sopaco

AI-powered Rust documentation generation engine for comprehensive codebase analysis, C4 architecture diagrams, and automated technical documentation. Use when Claude needs to analyze source code, understand software architecture, generate technical specs, or create professional documentation from any programming language.

25170

repo-research-analyst

parcadei

Analyze repository structure, patterns, conventions, and documentation for understanding a new codebase

16

Search skills

Search the agent skills registry