dbt-cost: know what a dbt model will cost before it runs
An open-source CLI on PyPI that dry-runs dbt models against BigQuery to estimate bytes scanned and cost, and fails a pull request when a change makes the project more expensive.
- role
- Author, open source
- when
- 2026
- stack
- Python, dbt, BigQuery, GitHub Actions
- code
- github
The problem
On BigQuery's on-demand pricing you pay by bytes scanned, and a dbt model's cost is invisible until the bill arrives. A pull request that swaps a filtered CTE for a full-table scan looks fine in review and runs fine in CI. A month later someone asks why the warehouse bill doubled.
BigQuery already has the answer: a dry run returns the bytes a query would process without running it, for free. The whole tool is wiring that into the pull request.
What I decided, and why
- Use the dry-run API and nothing else. Dry-run mode is hard-coded, so the tool cannot execute a query or touch data. It needs only the BigQuery Job User role and read access to the referenced tables.
- Speak dbt's selector syntax.
estimate stg_orders+or--selector tag:marketingcost exactly the models dbt would run, resolved from the compiledmanifest.json. - Make it a CI gate.
diffcompares the base branch's manifest with the pull request's, posts the cost change as a sticky comment, and exits non-zero when the increase crosses a threshold. The GitHub Actions workflow in the repo does this end to end. - Three outputs. A table in the terminal, JSON for scripts, Markdown for the pull request.
How it was built
A Python CLI on top of the compiled dbt manifest. The dependency graph is parsed to resolve selectors; each selected model's compiled SQL goes to the dry-run endpoint, with a concurrency limit; the returned bytes are priced at the on-demand rate (default $6.25 per TB, adjustable). report breaks the whole project down by layer; diff does the same for two manifests and shows what moved.
What it changed
Cost shows up in the pull request, next to the code that caused it, before anything runs. Installed with pip install dbt-cost; MIT licensed. BigQuery only for now.