| name | database-design |
| description | Database design principles, decision-making, and platform-specific patterns. Schema design, indexing strategy, ORM selection, serverless databases, DynamoDB single-table design, Drizzle ORM patterns. |
| tools | Read, Write, Edit, Glob, Grep |
Database Design
Learn to THINK, not copy SQL patterns.
🎯 Selective Reading Rule
Read ONLY files relevant to the request! Check the content map, find what you need.
| File | Description | When to Read |
|---|
database-selection.md | PostgreSQL vs Neon vs Turso vs SQLite | Choosing database |
orm-selection.md | Drizzle vs Prisma vs Kysely | Choosing ORM |
schema-design.md | Normalization, PKs, relationships | Designing schema |
indexing.md | Index types, composite indexes | Performance tuning |
optimization.md | N+1, EXPLAIN ANALYZE | Query optimization |
migrations.md | Safe migrations, serverless DBs | Schema changes |
⚠️ Core Principle
- ASK user for database preferences when unclear
- Choose database/ORM based on CONTEXT
- Don't default to PostgreSQL for everything
Decision Checklist
Before designing schema:
Anti-Patterns
❌ Default to PostgreSQL for simple apps (SQLite may suffice)
❌ Skip indexing
❌ Use SELECT * in production
❌ Store JSON when structured data is better
❌ Ignore N+1 queries
Platform-Specific Patterns
Standard database design patterns for specific platforms. Read the relevant resource file for the database technology in use.
Instructions
- Before designing any table, define access patterns first (queries before schema)
- Read
resources/dynamodb-design.md for DynamoDB projects
- Read
resources/drizzle-patterns.md for PostgreSQL/Drizzle projects
- ALWAYS document which index a query uses in code comments
Universal Rules
- Never use database scans in production code — always use indexed queries
- Use TTL for temporary data (sessions, OTPs, cache entries)
- Parameterized queries only — never concatenate user input
- Index-first design — design indexes before writing queries
- Soft deletes preferred over hard deletes for audit trails
- Timestamps on everything —
createdAt, updatedAt on every record
Auto-Clone to Project
When you first detect this project uses a database:
- Create
.agent/skills/database-design/ in the project root
- Copy this SKILL.md as the base
- Read the project's schema files (
schema.ts, table definitions, DynamoDB configs)
- Append a
## Project-Specific section listing:
- Tables/entities and their keys
- GSIs/indexes and their access patterns
- Common query patterns with index annotations
- Inform the user: "I've set up the local database-design skill with your project's schema details."