How to Configure Goose SQL Server Guardrails
You set up goose sql server guardrails by creating a restricted database user. Then you assign that user to a read-only database role. Teams often connect AI agents like Goose using shared developer accounts. Those accounts usually hold broad rights across the whole server. If the agent makes a mistake, it can change or delete production data. Scoping permissions down before the agent runs is your first safety step. How native goose sql server guardrails work SQL Server splits access into ser
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 sql server guardrails by creating a restricted database user. Then you assign that user to a read-only database role. Teams often connect AI agents like Goose using shared developer accounts. Those accounts usually hold broad rights across the whole server. If the agent makes a mistake, it can change or delete production data. Scoping permissions down before the agent runs is your first safety step.
How native goose sql server guardrails work
SQL Server splits access into server logins and database users. A database user is the identity of a login inside a database. When an person or agent needs many databases, teams create a login in master. Then they map a SQL user to that login.
For one or a few databases, you can use a contained database user. This is a SQL user with a password, not tied to master. An admin must enable contained databases on the server and database first. Microsoft supports 13 types of database users in total.
Once the user exists, you assign it to fixed database roles. Every role, including the public role, has basic connect rights. You cannot change the permissions inside these fixed roles. For read-only agent workflows, admins add the user to the datareader role. Members of this role can read all data from all user tables and views.
You can also add the denydatawriter role as an extra safety check. Members of this role cannot add, change, or delete any table data. If an agent never needs to read sensitive tables, the denydatareader role blocks reads and metadata. You should never put an automated agent in the owner role. The owner role allows all maintenance tasks and can even drop the database.
What native roles solve and what they miss
Native SQL Server roles decide who can log in to a database. They also set broad boundaries on reading or writing across user tables. Putting Goose in a read-only role stops accidental table drops and row deletes. This gives your team a solid baseline for database safety.
Still, fixed database roles are all-or-nothing across user tables. A user in the datareader role can read every single user table and view. It can pull emails, phone numbers, card numbers, and national IDs in one query. The database role cannot rewrite matched fields in query results on the fly.
Kubernetes API Server Access + AI Guardrails: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native roles also do not inspect what individual statements do in flight. An AI agent might run a massive join that locks up server memory. If the agent needs write rights for a task, the datawriter role is too broad. It lets the agent add, change, or delete rows in every user table. Static credentials also sit on the local machine where the agent runs. If those keys leak, anyone can use them until an admin rotates them.
Why query-level rules matter for AI agents
AI agents generate queries on the fly based on natural language prompts. Even a helpful prompt can lead to a bad query against a large table. Because the agent runs fast, it can execute dozens of bad queries in seconds.
Teams need a way to check each statement before the database runs it. You also need a way to require human approval for risky write commands. Combining native SQL Server roles with statement-level checks gives you full control.
Check SQL Server batches and results on the wire
SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server. It reads plain batches and parameterized queries on the TDS wire while passing Windows login through untouched.
Before a batch hits the server, hoop.dev guardrails check the statement against your rules. Disallowed actions get a native TDS error with your message. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns that match your rules. Every query and decision is logged. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should I use a login in master or a contained user for Goose?
Use a contained database user if Goose only needs one or a few databases. Use a login in master if the agent needs access to many databases.
Can I customize the permissions of fixed database roles in SQL Server?
No, the permissions assigned to fixed database roles cannot be changed. You can combine roles like datareader and denydatawriter to tighten access.
Why is the db_datareader role not enough for AI agent safety?
The datareader role lets the user read all data in all user tables. It does not mask sensitive fields like emails or card numbers in results.
Related guides
In this post