How to Configure Codex Supabase Prevent Delete
To set up a codex supabase prevent delete workflow, create a custom database role. Grant that role select, insert, and update rights, and leave out delete rights. Teams often give AI coding agents the default admin password to speed up local work. This broad role lets an automated script drop tables or wipe rows by mistake. A scoped database user stops the agent from running destructive commands on live tables. How to set up codex supabase prevent delete rules Every Supabase project starts wi
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 a codex supabase prevent delete workflow, create a custom database role. Grant that role select, insert, and update rights, and leave out delete rights. Teams often give AI coding agents the default admin password to speed up local work. This broad role lets an automated script drop tables or wipe rows by mistake. A scoped database user stops the agent from running destructive commands on live tables.
How to set up codex supabase prevent delete rules
Every Supabase project starts with a default postgres role that holds admin rights. The vendor docs warn against sharing this main password with any external tool. Instead, you should make a new database user for each tool or agent.
When an AI agent like OpenAI Codex runs, it reads local files for database keys. If it finds the admin string, every query it writes runs with full admin power. To block row removal, you build a dedicated role for the agent in Postgres.
You grant this new role permission to connect to the database and use the schema. Next, you grant select, insert, and update rights on the target tables. You do not grant the delete right or table drop rights to this role. If the agent sends a delete command, the database engine rejects it right away. You can also turn on row-level policies to limit which rows the agent updates.
Why native roles leave a gap for AI agents
Database roles work well when a tool needs the exact same rights all day. They decide who can log in and which table verbs are valid at rest. Still, static roles create friction when an AI agent helps with daily tasks.
Sometimes an engineer asks the agent to clean up test rows or fix a migration. A strict role blocks the task, so the developer swaps in the admin key. Once that admin key sits in a local file, the safety net is gone.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also cannot tell a safe single-row delete from a full table wipe. They cannot require a human check before a risky command runs in the database. Also, standard role checks do not rewrite sensitive fields in query results. If an agent queries a user table, it pulls back raw emails and phone numbers.
Separating read tasks from write tasks
A safer pattern splits agent work into two distinct paths based on the task. For debugging and schema checks, the agent uses a strictly read-only database user. This matches the standard advice for connecting coding agents to external databases.
When the agent needs to change data, it should not run direct delete statements. Instead, the agent writes a migration file for a human to review and run. This keeps destructive power out of the automated loop during a coding session.
Run guardrails and masking on the Postgres connection
Role grants and firewall rules are needed setup. Setup alone cannot check single SQL statements or mask sensitive rows in a response. By design, hoop.dev sits inline in the Postgres protocol beside Postgres, RDS, or Aurora as a sidecar for your Postgres. On every production query from an engineer or AI agent, hoop.dev decides whether to pass, mask, block, or hold it for approval.
First, hoop.dev guardrails refuse disallowed drops or deletes before they run, and risky statements can pause for human review. Next, hoop.dev data masking rewrites sensitive fields in returned rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and logs every statement and verdict per resource. Check out the project on GitHub.
Frequently asked questions
Should I give my AI coding agent the default postgres role?
No, the default postgres role has admin rights across your whole project. The official docs state you should create a separate user for each external service.
Can row-level security stop an agent from deleting rows?
Yes, if the agent connects with a role that respects row policies. Admin roles and service roles bypass these policies, so you must use a custom role.
What happens when Codex runs a blocked delete query?
Postgres stops the query before any data changes and returns a permission error. The agent reads this error message and knows the action is not allowed.
Related guides
In this post