一键导入
bigquery
Query and manage Google BigQuery datasets using the bq CLI and REST API. Run SQL queries, export results, manage tables and datasets in BigQuery.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Query and manage Google BigQuery datasets using the bq CLI and REST API. Run SQL queries, export results, manage tables and datasets in BigQuery.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Eliminate AI-sounding patterns from any written output. Applies editorial rules synthesized from the best open-source anti-slop tools: banned phrases, structural pattern detection, false agency checks, and a scoring rubric. Use as a quality gate for ANY content — blog posts, social media, emails, documentation, marketing copy. Triggers on: "make it sound human", "less AI", "remove slop", "humanize this", "doesn't sound natural", "too AI", "rewrite naturally", or when reviewing any AI-generated text before publishing.
AWS Bedrock AgentCore comprehensive expert for deploying and managing all AgentCore services. Use when working with Gateway, Runtime, Memory, Identity, or any AgentCore component. Covers MCP target deployment, credential management, schema optimization, runtime configuration, memory management, and identity services.
AWS Cloud Development Kit (CDK) expert for building cloud infrastructure with TypeScript/Python. Use when creating CDK stacks, defining CDK constructs, implementing infrastructure as code, or when the user mentions CDK, CloudFormation, IaC, cdk synth, cdk deploy, or wants to define AWS infrastructure programmatically. Covers CDK app structure, construct patterns, stack composition, and deployment workflows.
This skill provides AWS cost optimization, monitoring, and operational best practices with integrated MCP servers for billing analysis, cost estimation, observability, and security assessment.
AWS serverless and event-driven architecture expert based on Well-Architected Framework. Use when building serverless APIs, Lambda functions, REST APIs, microservices, or async workflows. Covers Lambda with TypeScript/Python, API Gateway (REST/HTTP), DynamoDB, Step Functions, EventBridge, SQS, SNS, and serverless patterns. Essential when user mentions serverless, Lambda, API Gateway, event-driven, async processing, queues, pub/sub, or wants to build scalable serverless applications with AWS best practices.
A comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems. Use when building, optimizing, or debugging agent systems that require effective context management.
| name | bigquery |
| description | Query and manage Google BigQuery datasets using the bq CLI and REST API. Run SQL queries, export results, manage tables and datasets in BigQuery. |
| version | 1.0.0 |
| allowed-tools | Bash |
| metadata | {"credentials":["GOOGLE_APPLICATION_CREDENTIALS_JSON","BIGQUERY_PROJECT_ID"]} |
Query and manage Google BigQuery datasets using the bq CLI tool and REST API.
# Run a query
bq query --use_legacy_sql=false --format=json \
'SELECT count(*) as total FROM `project.dataset.table`'
# List datasets
bq ls --project_id="$BIGQUERY_PROJECT_ID"
| Variable | Description | Example |
|---|---|---|
GOOGLE_APPLICATION_CREDENTIALS_JSON | Service account JSON key | {"type":"service_account","project_id":"my-project",...} |
BIGQUERY_PROJECT_ID | GCP project ID (optional if in credentials) | my-project-123 |
The bq CLI authenticates via service account. Write the credentials to a file and set the path:
# Write credentials to file
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /tmp/gcp-sa.json
export GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcp-sa.json
# Verify access
bq ls --project_id="$BIGQUERY_PROJECT_ID"
If bq is not installed, use BigQuery REST API directly with curl:
# Get access token from service account
ACCESS_TOKEN=$(python3 -c "
import json, time, base64, hashlib, urllib.request
sa = json.loads('''$GOOGLE_APPLICATION_CREDENTIALS_JSON''')
import jwt
token = jwt.encode({
'iss': sa['client_email'],
'scope': 'https://www.googleapis.com/auth/bigquery',
'aud': 'https://oauth2.googleapis.com/token',
'iat': int(time.time()),
'exp': int(time.time()) + 3600
}, sa['private_key'], algorithm='RS256')
data = urllib.parse.urlencode({'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion': token}).encode()
resp = json.loads(urllib.request.urlopen('https://oauth2.googleapis.com/token', data).read())
print(resp['access_token'])
")
# Query via REST API
curl -X POST \
"https://bigquery.googleapis.com/bigquery/v2/projects/$BIGQUERY_PROJECT_ID/queries" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "SELECT count(*) as total FROM `dataset.table`",
"useLegacySql": false
}'
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /tmp/gcp-sa.json
export GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcp-sa.json
bq query --use_legacy_sql=false --format=json \
'SELECT * FROM `my_dataset.users` LIMIT 10'
bq query --use_legacy_sql=false --format=json \
--parameter='name:STRING:John' \
'SELECT * FROM `my_dataset.users` WHERE name = @name'
bq ls --project_id="$BIGQUERY_PROJECT_ID" --format=json
bq ls --format=json "$BIGQUERY_PROJECT_ID:my_dataset"
bq show --format=json "$BIGQUERY_PROJECT_ID:my_dataset.users"
bq head --max_rows=10 "$BIGQUERY_PROJECT_ID:my_dataset.users"
bq query --use_legacy_sql=false --format=json \
'SELECT count(*) as total FROM `my_dataset.users`'
bq query --use_legacy_sql=false --format=csv \
'SELECT * FROM `my_dataset.users` LIMIT 1000' > users.csv
bq query --use_legacy_sql=false --format=json \
'SELECT * FROM `my_dataset.users` LIMIT 1000' > users.json
# Export to Google Cloud Storage
bq extract --destination_format=CSV \
"$BIGQUERY_PROJECT_ID:my_dataset.users" \
"gs://my-bucket/exports/users-*.csv"
# Download from GCS
gsutil cp "gs://my-bucket/exports/users-*.csv" ./
bq load --source_format=CSV --autodetect \
"$BIGQUERY_PROJECT_ID:my_dataset.new_table" \
./data.csv
bq load --source_format=NEWLINE_DELIMITED_JSON --autodetect \
"$BIGQUERY_PROJECT_ID:my_dataset.new_table" \
./data.jsonl
bq mk --dataset "$BIGQUERY_PROJECT_ID:my_new_dataset"
bq mk --table "$BIGQUERY_PROJECT_ID:my_dataset.users" \
name:STRING,email:STRING,age:INTEGER,created_at:TIMESTAMP
bq query --use_legacy_sql=false \
--destination_table="$BIGQUERY_PROJECT_ID:my_dataset.active_users" \
'SELECT * FROM `my_dataset.users` WHERE last_login > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)'
bq cp "$BIGQUERY_PROJECT_ID:dataset.source_table" \
"$BIGQUERY_PROJECT_ID:dataset.destination_table"
bq rm -f -t "$BIGQUERY_PROJECT_ID:my_dataset.old_table"
bq query --use_legacy_sql=false --format=json '
SELECT
DATE(event_timestamp) as date,
COUNT(DISTINCT user_id) as dau
FROM `my_dataset.events`
WHERE event_timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY date
ORDER BY date DESC
'
bq query --use_legacy_sql=false --format=json '
SELECT
page_path,
COUNT(*) as views,
COUNT(DISTINCT user_id) as unique_users
FROM `my_dataset.pageviews`
WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
GROUP BY page_path
ORDER BY views DESC
LIMIT 20
'
bq query --use_legacy_sql=false --format=json '
SELECT
FORMAT_DATE("%Y-%m", date) as month,
SUM(revenue) as total_revenue,
COUNT(DISTINCT customer_id) as customers
FROM `my_dataset.transactions`
GROUP BY month
ORDER BY month DESC
LIMIT 12
'
| Flag | Format | Best For |
|---|---|---|
--format=json | JSON array | Programmatic use, piping to jq |
--format=csv | CSV | Spreadsheets, further processing |
--format=pretty | Aligned table (default) | Human reading |
--format=sparse | Sparse output | Wide tables |
bq query --use_legacy_sql=false --format=json \
'SELECT name, email FROM `dataset.users` LIMIT 5' | jq '.[].name'
BigQuery Data Viewer (read) or BigQuery Data Editor (read/write)GOOGLE_APPLICATION_CREDENTIALS_JSON env varBIGQUERY_PROJECT_ID to your GCP project ID| Role | Permissions |
|---|---|
roles/bigquery.dataViewer | Read tables and run queries |
roles/bigquery.dataEditor | Read + write tables |
roles/bigquery.jobUser | Run query jobs (required for all queries) |
roles/bigquery.admin | Full access |
Minimum for read-only: bigquery.dataViewer + bigquery.jobUser
| Error | Cause | Solution |
|---|---|---|
Not found: Dataset | Dataset doesn't exist | Run bq ls to list available datasets |
Access Denied | Insufficient permissions | Check IAM roles, need at least dataViewer + jobUser |
Invalid credentials | Bad service account JSON | Verify GOOGLE_APPLICATION_CREDENTIALS_JSON is valid JSON |
Quota exceeded | Query size/frequency limit | Add LIMIT, use partitioned tables, check billing |
Resources exceeded | Query too large | Break into smaller queries, use LIMIT |
Table not found | Wrong project/dataset/table | Use fully qualified name: project.dataset.table |
bq: command not found | CLI not installed | Use REST API alternative above, or install Google Cloud SDK |
--use_legacy_sql=false — standard SQL is more readable and powerful--format=json for programmatic processing, pipe to jq for filteringLIMIT when exploring — BigQuery bills by data scanned, not rows returned--dry_run to check query cost before running: bq query --dry_run --use_legacy_sql=false 'SELECT ...'`project.dataset.table`LIMIT first