dbt-modeling
БесплатноБез исполняемых скриптовНе проверенWriting dbt models with proper CTE patterns, SQL structure, and layer-specific templates. Use this skill when writing or refactoring dbt models, implementing…
от sfc-gh-dflippo★ 35 звёзд на GitHubОб этом скилле
dbt Modeling
Purpose
Transform AI agents into experts on writing production-quality dbt models, providing guidance on CTE patterns, SQL structure, and best practices for creating maintainable and performant data models across all medallion architecture layers.
When to Use This Skill
Activate this skill when users ask about:
- Writing or refactoring dbt models
- Implementing CTE (Common Table Expression) patterns
- Creating staging, intermediate, or mart models
- Structuring SQL for readability and maintainability
- Implementing proper model dependencies with ref() and source()
- Converting existing SQL to dbt model format
- Debugging model SQL structure issues
CTE Pattern Structure
All dbt models should follow this consistent CTE pattern for readability and maintainability:
-- Import CTEs (staging and intermediate models)
with customers as (
select * from {{ ref('stg_customers') }}
),
orders as (
select * from {{ ref('stg_orders') }}
),
-- Logical CTEs (business logic)
customer_metrics as (
select
customer_id,
count(*) as order_count,
sum(order_amount) as lifetime_value
from orders
group by customer_id
),
-- Final CTE (column selection and standardization)
final as (
select
-- Primary key
customers.customer_id,
-- Attributes
customers.customer_name,
customers.customer_email,
-- Metrics
coalesce(customer_metrics.order_count, 0) as lifetime_orders,
coalesce(customer_metrics.lifetime_value, 0) as lifetime_value,
-- Metadata
current_timestamp() as dbt_updated_at
from customers
left join customer_metrics
on customers.customer_id = customer_metrics.customer_id
)
select * from final
Official dbt Documentation: How we structure our dbt projects
Bronze Layer: Staging Model Template
Purpose: One-to-one with source tables. Clean and standardize only.
Materialization: ephemeral (set at folder level in dbt_project.yml)
Basic Staging Model
-- models/bronze/stg_salesforce__accounts.sql
select
-- Primary key
id as account_id,
-- Attributes
name as account_name,
type as account_type,
industry,
-- Standardized fields
upper(trim(email)) as email_clean,
cast(annual_revenue as number) as annual_revenue,
-- Metadata
current_timestamp() as dbt_loaded_at
from {{ source('salesforce', 'accounts') }}
Staging Model with Light Cleaning
-- models/bronze/stg_ecommerce__customers.sql
select
-- Primary key
customer_id,
-- Attributes (cleaned)
trim(first_name) as first_name,
trim(last_name) as last_name,
lower(trim(email)) as email,
-- Phone standardization
regexp_replace(phone, '[^0-9]', '') as phone_clean,
-- Boolean conversions
case
when status = 'active' then true
else false
end as is_active,
-- Date standardization
cast(created_at as timestamp) as created_at,
-- Metadata
current_timestamp() as dbt_loaded_at
from {{ source('ecommerce', 'customers') }}
Staging Rules
✅ DO:
- Use
{{ source() }}for source references - Rename columns to standard naming conventions
- Cast data types explicitly
- Clean data (trim, upper/lower, standardize formats)
- Add metadata columns (dbt_loaded_at, dbt_updated_at)
❌ DON'T:
- Join multiple sources
- Add business logic or calculations
- Aggregate or group data
- Filter rows (except for obvious bad data)
- Hard-code table names
Silver Layer: Intermediate Model Template
Purpose: Reusable business logic, enrichment, and complex transformations.
Materialization: ephemeral or table (set at folder level, override if needed)
Basic Intermediate Model
-- models/silver/int_customers__with_orders.sql
with customers as (
select * from {{ ref('stg_salesforce__customers') }}
),
orders as (
select * from {{ ref('stg_ecommerce__orders') }}
),
customer_order_metrics as (
select
customer_id,
count(distinct order_id) as total_orders,
sum(order_amount) as lifetime_value,
min(order_date) as first_order_date,
max(order_date) as last_order_date
from orders
group by customer_id
),
final as (
select
c.customer_id,
c.customer_name,
c.customer_email,
coalesce(m.total_orders, 0) as total_orders,
coalesce(m.lifetime_value, 0) as lifetime_value,
m.first_order_date,
m.last_order_date,
datediff(day, m.first_order_date, m.last_order_date) as customer_tenure_days
from customers c
left join customer_order_metrics m
on c.customer_id = m.customer_id
)
select * from final
Complex Intermediate Model with Business Logic
-- models/silver/int_customers__segmented.sql
with cu
Установить dbt-modeling в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dbt-modeling?
Writing dbt models with proper CTE patterns, SQL structure, and layer-specific templates. Use this skill when writing or refactoring dbt models, implementing CTE patterns, creating staging/intermediate/mart models, or ensuring proper SQL structure and dependencies.
Как установить скилл dbt-modeling?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dbt-modeling запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic