- Home
- Skills
- Data & Databases
- safe sql
safe sql
Enforce a multi-step safety protocol for SQL reads and writes to prevent data loss and schema drift.
$12
Works with the AI Agents you already use
safe sql
Example session with this skill installed
Delete all users who haven't logged in for over two years. The database is production.
- Read your context and instructions
- Compiled the safe sql
I have established a connection to the production PostgreSQL database. Before proceeding, I inspected the users table schema and identified a foreign key constraint on orders.user_id with ON DELETE CASCADE.
I ran a preview query to determine the scope of this request:
SELECT count(*) FROM users WHERE last_login < NOW() - INTERVAL '2 years';
Database Impact Preview
| Metric | Value |
|---|---|
| Target Table | users |
| Environment | Production |
| Filtered Row Count | 1,248 |
| Cascaded Deletes | ~4,500 rows in orders |
| Action | DELETE |
| Backup Table | users_backup_20240522 |
Here is a sample of the records to be deleted:
| id | last_login | created_at | |
|---|---|---|---|
| 502 | user_502@example.net | 2021-11-12 | 2019-04-01 |
| 881 | test_account@dev.io | 2022-02-15 | 2020-01-10 |
| 1042 | dev_null@company.com | 2021-08-30 | 2018-12-22 |
Next steps
- Confirm if I should proceed with deleting these 1,248 users and their associated orders.
- Specify if you would like me to create the
users_backup_20240522table before execution. - I will wrap the final operation in a transaction and report the final engine count.
Connects securely to your tools. The creator never sees your data.
About this skill
Protect your data from accidental loss or corruption during database operations. This skill provides a strict safety protocol for agents interacting with PostgreSQL, MySQL, MariaDB, and SQLite databases via MCP tools, CLIs, drivers, or ORMs. It bridges the gap between authorized access and human error by ensuring every change is previewed, quantified, and explicitly confirmed.
What it does
- Schema discovery verifies actual table and column names before execution to prevent errors or target mismatches.
- Query previewing runs a
SELECTcount and sample before anyUPDATEorDELETEto confirm the impact scope. - Safe writing wraps all modifications in transactions with automated rollbacks if the affected row count deviates from the preview.
- Value binding enforces the use of placeholders for all query parameters to prevent SQL injection and formatting bugs.
- Environment awareness identifies production environments and enforces higher consent standards for any write operation.
How it works
- Context check identifies the target environment, connection method, and existing migration systems like Alembic or Prisma.
- Schema inspection fetches real metadata (types, keys, nullability) rather than guessing column names.
- Execution preview generates a row count and example set for the user to approve.
- Transaction management executes the write and verifies the engine's reported impact before committing.
Frameworks & tools
Supports PostgreSQL, MySQL, MariaDB, and SQLite. Compatible with migration tools like Alembic, Django, Rails, Prisma, and Knex. Works through MCP servers, drivers, or standard CLIs.
Why this beats prompting it yourself
Manual prompts often forget to check foreign key cascades or verify row counts before hitting production. This skill encodes a disciplined sequence that prevents silent failures and "zero-row success" reports that hide logic errors.
Use cases
- Data cleanup safely removes test records while accounting for cascaded deletes.
- Schema migrations ensures DDL changes align with existing project migration files.
- Bulk updates modifies large datasets using primary key batching to avoid table locking.
- Production hotfixes applies urgent data corrections with mandatory backups and explicit consent.
Known limitations
MySQL and MariaDB DDL operations (CREATE, ALTER, DROP) trigger implicit commits and cannot be rolled back. Ad-hoc DDL is discouraged in projects using migration managers.
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.
MySQL/MariaDB DDL cannot be rolled back. Large changes require manual primary key batching. Ad-hoc DDL is restricted in projects with migration systems.
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
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago