altimate-code
Delegates dbt and warehouse work to altimate-code, a specialized CLI agent with 100+ purpose-built data tools. USE THIS SKILL…
Optimizes Snowflake query performance using query ID from history. Use when optimizing Snowflake queries for: (1) User provides a Snowflake query_id (UUID format) to analyze or optimize (2) Task mentions "slow query", "optimize", "query history", or "query profile" with a query
$ npx -y skills add AltimateAI/data-engineering-skills --skill optimizing-query-by-id --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/optimizing-query-by-idContext preview
The summary Claude sees to decide when to auto-load this skill.
Optimizes Snowflake query performance using query ID from history. Use when optimizing Snowflake queries for: (1) User provides a Snowflake query_id (UUID format) to analyze or optimize (2) Task mentions "slow query", "optimize", "query history", or "query profile" with a query
name: optimizing-query-by-id description: | Optimizes Snowflake query performance using query ID from history. Use when optimizing Snowflake queries for: (1) User provides a Snowflake query_id (UUID format) to analyze or optimize (2) Task mentions "slow query", "optimize", "query history", or "query profile" with a query ID (3) Analyzing query performance metrics - bytes scanned, spillage, partition pruning (4) User references a previously run query that needs optimization Fetches query profile, identifies bottlenecks, returns optimized SQL with expected improvements.
**Fetch query → Get profile → Apply best practices → Verify improvement → Return optimized query**
SELECT
query_id,
query_text,
total_elapsed_time/1000 as seconds,
bytes_scanned/1e9 as gb_scanned,
bytes_spilled_to_local_storage/1e9 as gb_spilled_local,
bytes_spilled_to_remote_storage/1e9 as gb_spilled_remote,
partitions_scanned,
partitions_total,
rows_produced
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY())
WHERE query_id = '<query_id>';Note the key metrics:
-- Get operator-level statistics
SELECT *
FROM TABLE(GET_QUERY_OPERATOR_STATS('<query_id>'));Look for:
Based on profile, look for:
| Metric | Issue | Fix | |--------|-------|-----| | partitions_scanned = partitions_total | No pruning | Add filter on cluster key | | gb_spilled > 0 | Memory pressure | Simplify query, increase warehouse | | High bytes_scanned | Full scan | Add selective filters, reduce columns | | Join explosion | Cartesian or bad key | Fix join condition, filter before join |
Rewrite the query:
EXPLAIN USING JSON <optimized_query>;
Compare original vs optimized:
Provide: 1. Original query metrics (time, data scanned, spillage) 2. Identified issues 3. The optimized query 4. Summary of changes made 5. Expected improvement
**Original Query Metrics:**
**Issues Found:** 1. No partition pruning - filtering on non-cluster column 2. SELECT * scanning unnecessary columns 3. Large table joined without pre-filtering
**Optimized Query:**
WITH filtered_events AS (
SELECT event_id, user_id, event_type, created_at
FROM events
WHERE created_at >= '2024-01-01'
AND created_at < '2024-02-01'
AND event_type = 'purchase'
)
SELECT fe.event_id, fe.created_at, u.name
FROM filtered_events fe
JOIN users u ON fe.user_id = u.id;**Changes:**
**Expected Improvement:**
Claude Code skills for Analytics & Data engineers working with dbt and Snowflake Altimate Data Skills is a collection of Claude Code skills that encode the workflows and best practices of experienced analytics engineers.
Delegates dbt and warehouse work to altimate-code, a specialized CLI agent with 100+ purpose-built data tools. USE THIS SKILL…
Analyze DBSQL queries, including SQL embedded in notebooks (`spark.sql(...)`, `%sql` cells), for anti-patterns, lint issues, and…
Creates dbt models following project conventions. Use when working with dbt models for: (1) Creating new models (any layer -…
Debugs and fixes dbt errors systematically. Use when working with dbt errors for: (1) Task mentions "fix", "error", "broken",…
Develops and troubleshoots dbt incremental models. Use when working with incremental materialization for: (1) Creating new…
Documents dbt models and columns in schema.yml. Use when working with dbt documentation for: (1) Adding model descriptions or…