auditing-skills
Use when checking skills for security or quality issues, reviewing audit results from skills.sh or Tessl, or remediating findings across published skills.
Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt.
$ npx -y skills add dbt-labs/dbt-agent-skills --skill adding-dbt-unit-test --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/adding-dbt-unit-testContext preview
The summary Claude sees to decide when to auto-load this skill.
Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt.
name: adding-dbt-unit-test description: Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt. user-invocable: false metadata: author: dbt-labs
dbt unit tests validate SQL modeling logic on static inputs before materializing in production. If any unit test for a model fails, dbt will not materialize that model.
You should unit test a model:
More examples:
Cases we don't recommend creating unit tests for:
dbt unit test uses a trio of the model, given inputs, and expected outputs (Model-Inputs-Outputs):
1. `model` - when building this model 2. `given` inputs - given a set of source, seeds, and models as preconditions 3. `expect` output - then expect this row content of the model as a postcondition
Self explanatory -- the title says it all!
**Tip:** Use `dbt show` to explore existing data from upstream models or sources. This helps you understand realistic input structures. However, always sanitize the sample data to remove any sensitive or PII information before using it in your unit test fixtures.
# Preview upstream model data dbt show --select upstream_model --limit 5
**Unit tests require direct parent models to exist in the warehouse.** Before running unit tests standalone (`dbt test`), verify that upstream models already exist first:
# Check if upstream models exist in the warehouse dbt list --select +my_model --exclude my_model --resource-type model # Then verify the tables/views actually exist in the warehouse via dbt show or your SQL client dbt show --select upstream_model --limit 1
If upstream models **do not exist**, or **exist but have been modified and not yet refreshed**, build them using `--empty` to create schema-only versions:
# Build upstream models cheaply (schema only, no data read) dbt run --select +my_model --exclude my_model --empty
> **Warning:** `--empty` overwrites existing models with schema-only (zero-row) versions. Only use it when models don't exist yet, or when schema changes need to be applied. Do not use it if upstream models contain data you want to preserve — it will wipe that data.
Skip this step if using `dbt build --select my_model` (recommended) — it handles the full pipeline including unit tests.
Suppose you have this model:
-- model
A curated collection of Agent Skills for working with dbt. These skills help AI agents understand and execute dbt workflows more effectively.
Use when checking skills for security or quality issues, reviewing audit results from skills.sh or Tessl, or remediating findings across published skills.
Generates a Mermaid flowchart diagram of dbt model lineage using MCP tools, manifest.json, or direct code parsing as fallbacks. Use when visualizing dbt model…
Use when a user needs help triaging dbt-core to dbt v2 migration errors. Runs dbt-autofix first, then classifies remaining errors into actionable categories…
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…
Use when a user wants to upgrade, update, or migrate a dbt-core project to the latest version — e.g. "upgrade my dbt project," "migrate this off dbt-core 1.5,"…
Writes and executes SQL queries against the data warehouse using dbt's Semantic Layer or ad-hoc SQL to answer business questions. Use when a user asks about…