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.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.svg" alt="Measured on agentmods" 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 $0.00041 $0.00426
Sonnet 5 $0.00016 $0.00170
Haiku 4.5 $0.00008 $0.00085

Measured 7d ago against content hash d74eb4ffd5d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 7d 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. 7d 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 (15 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 82 tokens to every session and 852 once invoked, about $0.0004 per session on Opus 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

Other agents, from other repositories

data-scientist

An agent for data analysis and data science, including SQL queries, BigQuery work, data mining, statistics, visualisation, and business intelligence.

huangdijia/oh-my-claude-code-plugins · 88 tokens

MS-SQL Database Administrator

Work with Microsoft SQL Server databases using the MS SQL extension.

github/awesome-copilot · 18 tokens

core-data-auditor

Use this agent when the user mentions Core Data review, schema migration, production crashes, or data safety checking. Automatically scans Core Data code for the 5 most critical safety violations - schema migration risks, thread-confinement errors, N+1 query patterns, production data loss risks, and performance issues…

CharlesWiltgen/Axiom · 261 tokens

lens

Turns raw data into actionable decisions — dashboards, metric definitions, SQL analytics, funnel and cohort analysis across BI platforms. Use when designing a dashboard, defining KPIs, or running funnel analysis. Trigger with "design a dashboard", "analyze our funnel".

jeremylongshore/tons-of-skills-marketplace · 53 tokens

ecto-schema-designer

Ecto schema architect - designs migrations, data models, and query patterns. Use proactively when planning database structure for new features.

oliver-kriska/claude-elixir-phoenix · 30 tokens

django-migrations-specialist

Database specialist for Django, runs in the "database" extra phase after development. Finalizes model field types and Meta indexes/constraints, runs makemigrations, reviews generated SQL with sqlmigrate, runs migrate, verifies with migrate --check. Do NOT use for: application logic (django-architect), tests…

AratKruglik/claude-sdlc · 85 tokens