Skip to content

Configuration

dbt-contracts is configured via a config.yaml file in the contracts/ directory of your dbt project.

File location

my-dbt-project/
└── contracts/
    ├── config.yaml          # Configuration file
    ├── contracts/
    └── products/

Configuration reference

# contracts/config.yaml

# Project name (used in generated file headers)
project_name: my-dbt-project

# Path to the dbt project root (relative to config.yaml)
dbt_project_dir: ..

# Default server type for generation
default_server_type: snowflake

# Generation settings
generation:
  # Output directory for generated models (relative to dbt project root)
  models_dir: models/generated
  # Output directory for generated sources (relative to dbt project root)
  sources_dir: models/staging
  # Whether to generate source definitions
  generate_sources: true
  # Whether to generate tests from quality checks
  generate_tests: true
  # Header comment in generated files
  header: "-- Generated by dbt-contracts. Do not edit manually."

# Validation settings
validation:
  # Whether to validate cross-references between products and contracts
  cross_reference: true
  # Minimum contract status to consider valid
  min_status: draft

All fields are optional and have sensible defaults.

Field reference

Root fields

Field Type Default Description
project_name string — Project name, used in generated file headers
dbt_project_dir string .. Path to the dbt project root, relative to config.yaml
default_server_type string snowflake Default server type for generation
generation object — Generation settings (see below)
validation object — Validation settings (see below)

Generation settings

Field Type Default Description
models_dir string models/generated Output directory for generated models, relative to dbt project root
sources_dir string models/staging Output directory for generated sources, relative to dbt project root
generate_sources boolean true Whether to generate source definitions
generate_tests boolean true Whether to generate tests from quality checks
header string -- Generated by dbt-contracts. Do not edit manually. Header comment in generated files

Validation settings

Field Type Default Description
cross_reference boolean true Whether to validate cross-references between products and contracts
min_status string draft Minimum contract status to consider valid

Validation

Configuration is validated using Pydantic. Unknown fields are rejected — if your config.yaml contains a typo or unsupported field, you will get a clear validation error.

from dbt_contracts.models import Config

config = Config.from_file("contracts/config.yaml")

See the API reference for the full model definition.