SQL Migration Preflight
by Prateek
Reviews a SQL migration for data loss, table locks and failed deploys, with the safe rewrite for every risky statement.
Free
What it does
- Flags DROP, TRUNCATE and unscoped DELETE or UPDATE
- Catches NOT NULL columns and type changes that fail on existing rows
- Warns about index and foreign-key locks on large tables
- Gives an expand-migrate-contract deploy order
Who it's for
Software engineers and developers
Catch database errors before they crash your production site.
Try asking: “Review this migration: ALTER TABLE users ADD COLUMN phone_number VARCHAR(255) NOT NULL;”
Tech leads and senior engineers
Ensure your team never pushes a migration that locks the main database table.
Try asking: “Review the SQL file in migrations/0042_add_status.sql for safety.”
Startup founders building their own tech
Prevent data loss and downtime by checking your database changes first.
Try asking: “Is it safe to run this SQL? DROP COLUMN age FROM customers;”
SQL Migration Preflight
Example session with this skill installed
Please review this SQL migration: ALTER TABLE orders ADD COLUMN secret_code INTEGER NOT NULL; ALTER TABLE users DROP COLUMN temporary_token;
- Read your context and instructions
- Compiled the sql migration preflight
I have reviewed your SQL migration. There are critical issues that could cause data loss and deployment failure.
Verdict: BLOCK (2 High/Critical findings)
| Line | Severity | Statement | Why it matters | Safe Alternative |
|---|---|---|---|---|
| 1 | High | ADD COLUMN ... NOT NULL | This will fail if the table already has rows because they have no value for this column. | Add the column as nullable first, fill the data, then set to NOT NULL. |
| 2 | Critical | DROP COLUMN ... | This is permanent data loss. The column and all its data will be deleted immediately. | Only run this after you are certain the data is no longer needed and backed up. |
Deploy Order
Since you are dropping a column, you should follow these steps to avoid breaking your app:
- Expand: Deploy code that no longer uses the
temporary_tokencolumn. - Migrate: Run a migration to mark the column as nullable or unused.
- Contract: Once the new code is stable, run the
DROP COLUMNcommand.
Rollback
- Reversibility: This migration is irreversible.
- Data Loss: If you roll back, the data in
temporary_tokencannot be recovered because it was deleted.
Would you like me to help you write the safe version of the first statement?
Connects securely to your tools. The creator never sees your data.
About this skill
When you change a database, one wrong line can delete all your user data or freeze your website for hours. This skill acts like a senior database expert that reads your SQL code before you run it. It looks for hidden traps that typical testing misses, like statements that lock tables or changes that cannot be undone.
How it works
- You provide a SQL file path or paste the raw SQL code into the chat.
- Your AI agent runs a specialized check on the code to find dangerous patterns.
- You receive a clear report showing which lines are safe and which are risky.
- For every high-risk problem, you get a rewritten version of the code that is safe to use.
Frameworks & tools
This skill uses a Python script to scan SQL files for patterns like table drops, locks, and index creation.
Why this beats prompting it yourself
A standard AI often misses specific database locking behaviors or the exact steps needed for zero-downtime deploys. This skill uses a strict, pattern-based script to ensure no dangerous command is overlooked, and it forces a specific "expand and contract" plan for breaking changes that general prompts usually forget.
Use cases
- Reviewing a migration script before it goes to production
- Finding commands that will freeze a large database table
- Checking if a database change can be safely rolled back
- Planning a column rename without breaking your running app
Known limitations
This skill cannot see how many rows are in your actual database or check for replication lag. It treats all tables as potentially large and risky.
Built to review SQL migrations by running a bundled Python script (review_sql.py) against .sql files. The script uses pattern matching to identify risky statements (DROP, TRUNCATE, ALTER TYPE, etc.) and returns specific severity levels. It generates a structured report including a verdict (BLOCK/REVIEW/SAFE), a findings table, and a three-step deploy plan (expand/migrate/contract) for breaking schema changes. Suitable for integration into CI/CD workflows or manual PR reviews via an AI agent.
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 1 day ago
- Free with an Agensi account
- Software
Python 3.9+
Permissions
File Scopes
Read-only. The migration is never executed.
What's inside
Frequently Asked Questions
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.