erd-diagram

erd-diagram is a skill for Claude Code from closedloop-ai/claude-plugins. It costs 131 tokens per session (1,854 once invoked), scanned A, original, Apache-2.0.

A tool for creating or updating an interactive entity-relationship diagram as one offline HTML file from a PostgreSQL repository's schema files. An ERD shows database tables, their fields, and the relationships between them.

In plain words
What is it for?
Use it to visualize schemas from Prisma files, SQL dumps, or SQL migrations, and to update a diagram previously created by the tool.
Why use it?
It documents database structure without connecting to, querying, or changing a live database.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: reads .claude/ paths; names the AskUserQuestion tool.

Part of the closedloop-core plugin — 12 skills shipped together

Good fit Use it to visualize schemas from Prisma files, SQL dumps, or SQL migrations, and to update a diagram previously created by the tool.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/closedloop-ai/claude-plugins/erd-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 closedloop-ai/claude-plugins --skill erd-diagram
Clone the repo
git clone --depth 1 https://github.com/closedloop-ai/claude-plugins

Made for: Claude Code.

Or install closedloop-core, the plugin that ships this one along with the rest of its 12 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 erd-diagram

README.md
[![agentmods](https://agentmods.dev/badge/skills/closedloop-ai/claude-plugins/erd-diagram/github.svg)](https://agentmods.dev/skills/closedloop-ai/claude-plugins/erd-diagram)
Your own site
<a href="https://agentmods.dev/skills/closedloop-ai/claude-plugins/erd-diagram"><img src="https://agentmods.dev/badge/skills/closedloop-ai/claude-plugins/erd-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 erd-diagram

Your own site · 80×15
<a href="https://agentmods.dev/skills/closedloop-ai/claude-plugins/erd-diagram"><img src="https://agentmods.dev/badge/skills/closedloop-ai/claude-plugins/erd-diagram.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 131 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,854 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.00131 $0.01854
Opus 5.5 $0.00052 $0.00742
Sonnet 5.5 $0.00026 $0.00371
Haiku 4.5 $0.00013 $0.00185

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

Security

Grade A, and why

erd-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.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/dist/erd.mjs, scripts/dist/verify.mjs), 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.

plugins/closedloop-core/skills/erd-diagram/SKILL.md · 67 lines

How it starts

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

ERD diagram

Builds a self-contained, offline HTML ERD from schema code, or updates one this skill made earlier.

Code only. Never connect to, query, or test against any database, local or remote, and never start one (no psql, no Docker Postgres). Every fact in the diagram comes from files in the repository.

Arguments: $ARGUMENTS

The tool is scripts/dist/erd.mjs in this skill's directory. It needs only Node 18 or later, with no install step; the layout engine (elkjs) is bundled into it. Run it as node <skill-dir>/scripts/dist/erd.mjs <command>, where <skill-dir> is the absolute path of the directory you read this SKILL.md from, not the repository you are diagramming.

1. Read the arguments

Split $ARGUMENTS into words.

  • canvas-sidebar or schema-explorer is the style.
  • Everything else, joined back with spaces, is the path of an existing diagram. Expand a leading ~.

Then choose the mode:

  • Path given, file missing: stop. Tell the user the file does not exist and they may have mistyped the path, quoting the path you checked. Do nothing else: no new diagram, no guessing a nearby file.
  • Path given, file exists: update mode (section 3).
  • No path: new-diagram mode (section 2).

2. New diagram

  1. Style. If no style was passed, ask with AskUserQuestion, one question, header "Style", options:
    • canvas-sidebar: "Every table on one pannable, zoomable canvas, with a searchable table list grouped by domain on the left and a detail panel."
    • schema-explorer: "Overview of domains, a focused table view (its references on the left, what references it on the right), and a pannable diagram per domain."
  2. Repo. Use the git root of the current directory. If the user named another repo, pass --repo <dir>.
  3. Source. Run erd.mjs detect. It lists Prisma schemas, SQL dumps (structure.sql, schema.sql) and SQL migration folders, each with its database.
    • Only use sources whose database is postgres or unknown; never one marked sqlite, mysql or another engine.
    • Prefer a Prisma schema (it carries doc comments), then a SQL dump, then a migrations folder.
    • One candidate: use it. Several of the same kind: ask the user which one with AskUserQuestion.
    • None: the schema lives in ORM code (Rails schema.rb, Django models, TypeORM or Sequelize entities, SQLAlchemy, Drizzle TypeScript without generated SQL, and so on). Read that code and write the model JSON yourself, in the shape described in the model format. Save it as ~/.claude/erd-diagram/models/<repo-name>.json, check it with erd.mjs validate-model <file>, fix every problem it reports, and use --source json:<that path>. Name each model after its table; record a column's database name in column and doc comments in doc.
  4. Domains. These group tables in the sidebar, and are the per-domain diagrams in schema-explorer.
    • 20 tables or fewer: skip this step; the build uses one "All tables" group.
    • Otherwise run erd.mjs draft-domains --source <spec> --out <scratch>/domains.json and erd.mjs extract --source <spec> --out <scratch>/model.json. The draft is a clustering of the foreign-key graph and its names are placeholders. Read the table names, docs and relations in model.json and rewrite the draft into roughly 6 to 15 domains named for what they hold ("Billing", "Auth & sessions"), each table in exactly one domain, ids in lowercase-with-dashes. Hub tables that nearly everything references (the build reports them as hubs) go with the domain they belong to by meaning, usually accounts or organizations.
  5. Output path. ~/Desktop/<repo-name>-erd-<style>.html unless the user named one. If that file already exists, ask whether to update it or write a different name. Never pass --force without the user saying to replace it.
  6. Build. erd.mjs build --style <style> --out <path> --source <spec> [--domains <file>] [--repo <dir>]. It refuses an existing --out (exit code 3), rejects a domain map that names unknown tables or lists a table twice, and puts any table the map leaves out under "Unsorted".
  7. Verify. node <skill-dir>/scripts/dist/verify.mjs <path> renders the file headlessly (no window). It checks for script errors, that every table renders, that each domain diagram draws, and that search lands on a column. It prints ok; fix any failure before reporting. If it prints skipped (no puppeteer installed), say the render check was skipped.
  8. Report. Give the file path, style, source and commit, and the counts of tables, relations and domains. List any unsorted tables, and note that the diagram reflects the schema code at that commit, not any running database.

Read the full file on GitHub · 67 lines

Files

What ships with it

6 files 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. 3d ago First seen · 67 lines · 131 tokens per session scan A 0dea38e0a716

Subscribe to this mod's changes

erd-diagram is a skill published in the GitHub repository closedloop-ai/claude-plugins (123 stars, last pushed yesterday), licensed Apache-2.0. It adds 131 tokens to every session and 1,854 once invoked, about $0.0005 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-11-04.

Related

erd-diagram compared with skills from other repositories

erd-diagram next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
erd-diagramclosedloop-ai/claude-pluginsSkill123yesterdayApache-2.0A131Claude Code
postgres-patternsaffaan-m/ECCSkill298k4d agoMITA45Claude Code, Kiro
postgresql-table-designwshobson/agentsSkill42kyesterdayMITA37Claude Code
data-sql-optimizationvasilyu1983/AI-Agents-publicSkill10121d agoMITA41Claude Code, Codex
software-database-designvasilyu1983/AI-Agents-publicSkill10121d agoMITA43Claude Code, Codex
postgresql-expertpersonamanagmentlayer/pclSkill4411d agoApache-2.0A56Claude Code
ai-vector-brainvasilyu1983/AI-Agents-publicSkill10121d agoMITA40Claude Code, Codex