database-optimizer · davila7 — Claude Code skill: query and schema tuning
A Claude skill that digs into database bottlenecks: execution plans, indexes, N+1, caching and partitioning. Useful when queries are slow and the reason isn't obvious.
npx claude-code-templates@latest --skill database/database-optimizerWhat database-optimizer does
Install the skill and Claude starts acting as a database consultant. It covers execution plan analysis with EXPLAIN ANALYZE, query rewriting around subqueries and JOINs, window functions and recursive CTEs. Indexing gets its own section: B-tree, Hash, GiST, GIN, BRIN, composite and partial indexes, plus index bloat and rebuild strategies.
N+1 detection is handled too. The skill walks through ORM query analysis for Django ORM, SQLAlchemy, Entity Framework and ActiveRecord, then the fixes — eager loading, batch queries, DataLoader for GraphQL. Caching spans application-level results, Redis and Memcached, down to the database buffer pool, with TTL and event-driven invalidation. Scaling is covered by partitioning, sharding, read replicas and async writes.
PostgreSQL, MySQL, SQL Server, Oracle, MongoDB, DynamoDB and cloud databases like RDS, Aurora, Azure SQL and Cloud SQL are all in scope. For worked examples the skill points to resources/implementation-playbook.md, so that file needs to sit in the skill directory — without it you're left with the general instructions. Name your engine up front, because index advice for PostgreSQL and SQL Server pulls in different directions.
What it helps with
- read an execution plan for a slow query
- find and fix N+1 queries in ORM code
- pick indexes for frequently filtered columns
- plan partitioning for a large table
- add a cache layer between app and database
Example prompts for the agent
- Look at the execution plan for this query and tell me what to rewrite
- This Django ORM code has an N+1 problem — find it and fix it
- Which indexes should I add to the orders table for date and status filters?
How to install database-optimizer
1claude-code-templates
npx claude-code-templates@latest --skill database/database-optimizer2Skills CLI (Vercel)
npx skills add davila7/claude-code-templates --skill database-optimizer -a claude-code3Manually: put the files in place
~/.claude/skills/database-optimizer/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/database-optimizer/
Manually: put the files in place
.agents/skills/database-optimizer/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/database-optimizer/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install davila7/claude-code-templates database-optimizer2Manually: put the files in place
.github/skills/database-optimizer/SKILL.mdPlatform CLI
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/database/database-optimizerManually: put the files in place
.devin/skills/database-optimizer/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about database-optimizer
How do I install database-optimizer in Claude?
Use the templates CLI: npx claude-code-templates@latest --skill database/database-optimizer. Alternatively run npx skills add davila7/claude-code-templates --skill database-optimizer -a claude-code. The skill file ends up at ~/.claude/skills/database-optimizer/SKILL.md.
What does database-optimizer do?
It helps you work through database performance: execution plan analysis, query rewriting, index selection, N+1 elimination, caching, partitioning and sharding.
Which databases does it cover?
PostgreSQL, MySQL, SQL Server, Oracle, MongoDB, DynamoDB, plus cloud options such as RDS, Aurora, Azure SQL and Cloud SQL. Mention your engine in the prompt.
Similar skills
All skills for Data and databases →database-optimizer by other authors comes first.