dbt-unit-tests

A generator for dbt unit tests, which check a data model's logic using mock input rows and expected results. dbt is a tool for building and testing SQL-based data transformations.

In plain words
What is it for?
Use it to add unit-test coverage to a dbt model, test-driven development (writing tests around expected behavior), or verify how a model handles specific inputs and dependencies.
Why use it?
It reduces the manual work of designing test data and covers logic such as conditions, joins, window functions, missing values, and incremental processing.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/altimateai/altimate-code/dbt-unit-tests
Any agent
npx skills add AltimateAI/altimate-code --skill dbt-unit-tests
Clone the repo
git clone --depth 1 https://github.com/AltimateAI/altimate-code

Made for: Claude Code, Codex.

Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,327 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00079 $0.02327
Opus 5 $0.00039 $0.01163
Sonnet 5 $0.00016 $0.00465
Haiku 4.5 $0.00008 $0.00233

Measured 3d ago against content hash a5dd72b5aa24, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dbt-unit-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.opencode/skills/dbt-unit-tests/SKILL.md · 223 lines

How it starts

The opening of the file, as written. The whole thing — 223 lines — stays where its author put it; the contents beside it link to each section on GitHub.

dbt Unit Test Generation

Requirements

Agent: builder or migrator (requires file write access) Tools used: dbt_unit_test_gen, dbt_manifest, dbt_lineage, altimate_core_validate, altimate_core_testgen, bash (runs altimate-dbt commands), read, glob, write, edit

When to Use This Skill

Use when the user wants to:

  • Generate unit tests for a dbt model
  • Add test coverage to an existing model
  • Create mock data for testing
  • Test-driven development (TDD) for dbt
  • Verify CASE/WHEN logic, NULL handling, JOIN behavior, or aggregation correctness
  • Test incremental model logic

Do NOT use for:

  • Adding schema tests (not_null, unique, accepted_values) -> use dbt-test
  • Creating or modifying model SQL -> use dbt-develop
  • Writing descriptions -> use dbt-docs
  • Debugging build failures -> use dbt-troubleshoot

The Iron Rules

  1. Never guess expected outputs. Compute them by running SQL against mock data when possible. If you cannot run SQL, clearly mark expected outputs as placeholders that need verification.
  2. Never skip upstream dependencies. Every ref() and source() the model touches MUST have a mock input. Miss one and the test won't compile.
  3. Use sql format for ephemeral models. Dict format fails silently for ephemeral upstreams.
  4. Never weaken a test to make it pass. If the test fails, the model logic may be wrong. Investigate before changing expected values.
  5. Compile before committing. Always run altimate-dbt test --model <name> to verify tests compile and execute.
  6. Mock data MUST exercise the failure modes of every SQL construct in the model. A unit test that only covers the happy path validates that the model handles easy inputs — it does not validate correctness. Before writing given: rows, list every SQL construct in the model and the boundary case it can mishandle, then ensure at least one mock row triggers each. Universal cases to always cover when the construct appears:
    • LEFT JOIN / LEFT OUTER JOIN → at least one parent row with no matching child (catches COUNT(*) phantom rows, SUM over NULL, fan-out / dropout)
    • INNER JOIN → at least one parent row whose child is filtered out by the JOIN condition (catches missing rows)
    • COUNT(*) / COUNT(<col>) → row where the counted column is NULL (catches COUNT(*) vs COUNT(col) divergence)
    • NULLIF(x, y) → row where x = y (so the result is NULL, exercising downstream NULL-handling)
    • / division → row where the denominator is 0 or NULL
    • CASE WHEN → at least one row matching each branch, including the implicit ELSE NULL if no explicit ELSE is set
    • COALESCE / IFNULL → row where every argument is NULL
    • Window functions (OVER) → a partition of size 1 (single-row group exercises rank/first/last edge cases), a row at the partition boundary, and a tie-break row (two rows with the same ORDER BY key)
    • Date arithmetic / date spines → a row at the start of range, end of range, and a gap day with no events
    • Aggregations with GROUP BY → at least one group of size 1 (often masks fan-out bugs) and one group whose key is NULL
    • Incremental merge keys → both an "insert" row and an "update" row matching an existing key If you can't think of a failure mode for a construct, you don't yet understand it well enough to test it — read the SQL again before guessing inputs.

Read the full file on GitHub · 223 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 223 lines · 79 tokens per session scan A a5dd72b5aa24

Subscribe to this mod's changes

dbt-unit-tests is a skill published in the GitHub repository AltimateAI/altimate-code (803 stars, last pushed 3d ago), licensed MIT. It adds 79 tokens to every session and 2,327 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

writing-tests

How to write a Kiro Crew backend test that has NO side effects and does not flake. Use when adding, editing, reviewing, or debugging a pytest test in the Kiro Crew source repo: which conftest is under your file, what leaks (temp dirs, the real data home, /.kiro, cron, threads, child processes), how to tell which of…

kirodotdev/KiroCrew · 123 tokens

golang-testing

Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI…

samber/cc-skills-golang · 115 tokens

golang-stretchr-testify

Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification…

samber/cc-skills-golang · 97 tokens

test-pyramid

Analyze the repo's unit and E2E tests and propose rebalancing toward a test pyramid — which E2E tests (or assertions inside them) can be covered by unit tests, which unit-level gaps genuinely need E2E coverage, and where coverage is duplicated. Use when the user asks about test pyramid, test rebalancing, "should this…

kubernetes-sigs/agent-sandbox · 104 tokens

fix-flakes

Diagnose and fix flaky tests tracked as open kind/flake issues in kubernetes-sigs/agent-sandbox — reproduce the flake, apply a minimal fix, and open a PR linking the issue. Use when asked to fix a flake, work through kind/flake issues, or when run on a schedule after dev/tools/flake-report has filed flake issues.

kubernetes-sigs/agent-sandbox · 80 tokens

frontend-testing

Use when writing or changing Vitest or React Testing Library tests under web/ or packages/dify-ui/, or when the user explicitly requests frontend test strategy, including evaluation of an existing strategy. Do not use for frontend code-review-only requests, general testability discussion, Python tests, or…

langgenius/dify · 73 tokens