skills/cortex-code/SKILL.md
Routes Snowflake-related operations to Cortex Code CLI for specialized Snowflake expertise. Use when user asks about Snowflake databases, data warehouses, SQL queries on Snowflake, Cortex AI features, Snowpark, dynamic tables, data governance in Snowflake, Snowflake security, or mentions "Cortex" explicitly. Do NOT use for general programming, local file operations, non-Snowflake databases, web development, or infrastructure tasks unrelated to Snowflake.
npx skillsauth add kilo-org/kilo-marketplace cortex-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This marketplace skill is already installed; do not install or replace skill instructions dynamically. Cortex Code CLI must be installed and configured from the official Snowflake documentation. Verify the reviewed installation with:
which cortex
This skill enables your coding agent to leverage Cortex Code's specialized Snowflake expertise by intelligently routing Snowflake-related operations to Cortex Code CLI in headless mode.
Routing Principle: ONLY Snowflake operations → Cortex Code. Everything else → your coding agent.
Key Components:
The skill includes a security wrapper around Cortex execution with three approval modes:
prompt (default): High security
auto: Medium security
envelope_only: Medium security
Configuration: Set in config.yaml in the skill's install directory, or via organization policy.
IMPORTANT —
config.yamlis optional. The skill ships onlyconfig.yaml.exampleas a template. If noconfig.yamlexists, the Python scripts apply safe defaults (approval_mode: prompt,default_envelope: RO). Do not search, glob, orlsforconfig.yamlbefore executing —ConfigManagerhandles this internally. Only read/createconfig.yamlif the user explicitly asks to change settings.
~/.cache/cortex-skill/~/.snowflake/cortex/agent-skill-policy.yamlSession state is cached — do not re-run initialization steps on every query.
Skip the following steps if they've already run in the current session:
discover_cortex.py — output cached to ~/.cache/cortex-skill/cortex-capabilities.jsonroute_request.py — for obvious Snowflake queries (user says "Snowflake", "Cortex", "databases", "warehouse", etc.), you can skip routing and go straight to executioncortex connections list — the active connection doesn't change within a session; reuse itconfig.yaml / org-policy inspection — ConfigManager handles this (see note above)Minimal flow for a follow-up Snowflake query (after the first query in a session):
approval_mode: prompt) ask user for approvalexecute_cortex.py with the enriched prompt and envelopeThat's it. Three steps — no re-discovery, no re-routing, no config inspection.
When this skill is first loaded:
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/discover_cortex.py
This script:
cortex skill list to enumerate all available Cortex skillsCacheManager in the configured cache directoryExpected output: JSON mapping of skill names to their trigger patterns and capabilities.
The discovered capabilities are loaded into memory to inform routing decisions throughout the session.
Before taking any action, analyze the user's request:
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/route_request.py --prompt "USER_PROMPT_HERE"
This script:
Routing Logic:
Route to Cortex if request involves:
Route to your coding agent if request involves:
coding_agent (handle locally):Handle the request directly using your agent's built-in capabilities. No Cortex involvement.
Proceed to Step 3.
Before executing Cortex, the security wrapper handles approval based on configured mode.
security_wrapper.py reads approval_mode from config.yaml internally — do not inspect the config file yourself. If config.yaml doesn't exist, the default is prompt mode.
If using prompt mode:
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/security_wrapper.py \
--prompt "ENRICHED_PROMPT" \
--envelope "RW"
This will:
Cortex Code needs to execute the following tools:
• snowflake_sql_execute
• Read
• Write
Envelope: RW
Confidence: 85%
Approve execution? [yes/no]
Determine the appropriate security envelope based on the operation:
Build an enriched prompt that includes:
Current Agent Conversation Context:
Recent Cortex Session Context:
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/read_cortex_sessions.py --limit 3
This reads the most recent Cortex session files from ~/.local/share/cortex/sessions/ to understand what Cortex recently worked on.
Enriched Prompt Format:
# Context from Current Session
[Recent relevant conversation history]
# Recent Cortex Work
[Summary from recent Cortex sessions]
# User Request
[Original user prompt]
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/execute_cortex.py \
--prompt "ENRICHED_PROMPT" \
--connection "connection_name" \
--envelope "RW" \
--disallowed-tools "tool1" "tool2"
This script:
cortex -p "prompt" --output-format stream-json--disallowed-tools blocklist for safetyKey Insight: The wrapper intentionally does not combine -p with --input-format stream-json. Cortex reserves --input-format for JSON stdin input; with closed stdin, that combination can emit only an init event and exit before processing the prompt.
Security Envelopes:
Event Stream Handling:
type: assistant → Cortex's responses, display to usertype: tool_use → Cortex is calling a tooltype: result → Final outcomeWith the security wrapper:
The security wrapper handles permission management through:
audit.log in the skill's install directory--disallowed-toolsFormat Cortex's output for the current session:
User says: "Show me the top 10 customers by revenue in Snowflake"
Routing: → Cortex Code (Snowflake SQL query)
Security Envelope: RW (allows SQL execution)
Cortex Action:
SELECT customer_name, SUM(revenue) as total FROM sales GROUP BY customer_name ORDER BY total DESC LIMIT 10Result: Table displayed to user with top 10 customers.
User says: "Read the config.json file in this directory"
Routing: → your coding agent (local file operation)
Agent Action: Uses Read tool directly, no Cortex involvement.
Result: File contents displayed.
User says: "Check data quality for the SALES_DATA table"
Routing: → Cortex Code (Snowflake data quality - matches Cortex's data-quality skill)
Security Envelope: RW (allows SQL execution for analysis)
Cortex Action:
Result: Comprehensive data quality report with recommendations.
The skill uses a security wrapper that provides:
Configuration: config.yaml in the skill's install directory, or via organization policy
When using auto or envelope_only modes:
--disallowed-tools blocklist instead of interactive approval; use these modes only in trusted contextsEach Cortex invocation is stateless. Context must be explicitly provided via enriched prompts.
Choose envelopes based on operation risk:
Cause: Cortex Code is not installed or not in PATH
Solution:
which cortex
# If not found, check installation: ~/.snowflake/cortex/
Cause: Approval mode misconfiguration or organization policy override
Solution:
# Check approval mode in the agent-specific skill directory.
cat "$(dirname $(which cortex))/../skills/cortex-code/config.yaml" | grep approval_mode 2>/dev/null \
|| cat ~/skills/cortex-code/config.yaml | grep approval_mode
# Check organization policy (overrides user config)
cat ~/.snowflake/cortex/agent-skill-policy.yaml 2>/dev/null
# Expected:
# prompt = shows approval prompts (default)
# auto = auto-approves all operations
# envelope_only = auto-approves, no tool prediction
Cause: Prompt mentions paths matching credential allowlist (e.g., ~/.ssh/, .env)
Solution:
Symptom: Emails, phone numbers replaced with placeholders
Cause: Automatic sanitization enabled by default
Solution: Disable if needed (not recommended):
security:
sanitize_conversation_history: false
Cause: Tool is in the --disallowed-tools blocklist for current envelope
Solution:
NONE in auto/envelope_only modes; use a named envelope plus explicit custom blocklist if neededSymptom: No audit.log despite auto/envelope_only mode
Solution:
# Create the skill's install directory if missing and set permissions
# Path is agent-specific; use the configured cortex-code skill directory.
chmod 700 "$(cd "$(dirname "$0")/.." && pwd)"
# Verify audit_log_path in config.yaml within the skill directory
grep audit_log_path config.yaml
Cause: Approval mode, envelope blocklist, or stream JSON invocation is misconfigured
Solution: Ensure the wrapper invokes cortex -p "..." --output-format stream-json without --input-format, and that the configured envelope does not block the intended tool.
Cause: Routing logic didn't detect Snowflake keywords
Solution:
scripts/route_request.pyCause: Snowflake connection not configured in Cortex
Solution:
cortex connections list
# Verify connection is active
# Check ~/.snowflake/cortex/settings.json for cortexAgentConnectionName
Cause: Including too much conversation history
Solution: Limit to last 2-3 relevant exchanges, summarize older context.
To customize routing beyond default logic, edit scripts/route_request.py:
# Add custom patterns
FORCE_CORTEX_PATTERNS = [
"snowflake",
"cortex",
"warehouse",
"snowpark"
]
FORCE_CODING_AGENT_PATTERNS = [
"local file",
"git commit",
"python script" # unless Snowpark
]
See references/ directory for:
cortex-cli-reference.md - Full Cortex CLI documentationrouting-examples.md - More routing decision examplessession-file-format.md - Cortex session file structuretroubleshooting-guide.md - Extended troubleshootingdevelopment
Oracle Database guidance for SQL, PL/SQL, SQLcl, ORDS, administration, app development, performance, security, migrations, and agent-safe database workflows. Use when the user asks to write, edit, rewrite, review, format, debug, tune, or explain SQL; create or refactor PL/SQL; use SQLcl, Liquibase, ORDS, JDBC, node-oracledb, Python, Java, .NET, or database frameworks; troubleshoot queries, sessions, locks, waits, indexes, optimizer plans, AWR, ASH, migrations, schemas, users, roles, privileges, backup, recovery, Data Guard, RAC, multitenant, containers, monitoring, auditing, encryption, VPD, or safe agent database operations.
documentation
Patterns for reading and writing oleander Iceberg catalog tables in Spark jobs, including naming conventions, write modes, and catalog hierarchy.
data-ai
Integrate Okta for enterprise identity workflows including OIDC login, group claims, and policy-based access controls. Use when implementing workforce or B2B identity scenarios.
documentation
Use when arranging Apache NiFi processors, process groups, ports, comments, numbering, crossing connections, dense fan-in/fan-out, or reusable readable canvas layouts.