database-design
Skill65 starsChanged 3 months agoMITView on GitHub
Design schemas and migrations when persistent data structures change.
We split this skill into the rules it gives an agent
15 rules. 0 are common, 11 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 52 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Every table MUST have: id (primary key), created_at, updated_at
- Distinctive: line 22
Use UUIDs or auto-increment IDs consistently (per ADR decision)
- Distinctive: line 36
Every foreign key column MUST have an index
- Distinctive: line 40
DO NOT over-index: every index slows writes
- Very specific: line 44
Migrations MUST be reversible: every up must have a corresponding down
- Distinctive: line 45
Never modify a shipped migration: create a new migration instead
- Very specific: line 47
Test rollback: after writing migration, verify down works cleanly
- Distinctive: line 50
Use parameterized queries / ORM bindings — NEVER string concatenation for SQL
- Very specific: line 52
Add LIMIT to all list queries (even if paginated — belt and suspenders)
- Distinctive: line 53
Use transactions for multi-table writes
- Distinctive: line 58
NOT NULL on required fields (don't rely on application validation alone)
- Distinctive: line 59
CHECK constraints for enum-like fields or value ranges
- Distinctive: line 60
Default values for fields that have sensible defaults
- Distinctive: line 96
Missing indexes on FK: Every foreign key needs an index.
- Distinctive: line 101
Trusting application-only validation: No DB constraints means bad data WILL get in eventually.
“Common” is measured: kept by at least 6 in 10 of the 52 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
<!-- This is a SCAFFOLD skill -->Database Design
When to Apply
- Classification: feature (if new tables/columns), architecture-change (schema redesign), hotfix (data-related bug)
- Phase: /plan (schema design), /implement (migration creation), /review (schema review), /test (data integrity)
- Trigger: Task involves creating tables, modifying schema, writing migrations, or changing data access patterns
Conventions
Customize after /app-init: Replace these generic conventions with your project's ADR and ORM-specific patterns.
Table Design
- Every table MUST have:
id(primary key),created_at,updated_at - Use UUIDs or auto-increment IDs consistently (per ADR decision)
- Soft delete: add
deleted_atcolumn if ADR specifies soft delete - Table names: plural, snake_case (e.g.,
users,order_items) - Column names: snake_case (e.g.,
first_name,is_active)
Relationship Patterns
| Relationship | Implementation | Example |
| One-to-Many | Foreign key on "many" side | orders.user_id → users.id |
| Many-to-Many | Junction table | user_roles (user_id, role_id) |
| One-to-One | Foreign key + unique constraint | user_profiles.user_id (UNIQUE) → users.id |
| Self-referencing | Foreign key to same table | categories.parent_id → categories.id |
Index Strategy
- Every foreign key column MUST have an index
- Columns used in WHERE clauses frequently → add index
- Composite indexes: put the most selective column first
- Unique constraints for business uniqueness rules (email, username, etc.)
- DO NOT over-index: every index slows writes
Migration Rules
- One migration per logical change (don't mix table creation with data backfill)
- Migrations MUST be reversible: every
upmust have a correspondingdown - Never modify a shipped migration: create a new migration instead
- Data migrations separate from schema migrations: schema first, data second
- Test rollback: after writing migration, verify
downworks cleanly
Query Patterns
- Use parameterized queries / ORM bindings — NEVER string concatenation for SQL
- Limit SELECT columns:
SELECT id, namenotSELECT * - Add
LIMITto all list queries (even if paginated — belt and suspenders) - Use transactions for multi-table writes
- Batch inserts for bulk operations (not one INSERT per row)
Data Integrity
- Foreign key constraints enforced at DB level (not just application level)
- NOT NULL on required fields (don't rely on application validation alone)
- CHECK constraints for enum-like fields or value ranges
- Default values for fields that have sensible defaults
Checklist
During /plan:
- Schema changes documented in spec (new tables, modified columns)
- Indexes planned for query patterns
- Migration rollback strategy defined
- Data backfill plan (if modifying existing tables with data)
During /implement:
- Migration file created (not manual SQL against DB)
- Foreign keys have indexes
- NOT NULL and DEFAULT constraints set appropriately
- Migration tested: up → verify → down → verify → up
- No raw SQL string concatenation (use parameterized queries)
During /review:
- No N+1 queries (use eager loading / JOIN where appropriate)
- Transaction boundaries correct (all-or-nothing for related writes)
- No schema changes without migration file
- Backward compatibility: old code can still function until deployed together
- Sensitive data columns identified (for encryption/hashing per security guardrails)
Heading-Scoped Read Note
For phase-entry loading, read only:
When to ApplyChecklist
Load Conventions, Anti-Patterns, and References on full read or cache miss only.
Anti-Patterns
- Schema via ORM only: Relying on ORM auto-sync without migration files. No rollback, no history, no review.
- God table: One table with 30+ columns. Normalize or split by domain.
- Missing indexes on FK: Every foreign key needs an index. Databases don't add them automatically (except some).
- String-typed everything: Using VARCHAR for dates, numbers, booleans. Use proper types.
- No migration rollback: Writing
upwithoutdown. You will need to rollback someday. - Mixing DDL and DML: Schema changes and data backfill in the same migration. Split them.
- SELECT * in production code: Fetching all columns when you need two. Wastes memory and bandwidth.
- Trusting application-only validation: No DB constraints means bad data WILL get in eventually.
References
- Project ADR:
docs/adr/ADR-002-project-architecture.md§ Database Design - Security guardrails:
.agent/rules/security_guardrails.md(A03: SQL Injection, A02: Secrets in connection strings) - Spec template:
.agentcortex/templates/spec-app-feature.md§ Database Schema
Other versions54 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- KbWen/agentic-os★ 22499% same
Wrote their own version · 53
- 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
- kid-sid/claude-spellbook★ 190same name
- xenitV1/Antigravity-Workflows★ 130same name
- VoDaiLocz/kilo-kit-mcp★ 28same name
43 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.
Used alongsideProjects 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
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- api-designSkill
- auth-securitySkill
- dispatching-parallel-agentsSkill
- doc-lookupSkill
- frontend-patternsSkill
- karpathy-principlesSkill
- production-readinessSkill
- red-team-adversarialSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- using-git-worktreesSkill
- verification-before-completionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

