database-schema-design
Skill4 starsChanged 27 days agoMITView on GitHub
Use when designing a database from scratch, reviewing tables, an ERD, a Prisma/TypeORM/JPA/Django/SQLAlchemy schema or SQL migrations, adding indexes, normalizing data, or making a migration safe for production — Postgres, MySQL or SQLite.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- anuragsarkar97/skillstheir own version, first seen Nov 8, 2026
- reddygopalkrishna/developer-agent-skillstheir own version, first seen Nov 8, 2026
- manish1803/nextjs-fullstack-skillstheir own version, first seen Oct 13, 2026
- timwukp/agent-skills-best-practicetheir own version, first seen Sep 16, 2026
- yueheng-rgb/codex-factorytheir own version, first seen Sep 15, 2026
- agent-packs/registrytheir own version, first seen Jun 15, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- yueheng-rgb/codex-factory★ 100same name
- timwukp/agent-skills-best-practice★ 10same name
- reddygopalkrishna/developer-agent-skills★ 8same name
- manish1803/nextjs-fullstack-skills★ 2same name
- agent-packs/registry★ 0same name
- anuragsarkar97/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository30 other files it gives its agents.
- accessibility-auditSkill
- api-design-reviewSkill
- api-test-writerSkill
- architecture-diagramSkill
- bug-debuggerSkill
- bug-report-writerSkill
- changelog-writerSkill
- codebase-onboardingSkill
- code-reviewSkill
- dependency-upgradeSkill
- design-handoff-specSkill
- design-reviewSkill
- dockerize-appSkill
- figma-design-compareSkill
- flaky-test-fixerSkill
- git-commit-writerSkill
- github-actions-ciSkill
- playwright-e2e-testsSkill
- prd-writerSkill
- proof-of-done-liteSkill
- readme-writerSkill
- refactor-plannerSkill
- security-auditSkill
- seo-auditSkill
- test-case-generatorSkill
- test-plan-writerSkill
- test-writerSkill
- ux-research-synthesisSkill
- ux-writingSkill
- web-performance-auditSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Access patterns → indexes: Write the top 5-10 queries first.
- Distinctive: line 24
Check every table against checklist.md.
- Very specific: line 40
Add columns as nullable or with a constant default.
- Very specific: line 41
Create indexes concurrently (CREATE INDEX CONCURRENTLY / online DDL).
- Distinctive: line 43
Never drop a column or table in the same release that stops writing to it.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Schema Design
Overview
A good schema makes invalid data impossible and common queries fast. Push rules into constraints, derive indexes from real access patterns, and never ship a migration that locks or loses data.
Designing from scratch
- Entities and relationships. List nouns, their cardinality (1:1, 1:N, N:M) and ownership. N:M gets a join table.
- Keys. Surrogate primary key (bigint identity or UUIDv7). Natural uniqueness becomes a
UNIQUEconstraint, not the PK. - Columns. Right type,
NOT NULLby default, defaults where sensible. See the type table. - Constraints. Foreign keys with explicit
ON DELETE,UNIQUE,CHECK, enums or lookup tables for closed sets. - Access patterns → indexes. Write the top 5-10 queries first; index their
WHERE,JOINandORDER BYcolumns. - Lifecycle.
created_at,updated_at; soft delete only if the product needs restore or audit. - Migration plan (below).
Reviewing an existing schema
Check every table against checklist.md. Read the queries in the code too: a schema is only "wrong" relative to how it is used.
Type choices
| Data | Use | Avoid |
| Money | numeric(12,2) or integer cents + currency | float, double, real |
| Timestamps | timestamptz (Postgres) / UTC datetime | local time without zone |
| Closed set of values | enum or FK to lookup table + CHECK | free-text strings |
citext or lower-cased + UNIQUE | case-sensitive unique | |
| Booleans | boolean NOT NULL DEFAULT false | nullable tri-state by accident |
| Text | text with CHECK (length(...)) if limits matter | varchar(255) everywhere by habit |
| JSON | jsonb for truly flexible attributes only | JSON for data you filter or join on |
Safe migrations
- Add columns as nullable or with a constant default; backfill in batches; then add
NOT NULL. - Create indexes concurrently (
CREATE INDEX CONCURRENTLY/ online DDL). - Renames and drops: expand (add new) → migrate code and data → contract (drop old) across releases.
- Never drop a column or table in the same release that stops writing to it.
Output contract
### [Data integrity | Performance | Migration risk | Design] Title
- Where: table.column (file:line)
- Problem: the bad data or slow query this allows
- Fix: exact DDL or schema changeOrder by risk: data loss and integrity first, then performance, then design. When designing, deliver the full DDL or ORM schema plus the index list mapped to the queries it serves.
Common mistakes
- Missing indexes on foreign key columns (Postgres does not create them).
- Uniqueness enforced only in application code: races create duplicates.
- Polymorphic
owner_type+owner_idwith no referential integrity. - Adding an index for every column instead of for actual queries.
- Reviewing the schema without reading the queries that use it.
Made by Wageesha Tripathi · LinkedIn · Email · More skills
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

