By justvinhhere
Optimize BigQuery SQL by reviewing anti-patterns and rewriting queries for lower slot usage and costs, generate efficient SQL and schemas from natural language descriptions, design tables with partitioning clustering and data types, estimate query and storage expenses, explain features with examples, and audit codebases or projects for optimizations via reports.
Design a BigQuery table schema with optimal partitioning, clustering, and data types. Describe your data or paste a sample.
Estimate the cost of a BigQuery query or table. Pass a query, file path, or table description.
Explain a BigQuery feature, function, or concept with working examples. Pass the feature name or question.
Generate optimized BigQuery SQL from a natural language description. Pass a description of the data you need.
Optimize BigQuery SQL by fixing all detected anti-patterns. Pass a file path or paste SQL directly.
Use when asked to analyze BigQuery SQL files across a project for cost optimization opportunities, estimate total query costs, or audit a codebase for expensive query patterns. <example>Analyze all my SQL files for cost optimization opportunities</example> <example>Which queries in this project are the most expensive?</example> <example>Audit my BigQuery queries for cost reduction</example>
Use when asked to review all SQL files in a project or directory for BigQuery anti-patterns, scan a codebase for SQL performance issues, or audit BigQuery queries across multiple files. <example>Scan all SQL files in this project for BigQuery anti-patterns</example> <example>Audit my BigQuery queries for performance issues</example> <example>Review all the SQL in this repo and tell me what to optimize</example>
Use when asked to analyze table schemas across a project, recommend partitioning and clustering strategies for existing tables, audit schema design, or optimize table structure across a dataset or project. <example>Analyze my BigQuery schemas and recommend partitioning strategies</example> <example>Audit the table designs in this project and suggest improvements</example> <example>Review my DDL files and optimize the schema design</example>
Use when asking about BigQuery costs, pricing, bytes billed, slot usage, reducing query costs, choosing between on-demand and editions pricing, managing reservations, optimizing storage costs, or understanding query caching behavior. Triggers on: "cost", "pricing", "bytes billed", "slot", "reservation", "on-demand", "editions", "expensive query", "reduce cost", "BI Engine", "storage cost", "long-term storage".
Use when asking about BigQuery-specific features, syntax, or capabilities including: STRUCT/ARRAY/UNNEST patterns, MERGE statements, BigQuery scripting (DECLARE, IF, LOOP, BEGIN/END), scheduled queries, remote functions, JSON functions, approximate aggregation (APPROX_COUNT_DISTINCT, HLL_COUNT), geography/GIS functions, BigQuery ML (CREATE MODEL), search indexes, vector search, or BI Engine. Triggers on: "UNNEST", "STRUCT", "ARRAY", "MERGE", "DECLARE", "scripting", "scheduled query", "remote function", "JSON_EXTRACT", "APPROX_COUNT", "HLL", "ST_", "CREATE MODEL", "BQML", "search index", "vector search", "BI Engine".
Use when writing, reviewing, or optimizing BigQuery SQL, asking about BigQuery best practices, working with .sql files targeting BigQuery, or troubleshooting slow/expensive BigQuery queries. Symptoms: high slot consumption, full table scans, expensive joins, slow queries, high bytes billed.
Use when generating BigQuery SQL from natural language descriptions, converting queries from other SQL dialects to BigQuery, writing new BigQuery queries from scratch, or when the user describes what data they need and expects SQL output. Triggers on: "write me a query", "generate SQL", "how do I query", "convert this to BigQuery", "I need to get data from", "create a query".
Use when designing BigQuery table schemas, choosing partitioning or clustering strategies, deciding between nested/repeated fields vs flat schemas, selecting table types (native, external, views, materialized views), choosing data types, or planning denormalization. Triggers on: "partition", "cluster", "STRUCT", "ARRAY", "nested fields", "table design", "schema", "materialized view", "external table", "denormalize", "data type", "TIMESTAMP vs DATETIME".
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
A comprehensive BigQuery plugin for Claude Code. Five integrated skill areas that activate automatically -- writing queries, designing schemas, optimizing costs, detecting anti-patterns, and navigating BigQuery-specific features.
| Skill | Coverage |
|---|---|
| Query Generation | Generate optimized SQL from natural language. Convert queries from PostgreSQL, MySQL, Snowflake, Redshift, and SQL Server. |
| Query Optimization | Detect and fix 11 SQL anti-patterns with before/after rewrites. Project-wide scanning across .sql and code files. |
| Schema Design | Partitioning (time-unit, integer-range, ingestion-time), clustering, nested/repeated fields (STRUCT/ARRAY), denormalization, table types, and data type selection. |
| Cost Optimization | On-demand vs editions pricing, bytes-billed reduction, slot optimization, materialized views, query caching, storage management, and dry-run estimation. |
| BigQuery Features | STRUCT/ARRAY/UNNEST, MERGE DML, scripting, JSON functions, approximate aggregation, geography, BigQuery ML, search indexes, and vector search. |
Skills activate based on context. Ask Claude to write a query and the generation skill engages. Discuss partitioning and the schema design skill kicks in. Multiple skills can activate simultaneously when a request spans areas.
/plugin marketplace add justvinhhere/bigquery-expert
/plugin install bigquery-expert@justvinhhere-bigquery-expert
Or open /plugin, go to the Discover tab, and select bigquery-expert.
/reload-plugins
| Command | What It Does |
|---|---|
/bigquery-expert:bq-generate | Generate optimized SQL from a natural language description |
/bigquery-expert:bq-review | Review SQL for performance anti-patterns |
/bigquery-expert:bq-optimize | Rewrite SQL with all detected anti-patterns fixed |
/bigquery-expert:bq-design-table | Design a table schema with partitioning, clustering, and data types |
/bigquery-expert:bq-estimate-cost | Estimate the cost of a query or table |
/bigquery-expert:bq-explain | Explain a BigQuery feature with working examples |
All commands accept a file path, inline SQL, or a description as an argument. Without arguments, they use the most recent SQL in the conversation.
Examples:
/bigquery-expert:bq-generate "daily active users grouped by country for the last 30 days"
/bigquery-expert:bq-review path/to/query.sql
/bigquery-expert:bq-optimize "SELECT * FROM `project.dataset.events`"
/bigquery-expert:bq-design-table "user click events with timestamp, page URL, and session ID"
/bigquery-expert:bq-estimate-cost path/to/expensive_query.sql
/bigquery-expert:bq-explain "MERGE for upserts"
Agents run autonomously across your project when you ask naturally:
| Agent | Use When You Say... |
|---|---|
| bq-reviewer | "Review all SQL files in this project for anti-patterns" |
| bq-schema-advisor | "Audit my table schemas and recommend partitioning strategies" |
| bq-cost-analyzer | "Which queries in this project are the most expensive?" |
The query optimization skill detects 11 BigQuery SQL anti-patterns:
| # | Pattern | Fix | Severity |
|---|---|---|---|
| 1 | SELECT * on single-table query | Specify only needed columns | High |
| 2 | IN/NOT IN without DISTINCT | Add DISTINCT to subquery | Medium |
| 3 | CTE referenced multiple times | Convert to CREATE TEMP TABLE | High |
| 4 | ORDER BY without LIMIT | Add LIMIT clause | Medium |
| 5 | REGEXP_CONTAINS for simple patterns | Use LIKE instead | Low |
| 6 | ROW_NUMBER() + WHERE rn = 1 | Use ARRAY_AGG(... LIMIT 1) | High |
| 7 | Subquery inside WHERE | Extract to DECLARE variable or CTE | Medium |
| 8 | WHERE predicates not ordered by selectivity | Reorder by operator cost (advisory) | Low |
| 9 | Smaller table first in JOIN | Place largest table first (advisory) | Low |
| 10 | CREATE TEMP TABLE without DROP | Add DROP TABLE at end of script | Low |
| 11 | CREATE TABLE + DROP TABLE in same script | Use CREATE TEMP TABLE instead | Low |
Based on BigQuery Anti-Pattern Recognition by Google Cloud Platform (Apache 2.0).
Before -- ROW_NUMBER() for latest record per group (High severity):
SELECT taxi_id, trip_seconds, fare
FROM (
SELECT taxi_id, trip_seconds, fare,
ROW_NUMBER() OVER (PARTITION BY taxi_id ORDER BY fare DESC) rn
FROM `bigquery-public-data.chicago_taxi_trips.taxi_trips`
)
WHERE rn = 1
After -- ARRAY_AGG (optimized):
npx claudepluginhub justvinhhere/bigquery-expert --plugin bigquery-expertConnect, query, and generate data insights for BigQuery datasets and data.
BigQuery cost analysis and optimization utilities
This plugin provides a specialized suite of skills for data engineers and database practitioners working on Google Cloud. It acts as an expert assistant, allowing you to use natural language prompts in your preferred coding agent to architect complex data pipelines, transform data with dbt, write Spark and BigQuery SQL notebooks, and orchestrate end-to-end workflows across GCP's data ecosystem.
Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.
SQL query optimization and execution plan analysis
Build ClickHouse tables with sub-second queries, 10x compression, and zero full table scans