Claude Code dropped my database table. Here is how to stop the next one.

First, get it back

  1. Stop the agent and anything writing to the database.
  2. Restore from your provider's point-in-time recovery or latest backup (Postgres, Supabase, RDS and Neon all offer one).
  3. Give the agent a read-only or staging connection string from now on.

Then stop the next one

A line in CLAUDE.md is a request the model can forget. A PreToolUse hook runs before every command and can refuse it. This is what ThumbGate's hook answers when the agent tries psql "$DATABASE_URL" -c "DROP TABLE users;" (default install, recorded Dec 2, 2026, reasoning lines cut):

{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "[GATE:db-drop-table-production] DROP TABLE on a non-test table is blocked. Use a migration with a rollback path or confirm this is against a test/staging database."}}

DROP TABLE on a table that is not named like a test, temp or staging table is Denied on a default install, the first time. A production migration your agent ran (for example node scripts/migrate.js --env prod) can be thumbed down once and is Denied the next time, with your reason.

One command, free

Adds the hook to Claude Code. No account; the checks run on your machine.

$ npx thumbgate init --agent claude --ref dropped-my-database

What it does not catch

SQL that does the same damage in other words (TRUNCATE, a DELETE with no WHERE) is only caught once you thumb it down. ThumbGate checks the command the agent sends, not what your ORM runs inside it.

Free keeps 3 learned rules active. Pro keeps all of them.