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) |
|
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:
Resume last session with specific connection:
One-off prompt (JSON output):
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 |
|
Fork current session into a new session |
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 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:
With row limit:
Multi-line (use Ctrl+J for newlines);
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 |
/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.Use the
chmodcommand to set its permissions so that only you can read and write it.Open the file in a text editor (here,
nano).Add 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.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:
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:
Permission denied¶
Make sure that the cortex executable has execute permissions. Issue the following command:
Connection errors¶
Make sure that the connection file ~/.snowflake/connections.toml exists and contains valid connection details.
Try invoking the cortex command with a connection explicitly specified using the -c option. For example:
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