Skip to main content
SQLBuild projects are configured with two files in the project root:
  • sqlbuild_project.toml - shared project configuration, committed to version control
  • sqlbuild_local.toml - local developer overrides, gitignored
Macro, constant, and enum visibility is not configured in either file. Declaration scopes use filesystem conventions; see Declaration Scopes. Most projects need only one committed sqlbuild_project.toml. Define shared targets such as dev and prod there, including clone policies and team-wide defaults. Do not maintain separate complete project files for each environment. Create sqlbuild_local.toml only when a developer or execution environment needs different target selection, credentials, schemas, adapter settings, or variables. SQLBuild loads it automatically and merges its explicitly configured values over the shared project config.
Add the local file to .gitignore:

sqlbuild_project.toml

A complete example:

Required fields

Named connections

Define reusable connections under [connections.<name>], then reference one by name from each target. Connections own endpoint, authentication, and compute settings. Targets own the authoritative database, schema, variables, and operational policy.
Multiple targets can reuse one connection while keeping separate namespaces and policies:
A database or schema present in a named connection is connection/session metadata only; it does not satisfy the mandatory namespace strategy for a named target. Put the target’s authoritative database and schema on [targets.<name>]. SQLBuild validates connection references while loading configuration, without opening a warehouse connection, and reports an unknown targets.<name>.connection name as an offline configuration error. For migration only, SQLBuild still maps legacy [connection] to an implicit connection and legacy [targets.<name>.connection] blocks to target-specific implicit connections. These forms are compatibility syntax, not the canonical format for new or updated projects.

Targets

A target is a named build context - the database and schema you build into, plus execution policy (for example dev and prod). Each target references a named connection and can configure:
Managed loader writes use the active target’s loader_schema, falling back to its model schema. Managed source reads use the target named by defer_sources_to, or the active target itself when deferral is omitted. In the example, load --target dev writes to raw_dev, while models built in dev read from raw_prod. SQLBuild rejects targets on the same warehouse/database when their managed loader writes resolve to the same schema. Two targets may read the same schema through deferral, but they cannot both own loader writes there.

Selecting a target

The active target is determined by (in order of precedence):
  1. --target on the command line (highest priority)
  2. sqlbuild_local.toml target field
  3. default_target in sqlbuild_project.toml
  4. No target (models build to the default schema)
A typical developer keeps shared target definitions in sqlbuild_project.toml and selects their normal target once in the optional local file:
Commands then use dev automatically. An explicit command such as sqb build --target prod still takes precedence for that invocation.

Clone policies

Targets can declare whether they allow cloning to or from:
Both policies default to false. sqb clone --from prod --to dev requires allow_as_clone_origin = true on prod and allow_as_clone_destination = true on dev.

Defaults

Project-wide model defaults. Any field you can set in a MODEL() header can be set here as a default:
These apply to all models unless overridden by path defaults or the model’s own MODEL() header.

Constants

Collection constants default to parenthesized SQL value lists. Set a project-wide default when lists and sets should instead compile to first-class adapter-native arrays:
collection_rendering accepts value_list (the SQLBuild default) or array. A public constant’s render_as field or a model-local constant(...) wrapper overrides the project setting. The complete precedence order is declaration override, project setting, then value_list. This setting does not make unsupported adapter features portable. In particular, SQL Server rejects native arrays, and BigQuery rejects nested arrays. See Collections and Rendering for syntax, adapter output, and value-list usage constraints.

Path defaults

Per-directory model defaults. Useful for applying different config to different parts of your project:
Path matching uses the path below models/. A model at models/staging/stg_orders.sql matches the staging path default.

Config layering order

Configuration is layered in this order, with later layers overriding earlier ones:
  1. Project defaults (defaults)
  2. Path defaults (path_defaults) - if the model’s path matches
  3. MODEL() header - the model’s own config
Most keys are overridden by the more specific layer, but three merge instead:
  • tags are unioned across layers. A model with tags [marts] in its header that matches a path default with tags [managed] will have both tags.
  • row_diff_exclude_columns lists are unioned across layers.
  • row_diff_tolerances mappings are deep-merged across layers, so a header tolerance for one column adds to (rather than replaces) tolerances declared in defaults or path defaults.
Diff sampling values use ordinary replacement precedence. row_diff_sample_rows = 0 explicitly disables an inherited sample for a path or model. CLI --sample-rows, --sample-seed, and --exhaustive override the compiled configuration for one invocation.

Settings

Global feature toggles:

Table promotion mode

  • staged (default for most adapters): Materializes into a staging table, runs audits, then swaps into the target. If audits fail, the production table is untouched.
  • immediate: Creates the table directly at the target location. Audits run after materialization. Simpler but no pre-promotion safety net.

Rules

Rules configuration belongs in the shared sqlbuild_project.toml so local and CI compilation use the same checks:
Rules are opt-in. Exact codes activate individual checks and prefixes activate a family. Built-in codes begin with SQBR; repository-defined codes begin with XSQBR. See Compiler-integrated Rules for configuration, authoring, and suppressions.

Project variables

Variables are simple string substitutions available in model SQL via the @@name syntax:
Target-specific variables override project-level ones:
See Macros for details on variable substitution and how variables interact with macros.

Janitor

Configuration for the sqb janitor command, which cleans up stale warehouse relations:

Scenario

Configuration for scenario snapshot capture safety limits and local type overrides:
Local type overrides for DuckDB replay are configured per adapter dialect:
See Scenarios for details on local type overrides and capture limits.

dbt

Configuration for running SQLBuild alongside an existing dbt project:
Paths can be absolute or relative to the SQLBuild project root. See Using SQLBuild with dbt for setup and usage details.

Skills

Configuration for AI agent skill file installation:
See skills CLI reference for usage details.

sqlbuild_local.toml

Local developer overrides. This optional file is loaded automatically and should be gitignored. Only put values that differ from the shared project configuration here.
Project and local configuration merge named connections by name and merge their explicitly configured fields. Target blocks merge the same way and may override the connection reference, database, schema, loader_schema, variables, source deferral, and policy fields. Unspecified values continue to come from sqlbuild_project.toml; a local reference to an unknown merged connection still fails offline during configuration loading. This replaces the common dbt pattern of switching profiles or setting environment variables to change targets. Each developer sets their target, named connection, and preferences once in sqlbuild_local.toml and it persists across sessions.