How to Configure Goose ClickHouse Guardrails
You set up goose clickhouse guardrails by giving the agent a strict database role. This role limits which tables, columns, and settings the AI assistant can use. Engineering teams often connect Goose to ClickHouse using a shared admin account during tests. Broad permissions create serious risks when an autonomous agent writes and runs SQL queries. One bad prompt can trigger a heavy scan or drop an important analytics table. Setting up strict user rules in ClickHouse stops these mistakes before t
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 clickhouse guardrails by giving the agent a strict database role. This role limits which tables, columns, and settings the AI assistant can use. Engineering teams often connect Goose to ClickHouse using a shared admin account during tests. Broad permissions create serious risks when an autonomous agent writes and runs SQL queries. One bad prompt can trigger a heavy scan or drop an important analytics table. Setting up strict user rules in ClickHouse stops these mistakes before they cause outages.
How to set up native goose clickhouse guardrails
ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL access entities. To turn on SQL access control, admins set up a storage directory on the server. You also need an initial account with access management permissions enabled. Once this is active, you can create a dedicated user account just for Goose. Creating a user requires the specific privilege to create users in the database. Note that a ClickHouse user can only grant privileges that they hold themselves.
When you create the agent account, you define how it logs in. You can also limit which hosts the agent account is allowed to connect from. Next, you attach default roles and per-user settings profiles to that new account. For an AI tool like Goose, you should grant read privileges on safe tables. ClickHouse lets you grant read rights on specific columns rather than whole tables. If you grant read access on two columns, the agent can query only those. If Goose runs a query for all columns with an asterisk, ClickHouse refuses it. The query returns no data unless the table holds only those granted columns. You can also grant read rights across tables that share a name prefix.
Column grants and row rules for agent queries
Column grants help you keep sensitive data out of AI agent prompts and logs. Many analytics tables store customer emails, phone numbers, card numbers, or national IDs. By leaving those columns out of the grant, you block direct queries on them. Still, column grants have a sharp operational tradeoff for AI coding agents. Agents often explore schemas by running broad queries across all columns in a table. When ClickHouse refuses those queries, the agent hits errors and retries in a loop.
You can combine column grants with row policies and quotas to limit resource use. Row policies restrict which rows a role can read based on a filter condition. Quotas cap how much compute time or memory a user consumes in a window. Together, these native controls form the foundation of your database security setup. They define the outer boundary of what the Goose identity can touch inside ClickHouse.
ClickHouse Access Management + AI Guardrails: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Where native database roles fall short for AI agents
Native ClickHouse access entities decide who can log in and which objects they read. They do not inspect what individual statements do in flight based on context. Once Goose logs in with its local database credentials, every valid query runs right away. You cannot pause a risky query for human approval before ClickHouse executes it. Also, the agent stores static database credentials on the developer laptop or server.
Static column blocks also lack flexibility when an agent needs to read mixed tables. Sometimes a query must read a table where sensitive strings sit inside text columns. Native grants either block the entire column or return the raw values in full. They do not rewrite matched fields like emails or card numbers inside query results. Teams also struggle to link shared database user logs back to individual developer identities.
Check ClickHouse queries and result columns on the wire
ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.
Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.
Frequently asked questions
Why does ClickHouse refuse SELECT * queries from Goose?
When you grant read rights on specific columns only, ClickHouse blocks wildcard queries. It returns data only if the table contains solely the columns you granted.
Can a ClickHouse role grant permissions to another agent role?
A user or role can only grant privileges that they already hold themselves. They also need explicit access management rights enabled by an admin first.
How do native ClickHouse controls handle emails and card numbers?
ClickHouse uses column grants to block queries on sensitive columns completely. Native roles do not rewrite matched fields like phone numbers in returned results.
Related guides
In this post