🏃cortex-run
- ライセンス
- Proprietary. See LICENSE-SKILLS.md for complete terms
- ソース
- GitHub で見る ↗
説明
このスキルは、ユーザーが明示的に `$cortex-run` または `/cortex-run` と入力した場合にのみ読み込んでください。 自動ルーティングフックやキーワードマッチングによってこのスキルを読み込むことは絶対にしないでください。 自動ルーティングされたプロンプトには、代わりに `snowflake-cortex-code:cortex-router` を使用してください。
原文を表示
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.
本文(日本語訳)
Cortex Code(明示的な呼び出し)
ユーザーが明示的に Cortex Code にリクエストの処理を要求している場合に使用。
自動ルーティングのキーワードフィルターをバイパスし、プロンプトを直接 Cortex Code CLI に送信します。
前提条件
Cortex Code CLI がインストール済みで、PATH が通っている必要があります:
which cortex && cortex --version
cortex が見つからない場合は、snowflake-cortex-code:cortex-setup スキルをロードしてインストールしてください。
CLI なしで先に進まないでください。
ワークフロー
ステップ 1: Cortex CLI を確認する
このステップは必須です。毎回最初に実行してください。
which cortex 2>/dev/null && cortex --version
cortex が見つからない、またはコマンドが失敗した場合:
- ユーザーに伝える: 「Cortex Code CLI がインストールされていません。今すぐセットアップします。」
- Skill ツールを使用して
snowflake-cortex-code:cortex-setupスキルをロードする。 - その指示に従って CLI をインストールする。
- ここで一旦停止 — CLI がインストールされて正常に動作するまで、ステップ 2 に進まないでください。
ステップ 2: ユーザープロンプトを抽出する
$cortex-run に続くユーザーのメッセージが、送信するプロンプトになります。
ユーザーが追加テキストなしに $cortex-run のみを入力した場合は、Snowflake で何を行いたいかを尋ねてください。
ステップ 3: セキュリティエンベロープを選択する
操作の内容に応じてエンベロープを選択します:
| エンベロープ | 次のような場合に使用 | ブロック対象 |
|---|---|---|
| RO | クエリ、読み取り、データ探索 | 編集・書き込み・破壊的な Bash 操作 |
| RW | データ変更、DDL | 破壊的な Bash 操作(rm -rf、sudo) |
| RESEARCH | データ探索 + Web アクセス | 編集・書き込み・破壊的な Bash 操作 |
| DEPLOY | フルアクセスが必要な場合 | なし |
リクエストが明らかに読み取り専用でない限り、デフォルトは RW とします。
ステップ 4: Cortex Code 経由で実行する
実行スクリプトを通じてプロンプトを処理します:
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "USER_PROMPT_HERE" \
--envelope "RW"
読み取り専用クエリの場合:
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "USER_PROMPT_HERE" \
--envelope "RO"
Snowflake の接続先を指定する場合:
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "USER_PROMPT_HERE" \
--envelope "RW" \
--connection "connection_name"
ステップ 5: 結果を返す
Cortex の出力をユーザー向けに整形します:
- SQL の結果は見やすいテーブル形式で表示する
- 生成されたアーティファクトを表示する
- 成功・失敗を報告する
- Cortex がエラーになった場合は、エラー内容を表示して修正方法を提案する
コンテキストの補完
プロンプトを送信する前に、現在の Claude Code セッションの関連コンテキストを先頭に付加します:
# Context from Claude Code Session
[直近 2〜3 件の関連するやり取り — Snowflake 固有の情報のみ]
# User Request
[元のプロンプト]
コンテキストは最小限に抑えてください — Cortex は各プロンプトで送信された内容しか参照できません(セッションを再開する場合を除く)。
マルチターン: --resume-last か新規開始か
Cortex の各呼び出しは session_id を返し、自動的に保存されます。
後続のターンでそのセッションを再開することで、Cortex は直前の会話内容を参照できます —
プロンプトごとの一回限りの処理ではなく、真のマルチターン会話を実現します。
--resume-lastを付加する: 現在のプロンプトが前回の Cortex ターンの継続である場合。
例:「続けて」「上位の提案を適用して」「もっと詳しく」「〜も見せて」「先四半期についても」「それを修正して」、または Cortex が返した回答への質問・補足。--resume-lastを省略する(新規開始): ユーザーが話題を切り替えた場合、別のデータベース・ウェアハウスについて質問した場合、または明らかに新しいタスクを開始した場合。- 明示的な ID がある場合は
--resume <session_id>も使用できます。
# 前回の Cortex ターンへの追加質問
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "also show me the column types" --envelope "RO" \
--resume-last
使用例
ユーザー: $cortex-run show me tables in the RAW schema
- エンベロープ: RO
- プロンプト: "show me tables in the RAW schema"
ユーザー: $cortex-run create a dynamic table that aggregates daily sales
- エンベロープ: RW
- プロンプト: "create a dynamic table that aggregates daily sales"
ユーザー: $cortex-run(プロンプトなし)
- 確認: 「Cortex Code に何をさせますか?」
注意事項
- このスキルは明示的な呼び出し専用です。自動ルーティングは、プロンプトフィルタフックと cortex-router スキルが別途処理します。
- 追加質問のプロンプトには
--resume-lastを使用し、Cortex が会話コンテキストを保持できるようにしてください。新しいトピックの場合は省略し、関連するコンテキストをプロンプト内に含めるようにしてください。 - セキュリティエンベロープの強制適用には
--permission-prompt-tool stdioを使用しており、すべてのツール呼び出しはプロセス境界でenvelope_policy.decide()によってゲート制御されます。
原文(English)を表示
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:
- Tell the user: "Cortex Code CLI is not installed. Setting it up now."
- Load the
snowflake-cortex-code:cortex-setupskill using the Skill tool. - Follow its instructions to install the CLI.
- 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:
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "USER_PROMPT_HERE" \
--envelope "RW"
For read-only queries:
python "${CLAUDE_PLUGIN_ROOT}/scripts/router/execute_cortex.py" \
--prompt "USER_PROMPT_HERE" \
--envelope "RO"
To specify a Snowflake connection:
python "${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-lastwhen 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
python "${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-lastfor 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 byenvelope_policy.decide()at the process boundary.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。