How to Configure OpenHands Supabase Guardrails
You set up openhands supabase guardrails by making a dedicated Postgres user for the agent. Then you apply row level rules and restrict table permissions before the agent runs. Many engineering teams give coding agents the default database password to save time. This gives the agent admin privileges across your entire project. If the agent makes a mistake, it can drop tables or read customer data. A safe setup limits what the agent can touch from the very first query. How to set up openhands
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 openhands supabase guardrails by making a dedicated Postgres user for the agent. Then you apply row level rules and restrict table permissions before the agent runs.
Many engineering teams give coding agents the default database password to save time. This gives the agent admin privileges across your entire project. If the agent makes a mistake, it can drop tables or read customer data. A safe setup limits what the agent can touch from the very first query.
How to set up openhands supabase guardrails
Every new Supabase project comes with a default postgres role. This role has admin rights, though it is not a full superuser. Supabase blocks superuser access to prevent destructive actions on the server. Still, the default postgres role has broad power over your schema and data. You set its password when you create the project. Supabase says you should never share this password with an outside tool. Instead, you should create a brand new database user for each service.
Start by creating a dedicated role just for OpenHands. Give this role permissions only on the specific schemas and tables it needs. If the agent only needs to debug a feature, grant it read access. Do not grant it rights to alter tables or delete rows in production. Next, check the built-in roles that Supabase adds to every project. These include the anon role, the authenticated role, and the service role. Make sure your agent does not use the service role key unless required. By scoping the database user, you build a strong base layer of safety.
How database roles work in an agent workflow
OpenHands runs in its own workspace to write code and run terminal commands. When you ask it to build a feature, it often checks the database schema. It might also run test queries to verify that its new code works. If you pass database credentials into the agent workspace, the agent uses them directly. Postgres checks the role permissions when the agent logs in and sends a query. If the role lacks permission for a table, Postgres blocks the command right away. Queries run in the Supabase dashboard execute as the admin postgres role. Queries from your agent should always run under its own scoped user role.
AI Guardrails + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native roles solve and what they leave open
Database roles and permissions solve the problem of who can log in. They also control which tables a user can read or change. This stops an agent from touching parts of the database it has no business using. Still, static database roles cannot check what an individual statement does in flight. Once a role has permission to update a table, it can update one row. It can also update every single row in that same table by mistake. Native roles also do not rewrite sensitive fields like emails or phone numbers in results. If the agent has read access to a user table, it gets the raw columns. The database checks who is asking, not whether the specific query is safe right now.
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. It runs beside your database and reads the Postgres wire protocol. 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 check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and 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 OpenHands the default postgres password?
No, you should never give the default postgres password to an automated agent. That role has admin privileges, so you should create a separate user for the agent.
Can database roles stop an agent from reading customer emails?
Standard table roles allow or block access to whole tables or columns. To rewrite matched fields like emails or card numbers in results, you need data masking.
How do I know if a query came from the Supabase dashboard or my agent?
Queries run inside the Supabase dashboard execute as the postgres role with a dashboard comment. When you give your agent its own database user, its queries show that role name.
Related guides
In this post