db-schema

db-schema is a command for Claude Code from mertjane/awesome-claude-commands. It costs 41 tokens per session (1,234 once invoked), scanned A, original, MIT.

A command that reads database models and creates a Mermaid entity-relationship diagram, a visual map of tables, fields, and relationships, in docs/schema.md.

In plain words
What is it for?
Use it to document schemas built with Prisma, Drizzle, TypeORM, Sequelize, Mongoose, or raw SQL, including projects that use more than one.
Why use it?
It saves you from manually tracing ORM or SQL files to understand how the database is organised.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to document schemas built with Prisma, Drizzle, TypeORM, Sequelize, Mongoose, or raw SQL, including projects that use more than one.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/mertjane/awesome-claude-commands/db-schema
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.

Clone the repo
git clone --depth 1 https://github.com/mertjane/awesome-claude-commands

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-schema

README.md
[![agentmods](https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/db-schema/github.svg)](https://agentmods.dev/commands/mertjane/awesome-claude-commands/db-schema)
Your own site
<a href="https://agentmods.dev/commands/mertjane/awesome-claude-commands/db-schema"><img src="https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/db-schema/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-schema

Your own site · 80×15
<a href="https://agentmods.dev/commands/mertjane/awesome-claude-commands/db-schema"><img src="https://agentmods.dev/badge/commands/mertjane/awesome-claude-commands/db-schema.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 41 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,234 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.00041 $0.01234
Opus 5 $0.00020 $0.00617
Sonnet 5 $0.00008 $0.00247
Haiku 4.5 $0.00004 $0.00123

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

Security

Grade A, and why

db-schema 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 10d 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/db-schema.md · 172 lines

How it starts

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

Generate Database ERD Diagram

Analyze the project's database models and schema files, then produce a Mermaid erDiagram saved to docs/schema.md (or the path in $ARGUMENTS if provided).

Step 1 — Detect ORM

Search for known config and schema files in this order:

Prisma:

Glob: **/*.prisma (exclude node_modules)

If found → ORM is Prisma.

Drizzle:

Glob: {src,db,database,lib}/**/{schema,drizzle}.{ts,js}

Check for imports of drizzle-orm, pgTable, mysqlTable, sqliteTable → ORM is Drizzle.

TypeORM:

Glob: {src,lib}/**/*.entity.{ts,js}

Check for @Entity() decorator → ORM is TypeORM.

Sequelize:

Glob: {src,lib,models}/**/*.{ts,js}

Check for DataTypes, Model.init, sequelize.define → ORM is Sequelize.

Mongoose:

Glob: {src,lib,models}/**/*.{ts,js}

Check for new Schema(, mongoose.model( → ORM is Mongoose.

Raw SQL:

Glob: **/*.{sql,migration.ts,migration.js}

If CREATE TABLE statements found → parse SQL directly.

If multiple ORMs detected, list all and process each.

Step 2 — Extract Models and Fields

Prisma

Read each .prisma file. For every model block extract:

  • Model name
  • Fields: name, type (String, Int, Boolean, DateTime, Float, Json)
  • Relations: @relation fields — extract fields, references
  • Optional (?) vs required fields
  • @id, @unique, @@unique constraints

Drizzle

Read schema files. For every table definition extract:

  • Table name (first argument to pgTable/mysqlTable/sqliteTable)
  • Columns: name and type (varchar, integer, boolean, timestamp, text, json)
  • .primaryKey(), .notNull(), .unique() modifiers
  • references(() => otherTable.column) for foreign keys

TypeORM

Read each .entity.ts file. Extract:

  • Class name (model name)
  • @Column() fields with type
  • @PrimaryGeneratedColumn() or @PrimaryColumn()
  • @OneToMany, @ManyToOne, @OneToOne, @ManyToMany relations and their targets

Read the full file on GitHub · 172 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. 10d ago First seen · 172 lines · 41 tokens per session scan A 0aa39d214547

Subscribe to this mod's changes

db-schema is a command published in the GitHub repository mertjane/awesome-claude-commands (2 stars, last pushed 6mo ago), licensed MIT. It adds 41 tokens to every session and 1,234 once invoked, about $0.0002 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-31.