db-schema
Skill20 starsChanged 7 months agoMITView on GitHub
Apply when designing database schemas, writing migrations, or reviewing table structure. Covers naming, keys, indexes, constraints, nullability, and migration safety.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- adarshaccreteinfo/Claude-Skillstheir own version, first seen Aug 27, 2026
- Ericcccccc777/CCC-MAGItheir own version, first seen Jun 28, 2026
- Adit-Jain-srm/skill-forgetheir own version, first seen Jun 6, 2026
- Pascal-Neubauer/Claude_Skillstheir own version, first seen Apr 20, 2026
- zeon-kun/claude-skillstheir own version, first seen Apr 7, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- zeon-kun/claude-skills★ 6same name
- Adit-Jain-srm/skill-forge★ 2same name
- adarshaccreteinfo/Claude-Skills★ 1same name
- Ericcccccc777/CCC-MAGI★ 1same name
- Pascal-Neubauer/Claude_Skills★ 1same 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 repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/brainstorming.mdcCursor rule
- .cursor/rules/branch-finishing.mdcCursor rule
- .cursor/rules/code-quality.mdcCursor rule
- .cursor/rules/db-schema.mdcCursor rule
- .cursor/rules/debugging.mdcCursor rule
- .cursor/rules/docker.mdcCursor rule
- .cursor/rules/domain-template.mdcCursor rule
- .cursor/rules/drawio.mdcCursor rule
- .cursor/rules/error-log.mdcCursor rule
- .cursor/rules/fastapi.mdcCursor rule
- .cursor/rules/git-conventions.mdcCursor rule
- .cursor/rules/github-cli.mdcCursor rule
- .cursor/rules/implementation-plan.mdcCursor rule
- .cursor/rules/langchain.mdcCursor rule
- .cursor/rules/python.mdcCursor rule
- .cursor/rules/react.mdcCursor rule
- .cursor/rules/review-deployment.mdcCursor rule
- .cursor/rules/security-review.mdcCursor rule
- .cursor/rules/self-extension-workflow.mdcCursor rule
- .cursor/rules/shell-scripting.mdcCursor rule
- .cursor/rules/svg-check.mdcCursor rule
- .cursor/rules/tdd.mdcCursor rule
- .cursor/rules/typescript.mdcCursor rule
- skill-everythingSkill
- brainstormingSkill
- branch-finishingSkill
- code-qualitySkill
- debuggingSkill
- dockerSkill
- domain-templateSkill
- drawioSkill
- error-logSkill
- fastapiSkill
- git-conventionsSkill
- github-cliSkill
- implementation-planSkill
- langchainSkill
- pythonSkill
- reactSkill
- review-deploymentSkill
- security-reviewSkill
- self-extension-workflowSkill
- shell-scriptingSkill
- svg-checkSkill
- tddSkill
- <kebab-case-name>Skill
- typescriptSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. 0 are common, 3 are distinctive, and 17 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Snake case everywhere: Always use snake_case for table names, column names, and index names.
- Very specific: line 27
Plural table names: Always name tables in the plural (users, orders, line_items).
- Very specific: line 28
Consistent FK column naming: Always name foreign-key columns <referenced_table_singular>_id (e.g., user_id, order_id) so the reference is …
- Very specific: line 32
Surrogate primary key: Always define an explicit surrogate primary key (id) on every table.
- Very specific: line 33
UUID vs serial: Prefer uuid PKs for distributed systems or public-facing IDs.
- Very specific: line 37
Declare FK constraints: Always declare FOREIGN KEY constraints in the schema.
- Very specific: line 38
Explicit ON DELETE behaviour: Always specify ON DELETE behaviour (CASCADE, SET NULL, or RESTRICT) on every FK.
- Distinctive: line 39
Missing FK is a data-integrity bug: Never ship a column that references another table without a corresponding FK constraint — orphaned rows …
- Distinctive: line 43
Index every FK column: Always add an index on every foreign-key column.
- Very specific: line 44
Covering indexes for hot queries: Use covering indexes (include all columns in the SELECT) for read-heavy queries rather than adding …
- Distinctive: line 45
Unique constraints at DB level: Always enforce uniqueness at the database level rather than relying on application-layer deduplication.
- Very specific: line 49
Explicit NOT NULL: Always mark columns NOT NULL unless NULL carries distinct semantic meaning (unknown vs.
- Very specific: line 50
Meaningful defaults: Always supply a DEFAULT for columns that have a sensible zero-value (0, '', false, now()).
- Very specific: line 54
Standard audit columns: Always include created_at TIMESTAMPTZ NOT NULL DEFAULT now() and updated_at TIMESTAMPTZ NOT NULL DEFAULT now() on …
- Very specific: line 55
Soft delete with deleted_at: Prefer deleted_at TIMESTAMPTZ over hard deletes for user-facing entities.
- Very specific: line 59
DB-native enum or check constraint: Always enforce enum-like columns with a CHECK constraint or a native ENUM type.
- Very specific: line 63
Up and down migrations: Always write both an up and a down migration.
- Very specific: line 64
Idempotent migrations: Always guard DDL statements with IF NOT EXISTS / IF EXISTS so re-running a migration does not error.
- Very specific: line 65
Non-blocking index creation: Use CREATE INDEX CONCURRENTLY (Postgres) or equivalent for indexes on large tables.
- Very specific: line 69
Check constraints for invariants: Always encode business invariants (e.g., price > 0, quantity >= 0) as CHECK constraints.
“Common” is measured: kept by at least 6 in 10 of the 4 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
Sub-Skill: Database Schema Design
<!-- target: tokens_target above. Run `python tools/render_readme_table.py` to update README. -->Purpose: Prevent data-integrity bugs, race conditions, and irreversible migrations by enforcing database-level constraints and safe migration patterns before code reaches production.
Rules
Naming Conventions
- Snake case everywhere. Always use
snake_casefor table names, column names, and index names; never use camelCase or PascalCase in SQL identifiers. - Plural table names. Always name tables in the plural (
users,orders,line_items); singular names cause inconsistency across ORMs and query builders. - Consistent FK column naming. Always name foreign-key columns
<referenced_table_singular>_id(e.g.,user_id,order_id) so the reference is self-documenting.
Primary Keys
- Surrogate primary key. Always define an explicit surrogate primary key (
id) on every table; never rely on natural keys as the sole PK unless the domain guarantees immutability. - UUID vs serial. Prefer
uuidPKs for distributed systems or public-facing IDs; preferbigserial/bigint GENERATED ALWAYS AS IDENTITYfor high-insert internal tables where sort order matters.
Foreign Keys & Referential Integrity
- Declare FK constraints. Always declare
FOREIGN KEYconstraints in the schema; never rely on application-layer join logic to enforce referential integrity. - Explicit ON DELETE behaviour. Always specify
ON DELETEbehaviour (CASCADE,SET NULL, orRESTRICT) on every FK; omitting it defaults toRESTRICT, which can cause surprising errors at runtime. - Missing FK is a data-integrity bug. Never ship a column that references another table without a corresponding FK constraint — orphaned rows accumulate silently. Reference: ERR-2026-022
Indexes
- Index every FK column. Always add an index on every foreign-key column; unindexed FKs cause full-table scans on joins and cascade operations.
- Covering indexes for hot queries. Use covering indexes (include all columns in the
SELECT) for read-heavy queries rather than adding redundant columns to the base table. - Unique constraints at DB level. Always enforce uniqueness at the database level rather than relying on application-layer deduplication; race conditions between concurrent writes bypass app checks. Reference: ERR-2026-022
Nullability & Defaults
- Explicit NOT NULL. Always mark columns
NOT NULLunlessNULLcarries distinct semantic meaning (unknown vs. absent); nullable columns complicate query logic and ORM mapping. - Meaningful defaults. Always supply a
DEFAULTfor columns that have a sensible zero-value (0,'',false,now()); avoid forcing callers to supply values the DB can compute.
Timestamps & Soft Delete
- Standard audit columns. Always include
created_at TIMESTAMPTZ NOT NULL DEFAULT now()andupdated_at TIMESTAMPTZ NOT NULL DEFAULT now()on every table; omitting them makes debugging and auditing impossible. - Soft delete with deleted_at. Prefer
deleted_at TIMESTAMPTZover hard deletes for user-facing entities; ensure all queries filterWHERE deleted_at IS NULLor use a view/partial index.
Enum Columns
- DB-native enum or check constraint. Always enforce enum-like columns with a
CHECKconstraint or a nativeENUMtype; never store unconstrained strings and validate only in the application.
Migrations
- Up and down migrations. Always write both an
upand adownmigration; a rollback path is mandatory before any migration reaches production. - Idempotent migrations. Always guard DDL statements with
IF NOT EXISTS/IF EXISTSso re-running a migration does not error; this is required for blue-green and multi-replica deployments. - Non-blocking index creation. Use
CREATE INDEX CONCURRENTLY(Postgres) or equivalent for indexes on large tables; blocking index creation causes downtime.
Constraints Over App Logic
- Check constraints for invariants. Always encode business invariants (e.g.,
price > 0,quantity >= 0) asCHECKconstraints; application-layer validation is bypassed by direct DB writes, scripts, and migrations.
See also
skills/code-quality/SKILL.md— general code-quality rules that apply to migration scriptsskills/review-deployment/SKILL.md— deployment checklist that includes migration safety gates
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.

