diagram

diagram is a skill for Claude Code from skillmds/skillmd. It costs 63 tokens per session (1,732 once invoked), scanned A, original, MIT.

A guide for generating Mermaid diagrams from a codebase. Mermaid is a text-based diagram format, and the guide covers system structure, request flows, database relationships, and module dependencies.

In plain words
What is it for?
Use it to create C4 architecture diagrams, sequence diagrams, database entity-relationship diagrams, and dependency graphs.
Why use it?
It turns information already present in project files into diagrams, making architecture and important interactions easier to inspect and explain.

Skill for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: reads .claude/ paths.

Part of the data-ml plugin — 17 skills shipped together

Good fit Use it to create C4 architecture diagrams, sequence diagrams, database entity-relationship diagrams, and dependency graphs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/skillmds/skillmd/diagram
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add skillmds/skillmd --skill diagram
Clone the repo
git clone --depth 1 https://github.com/skillmds/skillmd

Made for: Claude Code.

Or install data-ml, the plugin that ships this one along with the rest of its 17 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for diagram

README.md
[![agentmods](https://agentmods.dev/badge/skills/skillmds/skillmd/diagram/github.svg)](https://agentmods.dev/skills/skillmds/skillmd/diagram)
Your own site
<a href="https://agentmods.dev/skills/skillmds/skillmd/diagram"><img src="https://agentmods.dev/badge/skills/skillmds/skillmd/diagram/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for diagram

Your own site · 80×15
<a href="https://agentmods.dev/skills/skillmds/skillmd/diagram"><img src="https://agentmods.dev/badge/skills/skillmds/skillmd/diagram.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,732 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00063 $0.01732
Opus 5.5 $0.00025 $0.00693
Sonnet 5 $0.00013 $0.00346
Haiku 4.5 $0.00006 $0.00173

Measured 4d ago against content hash d5b40dee8cb6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-23, from the pricing page.

Security

Grade A, and why

diagram scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/data-ml/skills/diagram/SKILL.md · 206 lines

How it starts

The opening of the file, as written. The whole thing — 206 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

Read the full file on GitHub · 206 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 206 lines · 63 tokens per session scan A d5b40dee8cb6

Subscribe to this mod's changes

diagram is a skill published in the GitHub repository skillmds/skillmd (1 stars, last pushed yesterday), licensed MIT. It adds 63 tokens to every session and 1,732 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-19.