dbt CLI cheat sheet
Selectors, state-based CI, testing, and debugging commands — one printable page.
Daily drivers
dbt run- Build all models in dependency order.
dbt test- Run all data and unit tests.
dbt build- run + test + snapshot + seed, in DAG order. Use this in production.
dbt compile- Render Jinja to raw SQL (target/compiled/) without running.
dbt docs generate && dbt docs serve- Build and open the lineage/documentation site.
Node selection
dbt run -s fct_orders- One model.
dbt run -s +fct_orders- Model plus all upstream parents.
dbt run -s fct_orders+- Model plus all downstream children.
dbt run -s staging.*- Everything in the staging folder/package path.
dbt run -s tag:nightly- All models tagged nightly.
dbt ls -s +fct_orders- Preview what a selector matches without running.
CI patterns (state comparison)
dbt build -s state:modified+ --defer --state prod-artifacts/- Slim CI: build only changed models and their children, deferring unchanged refs to production.
dbt run --full-refresh -s my_incremental- Rebuild an incremental model from scratch.
Debugging
dbt debug- Validate profiles.yml, connection, and dependencies.
dbt run -s my_model --vars '{"run_date": "2026-08-01"}'- Pass variables into Jinja.
dbt show -s my_model --limit 20- Preview a model's output without materializing.
dbt retry- Re-run only what failed in the previous invocation.
Project hygiene
dbt deps- Install packages from packages.yml.
dbt seed- Load CSVs from seeds/ as tables.
dbt snapshot- Capture slowly changing dimension history.
dbt source freshness- Check whether sources meet freshness SLAs.
From DataLane — tutorials at/blog, practice SQL live in theplayground.