How to Configure Gemini CLI Supabase Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up gemini cli supabase prevent delete rules, create a dedicated Postgres role without delete rights. Then give that restricted role to the terminal agent instead of your admin login. Many teams start by handing the default Postgres admin password to their coding agent. That admin role holds broad power across every table in the project. If the AI misreads a prompt, it can drop tables or wipe production rows in seconds. Scoping database rights before the agent runs is the safest way to pro

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To set up gemini cli supabase prevent delete rules, create a dedicated Postgres role without delete rights. Then give that restricted role to the terminal agent instead of your admin login. Many teams start by handing the default Postgres admin password to their coding agent. That admin role holds broad power across every table in the project. If the AI misreads a prompt, it can drop tables or wipe production rows in seconds. Scoping database rights before the agent runs is the safest way to protect live data.

How gemini cli supabase prevent delete roles work

Every Supabase project comes with a default Postgres role that holds admin rights. Supabase does not grant full superuser status to this role to stop dangerous system changes. Still, this default role can remove rows and drop tables across your schemas. Supabase docs advise that you never share this main password with an external tool. Instead, you should make a fresh database user for each tool or service.

Gemini CLI runs commands and database tools directly from your local shell. When the agent connects to your database, it uses the credentials in your shell. To stop row removal, an admin creates a custom Postgres role for the agent. You grant this role the right to read tables and insert or update rows. You leave out the delete privilege and block table drop rights on all schemas. When the agent sends a delete statement, Postgres blocks the command right away. You can also turn on Row Level Security to restrict which rows a role can touch. Combining table grants with row policies keeps your agent inside clear boundaries.

What native database roles solve and what they miss

Native Postgres roles are great at enforcing static rules at login time. They decide who can log in and which tables that user can read or change. If you revoke delete rights on a table, the database blocks every delete query from that user. This setup stops an AI agent from wiping a table by mistake.

Still, static roles have blind spots during live sessions. A role cannot tell the difference between a safe update and a bad one. For example, an agent with update rights can still overwrite every email or phone number with blank text. That action ruins your data without ever using a delete command. Also, managing dozens of tiny Postgres roles for different tasks takes a lot of manual work. Teams often give up and grant broad rights again just to finish a task. Static roles also do not mask sensitive fields like card numbers or national IDs in query results. If a table has private data, a basic read grant sends all of it back to the agent. Database roles decide who gets in, not what each query does in flight.

End-to-End Encryption + CLI Authentication Patterns: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why human review matters for terminal agents

AI terminal tools work fast and often chain several steps together. When an agent hits a permission error, it may try another path to finish the job. It might try to truncate a table, alter a column, or overwrite rows with null values. Relying only on local terminal prompts puts a heavy burden on the developer. Engineers get tired of reading long SQL queries in a small terminal window. One quick keystroke can approve a query that ruins thousands of customer records.

Teams need a clear way to inspect and control statements before they hit the database. Separating read tasks from write tasks helps teams move fast without risking live tables. When an agent needs to run a risky change, a peer should approve that single statement. Meanwhile, routine read queries can run right away with masking rewriting emails and card numbers in results.

Add query and result controls beside Postgres

Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.

When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.

Frequently asked questions

Can the default Supabase Postgres role be used safely with Gemini CLI?

No, the default Postgres role has full admin rights and can wipe data. You should always create a separate role with limited grants for any AI tool.

Does Row Level Security stop an agent from dropping a table?

No, Row Level Security only filters which rows a user can see or change. To stop table drops, you must revoke schema ownership and DDL rights from the role.

How can I let Gemini CLI fix data without giving it delete rights?

Grant the agent role only select, insert, and update privileges on the target tables. For rare cases where a row must go, require a human approval step for that single command.

The query runs. The emails stay hidden.