Getting started
dbt-forge is a Python CLI for scaffolding dbt projects, extending them with new
components, migrating legacy SQL, and validating project health. This guide covers the
current 0.4.x release.
Supported Python
Section titled “Supported Python”- Python 3.11
- Python 3.12
- Python 3.13
Install
Section titled “Install”Install dbt-forge with either pip or uv.
pip install dbt-forgeuv tool install dbt-forgeAfter installing, verify the installation:
dbt-forge --helpInitialize a dbt project
Section titled “Initialize a dbt project”Run the interactive flow when you want to choose the adapter, starter marts, packages, and optional setup files:
dbt-forge initUse defaults when you want a repeatable starting structure without prompts:
dbt-forge init my_dbt_project --defaultsPreview the scaffold without writing files:
dbt-forge init my_dbt_project --defaults --dry-runUse a preset to enforce team standards:
dbt-forge init my_dbt_project --preset company-standard.ymlScaffold a multi-project dbt Mesh setup:
dbt-forge init my_mesh --meshSee init for the full command reference and preset
for the preset file format.
Default selections
Section titled “Default selections”When you use --defaults, the CLI selects:
| Setting | Default value |
|---|---|
| Adapter | BigQuery |
| Marts | finance, marketing |
| Packages | dbt-utils, dbt-expectations |
| Example models | yes |
| SQLFluff config | yes |
| CI provider | GitHub Actions |
The following are disabled by default and must be enabled interactively or via a preset:
- Unit tests, MetricFlow examples, snapshots, seeds, exposures, macros
- Pre-commit hooks, environment config (
.env.example+generate_schema_name) - CODEOWNERS file
Treat the defaults as a starting point. Review the generated models, packages, and CI files before committing them to a team project.
Inspect the generated project
Section titled “Inspect the generated project”The exact output depends on the options you choose. A typical scaffold includes:
dbt_project.yml— project configurationpyproject.toml— Python dependencies (dbt adapter)profiles/profiles.yml— adapter-aware connection profilepackages.yml— dbt packages with pinned version rangesmodels/staging/,models/intermediate/, andmodels/marts/tests/,macros/, andselectors.yml.dbt-forge.yml— manifest for template updates (used bydbt-forge update)- optional files:
.sqlfluff, CI config,.pre-commit-config.yaml,.env.example,CODEOWNERS
Use Project structure for a complete breakdown of every generated file.
Run the next commands
Section titled “Run the next commands”After the scaffold is written, move into the new dbt project and run the local setup
commands. The generated .env file sets DBT_PROFILES_DIR=./profiles so dbt can
find the generated profiles/profiles.yml:
cd my_dbt_projectuv syncuv run --env-file .env dbt depsuv run --env-file .env dbt debugIf you skip starter packages during init, dbt deps is not required.
Extend an existing project
Section titled “Extend an existing project”Inside an existing dbt project, use the add subcommands to scaffold new components
without overwriting files that already exist:
dbt-forge add mart financedbt-forge add source salesforcedbt-forge add snapshot ordersdbt-forge add seed dim_countrydbt-forge add exposure weekly_revenuedbt-forge add macro cents_to_dollarsGenerate models, tests, and CI config interactively:
dbt-forge add model users # interactive model generatordbt-forge add test stg_orders # data test, unit test, or schema testdbt-forge add ci github # CI pipeline configdbt-forge add pre-commit # pre-commit hooks + editorconfigdbt-forge add package dbt-utils # add a dbt packageGenerate sources from live warehouse metadata:
dbt-forge add source raw_data --from-databaseAdd a sub-project to a dbt Mesh:
dbt-forge add project analyticsSee add for the full command reference.
Check project health
Section titled “Check project health”Run doctor from inside a dbt project to validate best practices:
dbt-forge doctor # run all 10 checksdbt-forge doctor --fix # auto-generate missing schema stubsdbt-forge doctor --ci # non-interactive, exit 1 on failuresdbt-forge doctor --check test-coverage # run a single checkThe doctor checks naming conventions, schema/test coverage, hardcoded references,
pinned package versions, source freshness, orphaned YAML entries, and more.
See doctor for details on each check.
View project stats
Section titled “View project stats”Run status for a dashboard overview:
dbt-forge statusShows model counts by layer (staging, intermediate, marts), test and documentation
coverage percentages, source counts with freshness status, and installed packages.
See status for output details.
Update templates
Section titled “Update templates”After upgrading dbt-forge, use update to re-apply templates and pick up improvements:
dbt-forge update --dry-run # preview what would changedbt-forge update # interactively accept/skip each changeThe command reads the .dbt-forge.yml manifest created during init, re-renders
templates with the current version, and shows a diff for each changed file.
See update for the full workflow.
Migrate legacy SQL
Section titled “Migrate legacy SQL”Convert a directory of SQL scripts into a dbt project:
dbt-forge migrate ./legacy_sql/dbt-forge migrate ./legacy_sql/ --dry-run # preview without writingThe command parses CREATE TABLE/VIEW statements, builds a dependency graph, and
generates dbt models with ref() and source() replacing raw table references. Each
model is assigned to staging, intermediate, or marts based on its dependencies. A
migration report summarizes the results.
See migrate for the full command reference.
Lint project structure
Section titled “Lint project structure”Run lint to check for architectural issues that SQL linters miss:
dbt-forge lint # run all 6 rulesdbt-forge lint --rule fan-out # single ruledbt-forge lint --ci # exit 1 on warningsThe lint rules check DAG fan-out, source-to-mart violations, model complexity,
duplicate logic, circular dependencies, and YAML-SQL column drift. Customize
thresholds with a .dbt-forge-lint.yml file.
See lint for the full command reference.
Analyze change impact
Section titled “Analyze change impact”Run impact to see which downstream models are affected by a change:
dbt-forge impact stg_orders # downstream tree for one modeldbt-forge impact --diff # detect changes from git diffdbt-forge impact --diff --pr # markdown for PR descriptionsSee impact for output examples and options.
Estimate query costs
Section titled “Estimate query costs”Run cost to identify expensive models from warehouse usage data:
dbt-forge cost # top 10 models, last 30 daysdbt-forge cost --days 7 --top 20 # custom rangedbt-forge cost --report # markdown reportSupports BigQuery, Snowflake, and Databricks. Includes materialization suggestions.
See cost for supported warehouses and output details.
Generate data contracts
Section titled “Generate data contracts”Run contracts generate to create dbt data contracts from warehouse column types:
dbt-forge contracts generate orders # single modeldbt-forge contracts generate --all-public # all public modelsdbt-forge contracts generate --dry-run # previewAdds contract: { enforced: true }, data_type, and not_null tests. Preserves
existing descriptions and tests.
See contracts for the full command reference.
Track model changes
Section titled “Track model changes”Run changelog generate to detect breaking schema changes between git refs:
dbt-forge changelog generate # latest tag to HEADdbt-forge changelog generate --from v1.0 --to v2.0dbt-forge changelog generate --format json # machine-readabledbt-forge changelog generate --breaking-only # breaking onlySee changelog for change classification details.
Generate documentation with AI
Section titled “Generate documentation with AI”Generate model and column descriptions using an LLM:
dbt-forge docs generate # all undocumented modelsdbt-forge docs generate --model stg_orders # single modeldbt-forge docs generate --provider ollama # use local OllamaSupports Claude (Anthropic), OpenAI, and Ollama. The command reads model SQL, sends it to the LLM, and presents generated descriptions for interactive review before updating YAML files. Existing descriptions are preserved.
See docs generate for the full command reference.