sql-pro · davila7 — Claude Code skill: SQL tuning and query plans
A skill that turns the agent into a SQL specialist: writes tricky queries, reads execution plans, picks indexes. Useful when a query is slow and the reason is not obvious.
npx claude-code-templates@latest --skill database/sql-proWhat sql-pro does
The skill frames the agent as a database expert. It walks the schema, statistics and access paths first, then rewrites the query and checks the result with EXPLAIN. Window functions, recursive CTEs, JSON handling and partitioning each get their own coverage.
The workflow is spelled out in four steps: pin down goals and constraints, inspect schema and statistics, optimize and validate against the plan, then confirm correctness under load. A safety section sits alongside it. Heavy queries against production without safeguards are called out, and read replicas or LIMIT are the suggested route for exploratory work.
Three cases fall outside its scope: you only want ORM-level advice, the store is not SQL or is document-only, or you have no access to query plans and schema details. That last one matters most. Without plans the whole exercise turns into guesswork, so check that you can pull them before installing.
What it helps with
- read an execution plan and locate the bottleneck
- rewrite a slow analytical query
- choose indexes that match real access patterns
- design a schema for OLTP or OLAP workloads
- validate a query against realistic data volumes
Example prompts for the agent
- Look at this query plan and tell me what is slowing it down
- Rewrite this query using window functions instead of the self-join
- Suggest indexes for this schema and explain the trade-offs
How to install sql-pro
1claude-code-templates
npx claude-code-templates@latest --skill database/sql-pro2Skills CLI (Vercel)
npx skills add davila7/claude-code-templates --skill sql-pro -a claude-code3Manually: put the files in place
~/.claude/skills/sql-pro/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/sql-pro/
Manually: put the files in place
.agents/skills/sql-pro/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/sql-pro/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install davila7/claude-code-templates sql-pro2Manually: put the files in place
.github/skills/sql-pro/SKILL.mdPlatform CLI
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/database/sql-proManually: put the files in place
.devin/skills/sql-pro/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 sql-pro
How do I install sql-pro in Claude Code?
Use the templates CLI: npx claude-code-templates@latest --skill database/sql-pro. Or install through the skills CLI: npx skills add davila7/claude-code-templates --skill sql-pro -a claude-code.
What does sql-pro do?
It helps write and tune SQL: inspects schema and statistics, rewrites queries, validates them with EXPLAIN and picks indexes. Data modeling for OLTP and OLAP is covered too.
When is sql-pro the wrong tool?
When you only need ORM-level guidance, when the system is not SQL or is document-only, or when query plans and schema details are out of reach.
Similar skills
All skills for Data and databases →sql-pro by other authors comes first.