database-design
Skill1 starsChanged 9 months agoMITView on GitHub
Designs database schemas, reviews queries, plans migrations, and optimizes data access patterns. Covers relational modeling, indexing strategy, normalization, and common anti-patterns. Use when designing schemas, writing complex queries, or diagnosing database performance issues.
42 other projects use a version of this.
Adopted by
Most recently taken up by
- vekzz-dev/opencode-skillstheir own version, first seen Oct 3, 2026
- hemapriyan-rk/claude-rigor-skillstheir own version, first seen Sep 26, 2026
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
- KbWen/agentic-ostheir own version, first seen Sep 10, 2026
- RealDougEubanks/ClaudeMarketplacetheir own version, first seen Sep 10, 2026
- VoDaiLocz/kilo-kit-mcptheir own version, first seen Aug 21, 2026
Used with
Projects with it also use intelligent-routing, i18n-localization 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.
tiendatworkSkillintelligent-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 3 projects that use this
xfstudioSkilli18n-localization
Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.
Also in 5 projects that use this
xfstudioSkillbehavioral-modes
AI operational modes (brainstorm, implement, debug, review, teach, ship, orchestrate). Use to adapt behavior based on task type.
Also in 3 projects that use this
GenerativeAgentsSkillarchitecture-design
アーキテクチャ設計書を作成するための詳細ガイドとテンプレート。アーキテクチャ設計時にのみ使用。
Also in 8 projects that use this
- +8 more from xfstudio
Other versions42 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 42
- CloudAI-X/claude-workflow-v2★ 1.4ksame name
- MoizIbnYousaf/ai-agent-skills★ 1.1ksame name
- KbWen/agentic-os★ 206same name
- thiientv/godmode★ 96same name
- KbWen/agent-virtual-office★ 35same name
- VoDaiLocz/kilo-kit-mcp★ 27same name
- krzysztofsurdy/code-virtuoso★ 22same name
- DauQuangThanh/hanoi-rainbow★ 17same name
- ishandutta2007/Awesome-Claude-Skills★ 15same name
- svngoku/coding-agents-skills★ 11same name
32 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 repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- cachingSkill
- ci-cdSkill
- config-managementSkill
- containerizeSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- error-handlingSkill
- estimateSkill
- feature-flag-opsSkill
- git-recoverySkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- loggingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 41 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Normalize first, denormalize for performance: Start with 3NF. Add denormalization only when you have measured performance problems.
- Very specific: line 12
Every table gets an
id,created_at,updated_at: No exceptions. You'll need them. - Distinctive: line 13
Use constraints: NOT NULL, UNIQUE, FOREIGN KEY, CHECK.
- Distinctive: line 141
Never rename columns in one step: Add new → backfill → update code → drop old.
- Distinctive: line 142
Never drop columns in the same deploy: Wait one release cycle.
“Common” is measured: kept by at least 6 in 10 of the 41 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
Schema Design Principles
- Model the domain, not the UI. Tables represent real-world entities, not screens or forms.
- Normalize first, denormalize for performance. Start with 3NF. Add denormalization only when you have measured performance problems.
- Every table gets an
id,created_at,updated_at. No exceptions. You'll need them. - Use constraints. NOT NULL, UNIQUE, FOREIGN KEY, CHECK. The database is your last line of defense.
- Name things clearly.
user_idnotuid.created_atnotts. Plural table names (users,orders) or singular (user,order) - pick one, be consistent.
Table Design Template
CREATE TABLE table_name (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
-- domain fields
field_name TYPE NOT NULL,
status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'inactive', 'archived')),
-- relationships
parent_id UUID NOT NULL REFERENCES parent_table(id),
-- timestamps
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- Indexes for common query patterns
CREATE INDEX idx_table_parent ON table_name(parent_id);
CREATE INDEX idx_table_status ON table_name(status) WHERE status = 'active';Indexing Strategy
When to Add an Index
- Columns in WHERE clauses on large tables
- Columns used in JOIN conditions
- Columns used in ORDER BY on large result sets
- Foreign key columns (almost always)
When NOT to Add an Index
- Small tables (< 1K rows) - full scan is faster
- Columns with low cardinality (boolean, status with 3 values) - unless using partial index
- Tables with heavy write load - every index slows writes
- "Just in case" - indexes have real storage and write costs
Index Types
| Type | Use Case | Example |
| B-tree (default) | Equality, range, sorting | WHERE created_at > '2024-01-01' |
| Hash | Equality only | WHERE email = 'x@y.com' |
| GIN | Full-text search, JSONB, arrays | WHERE tags @> '{go}' |
| Partial | Subset of rows | WHERE status = 'active' (index only active rows) |
| Composite | Multi-column queries | WHERE user_id = X AND status = 'active' |
Reading EXPLAIN Output
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 'abc' AND status = 'active';Look for:
- Seq Scan on large tables = missing index
- Rows estimate vastly different from actual = stale statistics
- Nested Loop with large outer table = consider different join strategy
- Sort with high cost = consider index for ORDER BY
Common Patterns
Soft Delete
-- Add deleted_at column instead of actually deleting
ALTER TABLE users ADD COLUMN deleted_at TIMESTAMPTZ;
-- Queries exclude deleted by default
CREATE VIEW active_users AS SELECT * FROM users WHERE deleted_at IS NULL;
-- Partial index for active records
CREATE INDEX idx_users_active ON users(email) WHERE deleted_at IS NULL;Enum-Like Values
-- Use CHECK constraints, not a separate lookup table (for small, stable sets)
status TEXT NOT NULL CHECK (status IN ('draft', 'published', 'archived'))
-- Use a reference table for large or dynamic sets
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name TEXT UNIQUE NOT NULL
);Audit Trail
CREATE TABLE audit_log (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
table_name TEXT NOT NULL,
record_id UUID NOT NULL,
action TEXT NOT NULL CHECK (action IN ('insert', 'update', 'delete')),
old_data JSONB,
new_data JSONB,
changed_by UUID REFERENCES users(id),
changed_at TIMESTAMPTZ NOT NULL DEFAULT now()
);Pagination
-- Cursor-based (preferred for large datasets)
SELECT * FROM posts
WHERE created_at < $cursor
ORDER BY created_at DESC
LIMIT 20;
-- Offset-based (simpler, fine for small datasets)
SELECT * FROM posts
ORDER BY created_at DESC
LIMIT 20 OFFSET 40;Anti-Patterns
| Anti-Pattern | Problem | Fix |
| EAV (Entity-Attribute-Value) | Unqueryable, no constraints | Use JSONB column or proper table |
| Storing CSV in a column | Can't query, join, or constrain | Normalize into a junction table |
| No foreign keys | Orphaned data, broken references | Add FK constraints |
| **SELECT *** | Fetches unnecessary data, breaks on schema change | List specific columns |
| N+1 queries | 1 query for list + 1 per item | JOIN or batch fetch |
| Unbounded queries | SELECT * FROM big_table with no LIMIT | Always paginate |
| Business logic in triggers | Hidden, hard to debug, hard to test | Keep logic in application code |
Migration Safety Rules
- Add columns as nullable or with a default. Never add NOT NULL without a default on a populated table.
- Never rename columns in one step. Add new → backfill → update code → drop old.
- Never drop columns in the same deploy. Wait one release cycle.
- Test on production-sized data. A migration that takes 1s on 1K rows can take hours on millions.
- Always write a down migration. Even if you "never" need it.
Schema Review Checklist
- Tables have primary keys
- Foreign keys have indexes
- NOT NULL where data is required
- CHECK constraints for enumerated values
created_atandupdated_aton all tables- Indexes exist for common query patterns
- No unbounded text/blob columns without size reasoning
- Migration is reversible
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.

