db-diagram

db-diagram is a skill for Claude Code from saajunaid/caddis-plugin. It costs 84 tokens per session (2,452 once invoked), scanned A, original, MIT.

A tool that turns SQL—such as a query, table, view, or stored procedure—into a diagram that explains how the data is connected or moves.

In plain words
What is it for?
Use it to create database relationship diagrams, explain queries visually, or show how a stored procedure processes data.
Why use it?
SQL can be difficult to understand from text alone. A diagram makes its structure and data flow easier to explain to people.

Skill for Claude Code

Written for Claude Code: context: fork in frontmatter.

Good fit Use it to create database relationship diagrams, explain queries visually, or show how a stored procedure processes data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/saajunaid/caddis-plugin/db-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 saajunaid/caddis-plugin --skill db-diagram
Clone the repo
git clone --depth 1 https://github.com/saajunaid/caddis-plugin

Made for: Claude Code.

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 db-diagram

README.md
[![agentmods](https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/db-diagram/github.svg)](https://agentmods.dev/skills/saajunaid/caddis-plugin/db-diagram)
Your own site
<a href="https://agentmods.dev/skills/saajunaid/caddis-plugin/db-diagram"><img src="https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/db-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 db-diagram

Your own site · 80×15
<a href="https://agentmods.dev/skills/saajunaid/caddis-plugin/db-diagram"><img src="https://agentmods.dev/badge/skills/saajunaid/caddis-plugin/db-diagram.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,452 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.00084 $0.02452
Opus 5.5 $0.00034 $0.00981
Sonnet 5.5 $0.00017 $0.00490
Haiku 4.5 $0.00008 $0.00245

Measured 17d ago against content hash 85e0f696a49a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

db-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 17d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/sql_to_graph.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

.github/skills/data/db-diagram/SKILL.md · 149 lines

How it starts

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

db-diagram — explain SQL as a diagram

Take a SQL artifact and produce a diagram that explains it to a human. Two output formats, one shared extraction: Mermaid (default — plain text, diffs cleanly, renders in VS Code/Gitea, regenerable) and Excalidraw (for a design review / ARB pack / slide — someone drags boxes around).

The structure is extracted deterministically by scripts/sql_to_graph.py (a real sqlglot-based parser); you (the model) add the business narration on top. Never hand-derive the node graph when the script can run — its whole value is reproducibility.

Two non-negotiable safety rules

  1. Never write to the database. Read-only by definition — no DDL, no DML, not even in a rolled-back transaction. The extractor only ever parses SQL text.
  2. Never guess schema. Inspect the actual tables/columns before diagramming. If you can't reach the database, diagram only what's provable from the SQL text and mark inferred elements clearly.

Step 1 — get the SQL

Resolve the argument:

  • A file path → read that file.
  • A database object name (proc/view/table) → look it up. Prefer a registered DB MCP tool if one is available in the session; else sqlcmd/psql read-only; else ask the user to paste it. Never guess an object's body.
  • No argument → operate on the SQL in the current file/context, or ask.
  • Multiple objects → diagram the relationships between them, in ONE diagram — not one diagram each.

Step 2 — run the deterministic extractor

python <skill-dir>/scripts/sql_to_graph.py --file <path>                       # Mermaid block (default)
python <skill-dir>/scripts/sql_to_graph.py --file <path> --format excalidraw   # native .excalidraw JSON
python <skill-dir>/scripts/sql_to_graph.py --file <path> --format html --title "..."   # self-contained page
python <skill-dir>/scripts/sql_to_graph.py --file <path> --format svg          # self-contained .svg
python <skill-dir>/scripts/sql_to_graph.py --sql "<SELECT ...>" --json         # full graph JSON

All five formats (mermaid | excalidraw | svg | html | json) come from one deterministic layout — same SQL always produces byte-identical output, boxes are grid-aligned, and every label is wrapped to fit inside its box.

Read the full file on GitHub · 149 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 17d ago Changed · -31 tokens per session 85e0f696a49a
  2. 1mo ago First seen · 149 lines · 115 tokens per session scan A acf0ca468b14

Subscribe to this mod's changes

db-diagram is a skill published in the GitHub repository saajunaid/caddis-plugin (0 stars, last pushed today), licensed MIT. It adds 84 tokens to every session and 2,452 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-03.