Build dbt staging models (stg_ prefix) that clean and standardize raw source data one-to-one. Use when adding a new source, building the first layer of transformation, or auditing existing staging models. Triggers: 'staging layer', 'staging model', 'stg_ model', 'build staging', 'raw to staging', 'clean source data', 'new source model'.
I'll help you build clean, consistent staging models — the first dbt transformation layer that converts raw source data into a standardized, well-named foundation.
Run schema introspection on the raw source before writing SQL to avoid column name surprises:
node tools/clis/schema-introspect.js
Also read existing sources.yml files under models/staging/ to avoid duplicate source declarations for tables already registered.
Read .claude/data-stack-context.md. Key inputs: warehouse, ingestion tool (Fivetran, Airbyte), raw schema names.
Staging models follow strict rules:
source() references — never ref() to other modelsstg_<source_name>__<table_name> (double underscore separates source from table)models/staging/
├── salesforce/
│ ├── _salesforce__sources.yml # source() declarations
│ ├── _salesforce__models.yml # staging model docs + tests
│ ├── stg_salesforce__accounts.sql
│ └── stg_salesforce__opportunities.sql
└── stripe/
├── _stripe__sources.yml
├── _stripe__models.yml
└── stg_stripe__charges.sql
# models/staging/salesforce/_salesforce__sources.yml