Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

BigQuery CLI (bq)

$ bq Official High Risk
Google Cloud · Database & Data · Apache-2.0 · macos / linux / windows

The bq CLI ships with the Google Cloud SDK to query BigQuery datasets, inspect table schemas, and manage jobs/tables. Crucially for AI agents, bq query --dry_run estimates bytes processed before incurring scan costs, and --format=json outputs clean structured records.

FCRS-1.0 Score
83 /100
Good
Medium Confidence
Zero-Friction Install
brew install --cask google-cloud-sdk
CLI vs MCP Decision CLI Preferred vs MCP

bq query --dry_run --format=json and bq show --schema provide exact cost estimation and schema inspection in one deterministic shell call.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Supports --format=json/prettyjson/csv, --dry_run, --maximum_bytes_billed, and non-interactive nouse_legacy_sql flags, though flag syntax uses --snake_case.

  • Supports --format=json, --dry_run, and --maximum_bytes_billed
Trust & Safety 21 / 25

--dry_run and --maximum_bytes_billed provide strong cost-safety guardrails; bq rm requires -f to skip confirmation.

  • Built-in --dry_run byte estimation and --maximum_bytes_billed hard cap
Setup & Portability 11 / 15

Bundled inside the large google-cloud-sdk distribution rather than a standalone small binary.

  • Requires full Google Cloud SDK installation and Python runtime
Utility & Efficiency 14 / 15

Unmatched for BigQuery schema inspection, dry-run cost checks, job polling, and data loading.

  • Full coverage of BigQuery queries, datasets, tables, and load/extract jobs
Maintenance & Lineage 9 / 10

Official Google Cloud CLI maintained by Google.

  • Official Google Cloud SDK component
Docs & Verifiability 7 / 10

Comprehensive Google Cloud reference docs, though legacy vs standard SQL flags can trip newcomers.

  • Official reference at cloud.google.com/bigquery/docs/reference/bq-cli-reference

Security, Auth & Guardrails

Auth Modes
OAuth Browser Service Account Config File
Credential Storage

Reuses gcloud credentials in ~/.config/gcloud/ or GOOGLE_APPLICATION_CREDENTIALS service account JSON.

Side Effects
Read-Only Remote Write Destructive Billing Impact
Cost & Quotas

CLI is free with Google Cloud SDK; BigQuery queries bill per TB scanned (1 TB/month free tier) or slot reservations.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# BigQuery bq CLI Agent Rules
- ALWAYS pass `--use_legacy_sql=false --format=json` and run `--dry_run` before executing queries.
- Set `--maximum_bytes_billed=<bytes>` on exploratory queries to cap scan billing.
- NEVER run `bq rm` on datasets or tables autonomously.

Agent-Ready Command Recipes

Safe Read-Only Queries

Inspect a table schema as JSON
bq show --schema --format=prettyjson <project>:<dataset>.<table>

Retrieves column names, types, and descriptions without scanning table bytes.

Estimate query scan cost with --dry_run
bq query --use_legacy_sql=false --dry_run --format=json 'SELECT count(*) FROM `<project>.<dataset>.<table>`'

Returns totalBytesProcessed in JSON so agents can verify cost before executing.

Controlled Writes & Previews

Execute a capped SQL query with byte limit
bq query --use_legacy_sql=false --maximum_bytes_billed=1000000000 --format=json 'SELECT * FROM `<project>.<dataset>.<table>` LIMIT 20'

Runs Standard SQL with a strict 1 GB billing guardrail cap.

Strengths for Agents

  • + --dry_run reports exact totalBytesProcessed before running any query.
  • + --maximum_bytes_billed enforces a hard cost ceiling per query.
  • + bq show --schema --format=prettyjson inspects schemas at zero query cost.

Caveats & Pitfalls

  • ! Defaults to Legacy SQL unless --use_legacy_sql=false (or ~/.bigqueryrc) is explicitly passed.
  • ! Ships only as part of the heavyweight Google Cloud SDK.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI