How to Configure Gemini CLI Supabase Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a gemini cli supabase sandbox by creating a limited database role. Then you run the AI tool inside a restricted local shell. Many teams start by giving the coding agent their default admin password. This choice lets the agent read or delete every table in the project. A wide role turns a simple prompt mistake into a big data loss. How a gemini cli supabase sandbox works Every Supabase project starts with a default postgres role. This role has admin rights across the database. The v

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.

You set up a gemini cli supabase sandbox by creating a limited database role. Then you run the AI tool inside a restricted local shell. Many teams start by giving the coding agent their default admin password. This choice lets the agent read or delete every table in the project. A wide role turns a simple prompt mistake into a big data loss.

How a gemini cli supabase sandbox works

Every Supabase project starts with a default postgres role. This role has admin rights across the database. The vendor does not grant full superuser status to prevent harmful system actions. Still, the password you set at project creation belongs to this admin role. Docs warns that you should never give this password to an outside service. Instead, you should make a fresh database user for each tool you run.

Gemini CLI runs commands and talks to outside systems from your terminal. When you connect it to a database, it uses the credentials in your shell. To build a safe sandbox, you first create a dedicated role for the agent. You grant this role read or write rights on only a few test tables. You also turn on row level security if the role uses the project API.

Supabase includes built-in roles like anon for public requests. When the CLI tool runs SQL directly, it uses your custom database role instead. The tool reads your local settings and sends queries straight to the database host. The database checks the role permissions before it runs the query.

What native roles solve and what they miss

Creating a custom database user solves the basic login problem. It stops the coding agent from using the main postgres admin account. If the agent tries to drop a protected table, the database blocks the action. You also know which account logged in because the role name is distinct. Queries from the web dashboard carry a source comment, while agent queries use your new role.

Still, static database roles only check who logs in at the start. They do not inspect what individual queries or shell commands do in flight. Once a role has read access to a table, it can pull every row by default. If test tables hold real emails, phone numbers, or card numbers, the agent gets them. The database sends those raw values right back to the AI model context.

AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native roles also require you to store a plain password on the user machine. Any process in that shell can read the secret and open a session. Static permissions cannot pause a risky delete statement to ask a human for approval. They cannot rewrite sensitive fields like national IDs in query results before the agent reads them.

Steps to tighten local agent sessions

Start by removing the default admin password from your local shell profile. Create a specific sandbox schema inside your project for the coding agent. Make a new database role that can only read from that test schema. Do not reuse this role for any other app or team member.

Next, clean the data inside your test tables before you start the agent. Replace real emails, phone numbers, and card numbers with fake sample strings. Keep the agent working folder separate from folders that hold production keys. Review the terminal output often to see which queries the agent builds and runs.

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

Should I give Gemini CLI the default postgres role password?

No, you should never share the default postgres password with an outside tool. That role holds admin rights, so you should create a separate limited user instead.

Does the Supabase admin role have full Postgres superuser access?

No, the default postgres role is an admin, not a full superuser. The platform blocks superuser access so users cannot run destructive system operations.

Can database roles stop an AI agent from reading sensitive columns in a permitted table?

Basic table grants allow the role to read every column and row in that table by default. Without field masking in flight, the query returns raw emails and card numbers to the agent.

The query runs. The emails stay hidden.