SQL query explainer
Explains what a SQL query does in plain language, step by step, and flags performance and correctness risks. Use when the user pastes a SQL query and asks what it does, why it is slow, or whether it is correct.
Save these files in a folder named sql-query-explainer, then add that folder to your agent's skills.
SKILL.md
md
--- name: sql-query-explainer description: "Explains what a SQL query does in plain language, step by step, and flags performance and correctness risks. Use when the user pastes a SQL query and asks what it does, why it is slow, or whether it is correct." --- # SQL query explainer ## Steps 1. State in one sentence what the query returns, in business terms. 2. Walk through it in execution order: FROM/JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. 3. For each join, say the join type and what happens to rows without a match. 4. Flag risks: - joins that can multiply rows (fan-out) before an aggregate - `NULL` handling in `WHERE`, `NOT IN` and outer joins - functions on indexed columns in `WHERE` that prevent index use - `SELECT *`, missing `LIMIT` on large tables, implicit type casts 5. If asked to optimize, propose one rewritten query and explain what changed. Ask for the dialect (PostgreSQL, MySQL, BigQuery…) when syntax differs. ## Rules - Do not claim performance numbers without an `EXPLAIN` plan; suggest running one. - Keep identifiers exactly as written.