running-dbt-commands

작성자: dbt-labs

dbt CLI 명령을 형식화하고 실행하며, 올바른 dbt 실행 파일을 선택하고 명령 매개변수를 구성합니다. 모델, 테스트, 빌드, 컴파일 등을 실행할 때 사용합니다.

npx skills add https://github.com/dbt-labs/dbt-agent-skills --skill running-dbt-commands

Running dbt Commands

Preferences

  1. Use MCP tools if available (dbt_build, dbt_run, dbt_show, etc.) - they handle paths, timeouts, and formatting automatically
  2. Always use build — even when users say "run" - When a user asks to "run" a model, recommend dbt build instead. build = run + test in one step, so it catches data quality issues immediately. dbt run alone is almost never the right answer during development.
  3. Always use --quiet with --warn-error-options '{"error": ["NoNodesForSelectionCriteria"]}' to reduce output while catching selector typos
  4. Always use --select - never run the entire project without explicit user approval

Quick Reference

# Standard command pattern
dbt build --select my_model --quiet --warn-error-options '{"error": ["NoNodesForSelectionCriteria"]}'

# Preview model output
dbt show --select my_model --limit 10

# Run inline SQL query
dbt show --inline "select * from {{ ref('orders') }}" --limit 5

# With variables (JSON format for multiple)
dbt build --select my_model --vars '{"key": "value"}'

# Full refresh for incremental models
dbt build --select my_model --full-refresh

# List resources before running
dbt list --select my_model+ --resource-type model

dbt CLI Flavors

Three CLIs exist. Ask the user which one if unsure.

FlavorLocationNotes
dbt CorePython venvpip show dbt-core or uv pip show dbt-core
dbt Fusion~/.local/bin/dbt or dbtfFaster and has stronger SQL comprehension
dbt Cloud CLI~/.local/bin/dbtGo-based, runs on platform

Common setup: Core in venv + Fusion at ~/.local/bin. Running dbt uses Core. Use dbtf or ~/.local/bin/dbt for Fusion.

Selectors

Always provide a selector. Graph operators:

OperatorMeaningExample
model+Model and all downstreamstg_orders+
+modelModel and all upstream+dim_customers
+model+Both directions+orders+
model+NModel and N levels downstreamstg_orders+1
--select my_model              # Single model
--select staging.*             # Path pattern
--select fqn:*stg_*            # FQN pattern
--select model_a model_b       # Union (space)
--select tag:x,config.mat:y    # Intersection (comma)
--exclude my_model             # Exclude from selection

Resource type filter:

--resource-type model
--resource-type test --resource-type unit_test

Valid types: model, test, unit_test, snapshot, seed, source, exposure, metric, semantic_model, saved_query, analysis

Fusion: --resource-type is not supported with dbt test (dbt-fusion#1628). To run unit tests in Fusion:

  • dbt build --select model_name — builds the model first, then runs all tests including unit tests
  • dbt build --select unit_test_name — targets a specific unit test by name
  • dbt list --resource-type unit_test — lists unit test names for use in selectors

List

Use dbt list to preview what will be selected before running. Helpful for validating complex selectors.

dbt list --select my_model+              # Preview selection
dbt list --select my_model+ --resource-type model  # Only models
dbt list --output json                   # JSON output
dbt list --select my_model --output json --output-keys unique_id name resource_type config

Available output keys for --output json: unique_id, name, resource_type, package_name, original_file_path, path, alias, description, columns, meta, tags, config, depends_on, patch_path, schema, database, relation_name, raw_code, compiled_code, language, docs, group, access, version, fqn, refs, sources, metrics

Show

Preview data with dbt show. Use --inline for arbitrary SQL queries.

dbt show --select my_model --limit 10
dbt show --inline "select * from {{ ref('orders') }} where status = 'pending'" --limit 5

Important: Use --limit flag, not SQL LIMIT clause.

Variables

Pass as STRING, not dict. No special characters (\, \n).

--vars 'my_var: value'                              # Single
--vars '{"k1": "v1", "k2": 42, "k3": true}'         # Multiple (JSON)

Analyzing Run Results

After a dbt command, check target/run_results.json for detailed execution info:

# Quick status check
cat target/run_results.json | jq '.results[] | {node: .unique_id, status: .status, time: .execution_time}'

# Find failures
cat target/run_results.json | jq '.results[] | select(.status != "success")'

Key fields:

  • status: success, error, fail, skipped, warn
  • execution_time: seconds spent executing
  • compiled_code: rendered SQL
  • adapter_response: database metadata (rows affected, bytes processed)

Defer (Skip Upstream Builds)

Reference production data instead of building upstream models:

dbt build --select my_model --defer --state prod-artifacts

Flags:

  • --defer - enable deferral to state manifest
  • --state <path> - path to manifest from previous run (e.g., production artifacts)
  • --favor-state - prefer node definitions from state even if they exist locally
dbt build --select my_model --defer --state prod-artifacts --favor-state

Static Analysis (Fusion Only)

Override SQL analysis for models with dynamic SQL or unrecognized UDFs:

dbt run --static-analysis=off
dbt run --static-analysis=unsafe

Common Mistakes

MistakeFix
Using test after model changeUse build - test doesn't refresh the model
Running without --selectAlways specify what to run
Using --quiet without warn-errorAdd --warn-error-options '{"error": ["NoNodesForSelectionCriteria"]}'
Running dbt expecting Fusion when we are in a venvUse dbtf or ~/.local/bin/dbt
Schema errors after changing files in FusionRun dbt clean to clear the stale schema cache, then re-run
Adding LIMIT to SQL in dbt_showUse limit parameter instead
Vars with special charactersPass as simple string, no \ or \n

dbt-labs의 다른 스킬

answering-natural-language-questions-with-dbt
dbt-labs
데이터 웨어하우스에 대해 dbt의 시맨틱 레이어 또는 임시 SQL을 사용하여 SQL 쿼리를 작성 및 실행하고 비즈니스 질문에 답변합니다. 사용자가 ~에 대해 질문할 때 사용하세요.
official
adding-dbt-unit-test
dbt-labs
업스트림 모델 입력을 모킹하고 예상 출력을 검증하는 단위 테스트 YAML 정의를 생성합니다. dbt 모델에 단위 테스트를 추가하거나 연습할 때 사용하세요...
official
building-dbt-semantic-layer
dbt-labs
dbt Semantic Layer 구성 요소(시맨틱 모델, 메트릭, 차원, 엔티티, 측정값, 타임 스파인)를 생성하거나 수정할 때 사용합니다. MetricFlow를 다룹니다…
official
configuring-dbt-mcp-server
dbt-labs
dbt용 MCP 서버 설정 JSON을 생성하고, 인증 설정을 해결하며, 서버 연결을 검증합니다. dbt를 설정, 구성하거나…할 때 사용하세요.
official
creating-mermaid-dbt-dag
dbt-labs
MCP 도구, manifest.json 또는 직접 코드 파싱을 대체 수단으로 사용하여 dbt 모델 계보의 Mermaid 플로우차트 다이어그램을 생성합니다. dbt 모델 시각화 시 사용합니다.
official
migrating-dbt-core-to-fusion
dbt-labs
Use when a user needs help triaging dbt-core to Fusion migration errors. Runs dbt-autofix first, then classifies remaining errors into actionable categories…
official
migrating-dbt-project-across-platforms
dbt-labs
Use when migrating a dbt project from one data platform or data warehouse to another (e.g., Snowflake to Databricks, Databricks to Snowflake) using dbt…
official
troubleshooting-dbt-job-errors
dbt-labs
Diagnoses dbt Cloud/platform job failures by analyzing run logs, querying the Admin API, reviewing git history, and investigating data issues. Use when a dbt…
official