diagram-as-code · git:20261120.76a1b83 · 2026-11-20 · sha256 3d1747a08a0fe841

diagram-as-code git:20261120.76a1b83A

Immutable. This exact content never changes and is served at /api/v1/blob/3d1747a08a0fe841.

No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_ugy5jbuzcqmd3xk3/3d1747a08a0fe8413e7773b7f1643cdc1d51cfd908e3be52bbe827c579ca0a17.json

Then /plugin install diagram-as-code@markdownregistry-ugy5jbuzcqmd3xk3 in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.

---
name: diagram-as-code
description: Produces Mermaid diagrams of flows, sequences and data models read from the actual code, ready to commit next to your docs.
---

# Diagram as code

Draw what the code does. Every box must trace to a file, table or service.

## Steps

1. Clarify the question the diagram answers (how a request flows, how services talk, what states an order has, how tables relate). One question per diagram.
2. Choose the type: `sequenceDiagram` for interactions over time, `flowchart` for decisions and pipelines, `stateDiagram-v2` for lifecycles, `erDiagram` for data models, `classDiagram` only for real type hierarchies.
3. Trace the code: start at the entry point (route, handler, job, CLI) and follow calls, queries and outgoing requests. For data models read migrations or ORM models for tables, keys and relations.
4. Write the Mermaid. Use real names from the code for nodes. Keep it to roughly 12 nodes; split into two diagrams when larger. Label edges with the verb or payload.
5. Check syntax: keep labels with brackets or colons in quotes, avoid reserved word `end` as a node id, and render with `npx @mermaid-js/mermaid-cli` if available.
6. Place the diagram in a Markdown file in a `mermaid` fenced block, with two sentences of explanation above it.

## Rules

- No invented components or "future" boxes.
- Do not draw every function; show boundaries that matter.
- Note what you left out below the diagram.

## Report

File path, what question each diagram answers, and the source files you traced.