dbtcx
Agent-friendly companion to
dbt-cloud-cli— solves the multi-step-job artifact trap.
The problem this solves
dbt-cloud-cli defaults to last-step artifacts when you call dbt-cloud run get-artifact. For any dbt Cloud job that ends with dbt docs generate (so: virtually every production job), the resulting run_results.json has empty adapter_response on every row. The BigQuery / Snowflake / Redshift job ID, slot_ms, bytes_processed — all live in adapter_response for the actual dbt run / dbt build step. So post-run diagnostic pulls are useless without manual step discovery.
dbtcx fetch-run probes the run's steps until it finds the materialization step (args.which ∈ {run, build, seed, snapshot} AND ≥1 non-empty adapter_response), and pulls artifacts from THAT step.
Quickstart
pip install dbtcx
# or
uv pip install dbtcx
Configure (token from dbt Cloud → Settings → API Tokens):
cat > .env <<'EOF'
DBT_CLOUD_API_TOKEN=dbtu_...
DBT_CLOUD_ACCOUNT_ID=12345
DBT_CLOUD_HOST=cloud.getdbt.com # bare hostname, no scheme
EOF
Pull diagnostic artifacts for a run (auto-detect materialization step):
dbtcx fetch-run 12345678
Bundle a model's compiled SQL too:
dbtcx fetch-run 12345678 --model-path 'compiled/<project>/models/marts/my_model.sql'
Output → ./artifacts/run_<run_id>/:
run_results.json— pulled from the materialization step (adapter_responsepopulated)manifest.json— full project statemanifest.slim.json— agent-friendly index (no compiled SQL bodies; node deps + materialization + schema only)<model>.compiled.sql— if--model-pathwas given (falls back to default-step if not in materialization bundle).step_used— marker file noting which step the artifacts came from
CLI
dbtcx fetch-run
dbtcx fetch-run <run_id> [--step N] [--model-path PATH] [--out-dir DIR] [--force] [--max-probe-steps N]
--step N— manual override (skip auto-detect)--force— re-download even if files exist--out-dir— default./artifacts/run_<id>/--max-probe-steps— default 15
Idempotent: re-runs skip existing files unless --force. If the resolved step changes between runs (e.g. you pass --step 4 after a default auto-detect), the previous artifacts are cleared to avoid mixing step-specific files.
dbtcx proxy
dbtcx proxy <dbt-cloud-cli args>
Pass-through to dbt-cloud with .env already loaded. Examples:
dbtcx proxy run list --job-id 12345 --order-by '-id' --limit 5
dbtcx proxy account get
dbtcx proxy job list --account-id 12345
dbt-cloud-cli reads DBT_CLOUD_API_TOKEN / DBT_CLOUD_ACCOUNT_ID / DBT_CLOUD_HOST natively — no flag plumbing.
Why agents love this
When a coding agent (Claude Code, Cursor, Aider, etc.) is asked to "diagnose why this dbt model is slow", the workflow is:
- Find the latest production run.
- Pull
run_results.jsonto getadapter_response.job_idfor the model. - Dump the warehouse query plan.
- Rank hot stages.
Step 2 is where dbt-cloud-cli quietly fails on multi-step prod jobs — the agent gets adapter_response: {} and burns N round-trips figuring out which step it actually needed. dbtcx fetch-run collapses all that to one call, with progress logs that tell the agent exactly which step won.
Configuration reference
| Var | Required | Notes |
|---|---|---|
DBT_CLOUD_API_TOKEN |
yes | Service token (dbtu_...) from dbt Cloud → Settings → API Tokens |
DBT_CLOUD_ACCOUNT_ID |
yes | Numeric account ID (visible in the URL after /accounts/) |
DBT_CLOUD_HOST |
yes | Bare hostname only — no https://. Multi-tenant US: cloud.getdbt.com; single-tenant US: <prefix>.us1.dbt.com; EMEA: emea.dbt.com; AU: au.dbt.com |
DBT_CLOUD_READONLY |
no | When true, suppresses destructive subcommands |
.env is loaded from the current working directory by default. Use --env-file PATH to point elsewhere:
dbtcx --env-file ~/.config/dbtcx/prod.env fetch-run 12345678
Development
git clone https://github.com/luutuankiet/dbtcx.git
cd dbtcx
uv venv
uv pip install -e ".[dev]"
pytest
Acknowledgements
Wraps dbt-cloud-cli by data-mie. This package adds the multi-step-aware fetcher + a thin env-loader pass-through; everything else delegates to the upstream CLI.
License
MIT — see LICENSE.
Metadata
Release files for dbtcx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dbtcx-0.1.0.tar.gz | 9.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dbtcx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / dbtcx-0.1.0.tar.gz
| Download URL | dbtcx-0.1.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc7b85714f5993ad8913d482b242ce2da2c565535e3e5e7cd87ae9ca309f0941
|
|
BLAKE2b-256 checksum How to use checksums |
264748bdeb8839e10c3f181734e2e1e32a1f30149fa77d0dd1ad11adb700de3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 21, 2026.
Transparency logRelease files / dbtcx-0.1.0-py3-none-any.whl
| Download URL | dbtcx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cac9997afcd924c24015f78bc2d53f91ee4d50aac0638326385958aff2c32cad
|
|
BLAKE2b-256 checksum How to use checksums |
a433892d2ed5f1962cbdc21541f115e4121bf100341325b2d54eb464cc30ac02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 21, 2026.
Transparency logSecurity for dbtcx 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for dbtcx-0.1.0.tar.gz
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 May 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.