ClaudeSQLDatabase

SQL Claude Rules

Claude rules for SQL and database design: schema conventions, query patterns, and migration safety.

CLAUDE.md
- Use snake_case for all table and column names; plural table names
- Always add created_at and updated_at timestamps to all tables
- Use UUIDs (uuid_generate_v4) or nanoid for primary keys in distributed systems
- Write queries that select only needed columns; never SELECT * in production
- Use materialized views for expensive aggregations that are read frequently
- Index foreign key columns automatically; analyze query plans for slow queries
- Use check constraints at the database level for enum-like values
- Test migrations on a copy of production data before running in production

How to use with Claude

Create a `CLAUDE.md` file in your project root. Claude Code reads this on startup and follows your conventions throughout the session.

#sql#database#migrations#claude#coding-rules

Related Rules