How to Configure Goose Neon Data Masking

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up goose neon data masking by pairing Postgres roles with database masking rules. Then you point the AI agent to a read-only database branch. Engineering teams often use one shared database user for local AI tools. When that role has broad permissions, the agent can read raw emails or phone numbers. A proper setup limits what the agent reads during task runs. How goose neon data masking works in Postgres Goose is a local developer agent that runs tasks and queries on your machine. Neo

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 goose neon data masking by pairing Postgres roles with database masking rules. Then you point the AI agent to a read-only database branch. Engineering teams often use one shared database user for local AI tools. When that role has broad permissions, the agent can read raw emails or phone numbers. A proper setup limits what the agent reads during task runs.

How goose neon data masking works in Postgres

Goose is a local developer agent that runs tasks and queries on your machine. Neon is a serverless Postgres platform that splits storage from compute. It lets teams create instant database branches for testing and local work. To set up goose neon data masking, you start at the database layer. You define masking rules on specific columns like card numbers or national IDs. These rules tie directly to a restricted Postgres role inside your Neon project.

Teams typically create a child branch from their main Postgres database for the agent. During branch creation or inside the database, an admin sets up static or dynamic masking. Static masking changes the stored data on the branch copy itself. Dynamic masking rewrites matched fields in results when the restricted role runs a query. Next, you give the local agent the login details for that restricted database role. When the agent runs a query, Postgres checks the role permissions first. The database then applies the masking rules before returning the rows to the agent.

What native database roles solve and what they miss

Native database branching and role rules solve the basic data exposure problem for test copies. Developers do not have to write custom scrubbing scripts for every new test run. Branch copies keep test queries away from your main production compute. Also, Postgres roles enforce column rules without changing how the agent formats its queries.

Still, static branch setups and database roles leave an operational gap during live debugging. Database roles decide who logs in, not what individual statements do in flight. Sometimes an engineer points the agent at a live database to fix a bug. On a live branch, creating and maintaining masked views for every table takes heavy effort. If a table schema changes, custom views can break or miss new columns. A database role also cannot pause a risky query to ask for human approval. Also, standard database logs do not tie queries back to an individual user identity. Teams need a way to inspect statements and mask fields in results on the fly.

Data Masking (Static) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing agent database sessions safely

To keep live queries safe, teams must separate agent credentials from developer laptops. Storing static database keys in local files creates a risk if a machine gets compromised. Instead, teams should route agent sessions through a central control point that checks every request. This setup lets you apply masking rules to emails and phone numbers in real time. It also records every query alongside the identity of the developer running the agent.

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

Does Neon database branching mask sensitive columns on its own?

No, a standard database branch creates an exact copy of your parent data. You must enable a masking extension or run a scrubbing step to rewrite sensitive fields.

Why do AI agents need separate database roles?

AI agents generate and run SQL queries based on natural language prompts. Separate roles ensure the agent only reads allowed tables and cannot drop production data.

What types of data should teams mask for local agents?

Teams should mask personal fields like emails, phone numbers, card numbers, and national IDs. Masking rewrites matched fields in results so raw values do not enter model prompts.

The query runs. The emails stay hidden.