debugging-dbt-errors

A troubleshooting guide for dbt, a tool that builds data models with SQL. It helps investigate compilation errors, database errors, failed tests, and incorrect model results.

In plain words
What is it for?
Use it when a dbt model is broken, failing, produces unexpected data, or needs debugging. It covers checking upstream models, previewing results, and running dbt build after a fix.
Why use it?
It replaces guesswork with a repeatable process: read the full error, inspect the data and compiled SQL, then rebuild and verify the output.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/altimateai/data-engineering-skills/debugging-dbt-errors
Any agent
npx skills add AltimateAI/data-engineering-skills --skill debugging-dbt-errors
Clone the repo
git clone --depth 1 https://github.com/AltimateAI/data-engineering-skills

Made for: Claude Code, Codex.

Per session 112 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,050 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00112 $0.01050
Opus 5 $0.00056 $0.00525
Sonnet 5 $0.00022 $0.00210
Haiku 4.5 $0.00011 $0.00105

Measured 2d ago against content hash 3a32473f71da, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

debugging-dbt-errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills/dbt/debugging-dbt-errors/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

dbt Troubleshooting

Read the full error. Check upstream first. ALWAYS run dbt build after fixing.

Critical Rules

  1. ALWAYS run dbt build after fixing - compile is NOT enough to verify the fix
  2. If fix fails 3+ times, stop and reassess your entire approach
  3. Verify data after build - build passing doesn't mean output is correct

Workflow

1. Get the Full Error

dbt compile --select <model_name>
# or
dbt build --select <model_name>

Read the COMPLETE error message. Note the file, line number, and specific error.

2. Inspect Actual Data (For Data Issues)

Before fixing "wrong output" or "incorrect results", query the actual data:

# Preview current output
dbt show --select <model_name> --limit 20

# Check specific values with inline query
dbt show --inline "select * from {{ ref('model_name') }} where <condition>" --limit 10

# Compare with expected - look for patterns
dbt show --inline "select column, count(*) from {{ ref('model_name') }} group by 1 order by 2 desc" --limit 10

Understand what's wrong before attempting to fix it.

3. Read Compiled SQL

cat target/compiled/<project>/<path>/<model_name>.sql

See the actual SQL that will run.

4. Analyze Error Type

Error Type Look For
Compilation Error Jinja syntax, missing refs, YAML issues
Database Error Column not found, type mismatch, SQL syntax
Dependency Error Missing model, circular reference

5. Check Upstream Models

# Find what this model references
grep -E "ref\(|source\(" models/<path>/<model_name>.sql

# Read upstream model to verify columns
cat models/<path>/<upstream_model>.sql

Many errors come from upstream changes, not the current model.

6. Apply Fix

Common fixes:

Error Fix
Column not found Check upstream model's output columns
Ambiguous column Add table alias: table.column
Type mismatch Add explicit CAST()
Division by zero Use NULLIF(divisor, 0)
Jinja error Check matching {{ }} and {% %}

Read the full file on GitHub · 154 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 154 lines · 112 tokens per session scan A 3a32473f71da

Subscribe to this mod's changes

debugging-dbt-errors is a skill published in the GitHub repository AltimateAI/data-engineering-skills (122 stars, last pushed 1mo ago), licensed MIT. It adds 112 tokens to every session and 1,050 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

pr-verify

Verify a Docglow change actually works before submitting or merging a PR. Runs the conformance suite, then a behavioral verification pass (flag matrix, artifact-join spot checks, pipeline contract sweep, payload budget). Use when reviewing a PR, self-reviewing a branch before opening a PR, or when asked to "verify…

docglow/docglow · 79 tokens

animation-best-practices

CSS and UI animation patterns for responsive, polished interfaces. Use when implementing hover effects, tooltips, button feedback, transitions, or fixing animation issues like flicker and shakiness.

northgraindata/dbt-doctor · 42 tokens

dbt-doctor

Static analysis and health checks for dbt projects. Use before committing SQL/YAML or when enforcing CI quality gates.

northgraindata/dbt-doctor · 28 tokens

datahub-verified-remediation

Use this skill when a source schema change has broken, or is about to break, a downstream transformation and the user wants a fix they can merge — not a summary. Triggers on: "a column was renamed, fix the dbt model", "this field is gone downstream", "schema drift", "our model still selects the old column", "generate…

Marc-Dvci/praxis-datahub · 140 tokens

Data Pipeline Architect

Design and implement robust data pipelines — ETL/ELT, streaming, batch processing. From architecture to code with Airflow, dbt, Kafka, and modern data stack.

demo112/yunqu-ai-skills · 40 tokens

weekly-report

Generate recurring weekly or monthly analytics reports with period-over-period comparison, anomaly detection, and executive summaries. Use when the user asks for a weekly report, monthly KPI review, recurring metrics snapshot, or needs automated period-over-period diffing. Saves templates for one-command re-runs.

adityawrk/analytics-with-claude-code · 59 tokens