Cortex Code CLI reference¶
Command line reference for Cortex Code CLI.
Starting Cortex Code¶
Command |
Description |
|---|---|
|
Start in current directory |
|
Start with specific connection |
|
Start in specific directory |
|
Combine workdir and connection |
|
Continue last session |
|
Resume specific session |
CLI options¶
Option |
Description |
|---|---|
|
Use specific Snowflake connection |
|
Set working directory for file operations |
|
Specify AI model to use |
|
Plan mode: require approval before all actions |
|
Automatically approve all planned actions |
|
Disable tool call permission prompts (caution) |
|
Use team configuration profile |
|
Resume most recent conversation |
|
Resume specific session by ID, or |
|
Pass specified prompt, print response, and exit |
|
Read prompt from file, execute, and exit |
|
JSON output (for scripting) |
|
Show installed version |
|
Show CLI help |
Connections must be defined in ~/.snowflake/connections.toml. See Cortex Code CLI for connection setup. Session IDs are shown at startup, at exit, and stored in ~/.snowflake/cortex/conversations/.
Examples¶
Start with working directory:
cortex -w /path/to/project
Resume last session with specific connection:
cortex --continue -c production
One-off prompt (JSON output):
cortex -p "List all Python files" --output-format stream-json
Apply a team profile:
cortex --profile data-team
Commands¶
update¶
Command |
Description |
|---|---|
|
Update to latest version |
|
Verify after update |
mcp¶
Command |
Description |
|---|---|
|
List configured servers |
|
Add new server (interactive) |
|
Remove server |
See Model Context Protocol (MCP) for details.
Interactive mode¶
Keyboard shortcuts¶
Shortcut |
Action |
|---|---|
|
Cancel current operation |
|
Exit Cortex Code CLI |
|
Clear terminal screen (keeps conversation) |
|
Navigate command history |
|
Command completion |
Slash commands¶
Session management¶
Command |
Description |
|---|---|
|
Show interactive help |
|
Enable planning mode |
|
Disable planning mode |
|
Clear the screen |
|
Start a new session |
|
Rename current session |
|
Exit Cortex Code CLI |
|
List and resume sessions |
|
Go back n steps in conversation or pick interactively |
|
List available skills |
|
Show MCP server status |
|
Send feedback |
Model and mode¶
Command |
Description |
|---|---|
|
Show/select AI model |
|
Enable plan mode |
|
Disable plan mode |
|
Enable bypass mode (auto-approve all including tool calls) |
|
Disable bypass mode |
|
Show current configuration |
Snowflake and data¶
Command |
Description |
|---|---|
|
Execute SQL query |
|
Limit displayed rows |
|
Open table viewer |
|
Manage Snowflake connections |
Development tools¶
Command |
Description |
|---|---|
|
Execute shell command |
|
Review git changes |
|
Manage git worktrees |
|
dbt operations |
|
dbt lineage visualization |
Configuration¶
Command |
Description |
|---|---|
|
View/modify settings |
|
Select color theme |
|
Manage sandbox settings |
|
Add working directory |
Extensibility¶
Command |
Description |
|---|---|
|
Manage skills |
|
MCP server status |
|
View hooks configuration |
|
Manage profiles |
|
Manage custom commands |
|
View subagents |
Utilities¶
Command |
Description |
|---|---|
|
Show task list |
|
Provide session feedback (Saved locally as a .tgz file) |
|
Update Cortex Code |
Session storage¶
Command |
Description |
|---|---|
|
Session files |
|
General settings |
|
Permission preferences |
See Cortex Code CLI Settings for configuration details.
Command details¶
/sql: Execute SQL examples¶
Basic query:
/sql SELECT * FROM users
With row limit:
/sql SELECT * FROM large_table --limit 1000
Multi-line (use Ctrl+J for newlines);
/sql SELECT
customer_id,
SUM(amount) as total
FROM orders
GROUP BY customer_id
Results open automatically in the table viewer (Ctrl+T).
/worktree: Git worktrees¶
Command |
Description |
|---|---|
|
Create new worktree |
|
List all worktrees |
|
Switch to worktree |
|
Delete worktree |
/profile:: Team profiles¶
Command |
Description |
|---|---|
|
List local profiles |
|
List remote profiles |
|
Add profile from Snowflake |
|
Update profile |
|
Show profile details |
|
Delete local profile |
/sandbox:: Sandbox control¶
Command |
Description |
|---|---|
|
Interactive selector |
|
Enable container sandbox |
|
Disable container sandbox |
|
Show sandbox status |
|
Enable OS sandbox |
|
Disable OS sandbox |
|
Auto-allow sandboxed commands |
|
Prompt for all commands |
/mcp: MCP servers¶
Command |
Description |
|---|---|
|
Show status viewer |
|
List all servers |
|
Start server |
|
Get server details |
|
Remove server |
Batch mode¶
Command |
Description |
|---|---|
|
Run single prompt and exit |
|
Read prompt from file |
|
JSON output |
|
Control context |
Exit codes¶
Code |
Description |
|---|---|
|
Success |
|
General error |
|
Configuration error |
|
Connection error |
|
Permission denied |
|
Interrupted by user (Ctrl+C) |
Configuration and setup¶
Updating Cortex Code CLI¶
Cortex Code CLI updates itself when a new version is available. You can also manually update to the latest version
by issuing cortex update. Issue cortex update <version> to install the specified version.
To disable automatic updates, edit ~/.snowflake/cortex/settings.json and add "autoUpdate": false.
Manually adding a connection¶
To manually create or edit the ~/.snowflake/connections.toml file to define your connection, follow the steps below:
Create the
~/.snowflake/connections.tomlfile if it doesn’t already exist.mkdir -p ~/.snowflake touch ~/.snowflake/connections.toml
Use the
chmodcommand to set its permissions so that only you can read and write it.chmod 600 ~/.snowflake/connections.toml
Open the file in a text editor (here,
nano).nano ~/.snowflake/connections.tomlAdd lines like the following to define a connection. Enter the name of the connection in place of
myaccountand replace the placeholder values with your Snowflake account details. Use browser-based SSO (external browser authentication) or PAT (programmatic access token). You can obtain a PAT from Snowsight (see Using programmatic access tokens for authentication). Include only theauthenticatorvalue orpasswordvalue, depending on the authentication method you choose.[myaccount] account = "<ACCOUNT>" user = "<USERNAME>" authenticator = "externalbrowser" # For browser-based SSO; omit for PAT password = "<PAT>" # For PAT authentication; omit for SSO warehouse = "<WAREHOUSE>" role = "<ROLE>" database = "<DATABASE>" schema = "<SCHEMA>"
Save and close the file.
Setting up shell completions¶
To give your shell the ability to auto-complete Cortex Code CLI commands and options, follow the instructions below for your shell.
Tip
If you’re not sure which shell you’re using, issue echo $(basename $SHELL) in your terminal. The name printed is the default
shell for your account, and may not be accurate if you have started a different shell manually.
Shell |
Command |
|---|---|
|
|
|
|
|
|
After running the appropriate command above for your shell, restart your shell with exec $SHELL.
Directory structure¶
Installing Cortex Code CLI creates the following directory structure in your home directory:
~/.snowflake/cortex/
├── settings.json # Main configuration
├── mcp.json # MCP server configs
├── conversations/ # Session history
├── skills/ # Global skills
├── commands/ # Custom commands
├── hooks/ # Hook scripts
├── profiles/ # Team profiles
└── cache/ # Temporary cache
Troubleshooting¶
Following are common error messages you may encounter during installation and setup.
Command not found¶
Make sure that the installation directory ~/.local/bin is included in your PATH environment variable.
For example, if you are using bash, issue the following commands:
export PATH="~/.local/bin:$PATH"
echo 'export PATH="~/.local/bin:$PATH"' >> ~/.bashrc
Permission denied¶
Make sure that the cortex executable has execute permissions. Issue the following command:
chmod +x ~/.local/bin/cortex
Connection errors¶
Make sure that the connection file ~/.snowflake/connections.toml exists and contains valid connection details.
cat ~/.snowflake/connections.toml
Try invoking the cortex command with a connection explicitly specified using the -c option. For example:
cortex -c myaccount
See also¶
- Cortex Code CLI
Installation, setup, and first prompts
- Cortex Code CLI Settings
Configuration file reference
- Cortex Code CLI workflow examples
Capabilities and workflow examples