sql-query-reviewer
Skill48 starsChanged 17 days agoMITView on GitHub
Reviews SQL queries for correctness, performance and safety problems such as SELECT star, missing indexes, unbounded updates, implicit casts and injection risks. Use when the user asks to optimize a query, explain why a query is slow, or check SQL before it runs on production data.
In this repository15 other files it gives its agents.
- api-endpoint-testerSkill
- changelog-generatorSkill
- commit-message-writerSkill
- csv-profilerSkill
- dockerfile-linterSkill
- env-file-auditorSkill
- json-diffSkill
- log-analyzerSkill
- meeting-notes-to-actionsSkill
- pr-description-writerSkill
- python-code-smellsSkill
- readme-doctorSkill
- secure-code-reviewSkill
- skill-authorSkill
- todo-extractorSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
If performance is the question and no EXPLAIN output was given, ask for it and say what to look for (sequential scans, row estimates far …
- Distinctive: line 59
If the schema is unknown, say which assumptions the review makes about indexes and types.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL query reviewer
When to use
- A query is slow or times out.
- The user is about to run an
UPDATEorDELETEon real data. - SQL is built from user input in application code.
Checklist
Safety first
UPDATEorDELETEwithout aWHEREclause. Ask for confirmation and suggest running aSELECT COUNT(*)with the same condition first.- Wrap destructive statements in a transaction and show how to roll back.
- String concatenation of user input into SQL. Replace it with bound parameters.
Correctness
NULLcomparisons written with=instead ofIS NULL.LEFT JOINfollowed by aWHEREcondition on the right table, which silently turns it into an inner join.GROUP BYthat does not match the selected columns, andCOUNT(column)used whereCOUNT(*)was meant.NOT INwith a subquery that can returnNULL. PreferNOT EXISTS.
Performance
SELECT *on wide tables. List the columns that are used.- Functions on indexed columns in
WHERE(WHERE LOWER(email) = ...). Suggest an expression index or a different predicate. - Leading wildcards (
LIKE '%term') that cannot use an index. - Missing indexes on join and filter columns. Ask for
EXPLAINoutput instead of guessing. OFFSETpagination on large tables. Suggest keyset pagination.ORDER BYwithoutLIMITon large results, andDISTINCTused to hide a bad join.
Steps
- Identify the database engine. Advice differs between PostgreSQL, MySQL, SQLite and SQL Server.
- Go through the checklist and list only real findings, most serious first.
- Show the rewritten query next to each finding.
- If performance is the question and no
EXPLAINoutput was given, ask for it and say what to look for (sequential scans, row estimates far from actual rows).
Example
Input: DELETE FROM sessions WHERE created_at < now() - interval '30 days'
Review: valid, but deletes an unknown number of rows. Run SELECT COUNT(*) with the same condition first, delete
in batches if the count is large, and keep it inside a transaction until the result looks right.
Errors
If the schema is unknown, say which assumptions the review makes about indexes and types.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

