# sql-pro

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.

- skill · `type=skill` · Claude Code · 281 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/database/sql-pro
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/sql-pro

## What it 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.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill database/sql-pro
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill sql-pro -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/sql-pro/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/sql-pro/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/sql-pro/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/sql-pro/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates sql-pro
```

2. **Manually: put the files in place**
- File: `.github/skills/sql-pro/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/database/sql-pro
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/sql-pro/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/database/sql-pro

## When to use it
- 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
- 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

## Similar
- [sql-best-practices](https://affpapa.org/en/nevibecode/skills/sql-best-practices.md) — skill · 790 installs
- [sql-optimization-patterns](https://affpapa.org/en/nevibecode/skills/sql-optimization-patterns.md) — skill · 19717 installs
- [sql-query-optimization](https://affpapa.org/en/nevibecode/skills/sql-query-optimization.md) — skill · 520 installs
- [mysql-best-practices](https://affpapa.org/en/nevibecode/skills/mysql-best-practices.md) — skill · 2700 installs
- [database-query-optimization](https://affpapa.org/en/nevibecode/skills/database-query-optimization.md) — skill · 586 installs
- [mongodb-query-optimizer](https://affpapa.org/en/nevibecode/skills/mongodb-query-optimizer.md) — skill · 7100 installs

## Other versions with the same name
- [sql-pro · jeffallan](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-sql-pro.md) — 6400 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 495 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
