thiagofernandes1987-create/apex/snowflake-development
Claude Code and agent skill by thiagofernandes1987-create/apex
- community
Checking that the SKILL.md file is still in the repository.
Build — Use when writing Snowflake SQL, building data pipelines with Dynamic Tables or Streams/Tasks, using Cortex AI
Install
npx vskill@latest install thiagofernandes1987-create/apex/snowflake-developmentSKILL.md
The same SKILL.md was published earlier as thiagofernandes1987-create/apex/snowflake-development.
Snowflake Development
Snowflake SQL, data pipelines, Cortex AI, and Snowpark Python development. Covers the colon-prefix rule, semi-structured data, MERGE upserts, Dynamic Tables, Streams+Tasks, Cortex AI functions, agent specs, performance tuning, and security hardening.
Originally contributed by James Cha-Earley — enhanced and integrated by the claude-skills team.
Quick Start
SQL Best Practices
Naming and Style
- Use
snake_casefor all identifiers. Avoid double-quoted identifiers -- they force case-sensitive names that require constant quoting. - Use CTEs (
WITHclauses) over nested subqueries. - Use
CREATE OR REPLACEfor idempotent DDL. - Use explicit column lists -- never
SELECT *in production. Snowflake's columnar storage scans only referenced columns, so explicit lists reduce I/O.
Stored Procedures -- Colon Prefix Rule
In SQL stored procedures (BEGIN...END blocks), variables and parameters must use the colon : prefix inside SQL statements. Without it, Snowflake treats them as column identifiers and raises "invalid identifier" errors.
This applies to DECLARE variables, LET variables, and procedure parameters when used inside SELECT, INSERT, UPDATE, DELETE, or MERGE.
Semi-Structured Data
- VARIANT, OBJECT, ARRAY for JSON/Avro/Parquet/ORC.
- Access nested fields:
src:customer.name::STRING. Always cast with::TYPE. - VARIANT null vs SQL NULL: JSON
nullis stored as the string"null". UseSTRIP_NULL_VALUE = TRUEon load. - Flatten arrays:
SELECT f.value:name::STRING FROM my_table, LATERAL FLATTEN(input => src:items) f;
MERGE for Upserts
Seereferences/snowflake_sql_and_pipelines.mdfor deeper SQL patterns and anti-patterns.
Data Pipelines
Choosing Your Approach
| Approach | When to Use | |
|---|---|---|
| Dynamic Tables | Declarative transformations. Default choice. Define the query, Snowflake handles refresh. | |
| Streams + Tasks | Imperative CDC. Use for procedural logic, stored procedure calls, complex branching. | |
| Snowpipe | Continuous file loading from cloud storage (S3, GCS, Azure). |
Dynamic Tables
Key rules:
- Set
TARGET_LAGprogressively: tighter at the top of the DAG, looser downstream. - Incremental DTs cannot depend on Full-refresh DTs.
SELECT *breaks on upstream schema changes -- use explicit column lists.- Views cannot sit between two Dynamic Tables in the DAG.
Streams and Tasks
Seereferences/snowflake_sql_and_pipelines.mdfor DT debugging queries and Snowpipe patterns.
Cortex AI
Function Reference
| Function | Purpose | |
|---|---|---|
AI_COMPLETE | LLM completion (text, images, documents) | |
AI_CLASSIFY | Classify text into categories (up to 500 labels) | |
AI_FILTER | Boolean filter on text or images | |
AI_EXTRACT | Structured extraction from text/images/documents | |
AI_SENTIMENT | Sentiment score (-1 to 1) | |
AI_PARSE_DOCUMENT | OCR or layout extraction from documents | |
AI_REDACT | PII removal from text |
Deprecated names (do NOT use): COMPLETE, CLASSIFY_TEXT, EXTRACT_ANSWER, PARSE_DOCUMENT, SUMMARIZE, TRANSLATE, SENTIMENT, EMBED_TEXT_768.
TO_FILE -- Common Pitfall
Stage path and filename are separate arguments:
Cortex Agents
Agent specs use a JSON structure with top-level keys: models, instructions, tools, tool_resources.
- Use
$spec$delimiter (not$$). modelsmust be an object, not an array.tool_resourcesis a separate top-level key, not nested insidetools.- Tool descriptions are the single biggest factor in agent quality.
Seereferences/cortex_ai_and_agents.mdfor full agent spec examples and Cortex Search patterns.
Snowpark Python
- Never hardcode credentials. Use environment variables or key pair auth.
- DataFrames are lazy -- executed on
collect()/show(). - Do NOT call
collect()on large DataFrames. Process server-side with DataFrame operations. - Use vectorized UDFs (10-100x faster) for batch and ML workloads.
dbt on Snowflake
- Do NOT use
{{ this }}without{% if is_incremental() %}guard. - Use
dynamic_tablematerialization for streaming or near-real-time marts.
Performance
- Cluster keys: Only for multi-TB tables. Apply on WHERE / JOIN / GROUP BY columns.
- Search Optimization:
ALTER TABLE t ADD SEARCH OPTIMIZATION ON EQUALITY(col); - Warehouse sizing: Start X-Small, scale up. Set
AUTO_SUSPEND = 60,AUTO_RESUME = TRUE. - Separate warehouses per workload (load, transform, query).
Security
- Follow least-privilege RBAC. Use database roles for object-level grants.
- Audit ACCOUNTADMIN regularly:
SHOW GRANTS OF ROLE ACCOUNTADMIN; - Use network policies for IP allowlisting.
- Use masking policies for PII columns and row access policies for multi-tenant isolation.
Proactive Triggers
Surface these issues without being asked when you notice them in context:
- Missing colon prefix in SQL stored procedures -- flag immediately, this causes "invalid identifier" at runtime.
- `SELECT *` in Dynamic Tables -- flag as a schema-change time bomb.
- Deprecated Cortex function names (
CLASSIFY_TEXT,SUMMARIZE, etc.) -- suggest the currentAI_*equivalents. - Task not resumed after creation -- remind that tasks start SUSPENDED.
- Hardcoded credentials in Snowpark code -- flag as a security risk.
Common Errors
| Error | Cause | Fix | |
|---|---|---|---|
| "Object does not exist" | Wrong database/schema context or missing grants | Fully qualify names (db.schema.table), check grants | |
| "Invalid identifier" in procedure | Missing colon prefix on variable | Use :variable_name inside SQL statements | |
| "Numeric value not recognized" | VARIANT field not cast | Cast explicitly: src:field::NUMBER(10,2) | |
| Task not running | Forgot to resume after creation | ALTER TASK task_name RESUME; | |
| DT refresh failing | Schema change upstream or tracking disabled | Use explicit columns, verify change tracking | |
| TO_FILE error | Combined path as single argument | Split into two args: TO_FILE('@stage', 'file.pdf') |
Practical Workflows
Workflow 1: Build a Reporting Pipeline (30 min)
- Stage raw data: Create external stage pointing to S3/GCS/Azure, set up Snowpipe for auto-ingest
- Clean with Dynamic Table: Create DT with
TARGET_LAG = '5 minutes'that filters nulls, casts types, deduplicates - Aggregate with downstream DT: Second DT that joins cleaned data with dimension tables, computes metrics
- Expose via Secure View: Create
SECURE VIEWfor the BI tool / API layer - Grant access: Use
snowflake_query_helper.py grantto generate RBAC statements
Workflow 2: Add AI Classification to Existing Data
- Identify the column: Find the text column to classify (e.g., support tickets, reviews)
- Test with AI_CLASSIFY:
SELECT AI_CLASSIFY(text_col, ['bug', 'feature', 'question']) FROM table LIMIT 10; - Create enrichment DT: Dynamic Table that runs
AI_CLASSIFYon new rows automatically - Monitor costs: Cortex AI is billed per token — sample before running on full tables
Workflow 3: Debug a Failing Pipeline
- Check task history:
SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY()) WHERE STATE = 'FAILED' ORDER BY SCHEDULED_TIME DESC; - Check DT refresh:
SELECT * FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY('my_dt')) ORDER BY REFRESH_END_TIME DESC; - Check stream staleness:
SHOW STREAMS; -- check stale_after column - Consult troubleshooting reference: See
references/troubleshooting.mdfor error-specific fixes
Anti-Patterns
| Anti-Pattern | Why It Fails | Better Approach | |
|---|---|---|---|
SELECT * in Dynamic Tables | Schema changes upstream break the DT silently | Use explicit column lists | |
| Missing colon prefix in procedures | "Invalid identifier" runtime error | Always use :variable_name in SQL blocks | |
| Single warehouse for all workloads | Contention between load, transform, and query | Separate warehouses per workload type | |
| Hardcoded credentials in Snowpark | Security risk, breaks in CI/CD | Use os.environ[] or key pair auth | |
collect() on large DataFrames | Pulls entire result set to client memory | Process server-side with DataFrame operations | |
| Nested subqueries instead of CTEs | Unreadable, hard to debug, Snowflake optimizes CTEs better | Use WITH clauses | |
| Using deprecated Cortex functions | CLASSIFY_TEXT, SUMMARIZE etc. will be removed | Use AI_CLASSIFY, AI_COMPLETE etc. | |
Tasks without WHEN SYSTEM$STREAM_HAS_DATA | Task runs on schedule even with no new data, wasting credits | Add the WHEN clause for stream-driven tasks | |
| Double-quoted identifiers | Forces case-sensitive names across all queries | Use snake_case unquoted identifiers |
Cross-References
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/engineering_devops/snowflake-development/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 4 Jul 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/thiagofernandes1987-create/apex/snowflake-development)