dbt-model-diff — Data-level diffs across Git branches
An open-source CLI that compares the actual data output of a dbt model between two Git refs (e.g. main vs a feature branch). It builds both versions, snapshots results into an isolated schema, and reports deterministic differences for CI, PR reviews, and safer refactors.
main and a feature branch, and make the result usable for CI checks and PR feedback.High-level architecture
The tool creates isolated Git worktrees for base/head, builds both with dbt, snapshots results into a diff schema, then runs comparisons and outputs a report.
The tool checks out base and head refs into isolated worktrees so builds don't conflict.
- Creates isolated folders for base + head refs
- Prevents dbt artifact collisions
- Keeps your working tree untouched
- Runs
dbt buildon both refs - Resolves relation via
manifest.json - Copies results into diff schema as
{model}__baseand{model}__head
- Row counts + schema diff
- Column profile: null %, uniqueness
- Key-based row diff (added/removed/changed)
Demo: usage & output formats
Example command and sample outputs. JSON is ideal for CI gating; markdown is PR-comment ready.
dbt-model-diff diff dim_customers \ --keys customer_id \ --base main \ --head feature/include-4 \ --profiles-dir . \ --project-dir . \ --format rich
Summary ──────────────────────── Base rowcount: 3 Head rowcount: 4 Added rows: 1 Removed rows: 0 Changed rows: 0 Schema Changes ──────────────────────── No column differences detected. Column Profile (example) ──────────────────────── customer_id: % nulls (base): 0.0 % nulls (head): 0.0 uniqueness (base): 1.0 uniqueness (head): 1.0
Tech stack
dbt-model-diff helps teams shift left on data correctness by catching data regressions before merge. It’s designed to be warehouse-native, CI-friendly, and easy to extend with new adapters.
Explore dbt-model-diff on GitHub