Skip to content

skillData and AI

dbt Modeling

Builds dbt models in staging, intermediate and mart layers with tests and generated docs. Use it when adding or restructuring warehouse transformations.

npx workspacetemplates add dbt-modeling --tool claude-code

Writes 1 file to .claude/skills/dbt-modeling/

.claude/skills/dbt-modeling/SKILL.md29 lines · 1.6 KBFile
---
name: dbt-modeling
description: Builds dbt models in staging, intermediate and mart layers with tests and generated docs. Use it when adding or restructuring warehouse transformations.
---

# dbt modeling

One model, one purpose. Tests and docs ship with the model.

## Steps

1. Read `dbt_project.yml` and two existing models to learn the naming, folder layout and default materializations. Match them.
2. Declare the raw tables in a `sources.yml` with a `loaded_at_field` and a freshness rule where one exists.
3. Staging (`stg_<source>__<table>`): one model per source table, `{{ source() }}` only here. Rename columns to snake case, cast types, convert timestamps to UTC, and do no joins or aggregation. Materialize as view.
4. Intermediate (`int_<entity>__<verb>`): joins, deduplication and reusable logic. Reference upstream models with `{{ ref() }}` only.
5. Marts (`dim_` and `fct_`): one grain per table, stated in the description. Materialize as table, or incremental with a `unique_key` and a lookback filter for large facts.
6. Write the YAML next to each model: a description, and tests on every key (`unique`, `not_null`), foreign keys (`relationships`), and enums (`accepted_values`).
7. Run `dbt build --select +<model>` and read the failures. Fix the model, not the test, unless the test is wrong.
8. Run `dbt docs generate` if the project publishes docs.

## Rules

- No `select *` in marts. List columns.
- Do not hardcode schema names; use refs.
- Keep logic out of YAML tests; put it in singular tests under `tests/`.

## Report

Models created with their layer and grain, tests added, `dbt build` result, and any data problem the tests exposed.

What it does

A dbt project stays maintainable when each layer has one job. This skill puts raw renaming and casting in staging, business logic in intermediate and marts, and attaches tests and descriptions to the model in the same change that creates it.

The agent follows your project's naming and materialization conventions, runs the models it touched, and reports test results rather than assuming they pass.

Example

you › Add the Stripe charges source and a fct_payments mart.

agent › Added sources.yml for stripe.charges, stg_stripe__charges (view), int_payments__enriched joining customers, and fct_payments (incremental, unique_key payment_id, grain: one row per charge). 11 tests added. dbt build passes except one: accepted_values on currency found "XBT" on 3 rows, reported rather than silenced.

Questions

Does it need a warehouse connection?
To run and test models, yes: it uses the profile you already have. Without one it still writes models and YAML and tells you they were not run.
Will it change my existing models?
Only when you ask for a refactor. For new work it adds files and leaves current models alone.
  • Data Pipeline Design

    SkillData and AI

    Free
  • LLM Cost and Latency

    SkillData and AI

    Free