[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KB5RE4PHQ5DCN608YW5M9W":3,"skill-same:01M6KB5RE4PHQ5DCN608YW5M9W":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":6,"ownerHtmlUrl":62,"ownerBlogUrl":63,"ownerDescription":6,"updatedAt":64,"install":65,"resources":78},"01M6KB5RE4PHQ5DCN608YW5M9W","snowflake-development",null,"Use when writing Snowflake SQL, building data pipelines with Dynamic Tables or Streams\u002FTasks, using Cortex AI functions, creating Cortex Agents, writing Snowpark Python, configuring dbt for Snowflake, or troubleshooting Snowflake errors.","afaizalam2003\u002FMaster-claude-skill","afaizalam2003","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F222019359?v=4","01M6K8F2XNT0HKBPF00JQ78SV3","Faiz Alam","01M6K8F31EBXAPER0EG8R9HTR5",3,"MIT","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002FSKILL.md",[18,23,28],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",{"categoryNo":29,"categoryName":30,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000033","数据分析师",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"development","snowflake","snowflake development","troubleshooting","for","tables","errors","streams","with","functions","pipelines","use","writing","cortex","data","data pipelines","dbt","tasks","sql","python","2026-11-10 10:12:30",false,"---\nname: \"snowflake-development\"\ndescription: \"Use when writing Snowflake SQL, building data pipelines with Dynamic Tables or Streams\u002FTasks, using Cortex AI functions, creating Cortex Agents, writing Snowpark Python, configuring dbt for Snowflake, or troubleshooting Snowflake errors.\"\n---\n\n# Snowflake Development\n\nSnowflake 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.\n\n> Originally contributed by [James Cha-Earley](https:\u002F\u002Fgithub.com\u002Fjamescha-earley) — enhanced and integrated by the claude-skills team.\n\n## Quick Start\n\n```bash\n# Generate a MERGE upsert template\npython scripts\u002Fsnowflake_query_helper.py merge --target customers --source staging_customers --key customer_id --columns name,email,updated_at\n\n# Generate a Dynamic Table template\npython scripts\u002Fsnowflake_query_helper.py dynamic-table --name cleaned_events --warehouse transform_wh --lag \"5 minutes\"\n\n# Generate RBAC grant statements\npython scripts\u002Fsnowflake_query_helper.py grant --role analyst_role --database analytics --schemas public,staging --privileges SELECT,USAGE\n```\n\n---\n\n## SQL Best Practices\n\n### Naming and Style\n\n- Use `snake_case` for all identifiers. Avoid double-quoted identifiers -- they force case-sensitive names that require constant quoting.\n- Use CTEs (`WITH` clauses) over nested subqueries.\n- Use `CREATE OR REPLACE` for idempotent DDL.\n- Use explicit column lists -- never `SELECT *` in production. Snowflake's columnar storage scans only referenced columns, so explicit lists reduce I\u002FO.\n\n### Stored Procedures -- Colon Prefix Rule\n\nIn 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.\n\n```sql\n-- WRONG: missing colon prefix\nSELECT name INTO result FROM users WHERE id = p_id;\n\n-- CORRECT: colon prefix on both variable and parameter\nSELECT name INTO :result FROM users WHERE id = :p_id;\n```\n\nThis applies to DECLARE variables, LET variables, and procedure parameters when used inside SELECT, INSERT, UPDATE, DELETE, or MERGE.\n\n### Semi-Structured Data\n\n- VARIANT, OBJECT, ARRAY for JSON\u002FAvro\u002FParquet\u002FORC.\n- Access nested fields: `src:customer.name::STRING`. Always cast with `::TYPE`.\n- VARIANT null vs SQL NULL: JSON `null` is stored as the string `\"null\"`. Use `STRIP_NULL_VALUE = TRUE` on load.\n- Flatten arrays: `SELECT f.value:name::STRING FROM my_table, LATERAL FLATTEN(input => src:items) f;`\n\n### MERGE for Upserts\n\n```sql\nMERGE INTO target t USING source s ON t.id = s.id\nWHEN MATCHED THEN UPDATE SET t.name = s.name, t.updated_at = CURRENT_TIMESTAMP()\nWHEN NOT MATCHED THEN INSERT (id, name, updated_at) VALUES (s.id, s.name, CURRENT_TIMESTAMP());\n```\n\n> See `references\u002Fsnowflake_sql_and_pipelines.md` for deeper SQL patterns and anti-patterns.\n\n---\n\n## Data Pipelines\n\n### Choosing Your Approach\n\n| Approach | When to Use |\n|----------|-------------|\n| Dynamic Tables | Declarative transformations. **Default choice.** Define the query, Snowflake handles refresh. |\n| Streams + Tasks | Imperative CDC. Use for procedural logic, stored procedure calls, complex branching. |\n| Snowpipe | Continuous file loading from cloud storage (S3, GCS, Azure). |\n\n### Dynamic Tables\n\n```sql\nCREATE OR REPLACE DYNAMIC TABLE cleaned_events\n    TARGET_LAG = '5 minutes'\n    WAREHOUSE = transform_wh\n    AS\n    SELECT event_id, event_type, user_id, event_timestamp\n    FROM raw_events\n    WHERE event_type IS NOT NULL;\n```\n\nKey rules:\n- Set `TARGET_LAG` progressively: tighter at the top of the DAG, looser downstream.\n- Incremental DTs cannot depend on Full-refresh DTs.\n- `SELECT *` breaks on upstream schema changes -- use explicit column lists.\n- Views cannot sit between two Dynamic Tables in the DAG.\n\n### Streams and Tasks\n\n```sql\nCREATE OR REPLACE STREAM raw_stream ON TABLE raw_events;\n\nCREATE OR REPLACE TASK process_events\n    WAREHOUSE = transform_wh\n    SCHEDULE = 'USING CRON 0 *\u002F1 * * * America\u002FLos_Angeles'\n    WHEN SYSTEM$STREAM_HAS_DATA('raw_stream')\n    AS INSERT INTO cleaned_events SELECT ... FROM raw_stream;\n\n-- Tasks start SUSPENDED. You MUST resume them.\nALTER TASK process_events RESUME;\n```\n\n> See `references\u002Fsnowflake_sql_and_pipelines.md` for DT debugging queries and Snowpipe patterns.\n\n---\n\n## Cortex AI\n\n### Function Reference\n\n| Function | Purpose |\n|----------|---------|\n| `AI_COMPLETE` | LLM completion (text, images, documents) |\n| `AI_CLASSIFY` | Classify text into categories (up to 500 labels) |\n| `AI_FILTER` | Boolean filter on text or images |\n| `AI_EXTRACT` | Structured extraction from text\u002Fimages\u002Fdocuments |\n| `AI_SENTIMENT` | Sentiment score (-1 to 1) |\n| `AI_PARSE_DOCUMENT` | OCR or layout extraction from documents |\n| `AI_REDACT` | PII removal from text |\n\n**Deprecated names (do NOT use):** `COMPLETE`, `CLASSIFY_TEXT`, `EXTRACT_ANSWER`, `PARSE_DOCUMENT`, `SUMMARIZE`, `TRANSLATE`, `SENTIMENT`, `EMBED_TEXT_768`.\n\n### TO_FILE -- Common Pitfall\n\nStage path and filename are **separate** arguments:\n\n```sql\n-- WRONG: single combined argument\nTO_FILE('@stage\u002Ffile.pdf')\n\n-- CORRECT: two arguments\nTO_FILE('@db.schema.mystage', 'invoice.pdf')\n```\n\n### Cortex Agents\n\nAgent specs use a JSON structure with top-level keys: `models`, `instructions`, `tools`, `tool_resources`.\n\n- Use `$spec$` delimiter (not `$$`).\n- `models` must be an object, not an array.\n- `tool_resources` is a separate top-level key, not nested inside `tools`.\n- Tool descriptions are the single biggest factor in agent quality.\n\n> See `references\u002Fcortex_ai_and_agents.md` for full agent spec examples and Cortex Search patterns.\n\n---\n\n## Snowpark Python\n\n```python\nfrom snowflake.snowpark import Session\nimport os\n\nsession = Session.builder.configs({\n    \"account\": os.environ[\"SNOWFLAKE_ACCOUNT\"],\n    \"user\": os.environ[\"SNOWFLAKE_USER\"],\n    \"password\": os.environ[\"SNOWFLAKE_PASSWORD\"],\n    \"role\": \"my_role\", \"warehouse\": \"my_wh\",\n    \"database\": \"my_db\", \"schema\": \"my_schema\"\n}).create()\n```\n\n- Never hardcode credentials. Use environment variables or key pair auth.\n- DataFrames are lazy -- executed on `collect()` \u002F `show()`.\n- Do NOT call `collect()` on large DataFrames. Process server-side with DataFrame operations.\n- Use **vectorized UDFs** (10-100x faster) for batch and ML workloads.\n\n## dbt on Snowflake\n\n```sql\n-- Dynamic table materialization (streaming\u002Fnear-real-time marts):\n{{ config(materialized='dynamic_table', snowflake_warehouse='transforming', target_lag='1 hour') }}\n\n-- Incremental materialization (large fact tables):\n{{ config(materialized='incremental', unique_key='event_id') }}\n\n-- Snowflake-specific configs (combine with any materialization):\n{{ config(transient=true, copy_grants=true, query_tag='team_daily') }}\n```\n\n- Do NOT use `{{ this }}` without `{% if is_incremental() %}` guard.\n- Use `dynamic_table` materialization for streaming or near-real-time marts.\n\n## Performance\n\n- **Cluster keys**: Only for multi-TB tables. Apply on WHERE \u002F JOIN \u002F GROUP BY columns.\n- **Search Optimization**: `ALTER TABLE t ADD SEARCH OPTIMIZATION ON EQUALITY(col);`\n- **Warehouse sizing**: Start X-Small, scale up. Set `AUTO_SUSPEND = 60`, `AUTO_RESUME = TRUE`.\n- **Separate warehouses** per workload (load, transform, query).\n\n## Security\n\n- Follow least-privilege RBAC. Use database roles for object-level grants.\n- Audit ACCOUNTADMIN regularly: `SHOW GRANTS OF ROLE ACCOUNTADMIN;`\n- Use network policies for IP allowlisting.\n- Use masking policies for PII columns and row access policies for multi-tenant isolation.\n\n---\n\n## Proactive Triggers\n\nSurface these issues without being asked when you notice them in context:\n\n- **Missing colon prefix** in SQL stored procedures -- flag immediately, this causes \"invalid identifier\" at runtime.\n- **`SELECT *` in Dynamic Tables** -- flag as a schema-change time bomb.\n- **Deprecated Cortex function names** (`CLASSIFY_TEXT`, `SUMMARIZE`, etc.) -- suggest the current `AI_*` equivalents.\n- **Task not resumed** after creation -- remind that tasks start SUSPENDED.\n- **Hardcoded credentials** in Snowpark code -- flag as a security risk.\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| \"Object does not exist\" | Wrong database\u002Fschema context or missing grants | Fully qualify names (`db.schema.table`), check grants |\n| \"Invalid identifier\" in procedure | Missing colon prefix on variable | Use `:variable_name` inside SQL statements |\n| \"Numeric value not recognized\" | VARIANT field not cast | Cast explicitly: `src:field::NUMBER(10,2)` |\n| Task not running | Forgot to resume after creation | `ALTER TASK task_name RESUME;` |\n| DT refresh failing | Schema change upstream or tracking disabled | Use explicit columns, verify change tracking |\n| TO_FILE error | Combined path as single argument | Split into two args: `TO_FILE('@stage', 'file.pdf')` |\n\n---\n\n## Practical Workflows\n\n### Workflow 1: Build a Reporting Pipeline (30 min)\n\n1. **Stage raw data**: Create external stage pointing to S3\u002FGCS\u002FAzure, set up Snowpipe for auto-ingest\n2. **Clean with Dynamic Table**: Create DT with `TARGET_LAG = '5 minutes'` that filters nulls, casts types, deduplicates\n3. **Aggregate with downstream DT**: Second DT that joins cleaned data with dimension tables, computes metrics\n4. **Expose via Secure View**: Create `SECURE VIEW` for the BI tool \u002F API layer\n5. **Grant access**: Use `snowflake_query_helper.py grant` to generate RBAC statements\n\n### Workflow 2: Add AI Classification to Existing Data\n\n1. **Identify the column**: Find the text column to classify (e.g., support tickets, reviews)\n2. **Test with AI_CLASSIFY**: `SELECT AI_CLASSIFY(text_col, ['bug', 'feature', 'question']) FROM table LIMIT 10;`\n3. **Create enrichment DT**: Dynamic Table that runs `AI_CLASSIFY` on new rows automatically\n4. **Monitor costs**: Cortex AI is billed per token — sample before running on full tables\n\n### Workflow 3: Debug a Failing Pipeline\n\n1. **Check task history**: `SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY()) WHERE STATE = 'FAILED' ORDER BY SCHEDULED_TIME DESC;`\n2. **Check DT refresh**: `SELECT * FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY('my_dt')) ORDER BY REFRESH_END_TIME DESC;`\n3. **Check stream staleness**: `SHOW STREAMS; -- check stale_after column`\n4. **Consult troubleshooting reference**: See `references\u002Ftroubleshooting.md` for error-specific fixes\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why It Fails | Better Approach |\n|---|---|---|\n| `SELECT *` in Dynamic Tables | Schema changes upstream break the DT silently | Use explicit column lists |\n| Missing colon prefix in procedures | \"Invalid identifier\" runtime error | Always use `:variable_name` in SQL blocks |\n| Single warehouse for all workloads | Contention between load, transform, and query | Separate warehouses per workload type |\n| Hardcoded credentials in Snowpark | Security risk, breaks in CI\u002FCD | Use `os.environ[]` or key pair auth |\n| `collect()` on large DataFrames | Pulls entire result set to client memory | Process server-side with DataFrame operations |\n| Nested subqueries instead of CTEs | Unreadable, hard to debug, Snowflake optimizes CTEs better | Use `WITH` clauses |\n| Using deprecated Cortex functions | `CLASSIFY_TEXT`, `SUMMARIZE` etc. will be removed | Use `AI_CLASSIFY`, `AI_COMPLETE` etc. |\n| 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 |\n| Double-quoted identifiers | Forces case-sensitive names across all queries | Use `snake_case` unquoted identifiers |\n\n---\n\n## Cross-References\n\n| Skill | Relationship |\n|-------|-------------|\n| `engineering\u002Fsql-database-assistant` | General SQL patterns — use for non-Snowflake databases |\n| `engineering\u002Fdatabase-designer` | Schema design — use for data modeling before Snowflake implementation |\n| `engineering-team\u002Fsenior-data-engineer` | Broader data engineering — pipelines, Spark, Airflow, data quality |\n| `engineering-team\u002Fsenior-data-scientist` | Analytics and ML — use alongside Snowpark for feature engineering |\n| `engineering-team\u002Fsenior-devops` | CI\u002FCD for Snowflake deployments (Terraform, GitHub Actions) |\n\n---\n\n## Reference Documentation\n\n| Document | Contents |\n|----------|----------|\n| `references\u002Fsnowflake_sql_and_pipelines.md` | SQL patterns, MERGE templates, Dynamic Table debugging, Snowpipe, anti-patterns |\n| `references\u002Fcortex_ai_and_agents.md` | Cortex AI functions, agent spec structure, Cortex Search, Snowpark |\n| `references\u002Ftroubleshooting.md` | Error reference, debugging queries, common fixes |\n","# Snowflake Development\n\nSnowflake 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.\n\n> Originally contributed by [James Cha-Earley](https:\u002F\u002Fgithub.com\u002Fjamescha-earley) — enhanced and integrated by the claude-skills team.\n\n## Quick Start\n\n```bash\n# Generate a MERGE upsert template\npython scripts\u002Fsnowflake_query_helper.py merge --target customers --source staging_customers --key customer_id --columns name,email,updated_at\n\n# Generate a Dynamic Table template\npython scripts\u002Fsnowflake_query_helper.py dynamic-table --name cleaned_events --warehouse transform_wh --lag \"5 minutes\"\n\n# Generate RBAC grant statements\npython scripts\u002Fsnowflake_query_helper.py grant --role analyst_role --database analytics --schemas public,staging --privileges SELECT,USAGE\n```\n\n---\n\n## SQL Best Practices\n\n### Naming and Style\n\n- Use `snake_case` for all identifiers. Avoid double-quoted identifiers -- they force case-sensitive names that require constant quoting.\n- Use CTEs (`WITH` clauses) over nested subqueries.\n- Use `CREATE OR REPLACE` for idempotent DDL.\n- Use explicit column lists -- never `SELECT *` in production. Snowflake's columnar storage scans only referenced columns, so explicit lists reduce I\u002FO.\n\n### Stored Procedures -- Colon Prefix Rule\n\nIn 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.\n\n```sql\n-- WRONG: missing colon prefix\nSELECT name INTO result FROM users WHERE id = p_id;\n\n-- CORRECT: colon prefix on both variable and parameter\nSELECT name INTO :result FROM users WHERE id = :p_id;\n```\n\nThis applies to DECLARE variables, LET variables, and procedure parameters when used inside SELECT, INSERT, UPDATE, DELETE, or MERGE.\n\n### Semi-Structured Data\n\n- VARIANT, OBJECT, ARRAY for JSON\u002FAvro\u002FParquet\u002FORC.\n- Access nested fields: `src:customer.name::STRING`. Always cast with `::TYPE`.\n- VARIANT null vs SQL NULL: JSON `null` is stored as the string `\"null\"`. Use `STRIP_NULL_VALUE = TRUE` on load.\n- Flatten arrays: `SELECT f.value:name::STRING FROM my_table, LATERAL FLATTEN(input => src:items) f;`\n\n### MERGE for Upserts\n\n```sql\nMERGE INTO target t USING source s ON t.id = s.id\nWHEN MATCHED THEN UPDATE SET t.name = s.name, t.updated_at = CURRENT_TIMESTAMP()\nWHEN NOT MATCHED THEN INSERT (id, name, updated_at) VALUES (s.id, s.name, CURRENT_TIMESTAMP());\n```\n\n> See `references\u002Fsnowflake_sql_and_pipelines.md` for deeper SQL patterns and anti-patterns.\n\n---\n\n## Data Pipelines\n\n### Choosing Your Approach\n\n| Approach | When to Use |\n|----------|-------------|\n| Dynamic Tables | Declarative transformations. **Default choice.** Define the query, Snowflake handles refresh. |\n| Streams + Tasks | Imperative CDC. Use for procedural logic, stored procedure calls, complex branching. |\n| Snowpipe | Continuous file loading from cloud storage (S3, GCS, Azure). |\n\n### Dynamic Tables\n\n```sql\nCREATE OR REPLACE DYNAMIC TABLE cleaned_events\n    TARGET_LAG = '5 minutes'\n    WAREHOUSE = transform_wh\n    AS\n    SELECT event_id, event_type, user_id, event_timestamp\n    FROM raw_events\n    WHERE event_type IS NOT NULL;\n```\n\nKey rules:\n- Set `TARGET_LAG` progressively: tighter at the top of the DAG, looser downstream.\n- Incremental DTs cannot depend on Full-refresh DTs.\n- `SELECT *` breaks on upstream schema changes -- use explicit column lists.\n- Views cannot sit between two Dynamic Tables in the DAG.\n\n### Streams and Tasks\n\n```sql\nCREATE OR REPLACE STREAM raw_stream ON TABLE raw_events;\n\nCREATE OR REPLACE TASK process_events\n    WAREHOUSE = transform_wh\n    SCHEDULE = 'USING CRON 0 *\u002F1 * * * America\u002FLos_Angeles'\n    WHEN SYSTEM$STREAM_HAS_DATA('raw_stream')\n    AS INSERT INTO cleaned_events SELECT ... FROM raw_stream;\n\n-- Tasks start SUSPENDED. You MUST resume them.\nALTER TASK process_events RESUME;\n```\n\n> See `references\u002Fsnowflake_sql_and_pipelines.md` for DT debugging queries and Snowpipe patterns.\n\n---\n\n## Cortex AI\n\n### Function Reference\n\n| Function | Purpose |\n|----------|---------|\n| `AI_COMPLETE` | LLM completion (text, images, documents) |\n| `AI_CLASSIFY` | Classify text into categories (up to 500 labels) |\n| `AI_FILTER` | Boolean filter on text or images |\n| `AI_EXTRACT` | Structured extraction from text\u002Fimages\u002Fdocuments |\n| `AI_SENTIMENT` | Sentiment score (-1 to 1) |\n| `AI_PARSE_DOCUMENT` | OCR or layout extraction from documents |\n| `AI_REDACT` | PII removal from text |\n\n**Deprecated names (do NOT use):** `COMPLETE`, `CLASSIFY_TEXT`, `EXTRACT_ANSWER`, `PARSE_DOCUMENT`, `SUMMARIZE`, `TRANSLATE`, `SENTIMENT`, `EMBED_TEXT_768`.\n\n### TO_FILE -- Common Pitfall\n\nStage path and filename are **separate** arguments:\n\n```sql\n-- WRONG: single combined argument\nTO_FILE('@stage\u002Ffile.pdf')\n\n-- CORRECT: two arguments\nTO_FILE('@db.schema.mystage', 'invoice.pdf')\n```\n\n### Cortex Agents\n\nAgent specs use a JSON structure with top-level keys: `models`, `instructions`, `tools`, `tool_resources`.\n\n- Use `$spec$` delimiter (not `$$`).\n- `models` must be an object, not an array.\n- `tool_resources` is a separate top-level key, not nested inside `tools`.\n- Tool descriptions are the single biggest factor in agent quality.\n\n> See `references\u002Fcortex_ai_and_agents.md` for full agent spec examples and Cortex Search patterns.\n\n---\n\n## Snowpark Python\n\n```python\nfrom snowflake.snowpark import Session\nimport os\n\nsession = Session.builder.configs({\n    \"account\": os.environ[\"SNOWFLAKE_ACCOUNT\"],\n    \"user\": os.environ[\"SNOWFLAKE_USER\"],\n    \"password\": os.environ[\"SNOWFLAKE_PASSWORD\"],\n    \"role\": \"my_role\", \"warehouse\": \"my_wh\",\n    \"database\": \"my_db\", \"schema\": \"my_schema\"\n}).create()\n```\n\n- Never hardcode credentials. Use environment variables or key pair auth.\n- DataFrames are lazy -- executed on `collect()` \u002F `show()`.\n- Do NOT call `collect()` on large DataFrames. Process server-side with DataFrame operations.\n- Use **vectorized UDFs** (10-100x faster) for batch and ML workloads.\n\n## dbt on Snowflake\n\n```sql\n-- Dynamic table materialization (streaming\u002Fnear-real-time marts):\n{{ config(materialized='dynamic_table', snowflake_warehouse='transforming', target_lag='1 hour') }}\n\n-- Incremental materialization (large fact tables):\n{{ config(materialized='incremental', unique_key='event_id') }}\n\n-- Snowflake-specific configs (combine with any materialization):\n{{ config(transient=true, copy_grants=true, query_tag='team_daily') }}\n```\n\n- Do NOT use `{{ this }}` without `{% if is_incremental() %}` guard.\n- Use `dynamic_table` materialization for streaming or near-real-time marts.\n\n## Performance\n\n- **Cluster keys**: Only for multi-TB tables. Apply on WHERE \u002F JOIN \u002F GROUP BY columns.\n- **Search Optimization**: `ALTER TABLE t ADD SEARCH OPTIMIZATION ON EQUALITY(col);`\n- **Warehouse sizing**: Start X-Small, scale up. Set `AUTO_SUSPEND = 60`, `AUTO_RESUME = TRUE`.\n- **Separate warehouses** per workload (load, transform, query).\n\n## Security\n\n- Follow least-privilege RBAC. Use database roles for object-level grants.\n- Audit ACCOUNTADMIN regularly: `SHOW GRANTS OF ROLE ACCOUNTADMIN;`\n- Use network policies for IP allowlisting.\n- Use masking policies for PII columns and row access policies for multi-tenant isolation.\n\n---\n\n## Proactive Triggers\n\nSurface these issues without being asked when you notice them in context:\n\n- **Missing colon prefix** in SQL stored procedures -- flag immediately, this causes \"invalid identifier\" at runtime.\n- **`SELECT *` in Dynamic Tables** -- flag as a schema-change time bomb.\n- **Deprecated Cortex function names** (`CLASSIFY_TEXT`, `SUMMARIZE`, etc.) -- suggest the current `AI_*` equivalents.\n- **Task not resumed** after creation -- remind that tasks start SUSPENDED.\n- **Hardcoded credentials** in Snowpark code -- flag as a security risk.\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| \"Object does not exist\" | Wrong database\u002Fschema context or missing grants | Fully qualify names (`db.schema.table`), check grants |\n| \"Invalid identifier\" in procedure | Missing colon prefix on variable | Use `:variable_name` inside SQL statements |\n| \"Numeric value not recognized\" | VARIANT field not cast | Cast explicitly: `src:field::NUMBER(10,2)` |\n| Task not running | Forgot to resume after creation | `ALTER TASK task_name RESUME;` |\n| DT refresh failing | Schema change upstream or tracking disabled | Use explicit columns, verify change tracking |\n| TO_FILE error | Combined path as single argument | Split into two args: `TO_FILE('@stage', 'file.pdf')` |\n\n---\n\n## Practical Workflows\n\n### Workflow 1: Build a Reporting Pipeline (30 min)\n\n1. **Stage raw data**: Create external stage pointing to S3\u002FGCS\u002FAzure, set up Snowpipe for auto-ingest\n2. **Clean with Dynamic Table**: Create DT with `TARGET_LAG = '5 minutes'` that filters nulls, casts types, deduplicates\n3. **Aggregate with downstream DT**: Second DT that joins cleaned data with dimension tables, computes metrics\n4. **Expose via Secure View**: Create `SECURE VIEW` for the BI tool \u002F API layer\n5. **Grant access**: Use `snowflake_query_helper.py grant` to generate RBAC statements\n\n### Workflow 2: Add AI Classification to Existing Data\n\n1. **Identify the column**: Find the text column to classify (e.g., support tickets, reviews)\n2. **Test with AI_CLASSIFY**: `SELECT AI_CLASSIFY(text_col, ['bug', 'feature', 'question']) FROM table LIMIT 10;`\n3. **Create enrichment DT**: Dynamic Table that runs `AI_CLASSIFY` on new rows automatically\n4. **Monitor costs**: Cortex AI is billed per token — sample before running on full tables\n\n### Workflow 3: Debug a Failing Pipeline\n\n1. **Check task history**: `SELECT * FROM TABLE(INFORMATION_SCHEMA.TASK_HISTORY()) WHERE STATE = 'FAILED' ORDER BY SCHEDULED_TIME DESC;`\n2. **Check DT refresh**: `SELECT * FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY('my_dt')) ORDER BY REFRESH_END_TIME DESC;`\n3. **Check stream staleness**: `SHOW STREAMS; -- check stale_after column`\n4. **Consult troubleshooting reference**: See `references\u002Ftroubleshooting.md` for error-specific fixes\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why It Fails | Better Approach |\n|---|---|---|\n| `SELECT *` in Dynamic Tables | Schema changes upstream break the DT silently | Use explicit column lists |\n| Missing colon prefix in procedures | \"Invalid identifier\" runtime error | Always use `:variable_name` in SQL blocks |\n| Single warehouse for all workloads | Contention between load, transform, and query | Separate warehouses per workload type |\n| Hardcoded credentials in Snowpark | Security risk, breaks in CI\u002FCD | Use `os.environ[]` or key pair auth |\n| `collect()` on large DataFrames | Pulls entire result set to client memory | Process server-side with DataFrame operations |\n| Nested subqueries instead of CTEs | Unreadable, hard to debug, Snowflake optimizes CTEs better | Use `WITH` clauses |\n| Using deprecated Cortex functions | `CLASSIFY_TEXT`, `SUMMARIZE` etc. will be removed | Use `AI_CLASSIFY`, `AI_COMPLETE` etc. |\n| 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 |\n| Double-quoted identifiers | Forces case-sensitive names across all queries | Use `snake_case` unquoted identifiers |\n\n---\n\n## Cross-References\n\n| Skill | Relationship |\n|-------|-------------|\n| `engineering\u002Fsql-database-assistant` | General SQL patterns — use for non-Snowflake databases |\n| `engineering\u002Fdatabase-designer` | Schema design — use for data modeling before Snowflake implementation |\n| `engineering-team\u002Fsenior-data-engineer` | Broader data engineering — pipelines, Spark, Airflow, data quality |\n| `engineering-team\u002Fsenior-data-scientist` | Analytics and ML — use alongside Snowpark for feature engineering |\n| `engineering-team\u002Fsenior-devops` | CI\u002FCD for Snowflake deployments (Terraform, GitHub Actions) |\n\n---\n\n## Reference Documentation\n\n| Document | Contents |\n|----------|----------|\n| `references\u002Fsnowflake_sql_and_pipelines.md` | SQL patterns, MERGE templates, Dynamic Table debugging, Snowpipe, anti-patterns |\n| `references\u002Fcortex_ai_and_agents.md` | Cortex AI functions, agent spec structure, Cortex Search, Snowpark |\n| `references\u002Ftroubleshooting.md` | Error reference, debugging queries, common fixes |\n",{"name":5,"description":7},"main","0b48cbb0e6d5be6ff68c0f6b28bc0c65ee21c4a1","engineering-team\u002Fsnowflake-development",2,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill","https:\u002F\u002Fgithub.com\u002Fafaizalam2003","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fmdfaizalam2003\u002F","2026-04-01 04:35:43",{"source":8,"skillName":5,"commands":66,"prompt":76,"zipAvailable":77},[67,70,73],{"tool":68,"command":69},"npx","npx skills add afaizalam2003\u002FMaster-claude-skill --skill snowflake-development",{"tool":71,"command":72},"bunx","bunx skills add afaizalam2003\u002FMaster-claude-skill --skill snowflake-development",{"tool":74,"command":75},"pnpm","pnpm dlx skills add afaizalam2003\u002FMaster-claude-skill --skill snowflake-development","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002FSKILL.md",true,[79,85,89,93,97],{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},".claude-plugin\u002Fplugin.json","REFERENCE","参考文档",588,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002F.claude-plugin\u002Fplugin.json",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fcortex_ai_and_agents.md",7724,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002Freferences\u002Fcortex_ai_and_agents.md",{"path":90,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fsnowflake_sql_and_pipelines.md",7553,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002Freferences\u002Fsnowflake_sql_and_pipelines.md",{"path":94,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Ftroubleshooting.md",5364,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002Freferences\u002Ftroubleshooting.md",{"path":98,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":101,"sourceHtmlUrl":102},"scripts\u002Fsnowflake_query_helper.py","SCRIPT","脚本",8444,"https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fengineering-team\u002Fsnowflake-development\u002Fscripts\u002Fsnowflake_query_helper.py",[104,132,157,182,212,232],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":113,"publishedAt":52},"01M6KC4E8MYR9DBAZTAXHKYMMH","soc2-compliance","Use when the user asks to prepare for SOC 2 audits, map Trust Service Criteria, build control matrices, collect audit evidence, perform gap analysis, or assess SOC 2 Type I vs Type II readiness.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Fsoc2-compliance\u002FSKILL.md",[110],{"categoryNo":111,"categoryName":112,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000037","律师与法务",[114,115,116,117,118,119,120,121,43,122,123,124,125,126,127,128,129,130,131,36],"compliance","soc2","soc2 compliance","audit evidence","audit","collect","soc","analysis","evidence","trust","build","map","control","type","gap","readiness","gap analysis","assess",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":52},"01M6KC461R3GKGZ1TAYHVR1MW9","risk-management-specialist","Medical device risk management specialist implementing ISO 14971 throughout product lifecycle. Provides risk analysis, risk evaluation, risk control, and post-production information analysis. Use when user mentions risk management, ISO 14971, risk analysis, FMEA, fault tree analysis, hazard identification, risk control, risk matrix, benefit-risk analysis, residual risk, risk acceptability, or post-market risk.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Frisk-management-specialist\u002FSKILL.md",[],[139,140,141,142,143,144,145,146,121,43,147,148,149,150,151,152,153,154,155,156],"risk","risk management specialist","management","risk management","risk evaluation","product","Evaluation","lifecycle","risk matrix","iso","medical","iso 14971","identification","information","post-production","tree","matrix","implementing",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":52},"01M6KC3HF5ZFSSP2NZF68PEPFB","regulatory-affairs-head","Senior Regulatory Affairs Manager for HealthTech and MedTech companies. Prepares FDA 510(k), De Novo, and PMA submission packages; analyzes regulatory pathways for new medical devices; drafts responses to FDA deficiency letters and Notified Body queries; develops CE marking technical documentation under EU MDR 2017\u002F745; coordinates multi-market approval strategies across FDA, EU, Health Canada, PMDA, and NMPA; and maintains regulatory intelligence on evolving standards. Use when users need to plan or execute FDA submissions, navigate 510(k) or PMA approval processes, achieve CE marking, prepare pre-submission meeting materials, write regulatory strategy documents, respond to agency queries, or manage compliance documentation for medical device market access.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Fregulatory-affairs-head\u002FSKILL.md",[],[164,165,166,167,168,169,170,171,172,43,173,174,175,176,177,178,179,180,181,36],"regulatory affairs head","regulatory","head","documents","devices","health","plan","write","strategy","standards","queries","manage","strategies","de","users","respond","medical devices","manager",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":194,"publishedAt":52},"01M6KC34Z8M1559EY1CXYBJB1A","quality-manager-qms-iso13485","ISO 13485 Quality Management System implementation and maintenance for medical device organizations. Provides QMS design, documentation control, internal auditing, CAPA management, and certification support. Use when working with medical device quality systems, preparing for ISO 13485 audits, managing regulatory compliance documentation, setting up corrective actions, or building audit preparation programs. Useful for quality management, audit preparation, regulatory compliance, medical device documentation, and corrective action workflows.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Fquality-manager-qms-iso13485\u002FSKILL.md",[188,191],{"categoryNo":189,"categoryName":190,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":192,"categoryName":193,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000032","设计师",[195,196,181,197,198,199,200,201,202,43,203,204,205,206,207,208,209,210,36,211],"quality manager qms iso13485","quality","design","workflows","validation","actions","certification","system","maintenance","document","systems","records","ISO 13485","organizations","corrective action","internal audit","preparation",{"skillNo":213,"name":214,"nameZh":6,"description":215,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":216,"categories":217,"keywords":219,"publishedAt":52},"01M6KC2FXHBHXYX2ZZ17Y3GDB4","quality-manager-qmr","Senior Quality Manager Responsible Person (QMR) for HealthTech and MedTech companies. Provides quality system governance, management review leadership, regulatory compliance oversight, and quality performance monitoring per ISO 13485 Clause 5.5.2.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Fquality-manager-qmr\u002FSKILL.md",[218],{"categoryNo":111,"categoryName":112,"taxonomyType":26,"taxonomyTypeDesc":27},[220,196,181,221,222,223,224,225,114,226,202,227,165,228,229,230,148,207,36,231],"quality manager qmr","review","policy","performance","governance","monitoring","regulatory compliance","oversight","cost","culture","leadership","person",{"skillNo":233,"name":234,"nameZh":6,"description":235,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":236,"categories":237,"keywords":245,"publishedAt":52},"01M6KC1VRR5JTDBNZANHPS6VR6","quality-documentation-manager","Document control system management for medical device QMS. Covers document numbering, version control, change management, and 21 CFR Part 11 compliance. Use for document control procedures, change control workflow, document numbering, version management, electronic signature compliance, or regulatory documentation review.","https:\u002F\u002Fgithub.com\u002Fafaizalam2003\u002FMaster-claude-skill\u002Fblob\u002Fmain\u002Fra-qm-team\u002Fquality-documentation-manager\u002FSKILL.md",[238,241,244],{"categoryNo":239,"categoryName":240,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":242,"categoryName":243,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":111,"categoryName":112,"taxonomyType":26,"taxonomyTypeDesc":27},[246,247,196,181,221,248,249,118,202,250,251,252,253,254,149,255,256,257,258,36],"documentation","quality documentation manager","workflow","change","change management","list","master","system management","documentation review","cfr","21 cfr part 11","change control","retention"]