How to Configure Claude Code Bigquery Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code bigquery prevent delete by assigning a read-only database role. You then pass that role to the Model Context Protocol server or local shell tool. Many teams start by giving their coding agent a broad developer role for fast testing. If that role includes write rights, a bad prompt can wipe out production tables fast. A single mistake in a query can drop rows or delete entire datasets in seconds. How to set up claude code bigquery prevent delete with native roles Claude

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 prevent delete by assigning a read-only database role. You then pass that role to the Model Context Protocol server or local shell tool. Many teams start by giving their coding agent a broad developer role for fast testing. If that role includes write rights, a bad prompt can wipe out production tables fast. A single mistake in a query can drop rows or delete entire datasets in seconds.

How to set up claude code bigquery prevent delete with native roles

Claude Code reaches external databases in two main ways during a coding session. First, it uses Model Context Protocol servers to reach tools, databases, and APIs. Second, it runs local shell commands through its built-in Bash tool. In both paths, the agent acts with the exact permissions of the local user account. Vendor docs advise using a read-only database user in the connection string. This step ensures the queries Claude runs cannot modify or delete your stored data.

To apply this in BigQuery, you create a dedicated cloud role for the agent. You grant this role permission to run jobs and read table metadata and rows. You leave out permissions that allow table drops, dataset deletes, or row updates. Next, you link this restricted identity to your local MCP server setup. When the agent sends a query, BigQuery checks the cloud role before running the job. If the agent tries to delete rows, the database rejects the request right away.

Why native roles are not enough for live queries

Static cloud roles work well when an agent only needs to read data. Still, many data tasks require the agent to build summary tables or insert test rows. If you block all write actions, the agent cannot finish these common engineering jobs. Teams often cave in and grant full editor roles so the agent can work. Once you grant editor rights, the native role can no longer stop a delete command. The cloud role decides who logs in, not what each query does in flight.

Using the Bash tool creates a similar risk for your data warehouse. In manual mode, Claude Code asks for approval before running most shell commands. Only a small set of basic read-only commands run without a human check. Yet humans get tired when reviewing dozens of long query strings in a terminal window. It is easy to miss a destructive statement hidden inside a multi-line script. Also, a read-only role does not stop the agent from pulling sensitive data. Raw query results can still return plain emails, phone numbers, card numbers, or national IDs.

Claude Code Security + BigQuery IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Controlling database queries at the statement level

A safer approach separates the ability to write data from the ability to destroy it. Instead of relying only on broad cloud roles, teams inspect each statement before it runs. This lets an engineer allow select and insert statements while blocking drop or delete commands. You also gain a clear log of every query the agent sends to the warehouse. Data masking can also rewrite matched fields in results, such as emails or card numbers. This setup lets the coding agent do useful work while keeping core tables safe.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

How does Claude Code connect to a BigQuery dataset?

Claude Code connects through a Model Context Protocol server or by running shell commands. In both cases, it uses the cloud credentials configured on the local machine.

Does manual mode in Claude Code stop all BigQuery delete commands?

Manual mode asks for user approval before running non-basic shell commands in the Bash tool. Still, if a human approves a bad script, the database still runs the delete command.

Can a read-only user role protect sensitive customer columns in BigQuery?

A read-only role stops data changes, but it still returns every column the user can read by default. To protect sensitive fields like phone numbers or national IDs, you need data masking rules.

The query runs. The emails stay hidden.