skills/dbt/debugging-dbt-errors/SKILL.md
Debugs and fixes dbt errors systematically. Use when working with dbt errors for: (1) Task mentions "fix", "error", "broken", "failing", "debug", "wrong", or "not working" (2) Compilation Error, Database Error, or test failures occur (3) Model produces incorrect output or unexpected results (4) Need to troubleshoot why a dbt command failed Reads full error, checks upstream first, runs dbt build (not just compile) to verify fix.
npx skillsauth add altimateai/data-engineering-skills debugging-dbt-errorsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Read the full error. Check upstream first. ALWAYS run dbt build after fixing.
dbt build after fixing - compile is NOT enough to verify the fixdbt compile --select <model_name>
# or
dbt build --select <model_name>
Read the COMPLETE error message. Note the file, line number, and specific error.
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.
cat target/compiled/<project>/<path>/<model_name>.sql
See the actual SQL that will run.
| 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 |
# 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.
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 {% %} |
dbt build --select <model_name>
3-Failure Rule: If build fails 3+ times, STOP. Step back and:
# Preview the data
dbt show --select <model_name> --limit 10
# Run tests
dbt test --select <model_name>
After fixing, re-read the original request and verify:
# Find downstream models
grep -r "ref('<model_name>')" models/ --include="*.sql"
# Rebuild downstream
dbt build --select <model_name>+
{{ }} and {% %}target/compiled/tools
Delegates data engineering tasks to altimate-code, a specialized CLI agent with 100+ purpose-built data tools — SQL analysis, column-level lineage, dbt build/test/run, warehouse profiling, FinOps, and connectivity to Snowflake, BigQuery, Redshift, Databricks, Postgres, MySQL, DuckDB. Use this skill when the task needs live warehouse access, column lineage, multi-step data exploration, dbt builds against a real warehouse, or when the user explicitly invokes "altimate", "altimate-code", or "the data agent".
testing
Optimizes Snowflake SQL query performance from provided query text. Use when optimizing Snowflake SQL for: (1) User provides or pastes a SQL query and asks to optimize, tune, or improve it (2) Task mentions "slow query", "make faster", "improve performance", "optimize SQL", or "query tuning" (3) Reviewing SQL for performance anti-patterns (function on filter column, implicit joins, etc.) (4) User asks why a query is slow or how to speed it up
development
Optimizes Snowflake query performance using query ID from history. Use when optimizing Snowflake queries for: (1) User provides a Snowflake query_id (UUID format) to analyze or optimize (2) Task mentions "slow query", "optimize", "query history", or "query profile" with a query ID (3) Analyzing query performance metrics - bytes scanned, spillage, partition pruning (4) User references a previously run query that needs optimization Fetches query profile, identifies bottlenecks, returns optimized SQL with expected improvements.
data-ai
Finds and ranks expensive Snowflake queries by cost, time, or data scanned. Use when: (1) User asks to find slow, expensive, or problematic queries (2) Task mentions "query history", "top queries", "most expensive", or "slowest queries" (3) Analyzing warehouse costs or identifying optimization candidates (4) Finding queries that scan the most data or have the most spillage Returns ranked list of queries with metrics and optimization recommendations.