Cortex Code CLI¶
This topic helps you get started with Cortex Code CLI, including installation, connection setup, and validation.
Before you begin, ensure you have a Snowflake account with access to the required Cortex models. See Prerequisites for full details.
Install Cortex Code CLI¶
To install Cortex Code CLI, issue the following command in your terminal:
curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh
This command downloads and runs the installation script, which installs the latest version of Cortex Code CLI.
The cortex executable is installed in ~/.local/bin by default.
Connect to Snowflake¶
After installing the Cortex Code CLI, issue the cortex command. A setup wizard guides you through the
initial configuration steps, including choosing or setting up a connection to Snowflake.
The first prompt asks you to choose a connection from the existing connections in the ~/.snowflake/connections.toml file
or to create a new connection.
To use an existing connection, choose the connection from the list using the up and down arrow keys, then press Enter.
To create a new connection, choose More options* by pressing the down arrow key until it is highlighted, then press Enter. Follow the prompts to enter your Snowflake account details.
Note
The connections.toml is also used by the Snowflake CLI (snow command). If you have already set up a connection
for use with the Snowflake CLI, you can use that connection with the Cortex Code CLI.
Start using Cortex Code¶
Once connected, try your first request:
What can I do with Cortex Code?
Type natural-language requests (such as “find tables with PII tags” or “generate a Streamlit app for SALES_MART.REVENUE”) and Cortex Code attempts to fulfill the request by orchestrating Snowflake-native skills and any MCP tools you have configured. For more information on configuring MCP tools, see Model Context Protocol (MCP).
As it works on your request, Cortex Code CLI displays its reasoning steps and actions in the terminal. From time to time, it may ask you for information that it needs. If you’re in plan mode, it will ask you to confirm each action.
Example requests¶
Discover your catalog¶
What databases do I have access to?
List every table tagged PII = TRUE in ANALYTICS_DB
Show the lineage from RAW_DB.ORDERS to downstream dashboards
Generate and run SQL commands¶
Write a query for top 10 customers by revenue
Add a 7-day moving average and show me the results
Explain why this query is slow and optimize it
Build applications¶
Build a Streamlit dashboard on SALES_MART.REVENUE with filters for date and region
Create a dbt project to transform raw sales data
Work with Cortex Analyst¶
Use the @models/revenue.yaml semantic model to answer "What was revenue last month?"
Debug my semantic model at @models/revenue.yaml
Prerequisites¶
To use Cortex Code CLI, you need the following:
A Snowflake user account with the necessary permissions to access the data you intend to use with Cortex Code CLI and to perform operations on them. This user must also have the SNOWFLAKE.CORTEX_USER database role.
Network access to your Snowflake server.
Snowflake CLI installed on your workstation.
One of the following supported platforms:
macOS on Apple Silicon or Intel
Linux on Intel
Windows Subsystem for Linux (WSL) on Intel
Note
Snowflake may add support for other platforms from time to time. Please let your Snowflake representative know if you have a specific platform requirement.
Local terminal access to the
bash,zsh, orfishshell on your platform.
For additional configuration options, troubleshooting, and advanced setup, see Cortex Code CLI reference.
Legal notices¶
Where your configuration of Cortex Agents uses a model provided on the Model and Service Pass-Through Terms, your use of that model is further subject to the terms for that model on that page.
The data classification of inputs and outputs are as set forth in the following table.
Input data classification |
Output data classification |
Designation |
|---|---|---|
Usage Data |
Customer Data |
Covered AI Features [1] |
For additional information, refer to Snowflake AI and ML.
Supported models and regions¶
Cortex Code CLI supports the following models, as long as your account has access to them (see Control model access):
autoClaude Sonnet 4.5 (
claude-sonnet-4-5)Claude Sonnet 4.0 (
claude-4-sonnet)
The default model is auto, which automatically uses the best available model subject to region restrictions and
permissions. To choose a different model, use the /model command inside a Cortex Code CLI session.
If a model you want to use is not available in your region, you can use Cortex cross-region inference to access the model in another region where it is available. For more information about configuring cross-region inference, see Cross-region inference.
Important
Cross-region inference is currently required to access Claude models in most regions. Set up inference for aws_us
if you are in a US AWS region, for azure_us if you are in a US Azure region, for aws_eu if you are in an EU
AWS region, or for aws_apj if you are in an APJ AWS region.
To enable cross-region inference, an ACCOUNTADMIN must run:
ALTER ACCOUNT SET CORTEX_ENABLED_CROSS_REGION = 'AWS_US';
Your organization can restrict model access. You may not have access to all models. See Control model access for details.