- Home
- Skills
- Data & Databases
- SQL Query Smell Detector
SQL Query Smell Detector
Audit your SQL for destructive statements, cartesian joins, index killers, and unbounded scans — and get a ranked findings table with a concrete fix for every finding.
Free
Works with the AI Agents you already use
SQL Query Smell Detector
Example session with this skill installed
8 fictional SQL queries against orders/customers/products tables (JSON or .sql file).
- Read your context and instructions
- Compiled the sql query smell
8 queries audited, 7 with findings, 11 total findings (2 High, 8 Medium, 1 Low). High: DELETE FROM products with no WHERE; SELECT * with CROSS JOIN over 1.2M rows. Clean: one point-lookup query.
Connects securely to your tools. The creator never sees your data.
About this skill
SQL Query Smell Detector — Free
Short description
A DELETE with no WHERE deletes every row. Audit your SQL for destructive statements, cartesian joins, index killers, and unbounded scans — and get a ranked findings table with a concrete fix for every finding. Free, runs in minutes, and it never executes SQL.
Before / after — the verified sample
Before — the smelly input (fictional US e-commerce queries):
DELETE FROM products; -- no WHERE
SELECT * FROM orders CROSS JOIN customers; -- cartesian + SELECT *
SELECT * FROM orders; -- no LIMIT, 1.2M rows
SELECT order_id, total_amount FROM orders
WHERE YEAR(order_date) = 2026; -- function on indexed column
After — the real dry run on 8 fictional queries (2026-11-30): 8 audited, 11 findings — 2 High, 8 Medium, 1 Low. High findings: a DELETE with no WHERE, and a CROSS JOIN of a 1.2M-row orders table with customers. Clean query: Recent order for one customer. Validator: 0 errors. Sample data is fictional and labelled as such.
What it catches
Four failure modes keep showing up in SQL codebases, and all four are cheap to fix once found — expensive to debug in production:
- Destructive statements — an
UPDATEorDELETEwith noWHEREtouches every row in the table. The most expensive single line in most codebases. - Cartesian products — a
CROSS JOIN, or a comma join whose condition was forgotten, pairs every row with every row. On a 1.2M-row orders table joined to 250k customers, that is 300 billion rows. - Index killers —
YEAR(order_date) = 2026oremail = ? OR phone = ?stops the planner from using the index you already built, so it scans the whole table instead. - Wasteful reads —
SELECT *with noLIMITon a large table fetches every column of every row, including columns nobody asked for. PlusSELECT DISTINCTused as a band-aid over duplicate rows from a bad join.
How it works
Script-first, stdlib-only, no database connection, no credentials:
- Collect — supply a JSON file of queries (
name,sql, plustable,row_count,contextwhere known), or a plain.sqlfile with one statement per query. Or run the included sample. - Run the audit —
scripts/main_pipeline.pyruns deterministic static checks and emits the ranked report as Markdown and JSON. - Validate —
scripts/validate_output.pychecks the output (schema, ranked order, non-empty findings, consistent counts) and must report 0 errors before the report is delivered. - Present — the ranked table, High first, one fix per finding, and the clean queries listed separately, so you know what passed as well as what failed.
No query text leaves your machine. No SQL is ever executed — destructive statements are flagged as text, never run.
What's included
SKILL.md— gated multi-stage workflow with[ASSUMPTION]disciplinescripts/main_pipeline.py— the audit (Python 3, stdlib only, CLI)scripts/validate_output.py— the output validator (CLI)references/decision_matrix.md— senior heuristics for SQL patternsreferences/failure_modes.md— common traps and recoverytemplates/output_template.md— findings report scaffoldsample_data/sample_input.json+sample_data/expected_output.md— fictional sample and its verified outputREADME.md,CHANGELOG.md,LICENSE(MIT)
Who it's for
Anyone who writes or reviews SQL: developers checking queries before a release, analysts debugging a slow report or a wrong row count, teams doing a code review of a migration. Works with any agent that can run Python and read files — Claude Code, Codex CLI, Gemini CLI, Cursor, OpenClaw.
Limits — read before you use it
- Static text checks only. They catch common shapes, not every slow query. Confirm slow patterns with
EXPLAIN/EXPLAIN ANALYZEbefore rewriting a production query. - Row counts come from the input file; if the input row count is wrong, the large-scan severity is wrong.
- Dialect-agnostic by design (standard SQL shapes); dialect-specific functions outside the checked list are not flagged.
- No live database connection, no SQL execution, no credentials required.
- Sample data is fictional. No customer results are claimed.
Creator
Tags
sql, database, performance, data-quality, developer-tools
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.
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
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed today
- Free with an Agensi account
- Software
Python 3.8+