dbt-testing
БесплатноБез исполняемых скриптовНе проверенdbt testing strategies using dbt_constraints for database-level enforcement, generic tests, and singular tests. Use this skill when implementing data quality…
Об этом скилле
dbt Testing
Purpose
Transform AI agents into experts on dbt testing strategies, providing guidance on implementing comprehensive data quality checks with database-enforced constraints, generic tests, and custom singular tests to ensure data integrity across all layers.
When to Use This Skill
Activate this skill when users ask about:
- Implementing data quality tests
- Adding primary key and foreign key constraints
- Using dbt_constraints package for database-level enforcement
- Creating generic (reusable) tests
- Writing singular (one-off) tests
- Testing strategies by layer (bronze/silver/gold)
- Debugging test failures
- Configuring test severity levels
- Storing test failures for analysis
Official dbt Documentation: Testing
Testing Philosophy
Implement tests in this order for maximum data quality:
- Primary Keys - Every dimension must have one
- Foreign Keys - All fact relationships
- Unique Keys - Business key constraints
- Business Rules - Domain-specific validations
- Data Quality - Completeness, accuracy, consistency
Why Use dbt_constraints?
The dbt_constraints package provides database-level enforcement (not just dbt tests):
✅ Database Enforcement - Creates actual constraints in the data warehouse ✅ Performance - Database-level constraints improve query optimization ✅ Data Integrity - Prevents invalid data at all access points (not just dbt) ✅ Documentation - Constraints visible in database metadata and BI tools ✅ Query Optimization - Database can use constraints for better execution plans
Standard dbt tests only validate during dbt test runs. dbt_constraints creates real
database constraints that are enforced 24/7.
Official dbt_constraints Documentation: GitHub - Snowflake-Labs/dbt_constraints
Package Installation
# packages.yml
packages:
- package: Snowflake-Labs/dbt_constraints
version: [">=0.8.0", "<1.0.0"]
- package: dbt-labs/dbt_utils
version: [">=1.0.0", "<2.0.0"]
Install packages:
dbt deps
Official dbt Docs: Package Management
Primary Key Testing
Simple Primary Key (dbt_constraints)
Required for every dimension:
# models/gold/_models.yml
models:
- name: dim_customers
columns:
- name: customer_id
tests:
- dbt_constraints.primary_key
Composite Primary Key
When primary key spans multiple columns:
models:
- name: fct_order_lines
tests:
- dbt_constraints.primary_key:
column_names:
- order_id
- line_number
Alternative: Built-in dbt Tests
Not recommended - no database enforcement:
columns:
- name: product_id
tests:
- not_null
- unique
Limitation: Only validates during dbt test runs, doesn't prevent bad data from other sources.
Foreign Key Testing
Simple Foreign Key (dbt_constraints)
Ensures referential integrity:
models:
- name: fct_orders
columns:
- name: customer_id
tests:
- dbt_constraints.foreign_key:
pk_table_name: ref('dim_customers')
pk_column_name: customer_id
Multiple Foreign Keys
For facts with multiple dimension relationships:
models:
- name: fct_order_lines
columns:
- name: order_id
tests:
- dbt_constraints.foreign_key:
pk_table_name: ref('fct_orders')
pk_column_name: order_id
- name: product_id
tests:
- dbt_constraints.foreign_key:
pk_table_name: ref('dim_products')
pk_column_name: product_id
- name: customer_id
tests:
- dbt_constraints.foreign_key:
pk_table_name: ref('dim_customers')
pk_column_name: customer_id
Alternative: Built-in dbt Relationships Test
Not recommended - no database enforcement:
columns:
- name: customer_id
tests:
- relationships:
to: ref('dim_customers')
field: customer_id
Unique Key Testing
Simple Unique Key (dbt_constraints)
For business keys (non-primary keys that must be unique):
columns:
- name: customer_email
tests:
- dbt_constraints.unique_key
Composite Unique Key
When uniqueness spans multiple columns:
models:
- name: stg_orders
tests:
- dbt_constraints.unique_key:
column_names:
- order_number
- order_source
Generic Tests (Reusable)
Built-in dbt Tests
columns:
- name: order_status
tests:
- not_null
- accepted_values:
values: ["pending", "processing", "shipped", "delivered", "cancelled"]
- name: or
Установить dbt-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dbt-testing?
dbt testing strategies using dbt_constraints for database-level enforcement, generic tests, and singular tests. Use this skill when implementing data quality checks, adding primary/foreign key constraints, creating custom tests, or establishing comprehensive testing frameworks across bronze/silver/gold layers.
Как установить скилл dbt-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dbt-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic