Skip to main content

dbt lineage CLI — outputs Mermaid flowchart diagrams from manifest.json

Project description

merlin

dbt lineage CLI — outputs Mermaid flowchart diagrams from manifest.json.

merlin +my_model+

Pipe the output into a GitHub PR description, embed it in documentation, or let an AI agent include it automatically.

Installation

curl (recommended)

curl -LsSf https://raw.githubusercontent.com/dgarhdez/merlin-dbt/main/install.sh | sh

npm

npm install -g merlin-dbt

pip / uv

pip install merlin-dbt
# or
uv tool install merlin-dbt

Usage

# Exact model only
merlin my_model

# Model and all upstream ancestors
merlin +my_model

# Model and all downstream descendants
merlin my_model+

# Full upstream + downstream subgraph
merlin +my_model+

# Use a specific dbt project directory
merlin +my_model+ --project-dir /path/to/dbt_project

# Emit raw Mermaid syntax (no fence, for scripting)
merlin +my_model+ --raw

Selector patterns

Pattern Meaning
model Exact match only
+model Model and all upstream ancestors
model+ Model and all downstream descendants
+model+ Model, all ancestors, and all descendants

Traversal terminates at source() nodes. Sources have no upstream ancestors in the manifest and are treated as roots.

Node shapes in the diagram

Resource type Mermaid shape
model rectangle
source stadium
seed hexagon
snapshot hexagon

Exit codes

Code Meaning
0 Success
1 User input error (model not found, invalid selector)
2 Environment error (manifest.json not found or invalid JSON)

Requirements

  • Python ≥ 3.10
  • A dbt project with a current manifest.json in target/ (run dbt compile first)
  • dbt Core 1.0+ (manifest schema v9+)

Known limitations

Code review workflow: merlin reads the manifest.json in your local target/ directory. When reviewing someone else's PR, your manifest reflects your own branch — not the PR author's. To see the PR author's lineage, check out their branch and run dbt compile first.

Large subgraphs: Selecting a highly connected model with +model+ may produce a diagram with many nodes. GitHub's Mermaid renderer may clip very large diagrams. Use a more specific selector to limit scope.

Example: GitHub Actions

- name: Add lineage diagram to PR
  run: |
    DIAGRAM=$(merlin +${{ env.CHANGED_MODEL }}+)
    gh pr comment ${{ github.event.pull_request.number }} --body "$DIAGRAM"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

merlin_dbt-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

merlin_dbt-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file merlin_dbt-0.1.0.tar.gz.

File metadata

  • Download URL: merlin_dbt-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.3

File hashes

Hashes for merlin_dbt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6a4b0e558859d2e8317d96ede5975596f630fba249f2b3c8f455a5b832fcb05
MD5 b9c25e3afdbe5dfb8f00e143fb42ca68
BLAKE2b-256 56f674eeefdf70d298d44fb337bf467896c1dc52f25a0e2d1a16e088d935325a

See more details on using hashes here.

File details

Details for the file merlin_dbt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for merlin_dbt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae038dc72160573610cedf28824f1b24670a96a4a65fc3c20f6f4112c52e9e4f
MD5 3f8d271ca2b34cf1eee1f1a916733664
BLAKE2b-256 227107b87a6a28ac0e7f7a6bac4a762ff765db9bd0fd48b253dfebc1adffd8d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page