How to Configure Devin Postgres Read Only Access
You set up devin postgres read only access by creating a dedicated database role. You then grant that role read permissions on specific schemas and tables. Many teams start by giving AI agents shared app keys to save time. Broad keys let an automated agent change rows or drop tables by mistake. A strict read role stops the agent from writing data during a task. Setting up devin postgres read only access with native roles PostgreSQL manages permissions through roles that act as users or groups
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 devin postgres read only access by creating a dedicated database role. You then grant that role read permissions on specific schemas and tables. Many teams start by giving AI agents shared app keys to save time. Broad keys let an automated agent change rows or drop tables by mistake. A strict read role stops the agent from writing data during a task.
Setting up devin postgres read only access with native roles
PostgreSQL manages permissions through roles that act as users or groups. You can set up a group role to hold your read rules. You then create a login role for Devin and add it to that group. First, the role needs permission to log in to the target database. By default, PostgreSQL gives a special group called PUBLIC the right to connect. The PUBLIC group also gets default rights to run functions and make temporary tables. You should revoke those default rights from PUBLIC to keep the database locked down.
Next, you grant schema usage to the read role so it can see objects. Then you grant the SELECT privilege on the tables and views the agent needs. PostgreSQL lets you grant SELECT on a whole table or just specific columns. You also need to plan for new tables that your team builds later. You can alter default privileges so future tables grant read rights to the group. Notice that default privileges only apply to objects created by the role you specify. If migrations run under a deploy role, you set defaults for that deploy role. Finally, check your database version to make sure the public schema is safe. PostgreSQL 15 and newer versions stop users from creating objects in the public schema. Older versions, or upgraded databases, need an admin to revoke that create right.
Why native roles are not enough for AI agents
Native database roles do a good job of blocking write commands. If Devin tries to update a row, the database rejects the query right away. Still, database roles only check who logs in and which tables they can read. They do not inspect what individual queries do while they run in flight. An AI agent with table read rights can still pull sensitive customer records. Even with column grants, maintaining permissions across hundreds of tables takes constant work. If a column holds mixed text, native grants cannot filter out secret values inside.
A read query can return emails, phone numbers, card numbers, or national IDs. When the agent reads those rows, that raw data enters the model context. Also, the SELECT privilege in PostgreSQL allows the user to run bulk data exports. An autonomous agent might run a massive table scan that slows down production traffic. Static passwords given to an agent workspace also create a long-term key rotation chore. Teams need a way to inspect queries and rewrite sensitive fields in results.
Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Locking down the agent workspace and network
Beyond database roles, you should restrict where the agent can log in from. Place the database on a private network instead of exposing a public IP address. Route the agent traffic through a private link or a strict firewall rule. Set statement timeouts on the Devin login role inside PostgreSQL as well. A short timeout stops a bad query from locking up CPU and memory. Pair that timeout with a connection limit on the role to save database slots. These controls protect server health when the AI agent tests heavy queries.
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 PostgreSQL restrict Devin to reading only certain columns?
Yes, PostgreSQL lets you grant the SELECT privilege on specific columns of a table. If Devin queries a restricted column, the database blocks the query completely. Still, managing column grants across many tables adds daily work for your team.
Why can a read-only role still create objects in some databases?
Before PostgreSQL 15, the PUBLIC group had rights to create objects in the public schema. If you run an older or upgraded database, you must revoke that right manually. You should also revoke temporary table rights from the PUBLIC group.
How do new tables get read permissions for Devin automatically?
You can set default privileges in PostgreSQL so new tables grant read access by default. Keep in mind that default privileges only apply to the specific role that creates the table. You must set this rule for the exact role that runs your schema migrations.
Related guides
In this post