erd

erd is a command for Claude Code from nasrulhazim/claude. It costs 13 tokens per session (1,014 once invoked), scanned A, original, MIT.

A command for creating and maintaining an entity-relationship diagram (ERD), a visual map of database tables and their links.

In plain words
What is it for?
Use it to set up the diagram tools, generate or rebuild the document, refresh it after database migrations, review database domains, and verify the result.
Why use it?
It keeps database documentation aligned with the live schema and provides checks before publishing updates.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the claude-toolkit plugin — 36 skills, 12 commands, 20 agents shipped together

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/nasrulhazim/claude/erd
Clone the repo
git clone --depth 1 https://github.com/nasrulhazim/claude

Made for: Claude Code.

Or install claude-toolkit, the plugin that ships this one along with the rest of its 36 skills, 12 commands, 20 agents.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/nasrulhazim/claude/erd.svg)](https://agentmods.dev/commands/nasrulhazim/claude/erd)
Your own site
<a href="https://agentmods.dev/commands/nasrulhazim/claude/erd"><img src="https://agentmods.dev/badge/commands/nasrulhazim/claude/erd.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,014 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.1 $0.00013 $0.01014
Opus 5 $0.00006 $0.00507
Sonnet 5 $0.00003 $0.00203
Haiku 4.5 $0.00001 $0.00101

Measured 6d ago against content hash 9f07185b84e8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

erd 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 6d 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/erd.md · 90 lines

How it starts

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

/erd Command

Drives the schema-diagram skill. Load it first — it carries the templates, the traps and the verification checklist:

Skill: schema-diagram

Subcommands

Command Does
/erd Detects what exists and picks the right path below
/erd init Scaffolds the whole toolchain into a project that has none
/erd generate php artisan docs:erd — reads the live database into the JSON payload
/erd build npm run build:erd — bundles the JSON into the standalone HTML
/erd refresh Generate + build + stage both outputs. The everyday command after a migration
/erd check php artisan docs:erd --check — domain coverage gate, writes nothing
/erd domains Review or extend the domain map without touching anything else
/erd verify Open the built document and walk the skill's verification checklist

/erd with no argument

  1. Does app/Support/Erd/ErdSchema.php exist?
    • No → this is /erd init. Confirm with the user before scaffolding.
    • Yes → continue.
  2. Is the database at head? php artisan migrate:status | tail -5
    • Behind → do not migrate their database. Build in a throwaway, drop it afterwards, and say so in the summary. A diagram of a half-migrated schema is worse than none, but a surprise migration is worse than both.
  3. Run /erd refresh.

/erd init

Do not scaffold silently — this writes ~10 files and adds four npm dependencies.

  1. Confirm the target docs path (default docs/03-architecture/).
  2. Draft the domain map and show it to the user before writing it. This is the only part that takes judgement; everything after is mechanical. Aim for 8–14 domains named after the product's own nouns, with framework tables in one system domain.
  3. Copy the extractor, the domain map, the React Flow island and the stylesheet from the skill's reference files.
  4. Set PRODUCT in ErdBoard.jsx and About.jsx; set the brand faces in erd.css.
  5. Rewrite the prose in About.jsx for this product — it is the first thing anyone reads.
  6. Install deps, generate, build, verify.
  7. Write the companion docs/03-architecture/03-database-erd.md — the HTML is not reviewable in a PR, does not render on GitHub, and does not appear in a grep.
  8. Add tests/Feature/Docs/ErdDomainCoverageTest.php so the map fails the suite, not the reader.

Read the full file on GitHub · 90 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. 6d ago First seen · 90 lines · 13 tokens per session scan A 9f07185b84e8

Subscribe to this mod's changes

erd is a command published in the GitHub repository nasrulhazim/claude (22 stars, last pushed 3d ago), licensed MIT. It adds 13 tokens to every session and 1,014 once invoked, about $0.0001 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.