SQL Pre-flight Review

    by SongRenShuo

    1

    Reviews UPDATE/DELETE/INSERT before execution: blast radius, performance smells, and a rollback plan with a COUNT pre-check.

    Free

    Security scanned

    Works with the AI Agents you already use

    SQL Pre-flight Review

    Example session with this skill installed

    Review this SQL for safety: UPDATE employees SET salary = salary * 1.1 WHERE department_id = department_id OR status = 'Active';

    • Read your context and instructions
    • Compiled the sql pre-flight review

    I have analyzed the UPDATE statement. It contains a critical logic error that will result in an unbounded update of the entire table.

    SQL Pre-flight Review

    Statement: UPDATE employees SET salary = salary * 1.1 WHERE department_id = department_id OR status = 'Active';
    Type: DML · Table: employees · Rows: unbounded by key

    Blast radius

    ERROR — Tautological predicate detected: department_id = department_id. This condition is true for every row where department_id is not null. Because it is joined by an OR to the second condition, this statement will update every employee in the table regardless of their status.

    Performance

    • WARN line 1: The use of OR with a tautology forces a full table scan and massive row locking.
    • INFO line 1: No primary key or indexed unique identifier used in the predicate.

    Rollback Plan: UNABLE

    • Pre-check: SELECT COUNT(*) FROM employees WHERE department_id = department_id OR status = 'Active';
    • Snapshot: SELECT id, salary FROM employees WHERE department_id = department_id OR status = 'Active';
    • Revert: UPDATE employees SET salary = <captured_value> WHERE id IN (<captured_ids>);

    Recommendation:

    DO NOT EXECUTE. The predicate department_id = department_id nullifies the filter. Rewrite the query to use a specific department_id literal (e.g., department_id = 50) and run the COUNT(*) pre-check to verify the number of affected rows matches your expectations before proceeding.

    Next steps

    1. Fix the department_id = department_id tautology.
    2. Run the provided COUNT(*) pre-check.
    3. Verify if a specific Primary Key list can be used for a COMPLETE rollback rating.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    A single destructive SQL statement can ruin a database before an engineer realizes the WHERE clause was missing or malformed. This skill acts as a mandatory pre-flight checklist for all database write operations, identifying dangerous predicates and performance bottlenecks before they hit production.

    What it does

    • Classifies statements by identifying DML, DDL, and QUERY types to prevent hidden write commands in long scripts.
    • Audits blast radius by scanning for missing WHERE clauses, tautologies like 1=1, or wildcard LIKE patterns that impact entire tables.
    • Detects performance smells including non-sargable functions, SELECT * on wide tables, and excessive IN lists.
    • Generates rollback plans by providing exact REVERT statements and pre-execution COUNT(*) checks.
    • Identifies NULL hazards to catch incorrect = or <> comparisons that fail on nullable columns.

    How it works

    1. Input Analysis: The agent splits multi-statement scripts and classifies each command by target table and operation type.
    2. Safety Audit: It runs the six-point blast radius check to flag high-risk predicates as errors or warnings.
    3. Performance Review: It scans for index-blocking functions or unindexed sorting that could cause locking or latency.
    4. Recovery Generation: It outputs a specific pre-check, snapshot query, and rollback statement for the affected rows.

    Frameworks & tools

    Works with any SQL dialect including PostgreSQL, MySQL, SQL Server, and Oracle. It integrates directly with the MyBatis SQL Visualizer MCP if available for deterministic static analysis.

    Why this beats prompting it yourself

    Generic prompts often miss subtle logical flaws like id = id or non-sargable predicates that look safe but cause table scans. This skill follows a strict safety hierarchy that treats unparseable or ambiguous SQL as unsafe by default, forcing a fail-closed review process.

    Use cases

    • Reviewing ad-hoc UPDATE or DELETE statements before running them in production.
    • Auditing migration scripts for hidden DROP or TRUNCATE commands.
    • Generating exact rollback SQL for database hotfixes.
    • Identifying why a specific query is ignoring indexes or running slowly.

    Known limitations

    Does not connect to live databases or provide actual row counts. Static analysis only; it cannot replace an EXPLAIN plan from the engine.

    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 11 days ago

    • Free with an Agensi account

    Permissions

    No special permissions declared or detected

    Listed11 days ago

    What's inside

    Frequently Asked Questions

    This skill performs deterministic static analysis to flag hazards like missing WHERE clauses, non-sargable functions, and NULL comparison errors that basic prompts often overlook, ensuring a 'fail-closed' safety protocol.

    The skill supports all major dialects, including PostgreSQL, MySQL, SQL Server, and Oracle, and it can integrate with the MyBatis SQL Visualizer MCP for enhanced static analysis.

    No, the agent operates entirely via static analysis for maximum security; it never requires a live connection to your production database or access to sensitive row-level data.

    The agent automatically generates precise rollback statements and pre-execution COUNT checks, giving you a ready-to-use recovery plan before you ever hit 'execute.'

    The skill is designed to handle both single queries and complex multi-statement migration scripts, splitting and auditing each command individually for hidden DDL or DML risks.

    New in Data & Databases

    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.

    Free