How to Configure Windsurf Postgres Prevent Delete
To set up a windsurf postgres prevent delete rule, restrict the database role permissions. You grant read and insert rights to the agent while holding back delete rights. Teams often give AI coding tools full database roles to move fast during setup. When a role is too broad, one bad prompt can wipe out production rows. A safer setup uses tight database roles and clear limits on agent terminal runs. How windsurf postgres prevent delete works in native roles Cognition renamed Windsurf to Devin
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 windsurf postgres prevent delete rule, restrict the database role permissions. You grant read and insert rights to the agent while holding back delete rights. Teams often give AI coding tools full database roles to move fast during setup. When a role is too broad, one bad prompt can wipe out production rows. A safer setup uses tight database roles and clear limits on agent terminal runs.
How windsurf postgres prevent delete works in native roles
Cognition renamed Windsurf to Devin Desktop in June 2026, keeping the same IDE features. Its agent can run terminal commands on its own when the user gives permission. The agent uses a dedicated shell that loads the user shell setup and variables. If a database key sits in those variables, the agent can use it. The legacy Cascade agent also talks to Model Context Protocol servers for database tasks.
To stop row removal at the database level, admins set up a dedicated role. You can create a group role to manage rights for agents and human users. Then you grant the select privilege on tables, views, or specific columns to read. If the agent must add or change rows, you grant insert or update rights. You leave out the delete privilege so the database blocks any delete statement.
Admins must also check the special PUBLIC role on the Postgres server. By default, PUBLIC gives every role connect rights and temporary table rights on databases. It also gives execute rights on functions and procedures to every role. If a stored function deletes rows, an agent could run it through PUBLIC rights. The object owner must revoke those default execute rights from PUBLIC to close this gap.
You should also check schema creation rights on older Postgres servers. Starting in Postgres 15, the default setup blocks users from creating objects in public. On older versions or upgraded databases, an admin must revoke create from PUBLIC manually.
Why native roles are not enough for agent queries
Database roles work well when an agent always needs the exact same access level. They decide who can log in and which table actions are always off limits. Still, static roles cannot judge the context of a specific query in flight. Sometimes a developer needs the agent to clean up a few test records. Granting delete rights for that one task opens the door to wider data loss.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
A role with update rights can still ruin data without running a delete command. An agent could run an update statement that blanks out every email in a table. Also, granting select on a whole table exposes sensitive fields in query results. While column grants exist, maintaining column rules across hundreds of tables takes heavy work. Masking rules that rewrite emails, phone numbers, and card numbers in results help more.
Native shell prompts inside the IDE also leave gaps during busy work sessions. Developers get tired of clicking approve and start allowing commands without reading the SQL. When the agent uses local shell variables, every command shares the same static key. Database logs only show that shared role name, not which prompt triggered the query. Teams need a way to check individual statements and mask fields like national IDs.
Add query and result controls beside Postgres
Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your Postgres. For every plain or prepared query an agent or human runs against production, hoop.dev decides to pass, mask, block, or escalate it for review.
When a tool or agent sends SQL, hoop.dev Postgres controls block banned statements before execution or hold risky ones for human approval via an AI Analyzer you configure. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.
Frequently asked questions
Can the Windsurf agent run database commands from my terminal?
Yes, Windsurf, now called Devin Desktop, runs terminal commands with user permission. Its dedicated shell loads your shell setup, including any database keys in your variables.
How do I stop a Postgres role from running delete functions?
By default, the special PUBLIC role lets any user run functions and procedures. The object owner must revoke execute rights from PUBLIC on any function that deletes data.
Does revoking delete stop an AI agent from ruining table data?
No, revoking delete only blocks row removal statements. If the role still holds update rights, a bad query can overwrite existing values with blank data.
Related guides
In this post