safe sql

    1

    Enforce a multi-step safety protocol for SQL reads and writes to prevent data loss and schema drift.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    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

    MetricValue
    Target Tableusers
    EnvironmentProduction
    Filtered Row Count1,248
    Cascaded Deletes~4,500 rows in orders
    ActionDELETE
    Backup Tableusers_backup_20240522

    Here is a sample of the records to be deleted:

    idemaillast_logincreated_at
    502user_502@example.net2021-11-122019-04-01
    881test_account@dev.io2022-02-152020-01-10
    1042dev_null@company.com2021-08-302018-12-22

    Next steps

    1. Confirm if I should proceed with deleting these 1,248 users and their associated orders.
    2. Specify if you would like me to create the users_backup_20240522 table before execution.
    3. 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 SELECT count and sample before any UPDATE or DELETE to 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

    1. Context check identifies the target environment, connection method, and existing migration systems like Alembic or Prisma.
    2. Schema inspection fetches real metadata (types, keys, nullability) rather than guessing column names.
    3. Execution preview generates a row count and example set for the user to approve.
    4. 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.

    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. 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 any payment.

    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

    Permissions

    Network Access
    Listed19 days ago

    What's inside

    Frequently Asked Questions

    Safe SQL is a procedural safety layer that enforces schema verification, impact previews, and transaction-based rollbacks to prevent accidental data loss or corruption during agent-led database operations.

    It supports PostgreSQL, MySQL, MariaDB, and SQLite, and is designed to work across various interfaces including MCP servers, CLIs, and popular ORMs like Prisma or Django.

    The skill identifies production environments and enforces a mandatory 'Execution Preview' step, requiring explicit user approval of the specific rows and counts affected before any data is modified.

    While most modifications are wrapped in transactions for safe rollback, DDL operations (like ALTER or DROP) in MySQL and MariaDB trigger implicit commits and cannot be reverted automatically.

    This skill is a logical protocol that can be integrated into any AI agent capable of using tools or calling APIs, provided the agent has the necessary database connection permissions.

    Purchase includes the core safety protocol, implementation documentation for various database environments, and updates to support new SQL flavors or migration tool integrations.

    New in Data & Databases