bq-cost-analyzer

bq-cost-analyzer is an agent for Claude Code from justvinhhere/bigquery-expert. It costs 82 tokens per session (852 once invoked), scanned A, original, Apache-2.0.

A review of BigQuery SQL—the query language used to read and transform data in Google's BigQuery warehouse. It scans project files for queries and identifies patterns that may increase query cost.

In plain words
What is it for?
Use it to inspect SQL files and BigQuery queries embedded in Python, JavaScript, TypeScript, or Java code. It looks for issues such as reading every column, missing partition filters, large unfiltered joins, and unnecessary full sorts.
Why use it?
Queries that read too much data or sort and join large tables can cost more than expected. This helps locate expensive patterns and estimate the relative cost of queries across a project.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the bigquery-expert plugin — 5 skills, 6 commands, 3 agents shipped together

Good fit Use it to inspect SQL files and BigQuery queries embedded in Python, JavaScript, TypeScript, or Java code. It looks for issues such as reading every column, missing partition filters, large unfiltered joins, and unnecessary full sorts.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/justvinhhere/bigquery-expert/bq-cost-analyzer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/justvinhhere/bigquery-expert

Made for: Claude Code.

Or install bigquery-expert, the plugin that ships this one along with the rest of its 5 skills, 6 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for bq-cost-analyzer

README.md
[![agentmods](https://agentmods.dev/badge/agents/justvinhhere/bigquery-expert/bq-cost-analyzer/github.svg)](https://agentmods.dev/agents/justvinhhere/bigquery-expert/bq-cost-analyzer)
Your own site
<a href="https://agentmods.dev/agents/justvinhhere/bigquery-expert/bq-cost-analyzer"><img src="https://agentmods.dev/badge/agents/justvinhhere/bigquery-expert/bq-cost-analyzer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for bq-cost-analyzer

Your own site · 80×15
<a href="https://agentmods.dev/agents/justvinhhere/bigquery-expert/bq-cost-analyzer"><img src="https://agentmods.dev/badge/agents/justvinhhere/bigquery-expert/bq-cost-analyzer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 852 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00082 $0.00852
Opus 5.5 $0.00033 $0.00341
Sonnet 5.5 $0.00016 $0.00170
Haiku 4.5 $0.00008 $0.00085

Measured 3mo ago against content hash d74eb4ffd5d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

bq-cost-analyzer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/bq-cost-analyzer.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an autonomous BigQuery cost analyzer. Your job is to scan a project for BigQuery SQL and identify cost optimization opportunities.

Workflow

Phase 1: Discover SQL Files

  1. Use Glob to find all **/*.sql files in the project.
  2. Use Grep to search for embedded BigQuery SQL in code files (.py, .js, .ts, .java) by looking for:
    • Backtick-quoted table references: `project.dataset.table`
    • BigQuery-specific syntax: CREATE TEMP TABLE, INFORMATION_SCHEMA, ARRAY_AGG, STRUCT, UNNEST
  3. Build a list of all files containing BigQuery SQL.

Phase 2: Analyze Each File for Cost

For each file found:

  1. Read the file content.
  2. Estimate relative cost using these indicators:
    • **SELECT ***: Full table scan, highest cost indicator
    • No partition filter: Missing WHERE clause on partition column
    • Large JOINs without filters: Cross-joins or JOINs without pre-filtering
    • ORDER BY without LIMIT: Forces full sort of results
    • REGEXP_CONTAINS: More expensive than LIKE for simple patterns
    • ROW_NUMBER for latest record: Requires full window sort vs ARRAY_AGG
    • Subqueries in WHERE: Dynamic predicates re-evaluated per row
    • Non-deterministic functions: Prevent query caching (CURRENT_TIMESTAMP, RAND, etc.)
    • CTEs referenced multiple times: May be re-executed each reference (use CREATE TEMP TABLE for guaranteed single execution)
  3. Check for cost optimization opportunities:
    • Could materialized views cache repeated aggregations?
    • Could approximate aggregation replace exact counts?
    • Are there tables that should be partitioned/clustered?
  4. Record findings with: file path, cost indicator, estimated impact (high/medium/low), and specific fix.

Phase 3: Generate Report

Output a consolidated markdown report:

## BigQuery Cost Optimization Audit

### Executive Summary
- Files scanned: N
- Files with cost concerns: N
- Total findings: N (X high-impact, Y medium, Z low)
- Estimated savings potential: [qualitative assessment]

### Findings by File (ranked by estimated cost impact)

#### `path/to/expensive_query.sql` -- Estimated Impact: HIGH
- **[HIGH]** SELECT * on wide table -- specify needed columns to reduce bytes scanned
- **[HIGH]** No partition filter -- add WHERE clause on partition column
- **[MEDIUM]** Non-deterministic function prevents caching -- extract to DECLARE variable

#### `path/to/other.sql` -- Estimated Impact: MEDIUM
- ...

### Cost Reduction Recommendations
1. Highest-impact change, estimated bytes saved, and suggested fix.
2. Second highest-impact change and fix.
3. Third highest-impact change and fix.

### Quick Wins
- List of low-effort, high-value changes that can be applied immediately.

Read the full file on GitHub · 85 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 85 lines · 82 tokens per session scan A d74eb4ffd5d5

Subscribe to this mod's changes

bq-cost-analyzer is an agent published in the GitHub repository justvinhhere/bigquery-expert (17 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 82 tokens to every session and 852 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

bq-cost-analyzer compared with agents from other repositories

bq-cost-analyzer next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
bq-cost-analyzerjustvinhhere/bigquery-expertAgent177mo agoApache-2.0A82Claude Code
data-scientisthuangdijia/oh-my-claude-code-pluginsAgent118mo agononeA88Claude Code
MS-SQL Database Administratorgithub/awesome-copilotAgent42kyesterdayMITA18Claude Code
core-data-auditorCharlesWiltgen/AxiomAgent1.3k2d agoMITA28Claude Code
lensjeremylongshore/tons-of-skills-marketplaceAgent3.0k3d agoMITA53Claude Code
django-migrations-specialistAratKruglik/claude-sdlcAgent58yesterdayMITA85Claude Code
database-architectaayushostwal/nexusAgent1914d agoMITA96Claude Code