How to Configure Devin Postgres Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a devin postgres sandbox by creating a limited database role for the agent. Then you grant that role read or write rights on specific test schemas and tables. Engineering teams often hand autonomous coding agents full database owner credentials to speed up testing. Broad roles create big risks because an agent can drop tables or read sensitive rows. How to set up a devin postgres sandbox with native roles A safe setup starts inside the database permission system. Instead of sharing

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 devin postgres sandbox by creating a limited database role for the agent. Then you grant that role read or write rights on specific test schemas and tables. Engineering teams often hand autonomous coding agents full database owner credentials to speed up testing. Broad roles create big risks because an agent can drop tables or read sensitive rows.

How to set up a devin postgres sandbox with native roles

A safe setup starts inside the database permission system. Instead of sharing a superuser login, you create a dedicated group role for your agents. PostgreSQL lets you set up group roles to manage permissions for many users at once. You then grant individual agent logins membership in that group role.

Next, you lock down what every role can do by default. In PostgreSQL, the special role name PUBLIC gives rights to every user on the system. By default, PUBLIC gets the right to connect and create temporary tables in a database. It also gets the right to run functions and procedures. The database owner can revoke these default rights from PUBLIC to tighten control.

Schema rules also matter when an agent writes and tests migrations. In PostgreSQL 15 and later, regular users cannot create objects in the public schema by default. Older databases, or systems upgraded from older versions, still allow this behavior. On those older systems, an admin must revoke create rights on the public schema from PUBLIC. You can then give the agent its own isolated schema for schema tests.

For data reading, you can limit the agent down to exact columns. The SELECT privilege allows reading from a full table, a view, or a materialized view. You can also grant SELECT on specific columns of a table. That way, the agent reads test columns without touching columns that hold emails or phone numbers. Note that granting SELECT also allows the role to export data using the copy command.

What native database roles solve and what they miss

Native database permissions do a great job of controlling who can log in. They also define which tables or columns a role can touch at a static level. If an agent tries to read a blocked table, the database stops the query right away. Group roles make it easy to keep these rules consistent across several test databases.

Still, static database roles only check permissions at the object level. Once a role has permission on a table, the database allows any valid query on it. Native roles cannot pause a risky drop command inside the agent's own test schema for review. They also cannot rewrite sensitive fields like card numbers or national IDs in 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.

Test databases often hold copies of real user records from production snapshots. When an agent queries a table, it receives every row that matches the query. A static role cannot tell if the agent asked for one test row or ten thousand rows. It also leaves credentials stored inside the agent workspace settings.

How to keep test data safe during agent runs

To keep a sandbox clean, teams pair strict database roles with synthetic test data. Generating fake records ensures the agent only works with safe dummy values. When real snapshots must be used, teams strip out emails, phone numbers, and card numbers first.

Teams should also rotate the database passwords given to automated coding tools after each project. Revoking temporary privileges after a task finishes keeps old agent sessions from lingering. Combining tight schema grants with clean test data keeps your database experiments safe and predictable.

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 is an open-source proxy that sits beside Postgres, RDS, or Aurora as a sidecar for your Postgres. Clients and agent tools keep their credentials and point their connection string at the listener.

On each query, hoop.dev guardrails refuse disallowed drops, deletes, or table reads before they run. Next, hoop.dev data masking rewrites sensitive fields in returned rows that match your rules. 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

Can I restrict an agent to specific columns in PostgreSQL?

Yes, PostgreSQL lets you grant the SELECT privilege on specific columns of a table or view. This lets the agent query safe columns while blocking columns with sensitive data.

Why can my agent still create tables in the public schema?

Databases running versions before PostgreSQL 15 allow PUBLIC to create objects in the public schema. An admin must revoke create rights on the public schema from the PUBLIC role.

What permissions does every new PostgreSQL role get by default?

Through the PUBLIC role, every new user can connect to the database and create temporary tables. They can also execute functions and procedures unless the owner revokes those defaults.

The query runs. The emails stay hidden.