How to Configure Windsurf ClickHouse Least Privilege
You set up windsurf clickhouse least privilege by making a scoped SQL role. Then you give that role to the coding agent instead of an admin key. Many teams first let their desktop assistant use a personal database profile. That choice gives the AI agent wide rights to read or drop tables. When an agent runs a bad query, wide rights turn mistakes into outages. How windsurf clickhouse least privilege works in practice Cognition renamed Windsurf to Devin Desktop in June 2026. It keeps the same I
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 windsurf clickhouse least privilege by making a scoped SQL role. Then you give that role to the coding agent instead of an admin key. Many teams first let their desktop assistant use a personal database profile. That choice gives the AI agent wide rights to read or drop tables. When an agent runs a bad query, wide rights turn mistakes into outages.
How windsurf clickhouse least privilege works in practice
Cognition renamed Windsurf to Devin Desktop in June 2026. It keeps the same IDE features and uses the Cascade agent. This agent can run terminal commands with user permission. It opens a dedicated shell that loads your local profile and variables. The agent also talks to external tools through Model Context Protocol servers. If your shell holds an admin database key, the agent inherits those rights.
To lock this down, you use SQL access control inside ClickHouse. ClickHouse treats users, roles, row policies, settings profiles, and quotas as access items. You must first set a storage folder for access rules on the server. You also need at least one admin user with access management turned on. Remember that a user can only grant rights that they already hold.
Next, you create a dedicated user and role for the desktop agent. The user creation step lets you pick the login method and default roles. You can also limit which hosts the agent user may connect from. Instead of granting full table reads, you can grant select on specific columns. The agent can then query only the allowed columns in that table. If the agent tries to select all columns with a star, the query fails. ClickHouse returns no data unless the table holds only those permitted columns. Since version 24.10, you can also grant select rights by table name prefix.
Why native roles are only the first step
Native roles and column grants stop the agent from reading blocked columns. They also block the agent from running drop or alter statements on production data. Host limits and quotas help keep basic resource use in check. These rules decide who can log in and which objects they can touch.
Least Privilege Principle + ClickHouse Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static database roles leave an operational gap during live coding sessions. Once the agent logs in, the database trusts every allowed query it sends. A static role cannot require a human check before a specific query runs. Also, column grants are all or nothing for the columns you allow. If an allowed text column holds emails, phone numbers, or card numbers, the query returns them. Static grants cannot rewrite matched fields in results while keeping the rest of the column readable. Finally, local shell keys sit on developer laptops where scripts can read them.
How to scope agent queries and protect sensitive fields
Start by removing shared admin keys from your local shell startup files. Create a separate ClickHouse role that holds only column-level select rights for safe tables. Pair that role with a settings profile and quota to cap heavy analytical scans. When the agent needs to query tables with emails or national IDs, add runtime controls.
Check ClickHouse queries and results before execution
Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits inline in the protocol beside the server as a sidecar for your ClickHouse. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations or hold them for review. Then hoop.dev data masking rewrites sensitive string columns in responses in memory and logs each decision per resource. Read the docs and source on GitHub.
Frequently asked questions
How does Windsurf run queries against ClickHouse?
Windsurf, now called Devin Desktop, runs terminal commands in a dedicated shell or uses MCP servers. It uses the database keys and variables loaded in that local shell.
What happens if the agent runs a star query on a column-restricted table?
ClickHouse refuses the star query and returns no data at all. The query only works if the user has rights on every column, or names allowed columns by default.
Can a ClickHouse user grant rights to the agent role on its own?
A ClickHouse user needs the create user privilege to make new accounts. Also, a user can only grant privileges that they already hold themselves.
Related guides
In this post