diagram

A command that creates Mermaid diagrams from a feature specification. Mermaid is a text-based format for drawing architecture diagrams, process flows, and relationships.

In plain words
What is it for?
Use it to visualize a feature’s components, users, external systems, data movement, states, and conditional flows. It can select a named feature or ask which feature to use when several are available.
Why use it?
It makes system structure and behavior easier to inspect than a specification written only as prose. It loads the feature’s context and requirements before creating the diagrams.

Command for Claude Code

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.

agentmods
npx agentmods add commands/marcelsud/spec-driven-agentic-development/diagram
Clone the repo
git clone --depth 1 https://github.com/marcelsud/spec-driven-agentic-development

Made for: Claude Code.

Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,310 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00009 $0.02310
Opus 5 $0.00005 $0.01155
Sonnet 5 $0.00002 $0.00462
Haiku 4.5 $0.00001 $0.00231

Measured 3d ago against content hash 21a66f553258, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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.

.claude/commands/spec/diagram.md · 401 lines

How it starts

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

Generate Feature Diagrams

Generate Mermaid diagrams to visualize architecture, flows, and relationships from feature specifications.

Feature: $ARGUMENTS

Feature Selection

  1. IF a feature name is provided in $ARGUMENTS:

    • Find a directory in features/ that matches $ARGUMENTS
    • If no exact match, search for closest match and ask for confirmation
  2. IF no feature name is provided:

    • List all directories under features/
    • If only one exists, select it automatically
    • If multiple exist, ask user to specify using AskUserQuestion

Your Task

Generate Mermaid diagrams that visualize the feature's architecture and flows based on its specification.

Process

Step 1: Load Feature Context

Read the specification files:

  • features/[feature-name]/context.md
  • features/[feature-name]/requirements.md

Extract key information:

  • Components: From Technical Decisions and Architecture sections
  • Actors: Users, external systems, services mentioned
  • Data flows: How data moves through the system
  • States: Any state-driven (WHILE) requirements
  • Decisions: Conditional (IF/THEN) and event-driven (WHEN/THEN) logic

Step 2: Ask User for Diagram Types

Use AskUserQuestion with multiSelect enabled:

"Which diagram type(s) would you like to generate for [feature-name]?"

Options:

  • Flowchart - Process flows and decision logic (best for IF/THEN, WHEN/THEN requirements)
  • Sequence Diagram - Actor interactions and API calls (best for multi-component flows)
  • Class Diagram - Component and entity relationships (best for data models)
  • State Diagram - State transitions and lifecycle (best for WHILE requirements)
  • ER Diagram - Data model and entity relationships (best for database design)

Step 3: Generate Selected Diagrams

For each selected diagram type, analyze the spec and generate appropriate Mermaid code.


Flowchart Generation

Best for: Process flows, conditional logic, decision trees

Read the full file on GitHub · 401 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. 3d ago First seen · 401 lines · 9 tokens per session scan A 21a66f553258

Subscribe to this mod's changes

diagram is a command published in the GitHub repository marcelsud/spec-driven-agentic-development (174 stars, last pushed 9mo ago), licensed MIT. It adds 9 tokens to every session and 2,310 once invoked, about $0.0000 per session on Opus 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-08-30.