← ClaudeAtlas

testing-dbt-modelslisted

Adds schema tests and data quality validation to dbt models. Use when working with dbt tests for: (1) Adding or modifying tests in schema.yml files (2) Task mentions "test", "validate", "data quality", "unique", "not_null", or "accepted_values" (3) Ensuring data integrity - primary keys, foreign keys, relationships (4) Debugging test failures or understanding why dbt test failed Matches existing project test patterns and YAML style before adding new tests.
AltimateAI/data-engineering-skills · ★ 102 · Testing & QA · score 86
Install: claude install-skill AltimateAI/data-engineering-skills
# dbt Testing **Every model deserves at least one test. Primary keys need unique + not_null.** ## Workflow ### 1. Study Existing Test Patterns **CRITICAL: Match the project's existing testing style before adding new tests.** ```bash # Find all schema.yml files with tests find . -name "schema.yml" -exec grep -l "tests:" {} \; # Read existing tests to learn patterns cat models/staging/schema.yml | head -100 cat models/marts/schema.yml | head -100 # Check for custom tests or dbt packages ls tests/ cat packages.yml 2>/dev/null ``` **Extract from existing tests:** - YAML formatting style (indentation, spacing) - Test coverage depth (all columns vs key columns only) - Use of custom tests (dbt_utils, dbt_expectations, custom macros) - Description style (brief vs detailed) - Severity levels used (warn vs error) ### 2. Read Model SQL ```bash cat models/<path>/<model_name>.sql ``` Identify: primary keys, foreign keys, categorical columns, date columns, business-critical fields. ### 3. Check Existing Tests for This Model ```bash cat models/<path>/schema.yml | grep -A 50 "<model_name>" # or find . -name "schema.yml" -exec grep -l "<model_name>" {} \; ``` ### 4. Identify Testable Columns | Column Type | Recommended Tests | |-------------|-------------------| | Primary key | `unique`, `not_null` | | Foreign key | `not_null`, `relationships` | | Categorical | `accepted_values` (ask user for valid values) | | Required field | `not_null` | | Date/timestamp | `not_null` | | Bool