Enables Codex to run Snowflake queries via the cortexcode-tool CLI.
Codex does not use a skill directory for this integration. Instead, cortexcode-tool is installed as a standalone CLI that Codex calls directly as a foreground command.
Codex uses cortexcode-tool as a standalone foreground command. The Codex-specific config defaults to approval_mode: prompt with the restrictive RO envelope so Snowflake reads require explicit approval before execution.
- Codex CLI installed
- Cortex Code CLI installed and configured (
which cortexshould return a path) - Active Snowflake connection (
cortex connections list) - Python 3.8+
git clone https://github.com/Snowflake-Labs/subagent-cortex-code.git
cd subagent-cortex-code
bash integrations/codex/install.shThe script:
- Installs
cortexcode-toolCLI to~/.local/bin/(viaintegrations/cli-tool/setup.sh) - Auto-detects your active Cortex connection from
cortex connections list - Writes config to
~/.local/lib/cortexcode-tool/config.yaml(auto-detected — no--configflag needed)
cortexcode-tool --version
cortexcode-tool --envelope RO "How many databases do I have in Snowflake?"Expected: the direct terminal query may ask for approval, then runs for 30–90 seconds and prints formatted results. Inside Codex chat, approve the planned execution first, then Codex should retry with --yes.
First time: paste these into a Codex session to confirm the tool is discoverable:
which cortexcode-tool
cortexcode-tool --help
Once discovered, Codex will invoke cortexcode-tool for Snowflake questions automatically. You can be explicit or implicit — both work:
# Explicit after Codex chat approval
cortexcode-tool --yes --envelope RO "How many databases do I have in Snowflake?"
# Implicit — Codex detects the Snowflake intent and calls cortexcode-tool on its own
How many databases do I have in Snowflake?No need to specify --envelope in your prompts. Codex selects the appropriate envelope based on the operation.
Use --yes only after Codex has shown the planned Cortex Code execution and the user has approved it in chat.
Do not background the command (& disown). Codex automatically waits for foreground commands to complete (30–90 seconds is normal).
~/.local/bin/cortexcode-tool # CLI entry point
~/.local/lib/cortexcode-tool/ # Python package
~/.local/lib/cortexcode-tool/config.yaml # Config (auto-detected by the tool)
Config example:
security:
approval_mode: "prompt"
audit_log_path: "~/.cache/cortexcode-tool/audit.log"
cache_dir: "~/.cache/cortexcode-tool"
cortex:
connection_name: "your-connection-name"
default_envelope: "RO"
logging:
file: "~/.cache/cortexcode-tool/cortexcode-tool.log"Audit/log paths use ~/.cache/cortexcode-tool/ so logs stay outside the repository. If Codex reports that network access is required, approve the planned Cortex Code execution in chat and retry the same foreground command with --yes.
approval_modedefaults toprompt; user config cannot relax this unless organization policy explicitly authorizes the relaxed field/value.ROis the default envelope for Codex reads.- Requested envelopes are checked against
security.allowed_envelopesbefore routing, approval, or Cortex execution. NONEis rejected before Cortex execution.DEPLOYrequires explicit confirmation and blocks Bash/destructive shell.- Output files are constrained under
CORTEX_CODE_OUTPUT_DIRor the current working directory. - Installers use private permissions (
0700directories and0600sensitive config files).
If you switch Cortex connections:
# Re-run install to auto-detect new active connection
bash integrations/codex/install.sh
# Or edit manually
vi ~/.local/lib/cortexcode-tool/config.yamlbash integrations/codex/uninstall.shcortexcode-tool not found:
which cortexcode-tool
# If missing, re-run: bash integrations/codex/install.sh
# Also ensure ~/.local/bin is in PATH
export PATH="$HOME/.local/bin:$PATH"Command waits or needs network approval in Codex:
# Verify approval_mode is prompt by default
cat ~/.local/lib/cortexcode-tool/config.yaml | grep approval_mode
# Must be: approval_mode: "prompt"
# Verify Cortex connection works
cortex connections list
cortex -p "SHOW DATABASES;" --output-format stream-jsonWrong connection used:
# Check which connection is active
cortex connections list
# Edit config
vi ~/.local/lib/cortexcode-tool/config.yaml # update connection_nameNetwork sandbox approval required:
Approve the planned Cortex Code execution in Codex chat, then retry the same foreground command with --yes. Do not background the command.