Skip to main content

dbt-arch-unit

CI License: MIT Python 3.13+ PyPI Ruff

Architectural unit testing for dbt projects.

Like ArchUnit for Java or import-linter for Python — but for dbt. Declare the architecture your team already agreed on in a single dbt_arch_unit.yaml, and enforce it in CI and pre-commit.

# dbt_arch_unit.yaml  (next to dbt_project.yml)
layers:
  staging:   { paths: ["models/staging/**"],   prefixes: ["stg_"] }
  marts:     { paths: ["models/marts/**"],      prefixes: ["fct_", "dim_"] }
  reporting: { paths: ["models/reporting/**"],  prefixes: ["rpt_"] }

rules:
  - name: layer-dependencies
    config:
      allow:
        staging:   [source]
        marts:     [staging, marts]
        reporting: [marts]
  - name: max-lines-of-code
    config: { max: 200 }
  - name: require-primary-key
    include: ["models/marts/**"]
# after `dbt parse` (produces target/manifest.json)
dbt-arch-unit check          # run all configured rules, exit 1 on violations
dbt-arch-unit check --json   # machine-readable output for CI
dbt-arch-unit report -o report.html --open   # full HTML report + open it
dbt-arch-unit list-rules     # every available rule
dbt-arch-unit explain layer-dependencies
dbt-arch-unit init           # validate this is a dbt project, then scaffold config

Installation

Requires Python 3.13+.

# once published to PyPI:
pip install dbt-arch-unit
pipx install dbt-arch-unit          # isolated CLI install
uv tool install dbt-arch-unit       # via uv

# from source (available today):
uv tool install git+https://github.com/dardanxh/dbt-arch-unit
pipx install git+https://github.com/dardanxh/dbt-arch-unit

# for local development:
git clone https://github.com/dardanxh/dbt-arch-unit
cd dbt-arch-unit
uv sync --extra dev
uv run dbt-arch-unit --help

Use as a pre-commit hook

Add to your dbt project's .pre-commit-config.yaml:

repos:
  - repo: https://github.com/dardanxh/dbt-arch-unit
    rev: v0.1.0
    hooks:
      - id: dbt-arch-unit

How it works

Hybrid parsing: target/manifest.json supplies the accurate dependency graph, configs, tags, columns and tests; raw .sql/.yml files supply line counts, CTE structure, select * usage and joins. Each rule is a small, self-contained function. See dbt-arch-unit list-rules for the full catalog.

init — guarded scaffolding

dbt-arch-unit init first checks that the target directory is actually a dbt project before writing anything:

  • dbt_project.yml exists and parses, and declares a name (required),
  • the model-paths directory exists (required),
  • it contains .sql models and a compiled target/manifest.json (advisory).

If the required checks fail, no file is written and it exits non-zero. On success it auto-detects your models/ layer folders (staging, intermediate, marts, reporting, …) and writes a dbt_arch_unit.yaml tailored to them.

dbt-arch-unit init                          # inspect ./ and scaffold
dbt-arch-unit init --project-dir path/to/dbt
dbt-arch-unit init --force                  # overwrite an existing config

HTML report

dbt-arch-unit report runs the checks and writes a single, self-contained .html file (no external assets) with:

  • a pass/fail banner and headline stats (total issues, errors, warnings),
  • percentages — % of models affected and % of rules passing,
  • bar-chart breakdowns of issues by category, by rule, and by severity,
  • the full findings table (severity, rule, location, message).
dbt-arch-unit report -o architecture_report.html          # write the report
dbt-arch-unit report -o report.html --open                # and open it
dbt-arch-unit check --html report.html                    # table + report in one go

Rule catalog

38 rules across six categories — dependencies, naming, testing, documentation, style, and materialization governance. Run dbt-arch-unit list-rules to see them all, or dbt-arch-unit explain <rule> for details and config keys.

Contributing

Contributions are very welcome — especially new rules. See CONTRIBUTING.md for the dev setup and a walkthrough of adding a rule, and please follow the Code of Conduct.

License

MIT © Dardan Xhymshiti

Metadata

Release files for dbt-arch-unit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbt-arch-unit 0.1.1
File Size Uploaded
dbt_arch_unit-0.1.1.tar.gz 69.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbt-arch-unit 0.1.1
File Interpreter ABI Platform
dbt_arch_unit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 103.2 kB

Release files / dbt_arch_unit-0.1.1.tar.gz

Download URL dbt_arch_unit-0.1.1.tar.gz
Size 69.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0631028d0c5ccfc012954d86dd1fc54ea9c5692ff1745d0939730087beca473c
BLAKE2b-256 checksum
How to use checksums
5f24466d946e2e3f35c189cda1acf0db35e4e59d09f74a5e26642b5b3ef2529f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release files / dbt_arch_unit-0.1.1-py3-none-any.whl

Download URL dbt_arch_unit-0.1.1-py3-none-any.whl
Size 33.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b604043f124a98ca738cd046ae07c137b92c1cf65427824a090b05cfc201617b
BLAKE2b-256 checksum
How to use checksums
8c896b7a7f2249a136403a24906be6539fbdcca17cc1db14772ef21d905ddc2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page