Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat(skills): Add snowflake-platform skill
Jeza38e4b822dbc
diff --git a/skills/snowflake-platform/README.md b/skills/snowflake-platform/README.mdnew file mode 100644index 00000000..5f526f01--- /dev/null+++ b/skills/snowflake-platform/README.md@@ -0,0 +1,90 @@+# snowflake-platform++Build on Snowflake's AI Data Cloud with snow CLI, Cortex AI functions, Native Apps, and Snowpark.++## Auto-Trigger Keywords++This skill activates when conversations include:++**Platform:**+- snowflake+- snow cli+- snowflake cli+- snowflake connection+- snowflake account++**Cortex AI:**+- cortex ai+- snowflake cortex+- AI_COMPLETE+- AI_SUMMARIZE+- AI_TRANSLATE+- AI_FILTER+- AI_CLASSIFY+- AI_SENTIMENT+- SNOWFLAKE.CORTEX+- cortex llm+- cortex functions++**Native Apps:**+- native app+- snowflake native app+- snowflake marketplace+- provider studio+- application package+- release channels+- snow app run+- snow app deploy+- snow app publish+- setup_script.sql+- manifest.yml++**Authentication:**+- snowflake jwt+- snowflake authentication+- account locator+- rsa key snowflake+- snowflake private key++**Snowpark:**+- snowpark+- snowpark python+- snowflake dataframe+- snowflake udf+- snowflake stored procedure++**Errors:**+- jwt validation error snowflake+- account identifier+- REFERENCE_USAGE+- external access integration+- release directive+- security review status++## What This Skill Covers++1. **Snow CLI** - Project management, SQL execution, app deployment+2. **Cortex AI** - LLM functions in SQL (COMPLETE, SUMMARIZE, TRANSLATE, etc.)+3. **Native Apps** - Development, versioning, marketplace publishing+4. **Authentication** - JWT key-pair, account identifiers (critical gotcha)+5. **Snowpark** - Python DataFrame API, UDFs, stored procedures+6. **Marketplace** - Security review, Provider Studio, paid listings++## What This Skill Does NOT Cover++- Streamlit in Snowflake (use `streamlit-snowflake` skill)+- Data engineering/ETL patterns+- BI tool integrations (Tableau, Looker)+- Advanced ML model deployment++## Key Corrections++- Account identifier confusion (org-account vs locator)+- External access integration reset after deploys+- Release channel syntax (CLI vs legacy SQL)+- Artifact nesting in snowflake.yml+- REFERENCE_USAGE grant syntax for shared data++## Related Skills++- `streamlit-snowflake` - Streamlit apps in Snowflakediff --git a/skills/snowflake-platform/SKILL.md b/skills/snowflake-platform/SKILL.mdnew file mode 100644index 00000000..ed3e073b--- /dev/null+++ b/skills/snowflake-platform/SKILL.md@@ -0,0 +1,598 @@+---+name: snowflake-platform+description: |+ Build on Snowflake's AI Data Cloud with snow CLI, Cortex AI (COMPLETE, SUMMARIZE, AI_FILTER), Native Apps, and Snowpark. Covers JWT auth, account identifiers, Marketplace publishing.++ Use when: Snowflake apps, Cortex AI SQL, Native App publishing. Troubleshoot: JWT auth failures, account locator confusion, release channel errors.+license: MIT+metadata:+ version: "1.0.0"+ last_verified: "2026-01-09"+ snowflake_cli: ">=3.14.0"+ python: ">=3.10"+ doc_sources:+ primary: "https://docs.snowflake.com/en/developer-guide/snowflake-cli/index"+ cortex: "https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions"+ native_apps: "https://docs.snowflake.com/en/developer-guide/native-apps/native-apps-about"+ ecosystem: pip+ package_name: snowflake-cli+ keywords:+ - snowflake+ - snow cli+ - cortex ai+ - snowflake cortex+ - native app+ - snowflake marketplace+ - snowpark+ - jwt authentication+ - account locator+ - release channels+ - AI_COMPLETE+ - AI_SUMMARIZE+ - AI_TRANSLATE+ - AI_FILTER+ - external access integration+ - provider studio+---++# Snowflake Platform Skill++Build and deploy applications on Snowflake's AI Data Cloud using the snow CLI, Cortex AI functions, Native Apps, and Snowpark.++## Quick Start++### Install Snowflake CLI++```bash+pip install snowflake-cli+snow --version # Should show 3.14.0++```++### Configure Connection++```bash+# Interactive setup+snow connection add++# Or create ~/.snowflake/config.toml manually+```++```toml+[connections.default]+account = "orgname-accountname"+user = "USERNAME"+authenticator = "SNOWFLAKE_JWT"+private_key_path = "~/.snowflake/rsa_key.p8"+```++### Test Connection++```bash+snow connection test -c default+snow sql -q "SELECT CURRENT_USER(), CURRENT_ACCOUNT()"+```++## When to Use This Skill++**Use when:**+- Building applications on Snowflake platform+- Using Cortex AI functions in SQL queries+- Developing Native Apps for Marketplace+- Setting up JWT key-pair authentication+- Working with Snowpark Python++**Don't use when:**+- Building Streamlit apps (use `streamlit-snowflake` skill)+- Need data engineering/ETL patterns+- Working with BI tools (Tableau, Looker)++## Cortex AI Functions++Snowflake Cortex provides LLM capabilities directly in SQL. Functions are in the `SNOWFLAKE.CORTEX` schema.++### Core Functions++| Function | Purpose | GA Status |+|----------|---------|-----------|+| `COMPLETE` / `AI_COMPLETE` | Text generation from prompt | GA Nov 2025 |+| `SUMMARIZE` / `AI_SUMMARIZE` | Summarize text | GA |+| `TRANSLATE` / `AI_TRANSLATE` | Translate between languages | GA Sep 2025 |+| `SENTIMENT` / `AI_SENTIMENT` | Sentiment analysis | GA Jul 2025 |+| `AI_FILTER` | Natural language filtering | GA Nov 2025 |+| `AI_CLASSIFY` | Categorize text/images | GA Nov 2025 |+| `AI_AGG` | Aggregate insights across rows | GA Nov 2025 |++### COMPLETE Function++```sql+-- Simple prompt+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ 'Explain quantum computing in one sentence'+) AS response;++-- With conversation history+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ [+ {'role': 'system', 'content': 'You are a helpful assistant'},+ {'role': 'user', 'content': 'What is Snowflake?'}+ ]+) AS response;++-- With options+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'mistral-large2',+ 'Summarize this document',+ {'temperature': 0.3, 'max_tokens': 500}+) AS response;+```++**Available Models:**+- `llama3.1-70b`, `llama3.1-8b`, `llama3.2-3b`+- `mistral-large2`, `mistral-7b`+- `snowflake-arctic`+- `gemma-7b`++### SUMMARIZE Function++```sql+-- Single text+SELECT SNOWFLAKE.CORTEX.SUMMARIZE(article_text) AS summary+FROM articles+LIMIT 10;++-- Aggregate across rows (no context window limit)+SELECT AI_SUMMARIZE_AGG(review_text) AS all_reviews_summary+FROM product_reviews+WHERE product_id = 123;+```++### TRANSLATE Function++```sql+-- Translate to English (auto-detect source)+SELECT SNOWFLAKE.CORTEX.TRANSLATE(+ review_text,+ '', -- Empty = auto-detect source language+ 'en' -- Target language+) AS translated+FROM international_reviews;++-- Explicit source language+SELECT AI_TRANSLATE(+ description,+ 'es', -- Source: Spanish+ 'en' -- Target: English+) AS translated+FROM spanish_products;+```++### AI_FILTER (Natural Language Filtering)++```sql+-- Filter with plain English+SELECT * FROM customer_feedback+WHERE AI_FILTER(+ feedback_text,+ 'mentions shipping problems or delivery delays'+);++-- Combine with SQL predicates+SELECT * FROM support_tickets+WHERE created_date > '2025-01-01'+ AND AI_FILTER(description, 'customer is angry or frustrated');+```++### AI_CLASSIFY++```sql+-- Categorize support tickets+SELECT+ ticket_id,+ AI_CLASSIFY(+ description,+ ['billing', 'technical', 'shipping', 'other']+ ) AS category+FROM support_tickets;+```++### Billing++Cortex AI functions bill based on tokens:+- ~4 characters = 1 token+- Both input AND output tokens are billed+- Rates vary by model (larger models cost more)++## Authentication++### JWT Key-Pair Authentication++**Critical**: Snowflake uses TWO account identifier formats:++| Format | Example | Used For |+|--------|---------|----------|+| **Organization-Account** | `irjoewf-wq46213` | REST API URLs, connection config |+| **Account Locator** | `NZ90655` | JWT claims (`iss`, `sub`) |++**These are NOT interchangeable!**++#### Discover Your Account Locator++```sql+SELECT CURRENT_ACCOUNT(); -- Returns: NZ90655+```++#### Generate RSA Key Pair++```bash+# Generate private key (PKCS#8 format required)+openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out ~/.snowflake/rsa_key.p8 -nocrypt++# Generate public key+openssl rsa -in ~/.snowflake/rsa_key.p8 -pubout -out ~/.snowflake/rsa_key.pub++# Get fingerprint for JWT claims+openssl rsa -in ~/.snowflake/rsa_key.p8 -pubout -outform DER | \+ openssl dgst -sha256 -binary | openssl enc -base64+```++#### Register Public Key with User++```sql+-- In Snowflake worksheet (requires ACCOUNTADMIN or SECURITYADMIN)+ALTER USER my_user SET RSA_PUBLIC_KEY='MIIBIjANBgkq...';+```++#### JWT Claim Format++```+iss: ACCOUNT_LOCATOR.USERNAME.SHA256:fingerprint+sub: ACCOUNT_LOCATOR.USERNAME+```++**Example:**+```+iss: NZ90655.JEZWEB.SHA256:jpZO6LvU2SpKd8tE61OGfas5ZXpfHloiJd7XHLPDEEA=+sub: NZ90655.JEZWEB+```++## Snow CLI Commands++### Project Management++```bash+# Initialize project+snow init++# Execute SQL+snow sql -q "SELECT 1"+snow sql -f query.sql++# View logs+snow logs+```++### Native App Commands++```bash+# Development+snow app run # Deploy and run locally+snow app deploy # Upload to stage only+snow app teardown # Remove app++# Versioning+snow app version create V1_0+snow app version list+snow app version drop V1_0++# Publishing+snow app publish --version V1_0 --patch 0++# Release Channels+snow app release-channel list+snow app release-channel add-version --channel ALPHA --version V1_0+snow app release-directive set default --version V1_0 --patch 0 --channel DEFAULT+```++### Streamlit Commands++```bash+snow streamlit deploy --replace+snow streamlit deploy --replace --open+```++### Stage Commands++```bash+snow stage list+snow stage copy @my_stage/file.txt ./local/+```++## Native App Development++### Project Structure++```+my_native_app/+├── snowflake.yml # Project config+├── manifest.yml # App manifest+├── setup_script.sql # Installation script+├── app/+│ └── streamlit/+│ ├── environment.yml+│ └── streamlit_app.py+└── scripts/+ └── setup.sql+```++### snowflake.yml++```yaml+definition_version: 2++native_app:+ name: my_app+ package:+ name: my_app_pkg+ distribution: external # For marketplace+ application:+ name: my_app+ source_stage: stage/dev+ artifacts:+ - src: manifest.yml+ dest: manifest.yml+ - src: setup_script.sql+ dest: setup_script.sql+ - src: app/streamlit/environment.yml+ dest: streamlit/environment.yml+ - src: app/streamlit/streamlit_app.py+ dest: streamlit/streamlit_app.py+ enable_release_channels: true # For ALPHA/BETA channels+```++### manifest.yml++```yaml+manifest_version: 1++artifacts:+ setup_script: setup_script.sql+ default_streamlit: streamlit/streamlit_app.py++# Note: Do NOT include privileges section - Native Apps can't declare privileges+```++### External Access Integration++Native Apps calling external APIs need this setup:++```sql+-- 1. Create network rule (in a real database, NOT app package)+CREATE DATABASE IF NOT EXISTS MY_APP_UTILS;++CREATE OR REPLACE NETWORK RULE MY_APP_UTILS.PUBLIC.api_rule+ MODE = EGRESS+ TYPE = HOST_PORT+ VALUE_LIST = ('api.example.com:443');++-- 2. Create integration+CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION my_app_integration+ ALLOWED_NETWORK_RULES = (MY_APP_UTILS.PUBLIC.api_rule)+ ENABLED = TRUE;++-- 3. Grant to app+GRANT USAGE ON INTEGRATION my_app_integration+ TO APPLICATION MY_APP;++-- 4. CRITICAL: Attach to Streamlit (must repeat after EVERY deploy!)+ALTER STREAMLIT MY_APP.config_schema.my_streamlit+ SET EXTERNAL_ACCESS_INTEGRATIONS = (my_app_integration);+```++**Warning**: Step 4 resets on every `snow app run`. Must re-run after each deploy!++### Shared Data Pattern++When your Native App needs data from an external database:++```sql+-- 1. Create shared_data schema in app package+CREATE SCHEMA IF NOT EXISTS MY_APP_PKG.SHARED_DATA;++-- 2. Create views referencing external database+CREATE OR REPLACE VIEW MY_APP_PKG.SHARED_DATA.MY_VIEW AS+SELECT * FROM EXTERNAL_DB.SCHEMA.TABLE;++-- 3. Grant REFERENCE_USAGE (CRITICAL!)+GRANT REFERENCE_USAGE ON DATABASE EXTERNAL_DB+ TO SHARE IN APPLICATION PACKAGE MY_APP_PKG;++-- 4. Grant access to share+GRANT USAGE ON SCHEMA MY_APP_PKG.SHARED_DATA+ TO SHARE IN APPLICATION PACKAGE MY_APP_PKG;+GRANT SELECT ON ALL VIEWS IN SCHEMA MY_APP_PKG.SHARED_DATA+ TO SHARE IN APPLICATION PACKAGE MY_APP_PKG;+```++In `setup_script.sql`, reference `shared_data.view_name` (NOT the original database).++## Marketplace Publishing++### Security Review Workflow++```bash+# 1. Deploy app+snow app run++# 2. Create version+snow app version create V1_0++# 3. Check security review status+snow app version list+# Wait for review_status = APPROVED++# 4. Set release directive+snow app release-directive set default --version V1_0 --patch 0 --channel DEFAULT++# 5. Create listing in Snowsight Provider Studio (UI only)+```++### Security Review Statuses++| Status | Meaning | Action |+|--------|---------|--------|+| `NOT_REVIEWED` | Scan hasn't run | Check DISTRIBUTION is EXTERNAL |+| `IN_PROGRESS` | Scan running | Wait |+| `APPROVED` | Passed | Can publish |+| `REJECTED` | Failed | Fix issues or appeal |+| `MANUAL_REVIEW` | Human reviewing | Wait (can take days) |++**Triggers manual review**: External access integrations, Streamlit components, network calls.++### Provider Studio Fields++| Field | Max Length | Notes |+|-------|------------|-------|+| Title | 72 chars | App name |+| Subtitle | 128 chars | One-liner |+| Description | 10,000 chars | HTML editor |+| Business Needs | 6 max | Select from dropdown |+| Quick Start Examples | 10 max | Title + Description + SQL |+| Data Dictionary | Required | **Mandatory for data listings (2025)** |++### Paid Listing Prerequisites++| # | Requirement |+|---|-------------|+| 1 | Full Snowflake account (not trial) |+| 2 | ACCOUNTADMIN role |+| 3 | Provider Profile approved |+| 4 | Stripe account configured |+| 5 | Provider & Consumer Terms accepted |+| 6 | Contact Marketplace Ops |++**Note**: Cannot convert free listing to paid. Must create new listing.++## Snowpark Python++### Session Setup++```python+from snowflake.snowpark import Session++connection_params = {+ "account": "orgname-accountname",+ "user": "USERNAME",+ "password": "PASSWORD", # Or use private_key_path+ "warehouse": "COMPUTE_WH",+ "database": "MY_DB",+ "schema": "PUBLIC"+}++session = Session.builder.configs(connection_params).create()+```++### DataFrame Operations++```python+# Read table+df = session.table("MY_TABLE")++# Filter and select+result = df.filter(df["STATUS"] == "ACTIVE") \+ .select("ID", "NAME", "CREATED_AT") \+ .sort("CREATED_AT", ascending=False)++# Execute+result.show()++# Collect to Python+rows = result.collect()+```++### Row Access (Common Gotcha)++```python+# WRONG - dict() doesn't work on Snowpark Row+config = dict(result[0])++# CORRECT - Access columns explicitly+row = result[0]+config = {+ 'COLUMN_A': row['COLUMN_A'],+ 'COLUMN_B': row['COLUMN_B'],+}+```++### UDFs and Stored Procedures++```python+from snowflake.snowpark.functions import udf, sproc++# Register UDF+@udf(name="my_udf", replace=True)+def my_udf(x: int) -> int:+ return x * 2++# Register Stored Procedure+@sproc(name="my_sproc", replace=True)+def my_sproc(session: Session, table_name: str) -> str:+ df = session.table(table_name)+ count = df.count()+ return f"Row count: {count}"+```++## Known Issues++### 1. Account Identifier Confusion++**Symptom**: JWT auth fails silently, queries don't appear in Query History.++**Cause**: Using org-account format in JWT claims instead of account locator.++**Fix**: Use `SELECT CURRENT_ACCOUNT()` to get the actual account locator.++### 2. External Access Reset++**Symptom**: API calls fail after `snow app run`.++**Cause**: External access integration attachment resets on every deploy.++**Fix**: Re-run `ALTER STREAMLIT ... SET EXTERNAL_ACCESS_INTEGRATIONS` after each deploy.++### 3. Release Channel Syntax++**Symptom**: `ALTER APPLICATION PACKAGE ... SET DEFAULT RELEASE DIRECTIVE` fails.++**Cause**: Legacy SQL syntax doesn't work with release channels enabled.++**Fix**: Use snow CLI: `snow app release-directive set default --version V1_0 --patch 0 --channel DEFAULT`++### 4. Artifact Nesting++**Symptom**: Files appear in `streamlit/streamlit/` instead of `streamlit/`.++**Cause**: Directory mappings in snowflake.yml nest the folder name.++**Fix**: List individual files explicitly in artifacts, not directories.++### 5. REFERENCE_USAGE Missing++**Symptom**: "A view that is added to the shared content cannot reference objects from other databases"++**Cause**: Missing `GRANT REFERENCE_USAGE ON DATABASE` for shared data.++**Fix**: Always grant REFERENCE_USAGE before `snow app run` when using external databases.++## References++- [Snowflake CLI Documentation](https://docs.snowflake.com/en/developer-guide/snowflake-cli/index)+- [Cortex AI Functions](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions)+- [Native Apps Framework](https://docs.snowflake.com/en/developer-guide/native-apps/native-apps-about)+- [Snowpark Python](https://docs.snowflake.com/en/developer-guide/snowpark/python/index)+- [Marketplace Publishing](https://docs.snowflake.com/en/developer-guide/native-apps/publish-app)++## Related Skills++- `streamlit-snowflake` - Streamlit in Snowflake appsdiff --git a/skills/snowflake-platform/references/snow-cli-commands.md b/skills/snowflake-platform/references/snow-cli-commands.mdnew file mode 100644index 00000000..9cc3c4be--- /dev/null+++ b/skills/snowflake-platform/references/snow-cli-commands.md@@ -0,0 +1,198 @@+# Snow CLI Command Reference++Version: 3.14.0+ (Dec 2025)++## Installation++```bash+pip install snowflake-cli+snow --version+```++## Global Options++```bash+snow --help+snow --version+snow --debug <command> # Enable debug output+snow --format json <command> # JSON output+```++## Connection Commands++```bash+# Add new connection+snow connection add++# Test connection+snow connection test -c <connection_name>++# List connections+snow connection list++# Set default connection+snow connection set-default <connection_name>+```++## SQL Commands++```bash+# Execute query+snow sql -q "SELECT CURRENT_USER()"++# Execute from file+snow sql -f query.sql++# Specify connection+snow sql -q "SELECT 1" -c my_connection++# Output format+snow sql -q "SELECT 1" --format json+```++## Native App Commands++```bash+# Development+snow app run # Deploy and create/upgrade app+snow app deploy # Upload to stage only+snow app teardown # Remove app completely++# Versioning+snow app version create V1_0+snow app version list+snow app version drop V1_0++# Publishing+snow app publish --version V1_0 --patch 0++# Release Channels+snow app release-channel list+snow app release-channel add-version --channel ALPHA --version V1_0+snow app release-directive set default --version V1_0 --patch 0 --channel DEFAULT+```++## Streamlit Commands++```bash+# Deploy Streamlit app+snow streamlit deploy+snow streamlit deploy --replace+snow streamlit deploy --replace --open # Open in browser++# List Streamlit apps+snow streamlit list+```++## Stage Commands++```bash+# List files in stage+snow stage list @my_stage++# Copy files+snow stage copy @my_stage/file.txt ./local/+snow stage copy ./local/file.txt @my_stage/++# Remove files+snow stage remove @my_stage/file.txt+```++## Snowpark Commands++```bash+# Deploy procedure+snow snowpark procedure deploy++# Deploy function+snow snowpark function deploy++# Execute procedure+snow snowpark procedure execute <name>+```++## SPCS (Container Services) Commands++```bash+# Compute pools+snow spcs compute-pool list+snow spcs compute-pool create <name>++# Services+snow spcs service list+snow spcs service deploy+snow spcs service status <name>++# Image repositories+snow spcs image-repository list+```++## Object Commands++```bash+# List objects+snow object list warehouse+snow object list database+snow object list schema++# Describe object+snow object describe warehouse <name>+```++## Log Commands (New 2025)++```bash+# View logs+snow logs++# Stream logs+snow logs --follow+```++## Helper Commands++```bash+# Check for SnowSQL env vars to migrate+snow helper check-snowsql-env-vars++# Import connections from SnowSQL+snow helpers import-snowsql-connections+```++## Project Initialization++```bash+# Initialize new project+snow init++# Initialize with template+snow init --template native-app+snow init --template streamlit+```++## Configuration File++Default location: `~/.snowflake/config.toml`++```toml+[connections.default]+account = "orgname-accountname"+user = "USERNAME"+authenticator = "SNOWFLAKE_JWT"+private_key_path = "~/.snowflake/rsa_key.p8"+warehouse = "COMPUTE_WH"+database = "MY_DB"+schema = "PUBLIC"++[connections.dev]+account = "orgname-accountname"+user = "DEV_USER"+password = "..."+```++## Environment Variables++```bash+SNOWFLAKE_DEFAULT_CONNECTION_NAME # Default connection to use+SNOWFLAKE_HOME # Config directory (~/.snowflake)+```diff --git a/skills/snowflake-platform/rules/snowflake-auth.md b/skills/snowflake-platform/rules/snowflake-auth.mdnew file mode 100644index 00000000..25b0e7ee--- /dev/null+++ b/skills/snowflake-platform/rules/snowflake-auth.md@@ -0,0 +1,80 @@+---+globs:+ - "**/*snowflake*"+ - "**/snow*.py"+ - "**/snow*.ts"+---++# Snowflake Authentication Corrections++## Account Identifier Confusion (Critical)++Snowflake uses TWO different account identifier formats:++| Format | Example | Used For |+|--------|---------|----------|+| **Organization-Account** | `irjoewf-wq46213` | REST API URLs, connection strings |+| **Account Locator** | `NZ90655` | JWT claims (`iss`, `sub`) |++**These are NOT interchangeable!**++## Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Single `SNOWFLAKE_ACCOUNT` env var | Separate `SNOWFLAKE_ACCOUNT_URL` and `SNOWFLAKE_ACCOUNT_LOCATOR` |+| `irjoewf-wq46213` in JWT iss claim | Account locator (e.g., `NZ90655`) |+| Guessing account format from URL | Run `SELECT CURRENT_ACCOUNT()` to get actual locator |++## Discover Account Locator++```sql+SELECT CURRENT_ACCOUNT(); -- Returns account locator (e.g., NZ90655)+```++Or via snow CLI:+```bash+snow sql -q "SELECT CURRENT_USER(), CURRENT_ACCOUNT(), CURRENT_REGION()" -c your_connection+```++## JWT Claim Format++```+iss: ACCOUNT_LOCATOR.USERNAME.SHA256:fingerprint+sub: ACCOUNT_LOCATOR.USERNAME+```++**Example:**+```+iss: NZ90655.JEZWEB.SHA256:jpZO6LvU2SpKd8tE61OGfas5ZXpfHloiJd7XHLPDEEA=+sub: NZ90655.JEZWEB+```++## REST API URL Format++Uses org-account format (NOT account locator):+```+https://irjoewf-wq46213.snowflakecomputing.com/api/v2/statements+```++## RSA Key Setup++```bash+# Generate key pair (PKCS#8 format required)+openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out ~/.snowflake/rsa_key.p8 -nocrypt+openssl rsa -in ~/.snowflake/rsa_key.p8 -pubout -out ~/.snowflake/rsa_key.pub++# Get fingerprint+openssl rsa -in ~/.snowflake/rsa_key.p8 -pubout -outform DER | openssl dgst -sha256 -binary | openssl enc -base64++# Register with Snowflake user+ALTER USER my_user SET RSA_PUBLIC_KEY='MIIBIj...';+```++## Symptoms of Wrong Identifier++- REST API returns 200 but with JWT validation error+- Queries don't appear in Snowflake Query History+- No clear error message indicating which identifier is wrong++**Fix**: Always use `SELECT CURRENT_ACCOUNT()` to get actual account locator.diff --git a/skills/snowflake-platform/rules/snowflake-cortex.md b/skills/snowflake-platform/rules/snowflake-cortex.mdnew file mode 100644index 00000000..aae654ac--- /dev/null+++ b/skills/snowflake-platform/rules/snowflake-cortex.md@@ -0,0 +1,100 @@+---+globs:+ - "**/*.sql"+ - "**/snowflake*.py"+---++# Snowflake Cortex AI Corrections++## Function Schema++All Cortex AI functions are in `SNOWFLAKE.CORTEX` schema.++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `CORTEX.COMPLETE(...)` | `SNOWFLAKE.CORTEX.COMPLETE(...)` |+| `COMPLETE(...)` without schema | `SNOWFLAKE.CORTEX.COMPLETE(...)` |++## Function Naming (Legacy vs New)++Snowflake renamed functions. Both work, but new names are preferred:++| Legacy (still works) | New (preferred) |+|---------------------|-----------------|+| `SNOWFLAKE.CORTEX.COMPLETE` | `AI_COMPLETE` |+| `SNOWFLAKE.CORTEX.SUMMARIZE` | `AI_SUMMARIZE` |+| `SNOWFLAKE.CORTEX.TRANSLATE` | `AI_TRANSLATE` |+| `SNOWFLAKE.CORTEX.SENTIMENT` | `AI_SENTIMENT` |++## Model Names++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `gpt-4` or `claude-3` | Snowflake-hosted models only |+| Generic model names | `llama3.1-70b`, `mistral-large2`, `snowflake-arctic` |++Available models:+- `llama3.1-70b`, `llama3.1-8b`, `llama3.2-3b`+- `mistral-large2`, `mistral-7b`+- `snowflake-arctic`+- `gemma-7b`++## COMPLETE Function Syntax++```sql+-- Simple prompt (string)+SELECT SNOWFLAKE.CORTEX.COMPLETE('llama3.1-70b', 'Your prompt here');++-- With conversation history (array of objects)+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ [+ {'role': 'system', 'content': 'You are helpful'},+ {'role': 'user', 'content': 'Hello'}+ ]+);++-- With options (temperature, max_tokens)+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ 'Prompt',+ {'temperature': 0.3, 'max_tokens': 500}+);+```++## TRANSLATE Function++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Missing source language parameter | Use empty string `''` for auto-detect |++```sql+-- Auto-detect source language+SELECT SNOWFLAKE.CORTEX.TRANSLATE(text, '', 'en');++-- Explicit source language+SELECT AI_TRANSLATE(text, 'es', 'en');+```++## AI_FILTER Usage++AI_FILTER returns boolean, use in WHERE clause:++```sql+-- CORRECT+SELECT * FROM table WHERE AI_FILTER(text_col, 'mentions shipping problems');++-- Can combine with SQL predicates+SELECT * FROM table+WHERE created_date > '2025-01-01'+ AND AI_FILTER(description, 'customer is frustrated');+```++## Billing Awareness++Both input AND output tokens are billed for:+- AI_COMPLETE, AI_CLASSIFY, AI_FILTER, AI_AGG+- AI_SUMMARIZE, AI_TRANSLATE+- Legacy SNOWFLAKE.CORTEX versions++~4 characters = 1 token (varies by model)diff --git a/skills/snowflake-platform/rules/snowflake-native-apps.md b/skills/snowflake-platform/rules/snowflake-native-apps.mdnew file mode 100644index 00000000..98c78e74--- /dev/null+++ b/skills/snowflake-platform/rules/snowflake-native-apps.md@@ -0,0 +1,101 @@+---+globs:+ - "snowflake.yml"+ - "manifest.yml"+ - "setup_script.sql"+ - "setup.sql"+ - "**/PROVIDER_STUDIO.md"+---++# Snowflake Native App Corrections++## Release Directive Syntax++When release channels are enabled (default in newer versions), legacy SQL syntax fails.++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `ALTER APPLICATION PACKAGE ... SET DEFAULT RELEASE DIRECTIVE VERSION = V1_0 PATCH = 0` | `snow app release-directive set default --version V1_0 --patch 0 --channel DEFAULT` |++Check if channels enabled: `snow app release-channel list`++## Data Sharing Syntax++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `GRANT REFERENCE_USAGE ON DATABASE ... TO SHARE` | `GRANT REFERENCE_USAGE ON DATABASE ... TO SHARE IN APPLICATION PACKAGE pkg_name` |++## External Access Integration Reset++**Critical**: External access integration attachment resets on EVERY `snow app run`.++After each deploy, re-run:+```sql+ALTER STREAMLIT [APP_NAME].config_schema.[streamlit_name]+ SET EXTERNAL_ACCESS_INTEGRATIONS = (integration_name);+```++## Artifact Mapping++Directory mappings nest the folder. Always list files explicitly:++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `src: app/streamlit/` with `dest: streamlit/` | List individual files explicitly |++```yaml+# WRONG - creates streamlit/streamlit/+artifacts:+ - src: app/streamlit/+ dest: streamlit/++# CORRECT - flat structure+artifacts:+ - src: app/streamlit/environment.yml+ dest: streamlit/environment.yml+ - src: app/streamlit/streamlit_app.py+ dest: streamlit/streamlit_app.py+```++## Manifest Privileges++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Privileges section in manifest.yml | Remove privileges section entirely |+| GRANT ALL/FUTURE in setup_script.sql | Use specific table grants only |++Native Apps cannot declare privileges in manifest.++## Snowpark Row Access++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `dict(result[0])` for Snowpark Row | `row['COLUMN_NAME']` explicit access |++```python+# WRONG+config = dict(result[0])++# CORRECT+row = result[0]+config = {'COLUMN_A': row['COLUMN_A'], 'COLUMN_B': row['COLUMN_B']}+```++## Security Review Statuses++Include all 5 statuses:+- `NOT_REVIEWED` - Scan hasn't run+- `IN_PROGRESS` - Scan running+- `APPROVED` - Passed+- `REJECTED` - Failed+- `MANUAL_REVIEW` - Human reviewing (can take business days)++## Provider Studio++- Description field uses WYSIWYG editor - cannot paste raw HTML+- Business Needs require individual descriptions (not just selection)+- **Data Dictionary is MANDATORY for data listings (2025)**++## Paid Listing++Cannot convert free listing to paid. Must create new paid listing.diff --git a/skills/snowflake-platform/templates/cortex-examples.sql b/skills/snowflake-platform/templates/cortex-examples.sqlnew file mode 100644index 00000000..1ad1de25--- /dev/null+++ b/skills/snowflake-platform/templates/cortex-examples.sql@@ -0,0 +1,158 @@+-- Snowflake Cortex AI Function Examples+-- Run these in Snowflake worksheet or via snow sql++-- ============================================+-- COMPLETE - Text Generation+-- ============================================++-- Simple prompt+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ 'Explain data warehousing in one sentence'+) AS response;++-- With conversation history+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'llama3.1-70b',+ [+ {'role': 'system', 'content': 'You are a data analyst assistant'},+ {'role': 'user', 'content': 'What is a fact table?'}+ ]+) AS response;++-- With options (lower temperature = more deterministic)+SELECT SNOWFLAKE.CORTEX.COMPLETE(+ 'mistral-large2',+ 'Generate a product description for: wireless earbuds',+ {'temperature': 0.3, 'max_tokens': 200}+) AS response;++-- ============================================+-- SUMMARIZE - Text Summarization+-- ============================================++-- Summarize single text+SELECT SNOWFLAKE.CORTEX.SUMMARIZE(+ 'Snowflake is a cloud-based data warehousing platform that enables+ organizations to store, process, and analyze large volumes of data.+ It separates compute from storage, allowing independent scaling of+ each resource. The platform supports structured and semi-structured+ data, including JSON, Avro, and Parquet formats.'+) AS summary;++-- Summarize column from table+SELECT+ product_id,+ SNOWFLAKE.CORTEX.SUMMARIZE(review_text) AS review_summary+FROM product_reviews+LIMIT 10;++-- Aggregate summaries across rows (no context window limit!)+SELECT AI_SUMMARIZE_AGG(feedback_text) AS all_feedback_summary+FROM customer_feedback+WHERE created_date > DATEADD(day, -30, CURRENT_DATE());++-- ============================================+-- TRANSLATE - Language Translation+-- ============================================++-- Auto-detect source language+SELECT SNOWFLAKE.CORTEX.TRANSLATE(+ 'Bonjour, comment allez-vous?',+ '', -- Empty = auto-detect+ 'en' -- Target: English+) AS translated;++-- Explicit source language+SELECT AI_TRANSLATE(+ 'Hola, buenos días',+ 'es', -- Source: Spanish+ 'en' -- Target: English+) AS translated;++-- Translate column+SELECT+ original_text,+ SNOWFLAKE.CORTEX.TRANSLATE(original_text, '', 'en') AS english_text+FROM international_reviews+LIMIT 10;++-- ============================================+-- SENTIMENT - Sentiment Analysis+-- ============================================++-- Single text (returns -1 to 1)+SELECT SNOWFLAKE.CORTEX.SENTIMENT(+ 'This product is amazing! Best purchase ever.'+) AS sentiment_score;++-- Categorize by sentiment+SELECT+ review_text,+ SNOWFLAKE.CORTEX.SENTIMENT(review_text) AS score,+ CASE+ WHEN SNOWFLAKE.CORTEX.SENTIMENT(review_text) > 0.3 THEN 'Positive'+ WHEN SNOWFLAKE.CORTEX.SENTIMENT(review_text) < -0.3 THEN 'Negative'+ ELSE 'Neutral'+ END AS sentiment_category+FROM product_reviews+LIMIT 20;++-- ============================================+-- AI_FILTER - Natural Language Filtering+-- ============================================++-- Filter with plain English+SELECT * FROM support_tickets+WHERE AI_FILTER(description, 'mentions billing or payment issues');++-- Combine with SQL predicates+SELECT * FROM customer_feedback+WHERE created_date > '2025-01-01'+ AND AI_FILTER(feedback_text, 'customer is frustrated or angry');++-- Find specific topics+SELECT * FROM news_articles+WHERE AI_FILTER(content, 'discusses artificial intelligence or machine learning');++-- ============================================+-- AI_CLASSIFY - Text Classification+-- ============================================++-- Categorize support tickets+SELECT+ ticket_id,+ description,+ AI_CLASSIFY(+ description,+ ['billing', 'technical', 'shipping', 'account', 'other']+ ) AS category+FROM support_tickets+LIMIT 20;++-- Priority classification+SELECT+ ticket_id,+ AI_CLASSIFY(+ description,+ ['urgent', 'high', 'medium', 'low']+ ) AS priority+FROM support_tickets+WHERE status = 'open';++-- ============================================+-- Practical Example: Customer Support Analysis+-- ============================================++-- Comprehensive ticket analysis+SELECT+ ticket_id,+ created_date,+ description,+ SNOWFLAKE.CORTEX.SENTIMENT(description) AS sentiment,+ AI_CLASSIFY(description, ['billing', 'technical', 'shipping', 'account']) AS category,+ SNOWFLAKE.CORTEX.SUMMARIZE(description) AS summary+FROM support_tickets+WHERE created_date > DATEADD(day, -7, CURRENT_DATE())+ORDER BY sentiment ASC -- Show most negative first+LIMIT 50;diff --git a/skills/snowflake-platform/templates/snowflake.yml b/skills/snowflake-platform/templates/snowflake.ymlnew file mode 100644index 00000000..cb3d1ac5--- /dev/null+++ b/skills/snowflake-platform/templates/snowflake.yml@@ -0,0 +1,31 @@+# Snowflake Native App Project Configuration+# Copy to your project root and update placeholders++definition_version: 2++native_app:+ name: {{APP_NAME}}+ package:+ name: {{APP_NAME}}_pkg+ distribution: external # For marketplace publishing+ application:+ name: {{APP_NAME}}+ source_stage: stage/dev++ # List files explicitly to avoid nesting issues+ artifacts:+ - src: manifest.yml+ dest: manifest.yml+ - src: setup_script.sql+ dest: setup_script.sql+ # Streamlit files (if using)+ - src: app/streamlit/environment.yml+ dest: streamlit/environment.yml+ - src: app/streamlit/streamlit_app.py+ dest: streamlit/streamlit_app.py+ # Add pages individually+ # - src: app/streamlit/pages/01_page.py+ # dest: streamlit/pages/01_page.py++ # Enable for ALPHA/BETA release tracks+ enable_release_channels: true