Agent skill
mozilla-query-writing
Write efficient BigQuery queries for Mozilla telemetry. Use when user asks about: Firefox DAU/MAU, telemetry queries, BigQuery Mozilla, baseline_clients, events_stream, search metrics, user counts, or Firefox data analysis.
Install this agent skill to your Project
npx add-skill https://github.com/akkomar/mozdata-claude-plugin/tree/main/skills/query-writing
SKILL.md
Mozilla BigQuery Query Writing
You help users write efficient, cost-effective BigQuery queries for Mozilla telemetry data.
Knowledge References
@knowledge/data-catalog.md @knowledge/query-writing.md @knowledge/architecture.md
Critical Constraints
- ALWAYS check for aggregate tables before suggesting raw tables
- NEVER generate queries without partition filters (DATE(submission_timestamp) or submission_date)
- NEVER call DAU/MAU counts "users" - use "clients" or "profiles"
- NEVER suggest joining across products by client_id (separate namespaces)
- ALWAYS include sample_id filter for development/testing queries
- ALWAYS use events_stream for event queries (never raw events_v1)
- ALWAYS use baseline_clients_last_seen for MAU calculations
Table Selection Quick Reference
ALWAYS start from the top of this hierarchy:
| Query Type | Best Table | Speedup |
|---|---|---|
| DAU/MAU by standard dimensions | {product}_derived.active_users_aggregates_v3 |
100x |
| DAU with custom dimensions | {product}.baseline_clients_daily |
100x |
| MAU/WAU/retention | {product}.baseline_clients_last_seen |
28x |
| Event analysis | {product}.events_stream |
30x |
| Mobile search | search.mobile_search_clients_daily_v2 |
45x |
| Specific Glean metric | {product}.metrics |
1x (raw) |
Required Filters
Aggregate tables (use DATE):
WHERE submission_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
Raw ping tables (use TIMESTAMP):
WHERE DATE(submission_timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
Development queries (add sample_id):
AND sample_id = 0 -- 1% sample
Workflow
-
Identify query type - What does the user want to measure?
- User counts (DAU/MAU/WAU)?
- Specific Glean metric?
- Event analysis?
- Search metrics?
-
Select optimal table using the hierarchy above
-
Verify table exists using DataHub MCP if needed:
mcp__dataHub__search(query="/q {table_name}", filters={"entity_type": ["dataset"]}) -
Add required filters:
- Partition filter (DATE or TIMESTAMP based on table)
- sample_id for development
- Channel/country/OS as needed
-
Write the query following templates in knowledge/query-writing.md
-
Execute the query if BigQuery MCP tools are available (
mcp__bigquery__*):- Offer to run the query for the user after writing it
- Use
mcp__bigquery__execute_sqlto execute queries directly - Use
mcp__bigquery__get_table_infoto inspect table schemas - Use
mcp__bigquery__list_dataset_ids/mcp__bigquery__list_table_idsto explore available data - Always include partition filters and sample_id in executed queries
- If the tools are not available, provide the query for the user to run manually
Response Format
- Table Choice: Which table and why (include speedup factor)
- Performance Note: Cost and speed implications
- Query: Complete, runnable SQL with proper filters
- Customization: How to modify for specific needs
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
airflow-debugging
Investigate Mozilla Airflow DAG failures. Use when user asks about: failed DAGs, Airflow task logs, DAG run errors, bqetl failures, telemetry-airflow issues, or data pipeline debugging.
mozilla-probe-discovery
Find Mozilla telemetry probes and Glean metrics. Use when user asks about: Firefox metrics, Glean probes, telemetry data, accessibility probes, search metrics, or any Mozilla product instrumentation.
scaffold-exercises
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
obsidian-vault
Search, create, and manage notes in the Obsidian vault with wikilinks and index notes. Use when user wants to find, create, or organize notes in Obsidian.
edit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
handoff
Compact the current conversation into a handoff document for another agent to pick up.
Didn't find tool you were looking for?