dbt
the model librarian
dbt compiles SQL selects into warehouse DDL; the warehouse does the work. Know which engine runs the project (v2 Fusion or v1 Core) and which adapter before advising: syntax, validation, and supported features differ. Types, uniqueness, and idempotence are the contract; prove them with dbt build output, not by reading SQL.
Use when building, testing, debugging, migrating, or reviewing a dbt project -- dbt Core v1.x or dbt v2 Fusion, dbt platform (Cloud) jobs, sources/staging/intermediate/marts models, ref/source, materializations, incremental strategies and microbatch, data/unit tests, model contracts, semantic layer and MetricFlow, macros and Jinja, packages, seeds, docs, exposures, adapters, slim CI, and warehouse cost.
methodology
- Identify the engine (
dbt --version), adapter,require-dbt-version, and packages. v2 rejects what v1 only warned about. - Read the official page for the mechanism (the docs snapshot below), then the learned layer for observed gotchas; community guides come last.
- Model in layers: sources ->
stg_views (rename + cast) ->int_->fct_/dim_marts. Cast keys and money in staging. - Incremental models always get
unique_key, a dedupe, and a lookback; pick the strategy from the adapter's support matrix. - Guard with
dbt build: generic tests, unit tests for logic, contracts on public marts. Use--emptyand--defer --stateonly against a CI target. - Verify by running: build twice (day 1 and day 2 data), check row counts and uniqueness, and on v2 run
--static-analysis strictanddbt lint. - Write each new lesson into the learned layer with date and versions.
contents
- trainedlearned layer: gotchas, known bugs, fixes, practiced cases; read first
- dbt-docsofficial docs snapshot (dbt-labs/docs.getdbt.com, 2026-09-26): build, reference, deploy/CI, semantic layer, upgrades
- upgrading-to-v2v1 -> v2 Fusion changes and strictness
- incremental-strategychoosing an incremental strategy per adapter
- unit-testsunit test syntax, fixtures, ephemeral inputs
- continuous-integrationslim CI, state, defer
- resource-configsadapter configs (duckdb, postgres, clickhouse, bigquery, snowflake)
- cli-helpbuilt-in `--help` of dbt 2.0.6 and dbt-core 1.12.5
- shoprunnable verified project (DuckDB v1+v2, Postgres v1)
- jaffle-shopofficial sample project (v2-only) and how to run it
- dbt-agent-skillsdbt Labs agent skills: unit tests, semantic layer, state, mesh, migration, job errors, MCP
- wshobson-dbt-transformation-patternscommunity patterns; its test YAML is outdated
- awesome-dbtcurated ecosystem list