All skills
dbt-labs avatar

/using-dbt-for-analytics-engineering

@8908932 official
by dbt Labsdbt-labs/dbt-agent-skills729 stars
62

Builds and modifies dbt models, writes SQL transformations using ref() and source(), creates tests, and validates results with dbt show. Use when doing any dbt work - building or modifying models, debugging errors, exploring unfamiliar data sources, writing tests, or evaluating impact of changes.

Use this Skill: https://skilld.dev/gh/dbt-labs/dbt-agent-skills/using-dbt-for-analytics-engineering

This session only. Nothing lands on disk.

referencesevaluating-impact-of-a-dbt-model-change.md

≈901 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Evaluating Impact of a dbt Model Change

Assess downstream dependencies before modifying a dbt model. Determines scope of impact and recommends appropriate build selectors.

When to Use

  • Before changing SQL logic in an existing model
  • Before renaming, removing, or changing column types
  • Before changing model materialization

Not for: New models (no downstream dependencies yet)

Workflow

flowchart TD
    A[Identify model to change] --> B{MCP tools available?}
    B -->|yes| C[Use get_model_lineage_dev]
    B -->|no| D[Use dbt ls --select model+]
    C --> E[Assess impact scope]
    D --> E
    E --> F{Column-level change?}
    F -->|yes| G[Check column lineage]
    F -->|no| H[Classify impact]
    G --> H
    H --> I{High impact?}
    I -->|yes| J[Ask user: limit depth?]
    I -->|no| K[Recommend build command]
    J --> K

Getting Downstream Dependencies

If dbt MCP Server Available

Check for these tools first - they provide richer lineage data:

Tool Use For
get_model_lineage_dev Model-level downstream dependencies
get_column_lineage Which downstream models reference specific columns

CLI Fallback (Worse data but always available)

List all downstream models:

dbt ls --select model_name+ --output name

Count downstream models:

dbt ls --select model_name+ --output name | wc -l

View as JSON with details:

dbt ls --select model_name+ --output json

Column-Level Impact

When changing or removing a column, identify which downstream models reference it:

# Search for column references in downstream model SQL files
# First get the list of downstream models
dbt ls --select model_name+ --output name > /tmp/downstream.txt

# Then search for column usage in those model files
grep -r "column_name" models/ --include="*.sql" | grep -f /tmp/downstream.txt

With MCP tools, use get_column_lineage for precise tracking.

Impact Classification

Level Criteria Action
Low 1-5 downstream models Proceed with state:modified+
Medium 6-15 downstream models Consider limiting depth
High 16+ downstream models Ask user about depth limit

Recommending Build Commands

Standard (all downstream):

dbt build --select state:modified+

Limited depth (user choice):

# Only 1 level downstream
dbt build --select state:modified+1

# Only 2 levels downstream
dbt build --select state:modified+2

# Only 3 levels downstream
dbt build --select state:modified+3

When impact is high, ask the user:

"This change affects N downstream models. Do you want to:

  1. Build all downstream models with state:modified+
  2. Limit to a specific depth (e.g., state:modified+2 for 2 levels)?"

Quick Reference

Task Command
List downstream dbt ls --select model_name+
Count downstream dbt ls --select model_name+ --output name | wc -l
Build all affected dbt build --select state:modified+
Build limited depth dbt build --select state:modified+N
Find column refs grep -r "col" models/ --include="*.sql"

Common Mistakes

Not checking before changing - Always run impact assessment first, even for "small" changes.

Ignoring column-level impact - Removing a column breaks downstream models that reference it. Check column usage, not just model dependencies.

Building everything - Use --select to limit scope. Never run dbt build without selectors on large projects.

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides comprehensive guidance for dbt analytics engineering. It includes explicit defensive instructions to mitigate indirect prompt injection risks by treating warehouse data and package registry responses as untrusted content. It interacts with the official dbt Hub for package management.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: MEDIUM · 1 issue

  • Runlayer6mo

    3/9 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 8908932. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 4 months ago
What it can do
Runs commands Reads files Edits files
user-invocable
false
metadata
{
  "author": "dbt-labs"
}
All 7 allowed tools
Bash(dbt *)Bash(jq *)ReadWriteEditGlobGrep
  • Testing
  • dbt
  • analytics-engineering
  • sql
  • data-transformation
  • modeling
  • warehouse
  • elt
  • data-pipeline

README badge

README badge for dbt-labs/dbt-agent-skills/using-dbt-for-analytics-engineering

Builds and modifies dbt models, writes SQL transformations using ref() and source(), creates tests, and validates work with dbt show. Targets analytics engineering workflows including model development, refactoring, debugging, and impact assessment in existing dbt projects.

Generated from the current SKILL.md.

Does this skill work with dbt Cloud or only dbt Core?
The skill works with dbt Core via the CLI. It also integrates with dbt Cloud APIs through the dbt MCP server if available in your environment, but the primary interaction model is the dbt CLI.
Can I use this skill to query dbt's semantic layer?
No. Use the `answering-natural-language-questions-with-dbt` skill for semantic layer queries. This skill focuses on building and modifying dbt models, writing SQL transformations, and running tests.
What warehouse databases does this skill support?
The skill works with any dbt-supported warehouse (Postgres, BigQuery, Snowflake, Redshift, etc.). Some guidance is warehouse-specific (e.g., avoiding large unpartitioned scans in BigQuery), but the core dbt workflows apply universally.
Can this skill help me debug dbt errors?
Yes. The skill includes a dedicated reference guide for debugging dbt errors covering project parsing, compilation, and database errors.
Does this skill modify my dbt project directly, or just provide guidance?
The skill both provides guidance and can modify your project. It has write access to create and edit dbt models, YAML files, tests, and documentation, but follows dbt best practices like using ref() and source() and validating changes with dbt show.

Generated from the current SKILL.md. These answers refresh after source changes.