Library / SQL query reviewer
SQL query reviewer
Review SQL for correctness, dangerous writes, and performance pitfalls before it runs.
Install in Claude Code
Create a folder whose name matches the skill name field (sql-query-reviewer/). Save the text below as SKILL.md inside it. Personal skills go in ~/.claude/skills/sql-query-reviewer/. Project skills go in .claude/skills/sql-query-reviewer/. Claude Code discovers them from the filesystem.
Upload on claude.ai
Zip the skill folder (the zip should contain the folder, which contains SKILL.md) and upload it in Claude’s Skills settings. Anthropic’s current platform docs list custom uploads on Pro, Max, Ultra, Team, and Enterprise plans when code execution is enabled. Check the Claude Help Center for the latest plan details. Read the files before you turn a skill on.
Use with the Claude API
Custom API Skills are uploaded through the Skills API and referenced with the code execution tool. Skills do not sync automatically from Claude Code or claude.ai — install this folder again on the surface where you need it. See Anthropic’s Agent Skills overview.
--- name: sql-query-reviewer description: Reviews SQL for correctness, unsafe writes, permission assumptions, and common performance issues, then suggests a safer rewrite when needed. Use when the user pastes a query, asks for a SQL review, or wants help improving or debugging a statement. --- # SQL query reviewer ## Goal Catch queries that are wrong, dangerous, or unnecessarily expensive. Explain the issue in plain language, then offer a rewritten statement when you have enough schema context. ## Review checklist 1. **Intent.** Restate what the query is trying to return or change. 2. **Safety.** Flag unrestricted `DELETE`, `UPDATE`, `DROP`, `TRUNCATE`, `ALTER`, and `GRANT`. Require a `WHERE` clause, a preview `SELECT`, and a transaction when the dialect allows it. 3. **Correctness.** Look at join keys, grain (row duplication), `NULL` behavior, `NOT IN` with nulls, filter placement (`WHERE` vs `HAVING`), and timezone or type conversions. 4. **Permissions and data exposure.** Warn if the query selects columns that look like secrets, personal data, or production dumps without a need. 5. **Performance.** Note missing join predicates, `SELECT *` on wide tables, functions on indexed columns, and `OR` patterns that prevent index use. Do not invent indexes that you have not seen. 6. **Injection.** If the query is built with string concatenation, show a parameterized alternative. ## Output format ```markdown ## What this query does ## Risk level Low / Medium / High — [why] ## Findings - ## Suggested rewrite [Only if schema and dialect are clear enough. Otherwise list what you need.] ## Questions - ``` ## Rules - If dialect is unknown (Postgres, MySQL, BigQuery, Snowflake, Spark SQL), say which syntax you assumed. - Never tell the user to run a destructive query to "see what happens". - Do not invent table or column names. If schema is missing, ask for `CREATE TABLE` or a sample row. - Prefer standard SQL first, then dialect-specific features.
You may copy and adapt this free skill for personal or commercial use. If you republish it, please credit Skillory with a link. Audit any skill — including this one — before enabling it in an environment with access to private data.
Related skills
Changelog writer
Turn commits and merged PRs into a readable changelog grouped the way users scan it.
Open skill →Code review
Review a diff like a careful teammate: correctness first, then security, then clarity.
Open skill →Git commit messages
Write conventional commit messages from a staged diff, without fluff or invented ticket IDs.
Open skill →