diagram

diagram is a command for Claude Code from wrxck/diagram-expert. It costs 0 tokens per session (649 once invoked), scanned A, original, MIT.

A command for generating Mermaid diagrams from a description or by examining the current codebase.

In plain words
What is it for?
Use it to create architecture, sequence, entity-relationship, deployment, data-flow, state, CI/CD, or Git branch diagrams.
Why use it?
It helps document system structure and behaviour without drawing diagrams by hand.

Command for Claude Code

Written for Claude Code: ${CLAUDE_PLUGIN_ROOT} variable.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the diagram-expert plugin — 1 skill, 1 command, 1 agent shipped together

Good fit Use it to create architecture, sequence, entity-relationship, deployment, data-flow, state, CI/CD, or Git branch diagrams.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add wrxck/diagram-expert
Claude Code
/plugin install diagram-expert

Made for: Claude Code.

Or install diagram-expert, the plugin that ships this one along with the rest of its 1 skill, 1 command, 1 agent.

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/commands/wrxck/diagram-expert/diagram/github.svg)](https://agentmods.dev/commands/wrxck/diagram-expert/diagram)
Your own site
<a href="https://agentmods.dev/commands/wrxck/diagram-expert/diagram"><img src="https://agentmods.dev/badge/commands/wrxck/diagram-expert/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/commands/wrxck/diagram-expert/diagram"><img src="https://agentmods.dev/badge/commands/wrxck/diagram-expert/diagram.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 649 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.00000 $0.00649
Opus 5 $0.00000 $0.00324
Sonnet 5 $0.00000 $0.00130
Haiku 4.5 $0.00000 $0.00065

Measured 10d ago against content hash c159bac6d8ac, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 10d 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.

commands/diagram.md · 85 lines

How it starts

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

/diagram

Generate a Mermaid diagram from a description or by analysing the current codebase.

Usage

/diagram <description or type>

Examples:

  • /diagram architecture — Architecture overview of the current project
  • /diagram sequence for the auth flow — Sequence diagram for authentication
  • /diagram erd — Entity-relationship diagram from database models
  • /diagram deployment — Deployment/infrastructure diagram
  • /diagram data flow from API to UI — Data flow for a specific path

Flow

1. Determine diagram type

If the user specified a type, use it. Otherwise, infer from context:

Context clue Suggested type
Database models, schemas, Prisma/Drizzle/TypeORM files Entity-Relationship (erDiagram)
API endpoints, request handling Sequence diagram
Component hierarchy, imports Class or flowchart
Docker, nginx, deployment configs Deployment/architecture (C4 or flowchart)
State machines, status fields State diagram
CI/CD, pipelines Flowchart (LR)
Git branching strategy Gitgraph
Timeline, roadmap Timeline or Gantt

2. Detect git provider

git remote get-url origin 2>/dev/null
  • github.com / gitlab / dev.azure.com → Use fenced Mermaid blocks
  • bitbucket.org → Warn user that Bitbucket doesn't render Mermaid natively; offer to generate a mermaid.live link or SVG alternative
  • No remote → Default to fenced Mermaid blocks

3. Analyse the codebase

Use the codebase-analyzer agent to:

  • Read relevant source files (models, routes, components, configs)
  • Extract relationships, dependencies, and flows
  • Build a mental model of the system

Do NOT read the entire codebase. Target files relevant to the requested diagram type.

4. Generate the diagram

Read ${CLAUDE_PLUGIN_ROOT}/skills/diagram-expert/references/mermaid-patterns.md for syntax patterns.

Rules:

  • Use descriptive node IDs, not single letters (e.g., AuthService not A)
  • Add meaningful labels on edges
  • Group related nodes with subgraphs where it helps clarity
  • Keep diagrams readable — split into multiple diagrams if >30 nodes
  • Use appropriate direction: TD for hierarchies, LR for flows/sequences
  • Include a title using --- frontmatter or accTitle

Read the full file on GitHub · 85 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. 10d ago First seen · 85 lines · 0 tokens per session scan A c159bac6d8ac

Subscribe to this mod's changes

diagram is a command published in the GitHub repository wrxck/diagram-expert (6 stars, last pushed 29d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 649 tokens. 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-08-31.