← Explore all skills

DATA AND ANALYTICS / dbt Labs

Adding a dbt unit test

Builds dbt SQL-model unit tests from explicit input fixtures and expected output rows.

“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.”

01 / THE REASONING

Why this made the selection.

  • Documents dict/CSV/SQL fixture tradeoffs and the special SQL-fixture requirement for ephemeral dependencies.
  • Separates unit checks from production data tests and explicitly warns that --empty can overwrite existing model contents.

02 / THE REVIEW RECORD

What we actually inspected.

Source review has boundaries.
A clear record is more useful than a “safe” badge.

Material inspected

  • skills/dbt/skills/adding-dbt-unit-test/SKILL.md (complete frontmatter and body)
  • https://github.com/dbt-labs/dbt-agent-skills/blob/168a2b0b92da59be88866257140907c206ff0e44/LICENSE (applicable licence text)

Our findings

  • Documents dict/CSV/SQL fixture tradeoffs and the special SQL-fixture requirement for ephemeral dependencies.
  • Separates unit checks from production data tests and explicitly warns that --empty can overwrite existing model contents.
  • Writes YAML/SQL/CSV fixtures and runs warehouse-connected dbt commands; --empty and build/run can replace relations.

Not established by this review

  • Host discovery, task execution and model quality were not tested.
  • Referenced helpers, sibling plugins and external service operations were not exhaustively audited or executed.

The review applies to the material and revision named here. A newer upstream release can change its behavior.

03 / PUT IT TO WORK

Add a skill to your workflow.

Upstream setup instructions ↗

DOCUMENTED COMMAND

npx skills@1.7.1 add https://github.com/dbt-labs/dbt-agent-skills/tree/168a2b0b92da59be88866257140907c206ff0e44/skills/dbt/skills/adding-dbt-unit-test --skill adding-dbt-unit-test

Copying does not execute this command. It may retrieve a newer version than the reviewed source.

  1. Use the exact reviewed directory/revision and select the intended host/project scope in Skills CLI.
  2. Retain all supporting files; separately configure companion skills, runtimes and service credentials named in the definition.
  3. Review the resulting diff and use an isolated target before any migration, deployment, load test or warehouse operation.

Before you start

  • A supported dbt/adapter version, the full reference directory and an isolated development warehouse schema with parent relations prepared.

04 / FOLLOW THE EVIDENCE

The source trail.

Our notes are separate from the original resource.
Check upstream before adopting a new version.

  1. Skill definition ↗Checked

    https://github.com/dbt-labs/dbt-agent-skills/blob/168a2b0b92da59be88866257140907c206ff0e44/skills/dbt/skills/adding-dbt-unit-test/SKILL.md

    Supports: summary, whySelected, limitations, access, review

  2. Repository licence ↗Checked

    https://github.com/dbt-labs/dbt-agent-skills/blob/168a2b0b92da59be88866257140907c206ff0e44/LICENSE

    Supports: Redistribution terms

  3. Install instructions ↗Checked

    https://github.com/dbt-labs/dbt-agent-skills/blob/168a2b0b92da59be88866257140907c206ff0e44/README.md

    Supports: Documented install path

Evidence & Ask