Generated banner for Cortex Run
Generated logo for Cortex Run

Cortex Run

SnowflakeOfficialCreated by Snowflake

  • Skill
  • Tool integration
  • Software development
  • Apache-2.0
  • No issues found

From the author

ONLY load this skill when the user explicitly types $cortex-run or /cortex-run. NEVER load this skill from auto-routing hooks or keyword matching. For auto-routed prompts, use snowflake-cortex-code:cortex-router instead.
— the description by Snowflake

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The cortex-run skill provides a dedicated interface for users to manually trigger the Snowflake Cortex Code CLI. By bypassing automatic routing, this skill allows for precise control over Snowflake operations, including data exploration, schema management, and DDL execution. It includes a robust security envelope system to manage permissions for read-only, read-write, research, and deployment tasks, while supporting multi-turn session persistence via resume functionality.

What it does

  • Verifies the presence of the Cortex Code CLI before execution.
  • Routes user prompts directly to the Cortex Code execution environment.
  • Applies security envelopes (RO, RW, RESEARCH, DEPLOY) to restrict command capabilities.
  • Supports session continuity using the resume-last flag for multi-turn interactions.
  • Enriches prompts with relevant conversation context for better model performance.
  • Formats and presents SQL results, errors, and artifacts to the user.

When to use it

  • When you need to explicitly invoke Cortex Code functionality.
  • When performing specific Snowflake database operations like querying or schema modifications.
  • When you need to continue a previous Cortex Code session to maintain context.
  • When you want to override automatic routing for a specific task.

Advantages

  • Bypasses auto-routing to ensure the correct tool is used for the task.
  • Provides granular security control through configurable execution envelopes.
  • Maintains conversation state across multiple turns for complex workflows.
  • Ensures the environment is correctly configured before attempting execution.

Usage examples

“$cortex-run list all tables in the sales_data schema”
The agent verifies the CLI, applies the RO (Read-Only) security envelope, and executes the query to list tables in the specified schema.
“$cortex-run create a new table for monthly reports”
The agent applies the RW (Read-Write) security envelope and executes the DDL command to create the table in Snowflake.
“$cortex-run (after a previous query) now show me the column types for that table”
The agent uses the --resume-last flag to maintain session context and retrieves the column metadata for the table identified in the previous turn.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/snowflake-labs/cortex-run/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip cortex-run.zip -d .agents/skills

Documentation by Snowflake

Cortex Code (Explicit Invocation)

Send a prompt directly to Cortex Code CLI, bypassing the auto-routing keyword filter. Use this when the user explicitly wants Cortex Code to handle their request.

Prerequisites

Cortex Code CLI must be installed and on PATH:

which cortex && cortex --version

If cortex is not found, load the snowflake-cortex-code:cortex-setup skill to install it. Do NOT proceed without it.

Workflow

Step 1: Check Cortex CLI

This step is mandatory. Do it first, every time.

which cortex 2>/dev/null && cortex --version

If cortex is NOT found or the command fails:

  1. Tell the user: "Cortex Code CLI is not installed. Setting it up now."

  2. Load the snowflake-cortex-code:cortex-setup skill using the Skill tool.

  3. Follow its instructions to install the CLI.

  4. STOP here — do NOT proceed to Step 2 until the CLI is installed and working.

Step 2: Extract the User Prompt

The user's message after $cortex-run is the prompt to send. If the user typed only $cortex-run with no additional text, ask what they want to do in Snowflake.

Step 3: Choose Security Envelope

Pick the envelope based on what the operation needs:

EnvelopeUse whenBlocks
ROQueries, reads, explorationEdit, Write, destructive Bash
RWData modifications, DDLDestructive Bash (rm -rf, sudo)
RESEARCHExploration + web accessEdit, Write, destructive Bash
DEPLOYFull access neededNothing

Default to RW unless the request is clearly read-only.

Step 4: Execute via Cortex Code

Run the prompt through the execution script:

Use the shared launcher in Bash (Git Bash on Windows). It prefers python3, accepts python only if it is Python 3, and never retries a failed script. On a configuration/policy error, STOP and report it; do not switch interpreters or bypass the plugin.

bash "${CLAUDE_PLUGIN_ROOT}/scripts/run_python.sh" "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
  --prompt "USER_PROMPT_HERE" \
  --envelope "RW"

For read-only queries:

bash "${CLAUDE_PLUGIN_ROOT}/scripts/run_python.sh" "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
  --prompt "USER_PROMPT_HERE" \
  --envelope "RO"

To specify a Snowflake connection:

bash "${CLAUDE_PLUGIN_ROOT}/scripts/run_python.sh" "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
  --prompt "USER_PROMPT_HERE" \
  --envelope "RW" \
  --connection "connection_name"
Step 5: Return Results

Format Cortex's output for the user:

  • Show SQL results in readable tables

  • Display generated artifacts

  • Report success or failure

  • If Cortex errored, show the error and suggest fixes

Context Enrichment

Before sending the prompt, prepend relevant context from the current Claude Code conversation:

# Context from Claude Code Session
[Last 2-3 relevant exchanges — Snowflake-specific details only]

# User Request
[The original prompt]

Keep context minimal — Cortex only sees what you send in each prompt (unless resuming a session).

Multi-turn: --resume-last vs fresh

Every Cortex invocation returns a session_id that is persisted automatically. Follow-up turns can resume that session so Cortex sees the prior conversation — real multi-turn, not one-shot batches per prompt.

  • Add --resume-last when the current prompt is a continuation of the previous Cortex turn: "keep going", "apply the top suggestion", "dig deeper", "also show me ...", "and for last quarter", "fix that", or any clarification of an answer Cortex just gave.

  • Omit --resume-last (start fresh) when the user switches topics, asks about a different database/warehouse, or begins a clearly new task.

  • --resume <session_id> is also accepted if you have an explicit id.

# Follow-up on the previous Cortex turn
bash "${CLAUDE_PLUGIN_ROOT}/scripts/run_python.sh" "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
  --prompt "also show me the column types" --envelope "RO" \
  --resume-last

Examples

User: $cortex-run show me tables in the RAW schema

  • Envelope: RO

  • Prompt: "show me tables in the RAW schema"

User: $cortex-run create a dynamic table that aggregates daily sales

  • Envelope: RW

  • Prompt: "create a dynamic table that aggregates daily sales"

User: $cortex-run (no prompt)

  • Ask: "What would you like Cortex Code to do?"

Notes

  • This skill is for explicit invocation only. Auto-routing is handled separately by the prompt filter hook + cortex-router skill.

  • Use --resume-last for follow-up prompts so Cortex retains conversation context. For new topics, omit it and include relevant context in the prompt instead.

  • Security envelope enforcement uses --permission-prompt-tool stdio — every tool call is gated by envelope_policy.decide() at the process boundary.

Files

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter, Needs Python

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Snowflake
Publisher
Snowflake (Official)
Source
Snowflake-Labs/snowflake-ai-kit · plugins/cortex-code/skills/cortex-run · commit 6a9165f
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Snowflake.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cortex-run.zip