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.
git clone --depth 1 https://github.com/justvinhhere/bigquery-expertWrote 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.
[](https://agentmods.dev/agents/justvinhhere/bigquery-expert/bq-cost-analyzer)<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>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.
| Model | Per session | Once 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 |
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.
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
- Use Glob to find all
**/*.sqlfiles in the project. - 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
- Backtick-quoted table references:
- Build a list of all files containing BigQuery SQL.
Phase 2: Analyze Each File for Cost
For each file found:
- Read the file content.
- 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 TABLEfor guaranteed single execution)
- 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?
- 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.
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.
- 7d ago First seen · 85 lines · 82 tokens per session scan A d74eb4ffd5d5
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.
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.
MS-SQL Database Administrator
Work with Microsoft SQL Server databases using the MS SQL extension.
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…
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".
ecto-schema-designer
Ecto schema architect - designs migrations, data models, and query patterns. Use proactively when planning database structure for new features.
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…