| name | database-patterns |
| description | Database design patterns for DynamoDB single-table design and Drizzle ORM. Use when designing schemas, writing queries, or setting up database infrastructure. |
Database Patterns
Standard database design patterns across all projects. 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-patterns/ 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-patterns skill with your project's schema details."