How to Configure Claude Code Bigquery Least Privilege

Published
Length
4 min read

Luis Felipe Dias

All posts

You set up claude code bigquery least privilege by assigning a read-only database role to the agent. You also limit its cloud service account to specific datasets and tables. Teams often start by letting the coding agent use a developer's personal cloud login. This shortcut gives the AI tool broad rights to alter tables or read sensitive rows. When a prompt goes wrong, an over-privileged agent can drop data or pull private records. How claude code bigquery least privilege works in practice Cl

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 claude code bigquery least privilege by assigning a read-only database role to the agent. You also limit its cloud service account to specific datasets and tables. Teams often start by letting the coding agent use a developer's personal cloud login. This shortcut gives the AI tool broad rights to alter tables or read sensitive rows. When a prompt goes wrong, an over-privileged agent can drop data or pull private records.

How claude code bigquery least privilege works in practice

Claude Code reaches outside systems through Model Context Protocol servers and its built-in Bash tool. Official docs note that MCP servers give Claude Code access to tools, databases, and APIs. Querying databases is a core use case in the docs. The vendor guide recommends using a read-only database user in the connection string. This step ensures the queries Claude runs cannot modify your stored data. The docs also tell teams to verify that they trust each MCP server before use.

Claude Code can also run shell commands through its Bash tool. In Manual mode, the Bash tool asks for human approval before it runs commands. Only a small built-in list of safe read-only file and git checks skips this prompt. When a developer approves a cloud CLI command, the agent uses local workspace keys. If those keys belong to an admin, the agent inherits full project rights.

To lock this down, teams create a dedicated cloud service account just for the agent. You grant that identity permission to run query jobs and read only approved datasets. You never attach project-wide editor or owner roles to the agent identity. You then point the MCP server or local tool profile to that restricted identity. This keeps the agent inside a tight boundary while it explores schemas and writes SQL.

What native IAM roles solve and what they leave open

Cloud IAM roles and read-only users solve the first half of the access problem. They decide who can log in and which datasets they can see. A read-only role stops the agent from dropping tables or changing production records. Dataset-level permissions keep the agent out of restricted finance or human resources folders. These native controls form a strong base for any AI coding setup.

Still, static cloud roles do not inspect individual SQL statements in flight. Once an identity has read rights on a table, it can read every column. A single query from the agent can pull thousands of customer emails or phone numbers. It can also read credit card numbers or national IDs stored in analytical tables. Those raw values then flow back into the model context window.

Least Privilege Principle + Claude Code Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native dataset roles also struggle with cost and query size limits per request. An agent might run a massive full-table scan during a debugging loop. Also, shared service account keys sit on developer laptops in plain text files. If a team shares one key, audit logs only show the generic service account name. Security teams cannot tell which developer or prompt triggered a specific warehouse query.

How to tighten dataset and query boundaries for AI agents

Start by separating schema discovery from raw table reads whenever you can. Many coding tasks only need table names, column types, and sample test rows. Give the agent identity access to staging views or synthetic datasets first. If the agent needs production structure, expose views that leave out sensitive columns. This keeps private fields like emails and phone numbers out of the agent workflow.

Next, keep Manual mode active for the Bash tool so humans review shell calls. Check every MCP server package before you add it to your project settings. Rotate service account credentials often and remove local keys when a project ends. Combine these cloud role limits with runtime checks that inspect queries and mask fields.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How does Claude Code connect to a BigQuery warehouse?

Claude Code reaches databases through Model Context Protocol servers or by running CLI commands in its Bash tool. Both paths use the credentials configured in the local environment or connection settings.

Why is a read-only role not enough for AI coding agents?

A read-only role stops data changes, but it still allows full SELECT queries on permitted tables. Without column masking, queries can return emails, phone numbers, or card numbers into the model context.

Should developers let Claude Code use their personal cloud login?

No, personal logins usually carry broad write access and access to many sensitive datasets. Always assign a dedicated, narrowly scoped identity with read-only permissions on approved tables.

The query runs. The emails stay hidden.