AI Coding Agents and Your Live Database: How to Keep One From Wrecking the Other

Illustration of a database symbol with a shield and lock badge, for keeping an AI coding agent away from live data

An AI coding agent can change or delete the data in your live app if it holds credentials that reach the live database. The fix is about access more than the agent: give it a copy of your data to work on, keep the live database behind narrow permissions, and make sure you can restore it.

Supabase, the database many AI app builders set up for you, released version 3 of its command-line tool on November 2. Its Supabase CLI v3 announcement says that in v2 a command run without a flag could reach a production database, and it names anyone running the CLI through an AI coding agent as affected.

How can an AI coding agent reach your live database?

There are three common routes, and many apps have more than one open.

  • The command line. An AI coding agent such as Claude Code or Cursor runs commands on a developer's laptop. If that laptop is linked to the live project, the agent can push database changes to it.
  • An MCP connection. MCP (Model Context Protocol) lets an AI assistant use outside tools. Supabase's MCP server lets an assistant apply migrations (structural changes to the database) and run SQL against your project.
  • The app builder itself. Lovable changes your database structure as it builds. Its drafts share your project's data, so changes made while testing one are real.

Each one is access someone granted and nobody revisited.

What did Supabase CLI v3 change?

Supabase CLI v3 points database commands at a local copy by default and asks before any change to a hosted project. Reaching the hosted database takes a --remote flag, and the confirmation defaults to No. In automated setups, where nothing can answer a prompt, hosted changes fail unless the command includes --yes.

That is a better default, but treat it as a seatbelt rather than a lock. An AI coding agent that runs commands can type --remote --yes as easily as a person can. A deploy pipeline that installs the latest CLI without pinning a version is already on v3, so ask whoever maintains it to check.

How do you keep an AI coding agent out of production?

Give an AI coding agent its own environment and make the live database hard to reach on purpose. In order of impact:

  1. Separate development from live. Keep a second Supabase project with test data for the agent, and promote changes to live only after a person reviews them. Supabase's branching feature does a similar job on paid plans.
  2. Replace broad access tokens with scoped ones. Supabase made scoped personal access tokens generally available on October 6. You can limit a token to selected projects, grant read or read-write per area, and set an expiry of up to a year. SQL runs read-only unless the token has database read-write permission.
  3. Lock down MCP connections. Supabase's MCP security guidance recommends scoping the server to one project, turning on read-only mode and enabling only the tool groups you need. Keep manual approval of tool calls switched on. Supabase calls its destructive-SQL confirmation a guardrail, not a guarantee.
  4. Leave risky builder permissions off. Lovable refuses changes that could break a published app, such as dropping or renaming a column, unless you enable "Execute backward incompatible database migrations" in your Cloud permissions. Leave that off for live apps.

It's the principle behind our vibe coding security checklist: nothing gets more access than its job needs.

What backup do you need before an AI coding agent touches anything?

You need a backup you have restored at least once, before an outage forces you to learn how. Supabase's backup documentation sets the limits:

  • Daily backups: Pro projects keep 7 days, Team projects 14, and Enterprise up to 30. Free plan projects should export their data regularly and keep copies off site, Supabase advises.
  • Point-in-time recovery: an add-on for paid plans that restores to within seconds. Seven days of retention is listed at about $100 a month.
  • The fine print: restoring takes the project offline for a while, replaces the current data, and does not bring back files stored through Supabase Storage.

For an app that takes orders or bookings, a daily backup can still mean losing a day of customer records. Price that against $100 a month.

Frequently asked questions

Can an AI coding agent delete my production database?

Yes, if an AI coding agent holds credentials with write access to the live project. It doesn't take malice; a misread instruction or a cleanup command run in the wrong place is enough.

Is Supabase CLI v3 enough protection on its own?

No. It changes defaults for one tool. It does nothing about MCP connections, builder permissions or broad access tokens that still reach your live project.

Should I connect the Supabase MCP server to my live project?

Only when a task needs real production data, and then scoped to that project in read-only mode. For everyday building, point the AI coding agent at your development project.

How often should I test a restore?

At least once before launch and again after any big change to your plan or setup. Restore to a new project so your live data stays untouched.

Do I need a developer to set this up?

Not for most of it. Creating a second project and scoped tokens is dashboard work most owners can do. Reviewing what an AI coding agent changed before it reaches live data is where a developer earns their fee.

Give the agent a sandbox, not the keys

The agent is rarely the problem; the credentials it inherits are. This week, list every token, MCP connection and laptop that can write to your live database, and remove anything that doesn't need to. If you'd like a second pair of eyes, our Prototype to Production team reviews AI-built apps before and after launch, and a free audit is a good place to start.

Let's build something that lasts.

Tell us what you're building, and we'll show you how we'd ship it.