Adding Dbt Unit Test

🏢Official
by dbt-labs · vlatest · Repository

Automatically generates and adds dbt unit tests to models based on schema and data analysis.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add adding-dbt-unit-test npx -- -y @trustedskills/adding-dbt-unit-test
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "adding-dbt-unit-test": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/adding-dbt-unit-test"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill enables AI agents to automatically generate and execute unit tests for dbt (data build tool) models. It ensures data transformation logic remains reliable by validating individual model files against expected outputs and schema constraints within the dbt project structure.

When to use it

  • Pre-deployment validation: Run before merging changes to catch regressions in data transformations early.
  • CI/CD integration: Automate testing pipelines to enforce quality gates for data engineering workflows.
  • Model maintenance: Verify logic integrity when refactoring complex SQL queries or macros.
  • Team collaboration: Standardize testing practices across different team members working on the same dataset.

Key capabilities

  • Generates unit tests directly from dbt model definitions without manual coding.
  • Executes tests against the local dbt project environment.
  • Validates data types, column constraints, and business logic rules.
  • Provides detailed error reports for failed test cases.

Example prompts

  • "Generate a unit test for my customers dbt model to validate that all email addresses follow standard format."
  • "Run all unit tests in the staging package and summarize any failures with line numbers."
  • "Create a new unit test ensuring the order_total column equals the sum of quantity and price in the orders model."

Tips & gotchas

Ensure your dbt project has proper dependencies installed before running generated tests, as missing packages can cause false negatives. Unit tests only validate individual models; they do not replace end-to-end integration testing for complex data pipelines.

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
dbt-labs
Installs
55

🏢 Official

Published by the company or team that built the technology.