Cortex Code with Postgres
Cortex Code is Snowflake's AI coding agent for data work. It reads your schema, writes and explains SQL, builds pipelines, and runs multi-step tasks for you. It works with Snowflake Postgres and with Postgres databases running somewhere else.
There are three ways to run it:
| Version | Best for |
|---|---|
| Cortex Code Desktop | A local IDE with the full agent |
| Cortex Code in Snowsight | Browser access from the Snowflake console, nothing to install |
| Cortex Code CLI | Terminal workflows, scripting, and automation |
Cortex Code Desktop
Cortex Code Desktop is a standalone IDE built on VS Code. It connects to Snowflake and to Postgres, and the agent can read your schema, write and run queries, edit files, and work through multi-step tasks.
Key capabilities
- An agent that can see your database schema and metadata
- Write, run, and debug SQL against Snowflake Postgres or any other Postgres
- Build Streamlit apps, stored procedures, and data pipelines with the agent's help
- Jupyter notebooks with inline execution
- Git integration for version-controlled work
Connecting to Postgres
Cortex Code Desktop manages Snowflake Postgres instances through your Snowflake connection. For Postgres outside Snowflake (RDS, Aurora, Cloud SQL, self-hosted), you connect with the usual Postgres connection details, and the agent works with either.
Get Cortex Code Desktop
See the docs for supported operating systems.
Cortex Code in Snowsight
Cortex Code is also built into Snowsight, so you can use it from the browser without installing anything.
Key capabilities
- Nothing to install; you just need a Snowflake account
- Chat for writing and explaining SQL, exploring schema, and building queries
- Works with the Snowflake Postgres instances your role can access
- Notebook and worksheet support with inline results
- Runs under your Snowflake role, so existing governance and access controls apply
Connecting to Postgres
In Snowsight, Cortex Code works through your Snowflake session and role, so there's no separate client to configure. What it can see and do with your Snowflake Postgres instances depends on the privileges your role has.
Access Cortex Code in Snowsight
Log in to your Snowflake account and open Cortex Code from Snowsight.
Cortex Code CLI
The Cortex Code CLI puts the agent in your terminal. It's handy for quick queries, scripts, automation, and fitting AI-assisted data work into the command-line habits you already have.
Key capabilities
- A terminal-based agent for Snowflake and Postgres
- Ask questions in plain English and have it generate and run the SQL
- Scriptable for automation
- Works alongside psql, pg_dump, and the rest of the Postgres CLI tools
- Light enough for ad-hoc exploration
Connecting to Postgres
The CLI manages Snowflake Postgres through your configured Snowflake connection. For other Postgres instances, use the same connection parameters (host, port, database, user) you'd give any Postgres client.
Install the Cortex Code CLI
The docs cover installation options for your platform.
Built-in Postgres Skills
Cortex Code Desktop and the CLI include a snowflake-postgres skill that kicks in when you're working with Postgres. You don't have to set anything up to use it.
What the Postgres skill does
It handles instance management, so you can create, suspend, resume, and resize Snowflake Postgres instances by asking in plain English.
It answers questions about your data. Ask in English, and Cortex Code writes and runs the SQL against your Postgres instance.
It runs health checks with pg_doctor. These are read-only diagnostics covering cache hit rates, table bloat, vacuum status, connections, locks, blocking queries, long-running queries, unused indexes, and table sizes. It's the same list of things we'd check by hand on a struggling database.
It walks you through data movement. Connecting Postgres to Snowflake with pg_lake touches Snowflake SQL, cloud storage permissions (for customer-managed S3 or Azure), and Postgres SQL, and the skill takes you through each piece.
It manages connections in the standard ~/.pg_service.conf and ~/.pgpass files, so psql and every other Postgres client can use them too.
Example prompts
"Create a new Postgres instance in us-west-2" "Show me all tables on my_instance" "How many orders were placed this month?" "Run a health check on my_instance" "Set up pg_lake on my_instance with s3://my-bucket/data/" "Reset credentials for my_instance"
Safety guardrails
Cortex Code asks for confirmation before write operations like INSERT, UPDATE, DELETE, and DROP. Read-only work such as SELECT, DESCRIBE, and health checks can run without stopping to ask.
Billable or security-sensitive operations also need confirmation. That includes creating instances, changing network policies, and changing storage integrations. Your approval settings in Cortex Code control how much it asks.
Working with External Postgres
Cortex Code Desktop and the CLI can connect to Postgres outside Snowflake: RDS, Aurora, Cloud SQL, Azure Database for PostgreSQL, or your own servers.
What you get with external Postgres
- SQL writing that knows your schema
- Query explanations and optimization suggestions
- Schema exploration and documentation
- Data exploration and visualization
Connection requirements
- Standard Postgres connection details (host, port, database, credentials)
- Network access from your machine (Desktop or CLI) to the database
- A supported Postgres version. Postgres 14 through 18 are supported today, and 14 reaches end of life on November 12, 2026, so 15 or later is a better bet.
Working with Snowflake Postgres
When you're connected to a Snowflake Postgres instance, Cortex Code can also help with the Snowflake side of things.
Platform advantages
Cortex Code knows how pg_lake connects your Postgres tables to Snowflake, so it can help you build pipelines and queries that span both.
It can write and test Cortex AI functions like AI_EMBED and AI_COMPLETE against your Postgres data. See Snowflake Postgres + Cortex AI for the patterns.
Instances are Snowflake objects, so Snowflake roles and privileges govern who can manage them. Cortex Code can create, resize, suspend, and monitor instances for you.
Example workflow
- Connect Cortex Code to your Snowflake account.
- Pick the Postgres instance you want to work on.
- Ask Cortex Code to explore your schema, write queries, or build data pipelines.
- Use pg_lake to get Postgres data into Snowflake for analytics at warehouse scale.
- Use Cortex AI functions to enrich or summarize that data.
Comparison: Which Version to Use
Here's how the three compare at a glance. Features change quickly, so check the docs for the current details.
| Desktop | CLI | Snowsight | |
|---|---|---|---|
| Installation | Download app | Install CLI | None (browser) |
| Best for | Full development sessions | Automation, scripting | Quick exploration, collaboration |
| External Postgres | Yes | Yes | No |
| Snowflake Postgres | Yes | Yes | Yes |
| Notebooks | Yes | No | Yes |
| Git integration | Yes | Yes | No |
This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances