dbt
dbt (data build tool) patterns for data transformation and analytics engineering. Use when building data models, implementing data quality tests, or managing data transformation pipelines.
When & Why to Use This Skill
This Claude skill provides comprehensive dbt (data build tool) patterns and best practices for analytics engineering. It enables users to architect robust data transformation pipelines, implement automated data quality testing, and manage complex SQL-based data models using industry-standard staging, intermediate, and marts structures to ensure data reliability and maintainability.
Use Cases
- Architecting Data Pipelines: Designing multi-layered data models to transform raw warehouse data into clean, business-ready insights using standardized staging and marts patterns.
- Automated Data Quality Testing: Implementing schema tests and data assertions (like unique and not_null) to ensure the integrity and reliability of analytics datasets.
- Incremental Data Loading: Developing efficient incremental models to process large-scale datasets by only updating new or changed records, reducing warehouse compute costs.
- Standardizing Analytics Workflows: Applying modular SQL development practices, including source referencing and macro usage, to improve code reusability and team collaboration.
| name | dbt |
|---|---|
| description | dbt (data build tool) patterns for data transformation and analytics engineering. Use when building data models, implementing data quality tests, or managing data transformation pipelines. |
dbt Skill
This skill provides dbt patterns for analytics engineering.
Project Structure
dbt_project/
├── dbt_project.yml
├── models/
│ ├── staging/
│ │ └── stg_customers.sql
│ ├── intermediate/
│ │ └── int_customer_orders.sql
│ └── marts/
│ └── fct_orders.sql
├── seeds/
├── macros/
├── tests/
└── snapshots/
Model Patterns
Staging Models
-- models/staging/stg_customers.sql
with source as (
select * from {{ source('raw', 'customers') }}
),
renamed as (
select
id as customer_id,
lower(email) as email,
created_at
from source
)
select * from renamed
Incremental Models
-- models/marts/fct_orders.sql
{{
config(
materialized='incremental',
unique_key='order_id'
)
}}
select *
from {{ ref('stg_orders') }}
{% if is_incremental() %}
where updated_at > (select max(updated_at) from {{ this }})
{% endif %}
Testing
# models/schema.yml
models:
- name: stg_customers
columns:
- name: customer_id
tests:
- unique
- not_null
- name: email
tests:
- unique
Best Practices
- Use staging → intermediate → marts pattern
- Source all raw data with
source() - Reference models with
ref() - Add documentation and tests
- Use incremental models for large datasets