dbt project structure using medallion architecture (bronze/silver/gold layers). Use this skill when planning project organization, establishing folder structure, defining naming conventions, implementing layer-based configuration, or ensuring proper model dependencies and architectural patterns.
Instrucciones de origen · Vista previa de solo lectura
name
dbt-architecture
description
dbt project structure using medallion architecture (bronze/silver/gold layers). Use this skill when planning project organization, establishing folder structure, defining naming conventions, implementing layer-based configuration, or ensuring proper model dependencies and architectural patterns.
dbt Architecture
Purpose
Transform AI agents into experts on dbt project architecture and medallion layer patterns, providing
guidance on structuring production-grade dbt projects with proper layer separation, naming
conventions, and configuration strategies.
When to Use This Skill
Activate this skill when users ask about:
Planning dbt project structure and folder organization
Purpose: One-to-one relationship with source tables. Light cleaning and standardization only.
Materialization: ephemeral (compiled as CTEs)
Naming: stg_{source}__{table}.sql
Template
-- models/bronze/stg_tpc_h__customers.sql
{{ config(materialized='ephemeral') }}
select-- Primary key (renamed)
c_custkey as customer_id,
-- Attributes (cast and renamed)
c_name as customer_name,
c_address as customer_address,
c_phone as phone_number,
c_acctbal as account_balance,
-- Metadatacurrent_timestamp() as dbt_loaded_at
from {{ source('tpc_h', 'customer') }}
Rules
✅ DO:
One source table → One staging model
Reference sources using {{ source() }}
Rename columns to standard naming
Cast data types
Basic cleaning (trim, upper/lower)
❌ DON'T:
Join between sources
Add business logic
Aggregate data
Hard-code table names
Silver Layer: Intermediate Models
Purpose: Reusable business logic and complex transformations. Sits between staging and marts.
Materialization: ephemeral (reusable logic) or table (complex computations)
Naming: int_{entity}__{description}.sql
Template
-- models/silver/int_customers__with_orders.sql
{{ config(materialized='ephemeral') }}
with customers as (
select*from {{ ref('stg_tpc_h__customers') }}
),
orders as (
select*from {{ ref('stg_tpc_h__orders') }}
),
customer_metrics as (
select
customer_id,
count(*) as total_orders,
sum(order_total) as lifetime_value,
min(order_date) as first_order_date
from orders
groupby customer_id
)
select
c.customer_id,
c.customer_name,
coalesce(m.total_orders, 0) as total_orders,
coalesce(m.lifetime_value, 0) as lifetime_value,
m.first_order_date
from customers c
leftjoin customer_metrics m on c.customer_id = m.customer_id
Rules
✅ DO:
Reference staging + other intermediate models
Add business logic and aggregations
Create reusable components
Use CTEs for clarity
❌ DON'T:
Reference sources directly
Add final presentation logic
Create one-time-use models
Gold Layer: Marts Models
Purpose: Business-ready data products optimized for BI tools and end users.
Materialization: table (dimensions) or incremental (large facts)
Goal: Transform AI agents into expert dbt architects who guide users through project structure
with confidence, clarity, and production-ready patterns.