← Vibe coding database safety

Make your AI coding agent ask before it touches the database

Updated · DBShifts · commands tested on real PostgreSQL, MySQL and MongoDB servers

Short answer

Every major coding agent can run terminal commands, and the commands that wipe a database are short: prisma migrate reset, prisma db push, drizzle-kit push, rails db:reset, dropdb, a psql with a DROP in it. Keep automatic execution off where a real database is reachable, deny the destructive commands outright, and treat every migration the agent writes as something you read and approve.

Key facts

  • prisma migrate reset drops the database (or schema), recreates it and re-applies every migration. All data in it is lost.
  • prisma db push and drizzle-kit push change the database to match your schema file directly, without a migration file to review.
  • rails db:reset drops and recreates the database, then loads the schema and seeds.
  • Command rules in an AI tool match the command text. An agent can still reach the database another way, for example a script it writes, so the database account's permissions matter more than any rule.

Claude Code

Claude Code reads permission rules from .claude/settings.json in your project: deny rules block a command, ask rules make it stop and ask you. Rules match the start of the command.

JSONClaude Code: .claude/settings.json in your project
{
  "permissions": {
    "deny": [
      "Bash(npx prisma migrate reset:*)",
      "Bash(npx prisma db push:*)",
      "Bash(npx drizzle-kit push:*)",
      "Bash(rails db:reset:*)",
      "Bash(dropdb:*)"
    ],
    "ask": [
      "Bash(psql:*)",
      "Bash(mysql:*)",
      "Bash(npx prisma migrate:*)"
    ]
  }
}

Cursor

In Cursor's agent settings, the auto-run option decides whether the agent runs terminal commands without asking. Keep it off in projects that can reach a real database, or keep an allowlist that contains no database commands.

GitHub Copilot (agent mode)

Copilot's agent mode in VS Code asks before it runs a terminal command unless you turn auto-approval on. Leave auto-approval off in workspaces with a production connection.

Windsurf

Cascade's auto-execution setting runs from off to fully automatic, with allow and deny lists. Put the database commands above on the deny list.

Replit, Lovable and Bolt

App builders that host the database for you write migrations and schema changes on your behalf. Use separate development and production databases where the platform offers them (Replit has since 2025), and read each generated migration before you approve it — especially DROP TABLE, DROP COLUMN, TRUNCATE and any change to row level security policies.

Whatever the tool

The rule that cannot be talked around is in the database: give the agent an account that cannot drop or delete, and production credentials it never sees.

Common mistakes

Auto-run on 'just for this session'

Sessions get long and agents get creative. The setting you turned on to save three clicks is on when it matters.

Allowing all of npx

npx prisma, npx drizzle-kit and npx anything else ride along. Allow specific commands, not the runner.

Approving without reading

A wall of approvals trains you to click yes. Keep approval for the few commands that matter so each one gets read.

Relying on the rule alone

A deny rule on psql does not stop a Node script that connects with the same URL. Fix the account, not only the command.

How DBShifts helps

  • Airlock Schema Guard checks every pull request's migrations against what your AI agents actually read, and fails the check before a rename or drop breaks them.
  • Agents that change data through Airlock propose named actions; a person approves each one, with undo.

Questions people ask

How do I stop Claude Code from running a command?

Add a deny rule to .claude/settings.json in your project, such as "Bash(npx prisma migrate reset:*)", and an ask rule for commands it may run with your approval.

What does prisma migrate reset do?

It drops the database (or the schema in some setups), creates it again and applies all migrations, so every row is lost. It is meant for development databases only.

Is Cursor's auto-run (YOLO) mode safe with a database?

Not with a database you cannot afford to lose. Keep auto-run off, or allow only commands that cannot reach the database, and give the agent a development database.

Writes from AI, approved by a person

Agents propose, you approve, every change can be undone. Free to start.

7 guides in this series. See the checklist.