database-design
Skill4 starsChanged 4 months agoMITView on GitHub
Schema design, data modeling, migrations, and query correctness for relational databases (and when to use non-relational). Use when creating or altering tables, designing schemas, writing migrations, modeling money/inventory/ledgers, adding indexes, or when the user says "schema", "data model", "migration", "database design", or "normalize".
58 other projects use a version of this.
Adopted by
Most recently taken up by
- chaunsin/agent-skillstheir own version, first seen Nov 8, 2026
- kinhluan/skillstheir own version, first seen Nov 8, 2026
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- mahdy-gribkov/arcanatheir own version, first seen Nov 8, 2026
- KbWen/agentic-ostheir own version, first seen Nov 7, 2026
- its-ash/skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use intelligent-routing, bash-linux and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SKB3002Skillintelligent-routing
Automatic agent selection and intelligent task routing. Analyzes user requests and automatically selects the best specialist agent(s) without requiring explicit user mentions.
Also in 6 projects that use this
xenitV1Skillbash-linux
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.
Also in 7 projects that use this
xenitV1Skillred-team-tactics
Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
Also in 7 projects that use this
pepebot-spaceSkillllm-application-dev
Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.
Also in 4 projects that use this
- +8 more from xenitV1
Other versions58 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 58
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- CloudAI-X/claude-workflow★ 1.4ksame name
- CloudAI-X/claude-workflow-v2★ 1.4ksame name
- MoizIbnYousaf/Ai-Agent-Skills★ 1.1ksame name
- skillcreatorai/Ai-Agent-Skills★ 1.1ksame name
- MoizIbnYousaf/ai-agent-skills★ 1.1ksame name
- KbWen/agentic-os★ 229same name
- kid-sid/claude-spellbook★ 190same name
- xenitV1/Antigravity-Workflows★ 130same name
48 more not listed
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 repository23 other files it gives its agents.
- ai-agent-designSkill
- ai-build-qualitySkill
- ai-engineeringSkill
- api-contract-designSkill
- architecture-designSkill
- change-hygieneSkill
- code-qualitySkill
- data-privacy-complianceSkill
- dependency-disciplineSkill
- deployment-safetySkill
- docs-and-runbooksSkill
- legacy-code-changesSkill
- observability-readinessSkill
- payments-and-moneySkill
- performance-improvementSkill
- product-ux-qualitySkill
- release-readinessSkill
- requirements-to-specSkill
- root-cause-debuggingSkill
- saas-multi-tenancySkill
- system-designSkill
- testing-strategySkill
- threat-model-securitySkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 55 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
Before shipping a list endpoint: it must paginate (keyset for large/growing sets), and its query must not be N+1 (verify by looking at …
- Distinctive: line 48
Every migration answers: is it idempotent/re-runnable?
“Common” is measured: kept by at least 6 in 10 of the 55 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 Design
The schema outlives every framework, every rewrite, and every AI model that touches the codebase. Code bugs ship and get fixed; schema mistakes and corrupted data are forever. Design the schema as if the application code were hostile — because one day, some version of it will be.
Principle: the database defends its own invariants
Any rule the business cannot tolerate being violated goes in the schema, not only in application code:
NOT NULLby default; nullable is an explicit decision meaning "absence is a valid state" (and every reader must handle it).FOREIGN KEYfor every reference.UNIQUEfor every natural key (mobile number, invoice number per tenant, SKU per account).CHECKfor domains (quantity >= 0, status in allowed set, rate between 0 and 100).- Application-level checks are UX; database constraints are truth. You need both, but only one of them holds under race conditions, bad deploys, and manual fixes.
Modeling rules that prevent the classic disasters
- Money and quantity are exact decimals (
NUMERIC), never float — no exceptions, including "it's just a percentage". Store currency explicitly if there could ever be more than one. - Timestamps: store UTC (
timestamptz), render in local zone. Name columns*_at. Every mutable table getscreated_at/updated_at. - IDs: surrogate primary key (UUID or bigint — pick per project and stay consistent); enforce natural keys with UNIQUE constraints, don't make them the PK. Never expose sequential IDs where enumeration leaks business volume (invoice counts, user counts) unless numbering is a product requirement.
- State machines as data: a
statuscolumn needs its legal transitions written down (in code comments/docs) and enforced in exactly one service function. If history matters, an append-only events/audit table beats overwriting. - Financial and inventory data is append-only at heart: model corrections as new compensating rows (credit notes, stock adjustments with reasons), not UPDATEs that destroy what happened. If a regulator, accountant, or angry customer could ask "what was it before?", keep the before.
- Soft delete vs hard delete is a product decision — but referencing rows must never dangle either way; decide
ON DELETEbehavior per FK deliberately (RESTRICT is the safe default). - Multi-tenant:
account_id NOT NULLon every tenant table, composite indexes leading with it, and row-level security or a mandatory scoping mechanism so a missing WHERE clause fails closed, not open.
Normalization: the practical rule
Normalize until it hurts (one fact, one place — eliminate update anomalies), then denormalize only with a named owner for the copy and its update path. Storing line_total = qty × rate is fine for immutable invoice lines (they're history, frozen at sale time — that's not denormalization, that's a snapshot). Storing a customer's "current balance" is a cache — it needs either a recomputation job or transactional dual-writes, and a way to audit drift.
Concurrency: assume two requests arrive at once
- Any read-modify-write (stock decrement, balance update, counter, "next invoice number") needs an explicit strategy: atomic single UPDATE (
SET stock = stock - :n WHERE stock >= :n),SELECT ... FOR UPDATE, or a serializable/retry pattern. "We'll be small" doesn't prevent double-submits from one user's double-click. - Uniqueness under concurrency is a constraint + handled violation, not check-then-insert.
- Multi-row financial writes (invoice + lines + stock + ledger) are one transaction, all or nothing — and keep transactions short; never call external APIs inside one.
Indexes and queries
- Index every FK, every column in frequent WHERE/ORDER BY, and tenant-scoped composites
(account_id, x). But each index taxes every write — add them for observed query shapes, not superstition. - Before shipping a list endpoint: it must paginate (keyset for large/growing sets), and its query must not be N+1 (verify by looking at emitted SQL once, not by assuming the ORM is smart).
EXPLAINany query you're about to optimize; never index-guess.
Migration discipline
- Migrations are code-reviewed, hand-verified artifacts — whether hand-written or generated, read every line and know its lock behavior before it touches production data.
- Additive first; destructive only after code no longer reads the old shape (see deployment-safety: expand → migrate → contract).
- Every migration answers: is it idempotent/re-runnable? does it run safely while old code is live? what's the down-path or restore plan? does the backfill batch (not one giant UPDATE locking the table)?
When someone says "let's use NoSQL / JSONB for this"
JSONB/document columns are right for genuinely schemaless payloads you don't query relationally (provider webhook dumps, user-defined custom fields). They are wrong for anything with relationships, constraints, or reporting needs — that's just a schema you've decided not to enforce. Default to relational; earn your way out.
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.

