|
| 1 | +--- |
| 2 | +name: solutions-installer |
| 3 | +id: solutions-installer |
| 4 | +title: Install Snowflake Solutions |
| 5 | +summary: Install pre-built industry solutions into your Snowflake account from the sf-solutions repository. |
| 6 | +description: >- |
| 7 | + Use for ALL requests to install, set up, deploy, or tear down a pre-built Snowflake industry solution. |
| 8 | + This skill reads a solution's manifest.json for metadata, then executes its setup SQL scripts |
| 9 | + against the user's Snowflake account. |
| 10 | + Triggers: install solution, coco solutions install, set up solution, deploy solution, |
| 11 | + teardown solution, uninstall solution, sf-solutions, solution accelerator, demo environment. |
| 12 | + Do NOT use for: adding pages to the solutions catalog website (use snowflake-solutions-catalog instead), |
| 13 | + building custom solutions from scratch, or general SQL authoring. |
| 14 | +tools: |
| 15 | + - snowflake_sql_execute |
| 16 | + - snowflake_object_search |
| 17 | + - Bash |
| 18 | + - Read |
| 19 | + - Write |
| 20 | + - Glob |
| 21 | + - Grep |
| 22 | + - WebFetch |
| 23 | +prompt: "$solutions-installer <solution-name>" |
| 24 | +language: en |
| 25 | +status: beta |
| 26 | +authors: Sho Tanaka |
| 27 | +type: snowflake |
| 28 | +categories: solutions, demo, installer |
| 29 | +--- |
| 30 | + |
| 31 | +# Install Snowflake Industry Solutions |
| 32 | + |
| 33 | +Installs a pre-built industry solution from the [sf-solutions](https://github.com/Snowflake-Labs/sf-solutions) repository into the user's Snowflake account. Each solution contains a `manifest.json` describing its metadata and a `scripts/` directory with SQL setup/teardown files. |
| 34 | + |
| 35 | +# When to Use |
| 36 | +- User wants to install a solution: `$solutions-installer <solution-name>` where `<solution-name>` is a directory name in the [sf-solutions](https://github.com/Snowflake-Labs/sf-solutions) repository (e.g., `manufacturing-predictive-maintenance`) |
| 37 | +- User wants to tear down / uninstall a solution |
| 38 | +- User wants to set up a demo environment for an industry use case |
| 39 | +- Do NOT use for editing the solutions catalog website |
| 40 | + |
| 41 | +# What This Skill Provides |
| 42 | +- Clones or locates the sf-solutions repository |
| 43 | +- Reads the solution's `manifest.json` to understand what will be created |
| 44 | +- Executes `install_scripts` (setup SQL) against the user's Snowflake account |
| 45 | +- Supports teardown via `teardown_scripts` |
| 46 | +- Verifies the installation by checking created objects |
| 47 | + |
| 48 | +# Solution Directory Convention |
| 49 | + |
| 50 | +Each solution follows this structure: |
| 51 | + |
| 52 | +``` |
| 53 | +<solution-slug>/ |
| 54 | +├── manifest.json # REQUIRED: solution metadata (see schema below) |
| 55 | +├── README.md # Solution overview, architecture, prerequisites |
| 56 | +└── scripts/ |
| 57 | + ├── setup.sql # Main installation script |
| 58 | + └── teardown.sql # Cleanup script (drops all created objects) |
| 59 | +``` |
| 60 | + |
| 61 | +## manifest.json Schema |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "name": "solution-slug", |
| 66 | + "display_name": "Human-Readable Solution Name", |
| 67 | + "version": "1.0.0", |
| 68 | + "industry": "Manufacturing", |
| 69 | + "source": "https://github.com/...", |
| 70 | + "license": "MIT", |
| 71 | + "database": "DATABASE_NAME", |
| 72 | + "schemas": ["SCHEMA_A", "SCHEMA_B"], |
| 73 | + "role": "ACCOUNTADMIN", |
| 74 | + "requires_warehouse": true, |
| 75 | + "install_scripts": ["scripts/setup.sql"], |
| 76 | + "teardown_scripts": ["scripts/teardown.sql"], |
| 77 | + "features": ["Cortex Analyst", "Semantic View", "Streamlit in Snowflake"] |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +| Field | Required | Description | |
| 82 | +|-------|----------|-------------| |
| 83 | +| `name` | Yes | Solution slug, matches the directory name | |
| 84 | +| `display_name` | Yes | Human-readable name shown to the user | |
| 85 | +| `version` | Yes | Semver version string | |
| 86 | +| `industry` | Yes | Primary industry vertical | |
| 87 | +| `database` | Yes | Database that will be created | |
| 88 | +| `schemas` | Yes | List of schemas that will be created | |
| 89 | +| `role` | Yes | Required Snowflake role to run the setup | |
| 90 | +| `install_scripts` | Yes | Ordered list of SQL scripts to execute for setup | |
| 91 | +| `teardown_scripts` | Yes | Ordered list of SQL scripts to execute for cleanup | |
| 92 | +| `requires_warehouse` | No | Whether the setup creates its own warehouse(s) | |
| 93 | +| `features` | No | Snowflake features used in this solution | |
| 94 | +| `source` | No | URL to the original source repository | |
| 95 | +| `license` | No | License of the source material | |
| 96 | + |
| 97 | +# Instructions |
| 98 | + |
| 99 | +## Step 0: Resolve the Solution |
| 100 | + |
| 101 | +**Actions:** |
| 102 | +1. Parse the solution slug from the user's prompt (e.g., `manufacturing-predictive-maintenance`) |
| 103 | +2. If no slug is provided, list available solutions by scanning `<repo>/**/manifest.json` and present a table: |
| 104 | + ``` |
| 105 | + | Slug | Name | Industry | Database | Role Required | |
| 106 | + ``` |
| 107 | +3. **Ask** the user to pick one if not specified |
| 108 | + |
| 109 | +**If the slug does not match any directory:** |
| 110 | +- Check if the repo has new solutions (git pull or re-scan) |
| 111 | +- If still not found, inform the user and stop |
| 112 | + |
| 113 | +## Step 1: Fetch the Solution Repository |
| 114 | + |
| 115 | +**Actions:** |
| 116 | +1. Check if the sf-solutions repo exists locally. Search these paths in order: |
| 117 | + - `~/project/sf-solutions/` |
| 118 | + - `./sf-solutions/` |
| 119 | + - The current working directory (check for `manifest.json` files) |
| 120 | +2. If not found locally, clone it: |
| 121 | + ```bash |
| 122 | + git clone https://github.com/Snowflake-Labs/sf-solutions.git /tmp/sf-solutions |
| 123 | + ``` |
| 124 | +3. Verify the solution directory exists: `<repo>/<slug>/manifest.json` |
| 125 | + |
| 126 | +**Output:** Path to the solution directory. |
| 127 | + |
| 128 | +## Step 2: Read manifest.json and Present Installation Plan |
| 129 | + |
| 130 | +**Actions:** |
| 131 | +1. Read `<slug>/manifest.json` |
| 132 | +2. Validate all required fields are present |
| 133 | +3. Read `<slug>/README.md` for additional context (architecture, prerequisites) |
| 134 | +4. List the install scripts that will be executed |
| 135 | + |
| 136 | +**⚠️ STOPPING POINT:** Present the installation plan to the user: |
| 137 | +``` |
| 138 | +Solution: <display_name> (v<version>) |
| 139 | +Industry: <industry> |
| 140 | +Source: <source> |
| 141 | +
|
| 142 | +Will create: |
| 143 | + Database: <database> |
| 144 | + Schemas: <schemas joined with ", "> |
| 145 | + Role required: <role> |
| 146 | + Features: <features joined with ", "> |
| 147 | +
|
| 148 | +Scripts to execute: |
| 149 | + 1. <install_scripts[0]> |
| 150 | + 2. <install_scripts[1]> (if any) |
| 151 | +
|
| 152 | +Proceed with installation? |
| 153 | +``` |
| 154 | + |
| 155 | +Wait for user confirmation before proceeding. |
| 156 | + |
| 157 | +## Step 3: Execute Install Scripts |
| 158 | + |
| 159 | +**Actions:** |
| 160 | +1. For each script in `install_scripts` (in order): |
| 161 | + a. Read the SQL file |
| 162 | + b. Split into individual SQL statements (split on `;`, respecting comments and string literals) |
| 163 | + c. Execute each statement sequentially using `snowflake_sql_execute` |
| 164 | +2. For long-running statements (ML models, large data generation, SPCS compute pools): |
| 165 | + - Use `timeout_seconds: 600` |
| 166 | + - Inform the user that the statement may take several minutes |
| 167 | +3. For statements that depend on `RESULT_SCAN(LAST_QUERY_ID())`: |
| 168 | + - Execute them immediately after the preceding statement |
| 169 | + - Do NOT batch these |
| 170 | +4. After each major section, log progress: |
| 171 | + - "Created database <name>" |
| 172 | + - "Created schema <name>" |
| 173 | + - "Loaded <N> rows into <table>" |
| 174 | + |
| 175 | +**If a statement fails:** |
| 176 | +- "insufficient privileges": Show the required role from manifest.json, ask the user to switch roles or grant privileges |
| 177 | +- "object already exists" (without CREATE OR REPLACE): Ask user whether to skip or drop-and-recreate |
| 178 | +- Other errors: Show the error and the failing SQL, ask user for guidance |
| 179 | + |
| 180 | +**Output:** Confirmation of each script completed. |
| 181 | + |
| 182 | +## Step 4: Verify Installation |
| 183 | + |
| 184 | +**Actions:** |
| 185 | +1. Run verification queries using the `database` and `schemas` from manifest.json: |
| 186 | + ```sql |
| 187 | + SELECT TABLE_SCHEMA, TABLE_NAME, ROW_COUNT |
| 188 | + FROM <database>.INFORMATION_SCHEMA.TABLES |
| 189 | + WHERE TABLE_SCHEMA IN (<schemas>) |
| 190 | + ORDER BY TABLE_SCHEMA, TABLE_NAME; |
| 191 | + ``` |
| 192 | +2. Check that all schemas from manifest.json exist |
| 193 | +3. Report any schemas that are empty or missing |
| 194 | + |
| 195 | +**Output:** Summary table of all created objects and row counts. |
| 196 | + |
| 197 | +## Step 5: Post-Install Summary |
| 198 | + |
| 199 | +**Present to the user:** |
| 200 | +``` |
| 201 | +Solution installed: <display_name> v<version> |
| 202 | +
|
| 203 | +Objects created: |
| 204 | + Database: <database> |
| 205 | + Schemas: <list schemas with object counts> |
| 206 | + Tables: <count> tables (<total rows> total rows) |
| 207 | + Views: <count> views |
| 208 | +
|
| 209 | +Features enabled: <features> |
| 210 | +
|
| 211 | +Next steps: |
| 212 | + - See README: <slug>/README.md |
| 213 | + - Teardown: $solutions-installer teardown <slug> |
| 214 | +``` |
| 215 | + |
| 216 | + |
| 217 | +# Best Practices |
| 218 | +- Always read manifest.json first — it is the source of truth for the solution |
| 219 | +- Execute SQL statements one at a time to isolate errors |
| 220 | +- Never modify the source SQL files — read and execute them as-is |
| 221 | +- Log each step clearly so the user knows what was created |
| 222 | +- For ML model training or large data loads, set timeout to 600s |
| 223 | +- Always present the installation plan and wait for confirmation before executing |
| 224 | + |
| 225 | +# Stopping Points |
| 226 | +- ✋ Step 2 — After presenting the installation plan, wait for user confirmation |
| 227 | +- ✋ Step 3 — If privilege errors occur, stop and ask user for role |
| 228 | +- ✋ Teardown — Before dropping any objects, confirm with user |
| 229 | + |
| 230 | +**Resume rule:** Upon user approval, proceed directly to the next step without re-asking. |
| 231 | + |
| 232 | +# Output |
| 233 | +- Fully provisioned Snowflake environment with the chosen solution |
| 234 | +- Database, schemas, tables, views, and ML models ready to use |
| 235 | +- Summary of all created objects with row counts |
| 236 | + |
| 237 | +# Examples |
| 238 | + |
| 239 | +## Example 1: Install manufacturing predictive maintenance |
| 240 | +User: $solutions-installer manufacturing-predictive-maintenance |
| 241 | +Assistant: |
| 242 | +1. Finds repo at ~/project/sf-solutions/ |
| 243 | +2. Reads manufacturing-predictive-maintenance/manifest.json |
| 244 | +3. Presents plan: Database SNOWCORE_INDUSTRIES, schemas BRONZE/SILVER/GOLD, role ACCOUNTADMIN |
| 245 | +4. User confirms → executes scripts/setup.sql statement by statement |
| 246 | +5. Verifies all tables created, shows row counts |
| 247 | +6. Shows summary with next steps |
| 248 | + |
| 249 | + |
| 250 | +## Example 2: List available solutions |
| 251 | +User: $solutions-installer |
| 252 | +Assistant: Scans repo for manifest.json files, shows table of available solutions, asks user to pick one |
0 commit comments