Skip to content
Back to skills

Snowflake Development

ASecurity

Review Snowflake SQL for pruning and join problems, size warehouses and cut credit spend. Use when a Snowflake query is slow or expensive, or when sizing or reviewing warehouses.

  • 1,271 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 30, 2026
ai-agentspythongobashsqldatabaseperformancedocumentation

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add borghei/Claude-Skills --skill snowflake-development --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Snowflake Development?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Snowflake Development
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/borghei-snowflake-development/badge)](https://www.skillsdirectory.com/skills/borghei-snowflake-development)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: snowflake-development
description: >
  Review Snowflake SQL for pruning and join problems, size warehouses and cut credit spend.
  Use when a Snowflake query is slow or expensive, or when sizing or reviewing warehouses.
license: MIT + Commons Clause
metadata:
  version: 1.0.0
  author: borghei
  category: engineering
  domain: data-warehouse
  updated: 2026-11-08
  tags: [snowflake, sql, data-warehouse, query-optimization, warehouse-sizing]
---

# Snowflake Development

> **Category:** Engineering
> **Domain:** Data Warehouse

## Overview

The **Snowflake Development** skill provides tools for analyzing and optimizing Snowflake SQL queries, recommending warehouse sizing, and enforcing Snowflake-specific best practices. Helps data engineers reduce costs and improve query performance.

## When to Use

- A Snowflake query is slow or a warehouse bill jumped and you need the likely causes.
- Sizing a new warehouse for an ETL, BI, ad-hoc, data-science or ingest workload.
- Reviewing SQL or a data model before it goes into a scheduled pipeline.

For other databases use `sql-database-assistant`; for pipeline orchestration use `senior-data-engineer`.

## Clarify First

Before analyzing or sizing, settle the inputs below. When one is missing or vague and would change the result, ask about it; the script will not guess: warehouse sizing exits 2 without a workload and data volume, and shows no cost without hours and credit price.

- **Action:** analyze or warehouse-sizing (`--action`; `optimize` is accepted as an alias of `analyze` and gives identical output).
- **SQL file or query:** the specific query(ies) to optimize (`--file`; the subject of the analysis).
- **Workload type & data volume:** ETL / BI / ad-hoc and the GB scale (`--workload`/`--data-volume`; drives the warehouse recommendation).

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, run what the supplied inputs allow and say what is missing.

## Quick Start

```bash
# Review a Snowflake SQL file (the bundled flawed sample reports 5 findings, exit 1)
python3 scripts/snowflake_query_helper.py --file assets/sample_queries.sql --action analyze

# Size a warehouse; cost appears only when you give both hours and your contract credit price
python3 scripts/snowflake_query_helper.py --action warehouse-sizing --workload etl --data-volume 500GB --hours 4 --credit-price 3
```

Real output of the first command (abridged):

```text
Read 2 statement(s); 0 fragment(s) not recognised as SQL.

Statement 1: SELECT *
  [HIGH] line 2: SELECT * reads every column  (select-star)
    > SELECT *
    fix: List the columns you use: SELECT <col1>, <col2> FROM ...
  [HIGH] line 4: CROSS JOIN or always-true join condition  (cartesian-join)
    > JOIN analytics.customers c ON 1 = 1
...
FIX 5 issues
```

Real output of the second command (abridged):

```text
Recommended size: Medium (4 credits/hour)
Daily cost: $48.0 (4.0 h x 4 credits x $3.0/credit)
```

Without `--hours` and `--credit-price` it prints `Warning: No cost shown: pass both --hours and --credit-price (your contract price).` and shows no cost.

## Tools Overview

| Tool | Purpose | Key Flags |
|------|---------|-----------|
| `snowflake_query_helper.py` | Analyze, optimize Snowflake SQL and recommend warehouse sizes | `--file`/`--sql`, `--action analyze/warehouse-sizing` (`optimize` = alias of `analyze`), `--workload`, `--data-volume`, `--hours`, `--credit-price`, `--format text/json` |

Exit codes: `0` clean (sizing computed, or no findings); `1` findings reported; `2` unusable input (missing file, no SQL, no workload/volume, unparsable volume).

## Workflows

### Query Performance Optimization
1. Collect the expensive queries with real numbers (needs access to the `SNOWFLAKE.ACCOUNT_USAGE` share; it lags by up to about 45 minutes):
   ```sql
   SELECT query_id, warehouse_name, total_elapsed_time / 1000 AS seconds,
          bytes_scanned, partitions_scanned, partitions_total, query_text
   FROM snowflake.account_usage.query_history
   WHERE start_time >= DATEADD(day, -7, CURRENT_TIMESTAMP())
     AND execution_status = 'SUCCESS'
   ORDER BY total_elapsed_time DESC
   LIMIT 20;
   ```
2. Run the analyzer on those query texts for pattern-level fixes (SELECT *, functions on filter columns, always-true joins).
3. For each query, open the Query Profile: the real evidence is partitions scanned vs total, spilling to local/remote storage, and the most expensive operator. Prefer it over the script whenever they disagree.
4. Apply the change and verify against the same metrics before/after; done when elapsed time or bytes scanned fell on the same input.

### Warehouse Right-Sizing
1. Identify workload type (ETL, BI, ad-hoc, etc.)
2. Run warehouse-sizing with data volume
3. Review recommendations
4. Implement multi-cluster settings if applicable

## Scope & Limitations

**In Scope:**
- Rule-based review of Snowflake SQL from a file or `--sql` text with `snowflake_query_helper.py --action analyze` (`optimize` is an alias with identical output). Each finding quotes the line and gives a concrete fix.
- Warehouse sizing for five workload types (etl, bi, ad-hoc, data-science, ingest) from a data volume, with credits per hour, a daily cost only when you pass `--hours` and `--credit-price`, and a `CREATE WAREHOUSE` statement.
- Query, warehouse, cost and data modeling practices in `references/snowflake-best-practices.md`.

**Out of Scope:**
- Connecting to Snowflake, reading query history or query profiles, or running any statement.
- SQL work for other databases (see `engineering/sql-database-assistant/`).
- Building and orchestrating data pipelines (see `engineering/senior-data-engineer/`).
- Access control, governance and data sharing setup.

**Important Caveats:**
- Analysis matches patterns in SQL text. It does not see execution plans, table sizes or clustering, so it misses issues that only show at run time.
- Sizing comes from a fixed table of data volume and concurrency limits. It is a starting point to adjust with observed query performance.
- No cost is shown unless you pass both `--hours` and `--credit-price`; the script has no default price or hours. Credit prices depend on edition, region and contract, and Snowflake features and pricing change over time.

## Reference Documentation

- [Snowflake Best Practices](references/snowflake-best-practices.md) - Query patterns, warehouse management, cost optimization

## Common Patterns

### Cost Reduction
- Right-size warehouses (don't use XL for small queries)
- Set auto-suspend to 60 seconds for ad-hoc warehouses
- Use materialized views for frequently accessed aggregations
- Let Snowflake's automatic micro-partitioning do its job; add a clustering key only to very large tables (multi-terabyte) whose frequent filters scan most partitions (`partitions_scanned` close to `partitions_total`), and check `SYSTEM$CLUSTERING_INFORMATION` first, since automatic reclustering costs credits
- Avoid SELECT * in production queries

## Anti-Patterns

### Sizing Up to Fix a Slow Query
**Mistake:** Moving a slow query to a larger warehouse without reading its profile.
**Why it happens:** It is one setting and often helps a little.
**Instead:** Check the Query Profile first. Poor pruning or a bad join is not fixed by more compute; spilling to remote storage is the case where a larger size usually pays for itself.

### Clustering Every Large Table
**Mistake:** Adding clustering keys as routine "partitioning".
**Why it happens:** Other warehouses need explicit partitioning.
**Instead:** Snowflake micro-partitions automatically. Cluster only when a frequent filter on a very large table scans most partitions, and watch the reclustering credits.

### Warehouses That Never Sleep
**Mistake:** Leaving `AUTO_SUSPEND` at hours or disabled on ad-hoc and BI warehouses.
**Why it happens:** Users dislike the resume delay.
**Instead:** Suspend after 60-300 seconds; resume takes seconds while idle compute bills every second it runs.

## Files

| File | Purpose |
|------|---------|
| `scripts/snowflake_query_helper.py` | SQL pattern analysis and warehouse sizing |
| `assets/sample_queries.sql` | Two queries with deliberate problems (5 findings, exit 1) |
| `assets/sound_queries.sql` | Clean queries (exit 0) |
| `assets/flawed_queries.sql` | Queries with several problems (exit 1) |
| `assets/malformed_queries.sql` | Not SQL (exit 2) |
| `assets/contract.json` | Commands and expected exit codes run by `scripts/skill_contract_check.py` |
| `references/snowflake-best-practices.md` | Query, warehouse, cost and modelling practices |

Files in this skill

  • SKILL.md2.3 KB
  • references/snowflake-best-practices.md3.7 KB
  • scripts/snowflake_query_helper.py19.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.