Skip to main content

This skill may not reflect the latest upstream change

Next.js Releases update on 2026-11-09 may affect this skill Last checked Nov 25, 2026.

DocsOfficialCertifiedAI reviewed Jul 21, 2026

diagram

Generate Mermaid architecture diagrams from your codebase. Produces C4 context and container diagrams, sequence diagrams for key flows, ER diagrams from database schemas, and module dependency graphs. Use when you need architecture diagrams, system diagrams, database ERD, sequence diagrams, dependency visualization, or C4 model diagrams.

v2.0.056 installs

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install diagram
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/diagram/SKILL.md

Setup guide →

Signing

SignedSLSA L2
Signed by
skills-hub.ai distributor
Method
Distributor-signed by skills-hub.aiSigned with the skills-hub.ai Ed25519 distributor key over this exact slug, version and content. Check it with `npx @skills-hub-ai/cli verify`.
Key
skills-hub-ed25519-2026-11
Signed
0Save

Instructions

You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze the project
codebase and generate comprehensive architecture diagrams using Mermaid.

INPUT:
$ARGUMENTS

Accepted arguments:

  • No arguments: generate all applicable diagram types.
  • c4: generate C4 Context and Container diagrams only.
  • sequence: generate sequence diagrams for key flows only.
  • er: generate ER diagram from database schema only.
  • deps or dependency: generate module dependency graph only.
  • A specific flow description (e.g., "user login flow"): generate a sequence
    diagram for that specific flow.

PHASE 1: CODEBASE ANALYSIS


Step 1.1 -- Tech Stack and Architecture Detection

Scan config files to determine: project type (web app, API, mobile, CLI, library,
monorepo), primary language/framework, database(s), external services (auth, payment,
email, storage), message queues, caching layers, and API gateway config.

Step 1.2 -- Service and Module Mapping

For monorepos/microservices: read docker-compose.yml or K8s manifests for service
definitions, map inter-service communication, identify external deps per service.

For monoliths: read directory structure to identify modules/domains, trace
import statements to map module dependencies, identify layer boundaries.

Step 1.3 -- Database Schema Extraction

Scan for schema definitions in: schema.prisma, .entity.ts (TypeORM/MikroORM),
models/
.js (Sequelize), models.py (Django), db/schema.rb (Rails), models/.py
(SQLAlchemy), schema.ts (Drizzle), migrations/
.sql, *.model.ts (Mongoose).

Extract: table/collection names, columns with types, primary/foreign keys,
relationships (1:1, 1:N, M:N), indexes, and enums.

Step 1.4 -- Key Flow Identification

Identify the most important flows to diagram:

  • Authentication flow (login, signup, token refresh)
  • Primary business flow (main use case)
  • Data write flow (create/update through layers)
  • API request lifecycle (middleware, validation, handler, response)
  • Background job flow (if applicable)

For each flow, trace: entry point, middleware, service layer, data access,
external calls, and response construction.


PHASE 2: DIAGRAM GENERATION


Generate Mermaid diagrams. Use C4 syntax for architecture diagrams.

Step 2.1 -- C4 Context Diagram

Show the system in its environment: users/actors, the system boundary, and all
external systems it connects to. Use C4Context with Person, System,
System_Ext, and Rel elements. Keep it high-level -- no internal details.

Step 2.2 -- C4 Container Diagram

Show major containers within the system boundary: web apps, API servers, databases,
caches, workers, message queues. Use C4Container with Container, ContainerDb,
ContainerQueue elements. Show relationships with protocols (HTTPS, SQL, AMQP).

Step 2.3 -- Sequence Diagrams

For each key flow, generate a sequenceDiagram showing participants and
message flow. Always generate auth flow if auth exists. Generate the primary
business flow. Include request/response payloads as notes where helpful.

Step 2.4 -- ER Diagram

Generate from extracted schema using erDiagram syntax. Include all tables with
columns (name, type, PK/FK/UK markers) and relationships with cardinality
notation (||--o{, }o--o{, etc.).

Step 2.5 -- Module Dependency Graph

Generate a graph TD showing how internal modules depend on each other.
Place entry points (routes/controllers) at top, data stores at bottom,
external systems on sides. Flag circular dependencies as warnings.
Use style directives to color-code layers.


PHASE 3: OUTPUT AND ORGANIZATION


Create docs/diagrams/ directory if it does not exist.

Write individual files:

  • docs/diagrams/c4-context.md -- C4 Context diagram
  • docs/diagrams/c4-container.md -- C4 Container diagram
  • docs/diagrams/sequence-auth.md -- Auth sequence (if applicable)
  • docs/diagrams/sequence-[flow].md -- Business flow sequence
  • docs/diagrams/er-diagram.md -- ER diagram (if database exists)
  • docs/diagrams/dependency-graph.md -- Module dependency graph

Each file: heading, brief explanation, Mermaid code block, notes on
simplifications. Skip diagram types with no data (no ER if no database).

Generate docs/diagrams/README.md index linking all diagrams with descriptions.


SELF-HEALING VALIDATION (max 2 iterations)


After producing documentation, validate completeness:

  1. Verify all required sections are present and non-empty.
  2. Verify internal cross-references and links resolve correctly.
  3. Verify no placeholder text remains ("{TODO}", "[TBD]", "...", "etc.").
  4. Verify code examples are syntactically valid.

IF VALIDATION FAILS:

  • Identify which sections are incomplete or contain placeholders
  • Re-generate only the deficient sections
  • Repeat up to 2 iterations

OUTPUT


Diagrams Generated

System Profile

  • Type: [monolith / microservices / monorepo]
  • Services: [count]
  • Database Tables: [count]
  • External Systems: [count]

Diagrams Created

DiagramFileEntities
C4 Contextdocs/diagrams/c4-context.mdN systems
C4 Containerdocs/diagrams/c4-container.mdN containers
Sequence: Authdocs/diagrams/sequence-auth.mdN participants
ER Diagramdocs/diagrams/er-diagram.mdN tables
Dependenciesdocs/diagrams/dependency-graph.mdN modules

Observations

  • [Circular dependencies detected]
  • [Isolated modules with no connections]
  • [Missing relationships that could not be determined]

SELF-EVOLUTION TELEMETRY


After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

  • Look for the project path in ~/.claude/projects/
  • If found, append to skill-telemetry.md in that memory directory

Entry format:

### /diagram — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.
Keep entries concise — /evolve will parse these for skill improvement signals.


DO NOT


  • Do NOT fabricate components, services, or tables. Only diagram what exists.
  • Do NOT include internal implementation details in C4 Context diagrams.
  • Do NOT generate diagrams for types with no data (no ER if no database).
  • Do NOT use PlantUML -- use Mermaid exclusively for GitHub compatibility.
  • Do NOT include sensitive info (credentials, internal URLs, IPs) in diagrams.
  • Do NOT overwrite existing diagram files without reading them first.

NEXT STEPS:

After generating diagrams:

  • "Run /document to check overall documentation health."
  • "Run /adr to create ADRs explaining architectural decisions shown in diagrams."
  • "Run /onboarding to include these diagrams in the developer onboarding guide."
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →
design-animateAdd purposeful motion to interfaces using modern CSS — scroll-driven animations, view transitions, @starting-style, and GPU-accelerated transforms. Triggers: 'add animation', 'animate', 'add motion', 'transitions', 'scroll animation'.78 installsdesign-auditComprehensive autonomous design quality audit across accessibility (WCAG 2.2), performance, theming, responsive/adaptive design, and anti-pattern detection. Triggers: 'audit design', 'check accessibility', 'a11y audit', 'design review', 'UI quality check'.61 installssecureFull-stack security posture assessment with 0-100 risk scoring. Scans dependency vulnerabilities (npm audit, pip-audit, cargo audit, govulncheck), dangerous code patterns (SQL injection, eval, command injection, ReDoS, innerHTML, XSS vectors), authentication gaps (missing auth middleware.56 installsdesign-polishFinal autonomous quality pass before shipping. Fixes alignment, spacing, consistency, typography hierarchy, color harmony, motion timing, and every micro-detail that separates good from great..55 installsresponsiveAudit and fix responsive design issues across all breakpoints. Scans for fixed widths that cause mobile overflow, missing media query variants, non-responsive images, undersized touch targets below 48px, unreadable typography, and horizontal scroll violations..49 installscode-smellScan codebase for Martin Fowler's catalog of code smells: god classes, long methods, feature envy, data clumps, primitive obsession, shotgun surgery, message chains, and more. Triggers: code feels messy, before a major refactor, to find maintainability problems.48 installs

More from Skills Hub

View source →
security-reviewSecurity audit and vulnerability assessment for any codebase. Scans for authentication bypasses, missing auth middleware, broken JWT validation (algorithm confusion, weak secrets, missing expiry), OAuth state and PKCE flaws, IDOR and horizontal privilege escalation.197 installsunit-testGenerate comprehensive unit tests with edge cases, error paths, and boundary values. Triggers: you need to add unit tests, increase code coverage, test edge cases, or verify error handling paths.164 installsweb-gameScaffolds a browser-based game with Phaser 3, PixiJS, or Three.js including game loop, asset pipeline, responsive canvas, input handling, audio, save/load, and deployment to itch.io or web. Triggers: on: "web game", "browser game", "html5 game", "phaser game", "pixi game".134 installshumanizerMulti-pass editor that removes AI-writing tells from drafted content — eliminates filler phrases, balances sentence length, restores opinion and voice, and strips em-dash overuse so posts sound human and opinionated rather than ChatGPT-generic..131 installsflutterBuilds Flutter applications from videos, screenshots, descriptions, or app clone requests. Triggers on: flutter app, build a mobile app, replicate this app in Flutter, build from video, build from screenshots, clone this app, build an app, make an app like, recreate this UI.127 installsdesign-to-codeTurn a design into production-quality frontend code: extract a design system with tokens and components, make layouts responsive across breakpoints, add dark mode with WCAG-compliant theming, then run a UX audit to validate everything..124 installs

More Docs skills

Browse category →

Frequently asked questions about diagram

What does the diagram skill do?

Generate Mermaid architecture diagrams from your codebase. Produces C4 context and container diagrams, sequence diagrams for key flows, ER diagrams from database schemas, and module dependency graphs. Use when you need architecture diagrams, system diagrams, database ERD, sequence diagrams, dependency visualization, or C4 model diagrams. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the diagram skill?

Run `npx @skills-hub-ai/cli install diagram` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/diagram/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does diagram work with?

diagram runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the diagram skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use diagram after installing it?

In Claude Code, type `/diagram` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the diagram skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.