- Home
- Skills
- Data & Databases
- SQL Query Clinic — Find Slow and Risky SQL Before It Runs
More screenshots
Works with the AI Agents you already use
SQL Query Clinic — Find Slow and Risky SQL Before It Runs
Send a .sql file and get back a list of slow, risky and broken queries with line numbers and cures, plus the SQLite query plan with every table scan marked.
$5
SQL Query Clinic — Find Slow and Risky SQL Before It Runs
Example session with this skill installed
Lint examples/queries.sql with SQL Query Clinic and show only the high-severity findings.
- Read your context and instructions
- Compiled the sql query clinic
Summary
4 high-severity findings in 10 statements (high 4, medium 0, low 0).
$ python3 scripts/sql_query_clinic.py lint examples/queries.sql --min-severity high
examples/queries.sql:3: high SQC001 LIKE pattern is 51 bytes, over the limit of 50
SELECT id, name FROM customers WHERE email LIKE 'projects/quarterly...
fix: Some engines (Cloudflare D1: 50 bytes) reject long LIKE/GLOB patterns. Use substr(col, 1, N) = 'prefix' or instr(col, 'text') > 0. (auto-fixable)
examples/queries.sql:9: high SQC003 UPDATE has no WHERE clause
UPDATE orders SET status = 'void'
fix: Every row is changed. Add a WHERE clause, or write WHERE 1 to show it is on purpose.
examples/queries.sql:12: high SQC004 DELETE has no WHERE clause
DELETE FROM events
fix: Every row is deleted. Add a WHERE clause, or write WHERE 1 to show it is on purpose.
examples/queries.sql:15: high SQC006 value looks pasted into the SQL: '{status}'
SELECT * FROM orders WHERE status = '{status}'
fix: Pass values as bound parameters (?, :name), never by string concatenation or formatting. That is how SQL injection happens.
4 findings in 10 statements (high 4, medium 0, low 0)
Next steps
- Run
planwith your schema to see which queries scan the whole table. - Run
fixto rewrite long LIKE patterns and= NULLautomatically.
Connects securely to your tools. The creator never sees your data.
About this skill
Send SQL, get back what is wrong with it. Most SQL problems are not syntax errors: a LIKE pattern one byte too long for your managed database, an UPDATE with no WHERE, a NOT IN that quietly returns nothing, a filter that reads every row. SQL Query Clinic finds them in the text, then shows the query plan to prove which queries scan the whole table.
What it does
- 10 lint rules with line numbers, severity and a one-line cure: long LIKE/GLOB patterns, leading wildcards, UPDATE/DELETE without WHERE,
SELECT *, values pasted into SQL, NOT IN with NULL,= NULL, functions around columns, LIMIT without ORDER BY - Reads the query plan from an in-memory SQLite built from your schema, and labels each step
table-scan,index-scan,searchortemp-sort - Builds each suggested index in memory, plans again, and reports
scan goneorscan stays, so you do not get an index that does nothing fixrewrites long LIKE patterns (substr,instr,=) and= NULL(IS NULL), keeps your comments, and lists every change- Text, Markdown or JSON output; exit codes for CI (0 clean, 1 findings, 2 unreadable, 3 invalid SQL)
- The 50-byte LIKE limit is a setting:
--max-pattern-bytes
Honest limits
The rules read text and do not know your data; plans come from SQLite on an empty database, so another engine may differ; substr/instr rewrites are case-sensitive while LIKE is not.
What is inside
SKILL.md, README.md, LICENSE, scripts/sql_query_clinic.py, tests/test_clinic.py (62 tests), and examples/ with a schema, sample queries and saved outputs.
Requirements and safety
Python 3.9+ (tested on macOS with Python 3.9 and 3.10), macOS or Linux. Standard library only. The tool makes no network calls, needs no credentials and never opens a database file; your schema runs only in memory.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Simulates plans via in-memory SQLite only; does not reflect real data volume. Rule-based linting is text-static and may differ from specific engine behaviors like Postgres or MySQL.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
- Software
Python