Agent skill

Optimizing Query By Id

by AltimateAI in AltimateAI/data-engineering-skills

Optimizes Snowflake query performance using query ID from history.

MITAuto-check passedDatabases

Install Optimizing Query By Id

skills CLI
$ npx skills add AltimateAI/data-engineering-skills --skill optimizing-query-by-id -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install AltimateAI/data-engineering-skills optimizing-query-by-id --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/AltimateAI/data-engineering-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/snowflake/optimizing-query-by-id .claude/skills/optimizing-query-by-id && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
optimizing-query-by-id
GitHub stars
127
Token cost
~919 tokens
SKILL.md length
282 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Optimizes Snowflake query performance using query ID from history.

  • Works in 7 steps: Fetch Query Details from Query ID → Get Query Profile Details → Identify Optimization Opportunities → …
  • Optimizing Snowflake queries for:
  • SKILL.md covers Workflow and Example Output
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Optimizing Query By Id is an agent skill from AltimateAI/data-engineering-skills. Optimizes Snowflake query performance using query ID from history. Use when optimizing Snowflake queries for: (1) User provides a Snowflake queryid (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…

Its SKILL.md is about 920 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Query optimization, Data warehousing and Data pipelines and ETL. It works with Snowflake and SQL. The repository describes itself as: Skills related to Data Engineering Work for Claude Code. The licence is MIT.

When your agent uses it

  • Optimizing Snowflake queries for:
  • User provides a Snowflake queryid (UUID format) to analyze
  • Task mentions slow query
  • Query profile with a query ID

Example prompts

  • “slow query”
  • “optimize”
  • “query history”
  • “/optimizing-query-by-id”

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Fetch Query Details from Query ID
  2. Get Query Profile Details
  3. Identify Optimization Opportunities
  4. Apply Optimizations
  5. Get Explain Plan for Optimized Query
  6. Compare Plans
  7. Return Results

What it can do on your machine

Read from SKILL.md and the folder at commit 705c68b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Optimizing Query By Id loads about 919 tokens when it runs. Until then it costs about 138 tokens; SKILL.md has 282 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~138
When it runs · the whole SKILL.md, loaded when a task matches
~919

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from AltimateAI/data-engineering-skills at commit 705c68b, republished under its MIT licence (© AltimateAI). 282 words, ~919 tokens.

Download SKILL.mdSave it as .claude/skills/optimizing-query-by-id/SKILL.md (or your agent's skills folder).
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.

Optimize Query from Query ID

Fetch query → Get profile → Apply best practices → Verify improvement → Return optimized query

Workflow

1. Fetch Query Details from Query ID
sql
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:

  • seconds: Total execution time
  • gb_scanned: Data read (lower is better)
  • gb_spilled: Spillage indicates memory pressure
  • partitions_scanned/total: Partition pruning effectiveness
2. Get Query Profile Details
sql
-- Get operator-level statistics
SELECT *
FROM TABLE(GET_QUERY_OPERATOR_STATS('<query_id>'));

Look for:

  • Operators with high output_rows vs input_rows (explosions)
  • TableScan operators with high bytes
  • Sort/Aggregate operators with spillage
3. Identify Optimization Opportunities

Based on profile, look for:

MetricIssueFix
partitions_scanned = partitions_totalNo pruningAdd filter on cluster key
gb_spilled > 0Memory pressureSimplify query, increase warehouse
High bytes_scannedFull scanAdd selective filters, reduce columns
Join explosionCartesian or bad keyFix join condition, filter before join
4. Apply Optimizations

Rewrite the query:

  • Select only needed columns
  • Filter early (before joins)
  • Use CTEs to avoid repeated scans
  • Ensure filters align with clustering keys
  • Add LIMIT if full result not needed
5. Get Explain Plan for Optimized Query
sql
EXPLAIN USING JSON
<optimized_query>;
6. Compare Plans

Compare original vs optimized:

  • Fewer partitions scanned?
  • Fewer intermediate rows?
  • Better join order?
7. Return Results

Provide:

  1. Original query metrics (time, data scanned, spillage)
  2. Identified issues
  3. The optimized query
  4. Summary of changes made
  5. Expected improvement

Example Output

Original Query Metrics:

  • Execution time: 45 seconds
  • Data scanned: 12.3 GB
  • Partitions: 500/500 (no pruning)
  • Spillage: 2.1 GB

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:

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

  • Added date range filter matching cluster key
  • Replaced SELECT * with specific columns
  • Pre-filtered in CTE before join

Expected Improvement:

  • Partitions: 500 → ~15 (97% reduction)
  • Data scanned: 12.3 GB → ~0.4 GB
  • Estimated time: 45s → ~3s

© AltimateAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/snowflake/optimizing-query-by-id of AltimateAI/data-engineering-skills.

Open the folder on GitHubat commit 705c68b

Compare with similar skills

Optimizing Query By Id next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Optimizing Query By Id compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Optimizing Query By Id this skillAltimateAI/data-engineering-skills127—~919Automated safety check: PassMIT
Snowflake Developmentsickn33/agentic-awesome-skills47k2 repos~2.1kAutomated safety check: PassMIT
Snowflake Developmentalirezarezvani/claude-skills28k—~3.2kAutomated safety check: PassMIT
Uipath Process MiningUiPath/skills166—~4.3kAutomated safety check: NotesMIT
Snowflake Data EngineeringMindrally/skills267—~2.3kAutomated safety check: PassApache-2.0
Analyzing Dataastronomer/agents450—~1.3kAutomated safety check: PassApache-2.0

Similar skills

  • Snowflake Development

    sickn33/agentic-awesome-skills

    Comprehensive Snowflake development assistant covering SQL best practices, data pipeline design (Dynamic Tables, Streams, Tasks, Snowpipe), Cortex AI functions, Cortex Agents, Snowpark Python, dbt…

    47k GitHub starsUsed in 2 repos~2.1k tokens
    DatabasesAuto-check passed
  • Snowflake Development

    alirezarezvani/claude-skills

    A skill your agent uses when writing Snowflake SQL, building data pipelines with Dynamic Tables or Streams/Tasks, using Cortex AI functions, creating Cortex Agents, writing Snowpark Python…

    28k GitHub stars~3.2k tokensUpdated 1 mo ago
    DatabasesAuto-check passed
  • UiPath Process Mining via uip pm — build and operate a process app end-to-end from a CSV / event log: templates, data mapping, upload, ingest, the dbt (Snowflake) transformation layer, publish, and…

    166 GitHub stars~4.3k tokensUpdated today
    DatabasesAuto-check: notes
  • Best practices for Snowflake SQL, semi-structured data, and data pipelines built with Dynamic Tables, Streams, Tasks, and Snowpipe.

    267 GitHub stars~2.3k tokensUpdated 1 mo ago
    DatabasesAuto-check passed
  • Analyzing Data

    astronomer/agents

    Queries the data warehouse with SQL and answers business questions about data.

    450 GitHub stars~1.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Modeler

    sidequery/sidemantic

    Build, validate, and manage semantic models using Sidemantic.

    129 GitHub stars~4.2k tokensUpdated today
    DatabasesAuto-check passed

More from AltimateAI/data-engineering-skills

All 12 skills in this repo
  • Altimate Data Warehouse Delegate

    AltimateAI/data-engineering-skills

    Delegates dbt and warehouse tasks such as lineage, migrations and cost attribution to the altimate-code CLI agent and relays its answer back.

    127 GitHub stars~1.4k tokensUpdated 5 days ago
    Auto-check passed
  • dbt Model Builder

    AltimateAI/data-engineering-skills

    Creates or modifies dbt models in line with a project's own conventions, then runs dbt build and dbt show to check the output instead of stopping at compile.

    127 GitHub stars~890 tokensUpdated 5 days ago
    Auto-check passed
  • dbt Error Debugging

    AltimateAI/data-engineering-skills

    Walks through fixing dbt compilation, database and test errors: read the full error, check upstream models, apply a fix, then verify with dbt build and a data preview.

    127 GitHub stars~1.1k tokensUpdated 5 days ago
    Auto-check passed
  • dbt Incremental Models

    AltimateAI/data-engineering-skills

    Helps choose an incremental strategy, design a reliable unique_key and debug failing dbt incremental models, and says when a plain table is the better choice.

    127 GitHub stars~2.3k tokensUpdated 5 days ago
    Auto-check passed
  • dbt Model Documentation

    AltimateAI/data-engineering-skills

    Writes model and column descriptions in dbt schema.yml files, matching the project's existing documentation style and recording grain, business rules and caveats.

    127 GitHub stars~1.2k tokensUpdated 5 days ago
    Auto-check passed
  • Expensive Snowflake Query Finder

    AltimateAI/data-engineering-skills

    Ranks the costliest, slowest or heaviest-scanning Snowflake queries from query history and suggests how to optimize them.

    127 GitHub stars~662 tokensUpdated 5 days ago
    Auto-check passed

Works with

Categories

Questions about Optimizing Query By Id

What does Optimizing Query By Id do?

Optimizes Snowflake query performance using query ID from history. Optimizing Query By Id is an agent skill from AltimateAI/data-engineering-skills. Optimizes Snowflake query performance using query ID from history.

When should I use Optimizing Query By Id?

Optimizing Query By Id fits situations like: optimizing Snowflake queries for:; user provides a Snowflake queryid (UUID format) to analyze; task mentions slow query; query profile with a query ID.

How do I install Optimizing Query By Id in Claude Code?

Run `npx skills add AltimateAI/data-engineering-skills --skill optimizing-query-by-id -a claude-code`. Or copy the skill folder (skills/snowflake/optimizing-query-by-id in AltimateAI/data-engineering-skills) into .claude/skills/optimizing-query-by-id in your project. Claude Code loads it when a task matches its description.

How do I install Optimizing Query By Id in Codex?

Run `npx skills add AltimateAI/data-engineering-skills --skill optimizing-query-by-id -a codex`. Or copy the skill folder (skills/snowflake/optimizing-query-by-id in AltimateAI/data-engineering-skills) into .agents/skills/optimizing-query-by-id in your project. Codex loads it when a task matches its description.

Can I use Optimizing Query By Id in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add AltimateAI/data-engineering-skills --skill optimizing-query-by-id -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimizing-query-by-id, .gemini/skills/optimizing-query-by-id, .github/skills/optimizing-query-by-id and .opencode/skills/optimizing-query-by-id in your project.

What does Optimizing Query By Id need to run?

SKILL.md names no scripts, command-line tools or credentials: Optimizing Query By Id is instructions for the agent only.

Does Optimizing Query By Id access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Optimizing Query By Id safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Optimizing Query By Id use?

Optimizing Query By Id is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Optimizing Query By Id use?

About 919 tokens (SKILL.md is roughly 3.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Optimizing Query By Id?

Skills that share tags, products or a category with Optimizing Query By Id: Snowflake Development (sickn33/agentic-awesome-skills, 47k stars), Snowflake Development (alirezarezvani/claude-skills, 28k stars), Uipath Process Mining (UiPath/skills, 166 stars) and Snowflake Data Engineering (Mindrally/skills, 267 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Optimizing Query By Id?

AltimateAI (a GitHub organization) maintains it in AltimateAI/data-engineering-skills, which has 127 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 1, 2026.

Source: AltimateAI/data-engineering-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.