How to Configure Codex Supabase Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a codex supabase sandbox by creating a limited Postgres database role. Then you give your AI coding agent that role instead of admin keys. Many teams start by handing the default project password to their agent workspace. That shortcut gives the automated tool full admin power over every table. If a prompt goes wrong, the agent can drop tables or read private rows. How a codex supabase sandbox works Every new Supabase project comes with a default postgres role. This role holds admi

AI Sandbox Environments + End-to-End Encryption: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up a codex supabase sandbox by creating a limited Postgres database role. Then you give your AI coding agent that role instead of admin keys. Many teams start by handing the default project password to their agent workspace. That shortcut gives the automated tool full admin power over every table. If a prompt goes wrong, the agent can drop tables or read private rows.

How a codex supabase sandbox works

Every new Supabase project comes with a default postgres role. This role holds admin rights across the database. Supabase does not grant full superuser status, to prevent destructive server commands. Still, the default role still owns your schemas and data. Supabase warns teams never to share this main password with outside tools. Instead, you should create a fresh database user for each external service.

When an AI coding agent runs tasks, it executes shell commands or database queries. It needs a database string to reach your test or staging tables. To build a safe codex supabase sandbox, you make a custom Postgres role. You grant this role read-only rights on specific tables in your test schema. You also block it from changing table structures or deleting rows.

Supabase also includes built-in roles like anon, authenticated, and service_role for app traffic. You should keep those app roles separate from your agent workspace. Give the coding agent its own dedicated Postgres user with strict table limits. This setup keeps agent tests isolated from the rest of your project.

What native roles solve and what keeps the session active

A dedicated Postgres user solves the initial login problem. It stops the coding agent from logging in as the main project admin. It also restricts which schemas and tables the agent can reach at rest. For basic testing on fake data, native database roles work well.

Still, static database roles only check who logs in at the start. They do not inspect individual queries as they run in flight. First, you still have to put a raw database password into the agent workspace. If the agent logs or prints its settings, that secret can leak.

Second, staging and test databases often hold copies of real user records. A read-only role still lets the agent pull thousands of emails or phone numbers. Static table grants cannot rewrite sensitive fields inside query results.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Third, database roles do not require human approval for risky statements. Once the agent has write rights in a test schema, it runs every command right away. Native grants cannot pause a single drop or delete statement for a quick check.

Why teams separate agent logins from data controls

Relying only on static passwords creates extra work for your team. You have to rotate keys by hand every time an agent finishes a task. You also have to scrub real card numbers and national IDs from test backups. When an agent runs fifty queries in a minute, standard logs get messy. It becomes hard to link a specific database change back to one developer.

Teams fix this gap by pairing database roles with query-level controls. The database role sets the baseline rules for the schema. Runtime controls handle secret safety, data masking, and live statement approvals.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres, inline in the Postgres wire protocol. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails refuse bad deletes or drops with a real Postgres error, or hold risky queries for approval. On the way back, hoop.dev data masking rewrites sensitive values in returned rows in memory, and every verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

Should I give my AI agent the default postgres password?

No, never share the default postgres role password with an AI coding agent. That role has admin rights and can change or delete your project data. Always create a separate user with limited permissions for the agent.

Can a read-only role protect sensitive test data?

A read-only role stops the agent from changing or deleting rows. Still, the agent can still read every column in the tables you allow. If your sandbox has real emails or phone numbers, you need field masking.

How do I stop an agent from running destructive queries?

Start by revoking drop, truncate, and delete permissions from the agent database role. For tasks that need write rights, use a tool that checks each query first. This lets a human approve risky commands before they run.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.