database-schema-designer

database-schema-designer is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 75 tokens per session (1,833 once invoked), scanned A, original, Apache-2.0.

A guide for designing database tables, relationships, indexes, migrations, and generated TypeScript or Python types from requirements.

In plain words
What is it for?
It helps plan new schemas, review normalisation and performance, add multi-tenant data structures, plan breaking migrations, and produce code types.
Why use it?
It helps prevent duplicated data, weak relationships, slow queries, and database changes that are difficult to apply safely.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps plan new schemas, review normalisation and performance, add multi-tenant data structures, plan breaking migrations, and produce code types.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/database-schema-designer
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 tmj-90/gaffer --skill database-schema-designer
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/database-schema-designer/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/database-schema-designer)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/database-schema-designer"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/database-schema-designer/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 database-schema-designer

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/database-schema-designer"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/database-schema-designer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,833 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.00075 $0.01833
Opus 5.5 $0.00030 $0.00733
Sonnet 5.5 $0.00015 $0.00367
Haiku 4.5 $0.00007 $0.00183

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

Security

Grade A, and why

database-schema-designer 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 20d 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.

runner/skills/database-schema-designer/SKILL.md · 112 lines

How it starts

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

Design schemas that survive production

A schema is the one place an invariant holds no matter which code path, process or concurrent request writes. Normalise first, let constraints enforce the rules, index for the real query patterns, and change it in steps that never block production. Sources: PostgreSQL docs (constraints, CREATE INDEX, ALTER TABLE, transaction isolation, row security); MySQL 8 reference (InnoDB locking, online DDL); Codd's normal forms as taught in standard database texts.

Steps

  1. Read the existing schema and conventions. search_lore for the ORM, migration tool, naming, key strategy and tenancy model. Extend them; never introduce a second pattern.
  2. Model entities and relationships. Nouns with attributes become tables. State cardinality before structure: 1:N → FK on the N side; M:N → junction table with a composite primary or unique key on the two FKs; 1:1 → FK with a UNIQUE constraint. Sketch the ERD (Mermaid is fine) in the plan or the evidence summary.
  3. Normalise to 3NF for transactional data. 1NF: atomic values, no repeating groups. 2NF: no column depends on part of a composite key. 3NF: no column depends on another non-key column. Denormalise only for a measured read need, and document who keeps the copy consistent (trigger, same-transaction write, or rebuild job).
  4. Write every invariant as a constraint — the application check alone is a race. Under Read Committed (Postgres default) and Repeatable Read (MySQL InnoDB default), two transactions can both "check, then insert" and both succeed:
    • uniqueness → UNIQUE; conditional ("one active subscription per user") → partial unique index WHERE status = 'active' (Postgres) or a generated column (MySQL);
    • no overlapping ranges (bookings) → Postgres EXCLUDE USING gist (room_id WITH =, during WITH &&) with btree_gist, or serialise via SELECT … FOR UPDATE on a parent;
    • value rules (amount >= 0, allowed states) → CHECK; references → FK with an explicit ON DELETE (RESTRICT unless cascade is truly intended);
    • counters and balances → a single UPDATE … SET n = n + :d WHERE … AND n + :d >= 0, never read-modify-write in application code; concurrent edits to one row → optimistic version column (UPDATE … WHERE id = ? AND version = ?, 0 rows → 409). Map constraint violations to a domain error (409/422), not a 500. If you use SERIALIZABLE, retry on SQLSTATE 40001.
  5. Choose types that cannot drift. Timestamps timestamptz (MySQL: UTC DATETIME by convention); money as numeric/integer minor units, never float; text with a CHECK length over arbitrary varchar(n) in Postgres; enums via CHECK or a lookup table (easier to extend than a native enum). Keys: bigint identity for single-node, UUIDv7 (time-ordered, index-friendly; Postgres 18 has uuidv7()) when ids are generated outside the database. NOT NULL by default; nullable only with a meaning. Absent a repo convention: created_at/updated_at timestamptz NOT NULL DEFAULT now() on every table; soft delete as a nullable deleted_at with partial indexes and unique keys WHERE deleted_at IS NULL; and an append-only audit table (entity_type, entity_id, action, actor_id, changed_at, before, after) for user-facing data with compliance implications.
  6. Tenancy. tenant_id NOT NULL on every tenant-scoped table, leading in composite unique keys and indexes; composite FKs (tenant_id, parent_id) make cross-tenant references impossible. With Postgres RLS: ENABLE and FORCE ROW LEVEL SECURITY (owners bypass otherwise) and connect as a non-owner role.
  7. Index for the query patterns in the ticket. Postgres does not index FK columns automatically (InnoDB does): add them. Composite indexes: equality columns, then range, then sort. Partial indexes for hot subsets. Every index costs every write; add none without a query that needs it (the sql-query-performance skill).
  8. Migrate without blocking (mechanics: the add-db-migration skill; review: the migration-review skill). Set lock_timeout for DDL. See the table below.
  9. Generate types from the schema (Prisma/Drizzle/sqlc/SQLAlchemy/pydantic tooling the repo uses); never hand-write a parallel model.

Read the full file on GitHub · 112 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. 20d ago Changed · +19 lines 6917581d2adf
  2. 1mo ago First seen · 93 lines · 75 tokens per session scan A f1c39d70b532

Subscribe to this mod's changes

database-schema-designer is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 20d ago), licensed Apache-2.0. It adds 75 tokens to every session and 1,833 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-08-31.

Related

Other skills, from other repositories

bulwark-brainstorm

Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.

QBall-Inc/the-bulwark · 50 tokens

plan-creation

Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.

QBall-Inc/the-bulwark · 38 tokens

anthropic-validator

Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.

QBall-Inc/the-bulwark · 40 tokens

code-review

Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.

QBall-Inc/the-bulwark · 61 tokens

create-subagent

Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.

QBall-Inc/the-bulwark · 42 tokens

test-audit

Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.

QBall-Inc/the-bulwark · 0 tokens