BigQuery Skills: BigQuery Expert

Comprehensive BigQuery plugin for optimizing SQL queries and managing costs.

BigQuery Skills: BigQuery Expert

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.

Skills

SkillCoverage
Query GenerationGenerate optimized SQL from natural language. Convert queries from PostgreSQL, MySQL, Snowflake, Redshift, and SQL Server.
Query OptimizationDetect and fix 11 SQL anti-patterns with before/after rewrites. Project-wide scanning across .sql and code files.
Schema DesignPartitioning (time-unit, integer-range, ingestion-time), clustering, nested/repeated fields (STRUCT/ARRAY), denormalization, table types, and data type selection.
Cost OptimizationOn-demand vs editions pricing, bytes-billed reduction, slot optimization, materialized views, query caching, storage management, and dry-run estimation.
BigQuery FeaturesSTRUCT/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.

Installation

Add the marketplace

/plugin marketplace add justvinhhere/bigquery-expert

Install the plugin

/plugin install bigquery-expert@justvinhhere-bigquery-expert

Or open /plugin, go to the Discover tab, and select bigquery-expert.

Activate

/reload-plugins

Commands

CommandWhat It Does
/bigquery-expert:bq-generateGenerate optimized SQL from a natural language description
/bigquery-expert:bq-reviewReview SQL for performance anti-patterns
/bigquery-expert:bq-optimizeRewrite SQL with all detected anti-patterns fixed
/bigquery-expert:bq-design-tableDesign a table schema with partitioning, clustering, and data types
/bigquery-expert:bq-estimate-costEstimate the cost of a query or table
/bigquery-expert:bq-explainExplain 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

Agents run autonomously across your project when you ask naturally:

AgentUse 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?"

Anti-Pattern Detection

The query optimization skill detects 11 BigQuery SQL anti-patterns:

#PatternFixSeverity
1SELECT * on single-table querySpecify only needed columnsHigh
2IN/NOT IN without DISTINCTAdd DISTINCT to subqueryMedium
3CTE referenced multiple timesConvert to CREATE TEMP TABLEHigh
4ORDER BY without LIMITAdd LIMIT clauseMedium
5REGEXP_CONTAINS for simple patternsUse LIKE insteadLow
6ROW_NUMBER() + WHERE rn = 1Use ARRAY_AGG(... LIMIT 1)High
7Subquery inside WHEREExtract to DECLARE variable or CTEMedium
8WHERE predicates not ordered by selectivityReorder by operator cost (advisory)Low
9Smaller table first in JOINPlace largest table first (advisory)Low
10CREATE TEMP TABLE without DROPAdd DROP TABLE at end of scriptLow
11CREATE TABLE + DROP TABLE in same scriptUse CREATE TEMP TABLE insteadLow

Based on BigQuery Anti-Pattern Recognition by Google Cloud Platform (Apache 2.0).

Example: Before and After

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):

SELECT event.*
FROM (
  SELECT ARRAY_AGG(
    t ORDER BY t.fare DESC LIMIT 1
  )[OFFSET(0)] event
  FROM `bigquery-public-data.chicago_taxi_trips.taxi_trips` t
  GROUP BY t.taxi_id
)

Plugin Contents

skills/
  bigquery-optimization/       11 anti-pattern references
  bigquery-query-generation/   Schema-aware generation, common patterns, dialect conversion
  bigquery-schema-design/      Partitioning, clustering, nested fields, denormalization, types
  bigquery-cost-optimization/  Pricing, bytes-billed, slots, materialized views, storage
  bigquery-features/           STRUCT/ARRAY, MERGE, scripting, JSON, geo, BQML, vector search
commands/
  bq-generate, bq-review, bq-optimize, bq-design-table, bq-estimate-cost, bq-explain
agents/
  bq-reviewer, bq-schema-advisor, bq-cost-analyzer

Uninstall

/plugin uninstall bigquery-expert@justvinhhere-bigquery-expert
/plugin marketplace remove justvinhhere-bigquery-expert

Contributing

Contributions welcome. Fork the repository, create a feature branch, and submit a pull request.

For bugs and feature requests, open an issue.

License

Apache License 2.0 -- see LICENSE for details.