Route Snowflake operations from any coding agent (Claude Code, Cursor, Codex, VSCode) to Cortex Code CLI — with smart routing, security envelopes, and headless execution.
npx skills add https://github.com/snowflake-labs/subagent-cortex-code --skill cortex-code使用 CLI 安装这个技能,并在你的工作区中直接复用对应的 SKILL.md 工作流。
This skill routes Snowflake-related operations to Cortex Code CLI, enabling coding agents to leverage specialized Snowflake expertise in headless mode.
Choose your coding agent:
| Agent | Install method | Details |
|---|---|---|
| Claude Code | npx skills add snowflake-labs/subagent-cortex-code --copy --global |
→ Claude Code |
| Cursor | npx skills add snowflake-labs/subagent-cortex-code --copy --global + copy routing rule |
→ Cursor |
| Windsurf | npx skills add snowflake-labs/subagent-cortex-code --copy --global |
→ Windsurf |
| Codex | bash integrations/codex/install.sh (not npx — skill hangs in sandbox) |
→ Codex |
| VSCode / terminal | bash integrations/cli-tool/setup.sh |
→ CLI tool |
Prerequisite for all: Cortex Code CLI installed and configured.
which cortex # must return a path
cortex connections list # must show an active connection
Install the skill via npx:
npx skills add snowflake-labs/subagent-cortex-code --copy --global
npx skills add installs to ~/.agents/skills/cortex-code/. Move it into Claude Code's skills directory:
mv ~/.agents/skills/cortex-code ~/.claude/skills/cortex-code
Verify:
ls ~/.claude/skills/cortex-code/SKILL.md
Start Claude Code and mention anything Snowflake-related — the skill activates automatically.
Optional: configure security mode
cp ~/.claude/skills/cortex-code/config.yaml.example \
~/.claude/skills/cortex-code/config.yaml
# edit as needed — default is "prompt" (asks before executing)
See integrations/claude-code/README.md for full details.
Step 1 — Install the skill:
npx skills add snowflake-labs/subagent-cortex-code --copy --global
This installs skills/cortex-code/ to ~/.cursor/skills-cursor/cortex-code/.
Step 2 — Activate the auto-routing rule:
mkdir -p ~/.cursor/rules
cp ~/.cursor/skills-cursor/cortex-code/cortex-snowflake-routing.mdc ~/.cursor/rules/
Step 3 — Restart Cursor.
Without the routing rule you type /cortex-code your question. With it, Cursor detects Snowflake queries automatically and invokes the skill.
Verify:
ls ~/.cursor/skills-cursor/cortex-code/SKILL.md
ls ~/.cursor/rules/cortex-snowflake-routing.mdc
See integrations/cursor/README.md for full details.
Install the skill via npx:
npx skills add snowflake-labs/subagent-cortex-code --copy --global
This installs skills/cortex-code/ to ~/.codeium/windsurf/skills/cortex-code/.
Verify:
ls ~/.codeium/windsurf/skills/cortex-code/SKILL.md
Restart Windsurf — Cascade auto-discovers the skill by name and description. Mention anything Snowflake-related and it activates automatically. No routing rule needed.
Optional: configure security mode
cp ~/.codeium/windsurf/skills/cortex-code/config.yaml.example \
~/.codeium/windsurf/skills/cortex-code/config.yaml
# edit as needed — default is "prompt" (asks before executing)
Codex uses the cortexcode-tool CLI directly — no skill directory needed.
Important: Do NOT run
npx skills addfor Codex. The skill-based approach hangs in Codex's sandbox because it requires interactive approval prompts. Use the CLI install below instead.
git clone https://github.com/Snowflake-Labs/subagent-cortex-code.git
cd subagent-cortex-code
bash integrations/codex/install.sh
The script:
cortexcode-tool CLI to ~/.local/bin/~/.local/lib/cortexcode-tool/config.yaml (auto-detected, no --config flag needed)Verify:
cortexcode-tool --version
cortexcode-tool "How many databases do I have in Snowflake?" --envelope RO
Usage from Codex sessions:
First time — paste into a Codex session to confirm the tool is discoverable:
which cortexcode-tool
cortexcode-tool --help
Once discovered, Codex invokes cortexcode-tool for Snowflake questions automatically. Both explicit and implicit prompts work — no --envelope needed:
# Explicit
cortexcode-tool "How many databases do I have in Snowflake?"
# Implicit — Codex detects Snowflake intent and calls cortexcode-tool on its own
How many databases do I have in Snowflake?
See integrations/codex/README.md for full details.
For VSCode task runners, Windsurf, or any terminal environment:
git clone https://github.com/Snowflake-Labs/subagent-cortex-code.git
cd subagent-cortex-code/integrations/cli-tool
bash setup.sh
Verify:
cortexcode-tool --version
cortexcode-tool "your question"
See integrations/cli-tool/README.md for full details.
The Cortex Code Integration Skill bridges coding agents and Cortex Code CLI, allowing seamless delegation of Snowflake-specific tasks while the agent handles everything else.
Key Features:
User Request
↓
[Your Coding Agent — Routing Layer]
↓
Is Snowflake-related?
↓ YES ↓ NO
[Cortex Code CLI] [Your Coding Agent]
↓ ↓
Snowflake Execution General Tasks
Routing Principle: ONLY Snowflake operations → Cortex Code. Everything else → your coding agent.
✅ Routes to Cortex:
❌ Stays with your agent:
| Mode | Security | Use Case |
|---|---|---|
| prompt (default) | High | Interactive sessions, production |
| auto | Medium | Automated workflows, CI/CD |
| envelope_only | Medium | Trusted environments, faster |
Configure in config.yaml in the skill's install directory (for skill-based agents) or ~/.local/lib/cortexcode-tool/config.yaml (for CLI-based agents):
security:
approval_mode: "auto" # or "prompt" or "envelope_only"
| Envelope | Use Case | Blocked Tools |
|---|---|---|
| RO (Read-Only) | Queries and reads | Edit, Write, destructive Bash |
| RW (Read-Write) | Data modifications | Destructive operations (rm -rf, sudo) |
| RESEARCH | Exploratory work | Write operations |
| DEPLOY | Full access | None |
| NONE | Custom blocklist | Specify via --disallowed-tools |
~/.ssh/, .env are detected~/.snowflake/cortex/claude-skill-policy.yamlSee SECURITY.md and SECURITY_GUIDE.md for full details.
The integration automatically discovers Cortex Code's native capabilities at session start:
cortex skill list to enumerate all available skills (32+ bundled in v1.0.42)SKILL.md from ~/.local/share/cortex/{version}/bundled_skills/This is future-proof: new Cortex releases with additional skills work automatically.
Cortex is invoked with --bypass for non-TTY headless execution:
cortex -p "ENRICHED_PROMPT" --output-format stream-json --bypass
Security is enforced via --disallowed-tools blocklist (controlled by the chosen envelope).
Scenario: Build a Cortex Agent for macroeconomic analysis
User: "Analyze FINANCE__ECONOMICS. Create a Cortex agent with Cortex Analyst
that can answer macro economic questions. Put assets in DB_STOCK."
DB_STOCK.CURATED.MACRO_ECONOMICS_INDICATORSDB_STOCK.CURATED.MACRO_ECONOMICS_ANALYST with Cortex AnalystProduction-ready Cortex Agent deployed in one conversation, tested and immediately queryable.
subagent-cortex-code/
├── skills/
│ └── cortex-code/ # Installable skill (npx skills add)
│ ├── SKILL.md # Skill definition — loaded by Claude Code, Cursor, etc.
│ ├── cortex-snowflake-routing.mdc # Cursor auto-routing rule
│ ├── config.yaml.example
│ ├── scripts/ # Routing, execution, discovery, context
│ └── security/ # Approval, audit, cache, sanitization modules
│
├── integrations/
│ ├── claude-code/ # Claude Code-specific notes and uninstall script
│ ├── cursor/ # Cursor-specific notes and uninstall script
│ ├── codex/ # Codex install script (cortexcode-tool + config)
│ └── cli-tool/ # cortexcode-tool Python package + setup script
│
└── shared/ # Canonical source for scripts/ and security/
├── scripts/ # (copied into skills/cortex-code/ by install process)
└── security/
Cortex CLI not found:
which cortex
# If missing: curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh
No active connection:
cortex connections list
cortex connections create # to add one
Skill not loading (Claude Code / Cursor):
ls ~/.claude/skills/cortex-code/SKILL.md # Claude Code
ls ~/.cursor/skills-cursor/cortex-code/SKILL.md # Cursor
ls ~/.codeium/windsurf/skills/cortex-code/SKILL.md # Windsurf
# If missing, re-run: npx skills add snowflake-labs/subagent-cortex-code --copy --global
Codex command hanging:
# Verify cortexcode-tool config exists and uses auto approval
cat ~/.local/lib/cortexcode-tool/config.yaml | grep approval_mode
# Should be: approval_mode: "auto"
cortexcode-tool not found (Codex / CLI):
which cortexcode-tool
# If missing: re-run the install script
Copyright © 2026 Snowflake Inc. All rights reserved.
For issues: GitHub Issues