Managing dbt Projects on Snowflake using Snowflake CLI¶
Note
The dbt Projects on Snowflake features in Snowflake CLI are available only in version 3.13.0 or later.
Note
Some features described on this page require a dbt project object that uses the mutable live version. To get a live-version object, opt in to the 2026_06 behavior change bundle or ask your Snowflake account representative to enable the separate single live version feature. Then create or replace the object, or migrate an existing versioned object with SYSTEM$MIGRATE_DBT_PROJECT. For details, see dbt Projects on Snowflake: dbt project objects migrate to a single mutable live version.
You can use Snowflake CLI to manage dbt project objects with the following operations:
- Deploying a dbt project object
- Listing all available dbt project objects
- Executing a dbt project object command
- Describing a dbt project object
- Dropping a dbt project object
- Copying dbt project files
Deploying a dbt project object¶
The snow dbt deploy command uploads local files to a temporary stage and creates a new dbt project object or updates it by
replacing its live version in a single operation. A valid dbt project must contain dbt_project.yml and one of the supported profile files:
-
dbt_project.yml: A standard dbt configuration file that specifies the profile to use. -
dbt_projects_profiles.ymlorprofiles.yml: A dbt connection profile definition referenced indbt_project.yml. The selected profile file must define the database, role, schema, and type. If both files are present, Snowflake usesdbt_projects_profiles.ymland ignoresprofiles.ymlduring deployment, compilation, and subsequent commands.- By default, dbt Projects on Snowflake uses your target schema (
target.schema) specified from your dbt environment or profile. When you execute a dbt project object, dbt attempts to create the target schema specified indbt_projects_profiles.ymlorprofiles.ymlif it doesn’t already exist. For more information, see Understand schema generation and customization.
- By default, dbt Projects on Snowflake uses your target schema (
The following examples illustrate how to use the snow dbt deploy command:
Warning
Don’t use --force unless you intentionally want to recreate the dbt project object. In snow dbt deploy, --force runs CREATE OR REPLACE DBT PROJECT, which may remove run history.
-
Deploy a dbt project object named
jaffle_shop: -
Deploy a project named
jaffle_shopfrom a specified directory, using a profile file from a separate directory. The CLI looks fordbt_projects_profiles.ymlfirst and usesprofiles.ymlonly ifdbt_projects_profiles.ymlisn’t present. The CLI copies the file into the root of the deployed project object with the same filename, overwriting a file with the same name in this location: -
Deploy a project named
jaffle_shopfrom a specified directory, supplying a profile file from outside the project, setting a default target, pinning a dbt version, and enabling external access integrations: -
Deploy a project named
jaffle_shopand set a specific dbt runtime version: -
Deploy a project named
jaffle_shop, pull in anenv.ymlfile from a separate directory, and set the default environment for compilation and later executions:The
--env-file-dirflag points the CLI at anenv.ymlfile elsewhere in your repo (similar to--profiles-dir) and pulls it into the deployed object, overwriting the object’s rootenv.ymlif one already exists. The--default-envflag sets the environment used for compilation and subsequent executions. These flags require Snowflake CLI 3.21 or later. For more information, see Using SQL environment variables and private Git packages for dbt Projects on Snowflake.
Listing all available dbt project objects¶
The snow dbt list command lists all available dbt project objects on Snowflake.
The following examples illustrate how to use the snow dbt list command:
-
List all available dbt project objects:
-
List dbt project objects in the
productdatabase whose names begin withJAFFLE:
Executing a dbt project object command¶
The snow dbt execute command executes one of the following dbt commands (https://docs.getdbt.com/reference/dbt-commands) on a Snowflake dbt project object:
- build (https://docs.getdbt.com/reference/commands/build)
- clean (https://docs.getdbt.com/reference/commands/clean)
- compile (https://docs.getdbt.com/reference/commands/compile)
- deps (https://docs.getdbt.com/reference/commands/deps)
- list (https://docs.getdbt.com/reference/commands/list)
- parse (https://docs.getdbt.com/reference/commands/parse)
- retry (https://docs.getdbt.com/reference/commands/retry)
- run (https://docs.getdbt.com/reference/commands/run)
- run-operation (https://docs.getdbt.com/reference/commands/run-operation)
- seed (https://docs.getdbt.com/reference/commands/seed)
- show (https://docs.getdbt.com/reference/commands/show)
- snapshot (https://docs.getdbt.com/reference/commands/snapshot)
- source freshness (https://docs.getdbt.com/reference/commands/source)
- test (https://docs.getdbt.com/reference/commands/test)
For more information about using dbt commands, see the dbt Command reference (https://docs.getdbt.com/reference/dbt-commands).
The following examples illustrate how to use the snow dbt execute command:
-
Execute the dbt
testcommand: -
Execute the
rundbt command asynchronously: -
Execute the
rundbt command with a specific dbt version: -
Execute the
rundbt command against a selected environment, overriding individual variables for this run:The
--envflag selects the environment defined in the project’senv.ymlfile, and--env-varsapplies inline key/value overrides for this execution. Use--use-shell-env-varsto pullDBT_-prefixed shell variables (excludingDBT_ENV_SECRET_*variables) into the run. These flags require Snowflake CLI 3.21 or later. For more information, see Use the Snowflake CLI.
Describing a dbt project object¶
The snow dbt describe command describes a dbt project object on Snowflake.
The following example describes the dbt project object named my_dbt_project on Snowflake:
Dropping a dbt project object¶
The snow dbt drop command deletes a dbt project object on Snowflake.
The following example deletes the dbt project object named my_dbt_project on Snowflake:
Copying dbt project files¶
The snow dbt copy command copies files between local directories,
stages, and a dbt project object’s live version. Use snow dbt execute --import instead when files only need to be mounted under ./imports
for one execution.
Use snow dbt commands in a CI/CD workflow¶
Note
When building CI/CD workflows, you only need your Git server, such as GitHub, and Snowflake CLI. A Git repository object is not required.
You can run dbt commands with Snowflake CLI to test pull requests and update the production dbt project object after changes merge. Choose a workflow based on the amount of the project that CI needs to validate:
- Basic CI workflow: Deploy a tester dbt project object and run
dbt buildacross the project. Start with Tutorial: Set up CI/CD integrations on dbt Projects on Snowflake. - Advanced Slim CI: Deploy with automatic compilation disabled, import dbt artifacts from the last successful production execution, and use state selection with defer to process only changed models and their downstream dependencies. For a complete per-pull-request CI workflow, see Tutorial: Set up CI/CD with Slim CI and per-PR databases for dbt Projects on Snowflake.
To build a CI/CD workflow with snow dbt commands, follow these steps:
-
Prepare your dbt project:
- Download your dbt project or start a new one.
-
Ensure that the main project directory contains
dbt_project.ymland eitherdbt_projects_profiles.ymlorprofiles.yml. -
Verify that the profile name referenced in
dbt_project.ymlis defined indbt_projects_profiles.ymlorprofiles.yml. If both files are present, Snowflake usesdbt_projects_profiles.yml.Note
Ensure that credentials are excluded from the profile file. Leave
accountanduseras placeholder strings and let your CI/CD platform supply the connection through secrets or environment variables.
-
- Download your dbt project or start a new one.
-
Set up Snowflake CLI GitHub Action.
Follow the guidelines for setting up GitHub Action for Snowflake CLI and verify your connection to Snowflake.
-
Define your workflow.
The following example illustrates a CI workflow that replaces the live version of the dbt project object named
product_pipelinein a single operation, then builds models and runs tests in DAG order: