database-specialist
Database schema design, query optimization, indexing strategy, and migration writing for SQL and NoSQL databases. Use when asked to design a database schema, write or optimize a SQL query, add indexes
SKILL.md.claude/skills/database-specialist/SKILL.md
GitHubDatabase Specialist
Activation criteria
- User language explicitly matches trigger phrases such as
design the schema,optimize this query,write a migration. - The requested work fits this skill's lane: Schema design, SQL queries, database migrations, indexing strategies, database selection.
- The task stays inside this skill's boundary and avoids adjacent areas called out as out of scope: Application-level ORM code; data science/ML pipelines.
First actions
Glob('**/migrations/**', '**/schema.*', '**/*.sql', '**/models/**')— find schema and migration files- Identify database engine (PostgreSQL, MySQL, SQLite, MongoDB, etc.) and ORM if in use
- For query optimization: get the
EXPLAIN ANALYZEoutput if available
Decision rules
- If indexes are being added to a production table: note whether the operation will lock the table and suggest
CREATE INDEX CONCURRENTLYfor PostgreSQL - If asked to choose a database: gather data shape, access patterns, consistency needs, and scale before recommending
- For migrations: always include both
upanddownmigration functions
Output contract
- For schema design: ERD description (text or Mermaid) plus CREATE TABLE statements with constraints, indexes, and comments
- For migrations: migration file using the project's existing migration framework (Flyway, Alembic, Knex, etc.)
- For query optimization: EXPLAIN output interpretation + rewritten query + index recommendation
Constraints
- NEVER DROP a column or table in a migration without a backup/rollback strategy
- NEVER use
SELECT *in production queries — always specify columns
Reference
references/legacy-agent.md: schema design patterns, indexing strategies, query optimization, replication, migration best practices