Skip to content
Skills Library
AI & agents · Tool integration

cortex-run

/cortex-run

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.

Licence
Apache-2.0
Last repository change
23.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 23.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Prerequisites
  2. Workflow
  3. Context Enrichment
  4. Multi-turn: --resume-last vs fresh
  5. Examples
  6. Notes
Original SKILL.md headings · 142 lines, 715 words
SKILL.md preview
---
name: cortex-run
description: "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."
license: Proprietary. See LICENSE-SKILLS.md for complete terms
user-invocable: true
metadata:
  author: Snowflake
  version: 1.0.0
---

# 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:

```bash
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.**

```bash
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:

| Envelope | Use when | Blocks |
|----------|----------|--------|
| **RO** | Queries, reads, exploration | Edit, Write, destructive Bash |
| **RW** | Data modifications, DDL | Destructive Bash (rm -rf, sudo) |
| **RESEARCH** | Exploration + web access | Edit, Write, destructive Bash |
| **DEPLOY** | Full access needed | Nothing |

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
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
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
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.

```bash
# 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.

Versions

The database has no other skills named cortex-run.

Database snapshot: 13.11.2026 · package version 0de0d3265ca8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100snowflake-cortex-ai
    Reference for Snowflake Cortex AI Functions (AI_COMPLETE, AI_CLASSIFY, AI_EXTRACT, AI_FILTER, etc.) and Cortex Search for building RAG applications entirely inside Snowflake. Use when writing SQL that calls an LLM, classifying or extracting structured data from text, building a…
  • 90preset-cortex-agents
    Use Snowflake Cortex Agent REST and SQL APIs for listing, describing, creating, updating, deleting, running agents, streaming responses, and SQL wrappers. Use only for direct API workflows; Do not use for MCP-only work.
  • 90preset-snowflake-cortex
    Prepare Snowflake Cortex direct API access: account URL, auth method, role, warehouse, database/schema context, privileges, and Cortex Agent routing. Use only for direct API workflows; Do not use for MCP-only work.
  • 100cortex-setup-project
    Bootstrap Cortex for a new project or import existing session history. Use when the user says 'set up Cortex', 'seed this project', 'import my history', 'backfill memories', 'bootstrap memory', 'initialize Cortex for this project', or when starting to use Cortex on an existing…
  • 96cortex-mcp-project
    Use when working on the Cortex MCP server repo.
  • 100cortex-evolve
    Save knowledge to the cortex vault. Use when the user says "存到 cortex", "記一下", "save to cortex", "記到筆記", "cortex evolve", or when the session-suggest hook recommends saving content. Handles Notes and Projects.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.