- Home
- Skills
- Data & Databases
- SQL Pre-flight Review
SQL Pre-flight Review
by SongRenShuo
Reviews UPDATE/DELETE/INSERT before execution: blast radius, performance smells, and a rollback plan with a COUNT pre-check.
Free
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
ORwith 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
- Fix the
department_id = department_idtautology. - Run the provided
COUNT(*)pre-check. - Verify if a specific Primary Key list can be used for a
COMPLETErollback 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, andQUERYtypes to prevent hidden write commands in long scripts. - Audits blast radius by scanning for missing
WHEREclauses, tautologies like1=1, or wildcardLIKEpatterns that impact entire tables. - Detects performance smells including non-sargable functions,
SELECT *on wide tables, and excessiveINlists. - Generates rollback plans by providing exact
REVERTstatements and pre-executionCOUNT(*)checks. - Identifies NULL hazards to catch incorrect
=or<>comparisons that fail on nullable columns.
How it works
- Input Analysis: The agent splits multi-statement scripts and classifies each command by target table and operation type.
- Safety Audit: It runs the six-point blast radius check to flag high-risk predicates as errors or warnings.
- Performance Review: It scans for index-blocking functions or unindexed sorting that could cause locking or latency.
- 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
UPDATEorDELETEstatements before running them in production. - Auditing migration scripts for hidden
DROPorTRUNCATEcommands. - 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
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 11 days ago
- Free with an Agensi account
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
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.