Логотип Cortex Code

Cortex Code

Организация
Kilo-Org
cortex-code

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.

Обзор

ИздательKilo-Org
Репозиторийkilo-marketplace
Название навыкаcortex-code
Звёзды
179
Форки
168
Файлы в комплекте
17
ЛицензияApache-2.0
Ссылки
  • Инструкции в формате Markdown

    Модель загружает файл SKILL.md по мере необходимости, поэтому токены расходуются только при подходящем запросе.

  • Работает с любой большой языковой моделью

    Навыки ИИ — это обычный Markdown, а не код для конкретного поставщика, поэтому они работают с GPT, Claude, Gemini, Grok и локальными моделями.

  • Файлы в комплекте: 17

    Скрипты, шаблоны и справочные материалы, которые модель может читать во время работы. Файлы доступны только для чтения и никогда не выполняются.

  • Открытый исходный код

    Издатель навыка на GitHub — Kilo-Org. Перед установкой изучите исходные материалы.

Установка

Установите навык ИИ Cortex Code в TypingMind, чтобы использовать его с любой LLM, или добавьте его в другой агент, который умеет читать SKILL.md.

1

Установка в TypingMind

TypingMind устанавливает навык прямо из его папки на GitHub: читает SKILL.md, собирает файлы ресурсов и сохраняет результат локально.

  1. Откройте приложение и перейдите в раздел «Плагины → Навыки».
  2. Выберите «Установить из GitHub».
  3. Вставьте указанную ниже ссылку на папку навыка и подтвердите установку.
    https://github.com/Kilo-Org/kilo-marketplace/tree/main/skills/cortex-code
  4. Включите навык в каждом чате, где хотите его использовать.
Плагины → Навыки → Добавить навык → По ссылке GitHub, затем вставьте ссылку на папку и нажмите «Продолжить».
2

Установка в другом агенте

Любой агент с поддержкой формата Agent Skills может использовать этот навык — скопируйте папку в каталог навыков этого агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Kilo-Org/kilo-marketplace.git /tmp/kilo-marketplace
mkdir -p .claude/skills
cp -r /tmp/kilo-marketplace/skills/cortex-code .claude/skills/cortex-code
После копирования перезапустите Claude Code, чтобы загрузить новый навык.

Использование в TypingMind

Включите навык Cortex Code в любом чате TypingMind, и дальше модель всё сделает сама. Его название и описание хранятся в системном промпте, а при появлении подходящего запроса модель сама загружает полные инструкции. Вам не нужно вызывать навык вручную, и до фактического использования он не расходует токены.

Модель сама загружает навык Cortex Code, как только появляется подходящий для него запрос.

Работает с любой моделью ИИ

Навыки ИИ — это обычные инструкции в Markdown, а не код для конкретного поставщика, поэтому навык Cortex Code не привязан к модели, для которой он был создан. Установите его один раз в TypingMind и используйте с GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama или локальной моделью, которую запускаете самостоятельно, — со своими ключами API.

  • Загружается только при необходимости

    Системный промпт содержит только название и описание. Инструкции загружаются при первом подходящем запросе, поэтому неиспользуемый навык не расходует токены.

  • Меняйте модели прямо в чате

    Навык состоит из инструкций, а не кода, поэтому смена модели не нарушает его работу: новая модель читает тот же файл SKILL.md.

Инструкции навыка

Это содержимое файла SKILL.md, которое загружает модель. Прочитайте его перед установкой: навык — это инструкции, которым будет следовать ваша модель.

Cortex Code Integration Skill

Prerequisite

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:

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

Architecture Overview

Routing Principle: ONLY Snowflake operations → Cortex Code. Everything else → your coding agent.

Key Components:

  • Dynamic skill discovery at session initialization
  • LLM-based semantic routing (not keyword matching)
  • Security wrapper with approval modes (prompt/auto/envelope_only)
  • Stateless Cortex execution with context enrichment
  • Hybrid memory management
  • Audit logging for compliance

Security

The skill includes a security wrapper around Cortex execution with three approval modes:

Approval Modes

  1. prompt (default): High security

    • User shown approval prompt with predicted tools and confidence
    • User must approve before execution
    • No audit logging required
    • Best for: Interactive sessions, untrusted prompts, production
  2. auto: Medium security

    • All operations auto-approved
    • Mandatory audit logging
    • Envelopes still enforced
    • Best for: Automated workflows, trusted environments
  3. envelope_only: Medium security

    • No tool prediction (faster)
    • Auto-approved with audit logging
    • Relies on envelope blocklist only
    • Best for: Trusted environments, low latency needs

Configuration: Set in config.yaml in the skill's install directory, or via organization policy.

IMPORTANT — config.yaml is optional. The skill ships only config.yaml.example as a template. If no config.yaml exists, the Python scripts apply safe defaults (approval_mode: prompt, default_envelope: RO). Do not search, glob, or ls for config.yaml before executing — ConfigManager handles this internally. Only read/create config.yaml if the user explicitly asks to change settings.

Built-in Protections

  • Prompt Sanitization: Automatic PII removal and injection detection
  • Credential Blocking: Prevents routing when credential paths detected
  • Secure Caching: SHA256-validated cache in ~/.cache/cortex-skill/
  • Audit Logging: Structured JSONL logs (mandatory for auto/envelope_only)
  • Organization Policy: Enterprise override via ~/.snowflake/cortex/agent-skill-policy.yaml

Fast Path for Repeat Queries

Session 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.json
  • route_request.py — for obvious Snowflake queries (user says "Snowflake", "Cortex", "databases", "warehouse", etc.), you can skip routing and go straight to execution
  • cortex connections list — the active connection doesn't change within a session; reuse it
  • Any config.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):

  1. (If approval_mode: prompt) ask user for approval
  2. Call execute_cortex.py with the enriched prompt and envelope
  3. Return results

That's it. Three steps — no re-discovery, no re-routing, no config inspection.

Session Initialization

When this skill is first loaded:

Step 1: Discover Cortex Capabilities

bash
PYTHON=$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)
$PYTHON scripts/discover_cortex.py

This script:

  1. Runs cortex skill list to enumerate all available Cortex skills
  2. Reads each skill's SKILL.md frontmatter and trigger patterns
  3. Caches capabilities with CacheManager in the configured cache directory
  4. Returns structured data about what Cortex can handle

Expected output: JSON mapping of skill names to their trigger patterns and capabilities.

Step 2: Load Routing Context

The discovered capabilities are loaded into memory to inform routing decisions throughout the session.

Workflow: Handling User Requests

Step 1: Analyze Request with LLM-Based Routing

Before taking any action, analyze the user's request:

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

  1. Loads Cortex capabilities from cache
  2. Uses LLM reasoning to classify the request
  3. Returns routing decision with confidence score

Routing Logic:

  • Route to Cortex if request involves:

    • Snowflake databases, warehouses, schemas, tables
    • SQL queries specifically for Snowflake
    • Cortex AI features (Cortex Search, Cortex Analyst, ML functions)
    • Snowpark, dynamic tables, streams, tasks
    • Data governance, data quality, or security in Snowflake context
    • User explicitly mentions "Cortex" or "Snowflake"
  • Route to your coding agent if request involves:

    • Local file operations (reading, writing, editing local files)
    • General programming (Python, JavaScript, etc. not Snowflake-specific)
    • Non-Snowflake databases (PostgreSQL, MySQL, MongoDB, etc.)
    • Web development, frontend work
    • Infrastructure/DevOps unrelated to Snowflake
    • Git operations, GitHub, version control

Step 2: Execute Based on Routing Decision

If routing is coding_agent (handle locally):

Handle the request directly using your agent's built-in capabilities. No Cortex involvement.

If routed to Cortex Code:

Proceed to Step 3.

Step 3: Choose Security Envelope and Handle Approval

Before executing Cortex, the security wrapper handles approval based on configured mode.

Step 3a: Check Approval 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.

  • prompt mode (default): Requires user approval
  • auto mode: Auto-approve with audit logging
  • envelope_only mode: Auto-approve, no tool prediction
Step 3b: Handle Approval (if prompt mode)

If using prompt mode:

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

  1. Predict required tools using LLM
  2. Display approval prompt to user:
    Cortex Code needs to execute the following tools:
    
      • snowflake_sql_execute
      • Read
      • Write
    
    Envelope: RW
    Confidence: 85%
    
    Approve execution? [yes/no]
  3. If approved, proceed to Step 3c
  4. If denied, abort execution
Step 3c: Determine Security Envelope

Determine the appropriate security envelope based on the operation:

  • RO (Read-Only): For queries and read operations - blocks Edit, Write, destructive Bash
  • RW (Read-Write): For data modifications - allows most operations, blocks destructive Bash
  • RESEARCH: For exploratory work - read access plus web tools
  • DEPLOY: For deployment operations - blocks destructive Bash commands
  • NONE: Custom blocklist via --disallowed-tools

Step 4: Enrich Context for Cortex

Build an enriched prompt that includes:

Current Agent Conversation Context:

  • Last 2-3 relevant exchanges from the current agent session
  • Any Snowflake-specific details already discussed

Recent Cortex Session Context:

bash
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]

Step 5: Execute Cortex Code Headlessly

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

  1. Invokes cortex -p "prompt" --output-format stream-json
  2. Uses print mode for prompt delivery and stream JSON output for non-TTY parsing
  3. Applies envelope-based security via --disallowed-tools blocklist for safety
  4. Parses NDJSON event stream in real-time
  5. Detects tool use events and execution results

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

  • RO (Read-Only): Blocks Edit, Write, destructive Bash commands
  • RW (Read-Write): Blocks destructive operations like rm -rf, sudo
  • RESEARCH: Read access plus web tools, blocks write operations
  • DEPLOY: Deployment operations, blocks destructive Bash commands
  • NONE: Custom blocklist via --disallowed-tools parameter

Event Stream Handling:

  • type: assistant → Cortex's responses, display to user
  • type: tool_use → Cortex is calling a tool
  • type: result → Final outcome

Step 6: Handle Permission Requests

With the security wrapper:

  • prompt mode: User approves BEFORE execution (no mid-execution prompts)
  • auto/envelope_only modes: Non-blocked tools are auto-approved in stream JSON mode

The security wrapper handles permission management through:

  1. Upfront approval (prompt mode): User approves predicted tools before execution
  2. Audit logging (auto/envelope_only): All operations logged to audit.log in the skill's install directory
  3. Envelope enforcement: Tool blocklist still enforced via --disallowed-tools

Step 7: Return Results to User

Format Cortex's output for the current session:

  • Show SQL query results in readable format
  • Display any generated artifacts
  • Report success/failure status
  • Provide relevant excerpts from Cortex's analysis

Examples

Example 1: Snowflake Query

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:

  1. Uses snowflake_sql_execute to run: SELECT customer_name, SUM(revenue) as total FROM sales GROUP BY customer_name ORDER BY total DESC LIMIT 10
  2. Returns formatted results

Result: Table displayed to user with top 10 customers.

Example 2: Local File Operation

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.

Example 3: Data Quality Check

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:

  1. Runs data quality checks using its data-quality skill
  2. Analyzes schema, null rates, duplicates, etc.
  3. Generates quality report

Result: Comprehensive data quality report with recommendations.

Important Notes

Security Wrapper

The skill uses a security wrapper that provides:

  • Approval modes: prompt (default), auto, envelope_only
  • Prompt sanitization: Automatic PII removal and injection detection
  • Credential blocking: Prevents routing when credential paths detected
  • Audit logging: Mandatory for auto/envelope_only modes
  • Tool prediction: LLM predicts required tools for approval prompt

Configuration: config.yaml in the skill's install directory, or via organization policy

Headless Execution with Auto-Approval

When using auto or envelope_only modes:

  • All tool calls are automatically approved without interactive prompts
  • Works for built-in tools (Read, Write, Edit, Bash, Grep, Glob) and non-builtin tools (snowflake_sql_execute, data_diff, MCP tools)
  • Uses print mode for prompt delivery and stream JSON mode for non-TTY output parsing
  • Security is controlled via --disallowed-tools blocklist instead of interactive approval; use these modes only in trusted contexts

Stateless Execution

Each Cortex invocation is stateless. Context must be explicitly provided via enriched prompts.

Memory Boundaries

  • Your coding agent maintains: Full conversation history, user preferences, project context
  • Cortex Code receives: Only task-specific context for current operation
  • Cortex sessions are read: For historical context enrichment only

Security Envelope Strategy

Choose envelopes based on operation risk:

  1. Start with RO or RW: Most operations fit here
  2. Use RESEARCH: When web access is needed for exploratory work
  3. Use DEPLOY: Only for deployment-style operations that require broader non-destructive tool access
  4. Use NONE with custom blocklist: When fine-grained control is needed

Performance Considerations

  • Cortex skill discovery runs once per session (cached)
  • Each Cortex execution adds ~2-5 seconds latency
  • Use routing wisely to minimize unnecessary Cortex calls

Troubleshooting

Error: "Cortex CLI not found"

Cause: Cortex Code is not installed or not in PATH

Solution:

bash
which cortex
# If not found, check installation: ~/.snowflake/cortex/

Error: Approval prompt not appearing (or appearing unexpectedly)

Cause: Approval mode misconfiguration or organization policy override

Solution:

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

Error: "Prompt contains credential file path"

Cause: Prompt mentions paths matching credential allowlist (e.g., ~/.ssh/, .env)

Solution:

  1. Remove credential references from prompt
  2. Or customize allowlist in config.yaml if false positive

Error: PII removed from prompts

Symptom: Emails, phone numbers replaced with placeholders

Cause: Automatic sanitization enabled by default

Solution: Disable if needed (not recommended):

yaml
security:
  sanitize_conversation_history: false

Error: "Permission denied" despite auto mode

Cause: Tool is in the --disallowed-tools blocklist for current envelope

Solution:

  1. Check which envelope is being used (RO/RW/RESEARCH/DEPLOY)
  2. If operation is safe, switch to a less restrictive envelope
  3. Avoid NONE in auto/envelope_only modes; use a named envelope plus explicit custom blocklist if needed

Error: Audit log not created

Symptom: No audit.log despite auto/envelope_only mode

Solution:

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

Error: Tools still requiring approval

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.

Issue: Routing sends Snowflake query to your coding agent

Cause: Routing logic didn't detect Snowflake keywords

Solution:

  1. Check if user mentioned "Snowflake" explicitly
  2. Review routing script logic in scripts/route_request.py
  3. Add more trigger patterns to routing context

Issue: Cortex returns "Connection refused"

Cause: Snowflake connection not configured in Cortex

Solution:

bash
cortex connections list
# Verify connection is active
# Check ~/.snowflake/cortex/settings.json for cortexAgentConnectionName

Issue: Context enrichment too large

Cause: Including too much conversation history

Solution: Limit to last 2-3 relevant exchanges, summarize older context.

Advanced: Custom Routing Rules

To customize routing beyond default logic, edit scripts/route_request.py:

python
# Add custom patterns
FORCE_CORTEX_PATTERNS = [
    "snowflake",
    "cortex",
    "warehouse",
    "snowpark"
]

FORCE_CODING_AGENT_PATTERNS = [
    "local file",
    "git commit",
    "python script" # unless Snowpark
]

References

See references/ directory for:

  • cortex-cli-reference.md - Full Cortex CLI documentation
  • routing-examples.md - More routing decision examples
  • session-file-format.md - Cortex session file structure
  • troubleshooting-guide.md - Extended troubleshooting

Файлы в комплекте

Модель читает эти файлы по мере необходимости, пока навык загружен. Они доступны только для чтения и никогда не выполняются.

Часто задаваемые вопросы

Что делает навык ИИ Cortex Code?

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.

Зачем использовать Cortex Code в TypingMind?

Потому что вы устанавливаете навык один раз и используете его с любой моделью. Cortex Code — это обычный текст в формате Markdown, а не код для конкретного поставщика, поэтому один и тот же навык работает с GPT-5, Claude, Gemini, Grok или локальной моделью. Вы можете менять модель прямо во время чата, и навык продолжит работать. TypingMind использует ваши собственные ключи API, поэтому вы платите поставщикам напрямую, а не оформляете подписку с оплатой за каждое место. Ваши навыки и чаты остаются в вашем собственном хранилище.

Как установить Cortex Code в TypingMind?

В TypingMind откройте «Плагины → Навыки → Установить из GitHub» и вставьте https://github.com/Kilo-Org/kilo-marketplace/tree/main/skills/cortex-code. TypingMind прочитает файл SKILL.md, включит сопутствующие файлы в пакет и установит навык, который можно включать отдельно для каждого чата.

Какие модели ИИ могут использовать Cortex Code?

Любая модель, которую вы подключите в TypingMind. Навыки ИИ — это обычные инструкции в формате Markdown, а не код для конкретного поставщика, поэтому GPT, Claude, Gemini, Grok и локальные модели могут загружать этот навык, когда запрос ему соответствует.

Со сколькими моделями ИИ можно использовать Cortex Code?

С любым количеством. В TypingMind вы можете использовать Cortex Code с любой моделью, которая поддерживает навыки, в том числе с GPT, Claude, Gemini, Grok, DeepSeek, Mistral и Llama. Для этого вы используете собственные ключи API.

Бесплатен ли навык ИИ Cortex Code?

Да. Навык опубликован на GitHub по лицензии Apache-2.0. Издатель — Kilo-Org. Вы платите только своему поставщику ИИ за использованные токены.

Что такое навыки ИИ?

Навык ИИ — это набор инструкций, которыми модель ИИ может пользоваться каждый раз, когда ей нужно выполнить конкретную задачу. Он соответствует открытому формату Agent Skills: файл SKILL.md с названием и описанием, а также любые скрипты, шаблоны или справочные файлы, которые могут понадобиться модели. Модель читает инструкции, только когда ваш запрос соответствует навыку, поэтому установленный навык ничего не стоит, пока не используется.

Чем навыки ИИ отличаются от плагинов и серверов MCP?

Плагин или сервер MCP даёт модели новые инструменты, которые она может вызывать: при вызове где-то выполняется код и возвращает результат. Навык ИИ, напротив, даёт модели знания и описывает порядок действий: как подойти к задаче, какие шаги выполнить и каким должен быть хороший результат. Навыки — это обычный текст в формате Markdown, поэтому им не нужны сервер, ключ API или среда выполнения, и они работают с любой моделью.

Все

Создайте своё рабочее пространство с ИИ прямо сейчас

Подпишитесь на нашу рассылку, чтобы узнавать о новых функциях и предстоящих розыгрышах 👇