# SQL Pre-flight Review

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

SQL Pre-flight Review is a free AI agent skill on Agensi by SongRenShuo, in Data & Databases. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [SongRenShuo](https://www.agensi.io/creators/songrenshuo)
- Category: [Data & Databases](https://www.agensi.io/skills/data-databases)
- Version: 1.0
- Last updated: 2026-11-24
- Security: scan passed (2026-11-24); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/sql-pre-flight-review
- Tags: api, sql, database, code-review, postgres, mysql

## 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 this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the SQL Pre-flight Review skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill differ from simply asking a standard LLM to review my SQL?

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.

### Which SQL dialects and database tools is this skill compatible with?

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.

### Does this skill need direct access to my production database to function?

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.

### What kind of recovery or rollback assistance does the agent provide?

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.'

### Can I use this for large batch migration scripts or only for single-line queries?

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.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
