SQL Query Smell Detector

    1

    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

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    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:

    1. Destructive statements — an UPDATE or DELETE with no WHERE touches every row in the table. The most expensive single line in most codebases.
    2. 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.
    3. Index killers — YEAR(order_date) = 2026 or email = ? OR phone = ? stops the planner from using the index you already built, so it scans the whole table instead.
    4. Wasteful reads — SELECT * with no LIMIT on a large table fetches every column of every row, including columns nobody asked for. Plus SELECT DISTINCT used as a band-aid over duplicate rows from a bad join.

    How it works

    Script-first, stdlib-only, no database connection, no credentials:

    1. Collect — supply a JSON file of queries (name, sql, plus table, row_count, context where known), or a plain .sql file with one statement per query. Or run the included sample.
    2. Run the audit — scripts/main_pipeline.py runs deterministic static checks and emits the ranked report as Markdown and JSON.
    3. Validate — scripts/validate_output.py checks the output (schema, ranked order, non-empty findings, consistent counts) and must report 0 errors before the report is delivered.
    4. 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] discipline
    • scripts/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 patterns
    • references/failure_modes.md — common traps and recovery
    • templates/output_template.md — findings report scaffold
    • sample_data/sample_input.json + sample_data/expected_output.md — fictional sample and its verified output
    • README.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 ANALYZE before 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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+

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Listedtoday

    What's inside

    Frequently Asked Questions

    Static audit for SQL queries: SELECT *, UPDATE/DELETE with no WHERE, CROSS JOINs, functions on indexed columns, unbounded scans — ranked findings with a fix each. Never executes SQL. Verified sample: 8 queries, 11 findings, including a DELETE with no WHERE and a CROSS JOIN over a 1.2M-row table.

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use SQL Query Smell Detector on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    New in Data & Databases

    Free