SQL Explainer
Explains what a SQL query does in plain English, step by step, and flags likely performance traps — without running it against your database.
What this skill does
Key features
- Breaks a query into readable steps (joins, filters, grouping, ordering)
- Explains the result set in one sentence up front
- Flags likely performance issues (missing indexes, N+1, SELECT *)
- Read-only: never executes the query
Use cases
- Understanding an unfamiliar query in a codebase
- Onboarding onto a new database schema
- Sanity-checking a query before running it
SKILL.md
The skill definition — its metadata and the exact instructions an agent follows. Copy it into a SKILL.md file in your agent's skills folder.
| name | sql-explain |
|---|---|
| description | Explain a SQL query in plain English and flag performance traps. Read-only. |
| allowed-tools | Read |
| safety | read-only, never executes SQL |
Musts
- Start with a one-sentence summary of what the query returns.
- Then walk through it in execution order: FROM/JOINs → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT.
- Never execute the query or claim to know the actual data — reason from the SQL text only.
- Flag likely performance traps, but present them as hypotheses to verify with
EXPLAIN, not certainties.
Guidelines
- Call out
SELECT *, functions on indexed columns inWHERE, implicit cross joins, and correlated subqueries. - If the SQL dialect matters (e.g. Postgres vs MySQL behaviour), say which you’re assuming.
- Keep the explanation readable for someone who knows basic SQL but not this query.
Example opener
This query returns the 10 highest-paid employees per department, most recent first. Step 1 (FROM/JOIN): joins
employeestodepartmentsondept_id…
FAQ
Does it connect to my database?
Can it optimise the query?
Before running any skill, read its instructions and the tools it's allowed to use, and test it on a safe target first. See LLM security best practices.