数据库诊断
- 作者仓库星标 620
- 作者更新于 实时读取
- 作者仓库 altimate-code
- 领域
- 数据
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @AltimateAI · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: dbt-troubleshoot
description: Debug dbt errors — compilation failures, runtime database errors, test failures, wrong data, and…
category: 数据
runtime: Python
---
# dbt-troubleshoot 输出预览
## PART A: 任务判断
- 适用问题:表格、CSV、数据集、指标或分析流程。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Requirements / When to Use This Skill / Iron Rules”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于表格、CSV、数据集、指标或分析流程,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Requirements / When to Use This Skill / Iron Rules”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Requirements / When to Use This Skill / Iron Rules”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: dbt-troubleshoot
description: Debug dbt errors — compilation failures, runtime database errors, test failures, wrong data, and…
category: 数据
source: AltimateAI/altimate-code
---
# dbt-troubleshoot
## 什么时候使用
- dbt-troubleshoot 是数据方向的技能,让 Agent 处理结构化文件(Excel / CSV / 表格) 适合处理表格、CSV、指标、数据集、分析和可视化报告,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 A…
- 面向表格、CSV、数据集、指标或分析流程,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Requirements / When to Use This Skill / Iron Rules」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "dbt-troubleshoot" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Requirements / When to Use This Skill / Iron Rules
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Python | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} dbt Troubleshooting
Requirements
Agent: any (read-only diagnosis), builder (if applying fixes)
Tools used: bash (runs altimate-dbt commands), read, glob, edit, altimate_core_semantics, altimate_core_column_lineage, altimate_core_correct, altimate_core_fix, sql_fix
When to Use This Skill
Use when:
- A dbt model fails to compile or build
- Tests are failing
- Model produces wrong or unexpected data
- Builds are slow or timing out
- User shares an error message from dbt
Do NOT use for:
- Creating new models → use
dbt-develop - Adding tests → use
dbt-test - Analyzing change impact → use
dbt-analyze
Iron Rules
- Never modify a test to make it pass without understanding why it's failing.
- Fix ALL errors, not just the reported one. After fixing the specific issue, run a full
dbt build. If other models fail — even ones not mentioned in the error report — fix them too. Your job is to leave the project in a fully working state. Never dismiss errors as "pre-existing" or "out of scope".
Diagnostic Workflow
Step 1: Health Check
altimate-dbt doctor
altimate-dbt info
If doctor fails, fix the environment first. Common issues:
- Python not found → reinstall or set
--python-path - dbt-core not installed →
pip install dbt-core - No
dbt_project.yml→ wrong directory - Missing packages → if
packages.ymlexists butdbt_packages/doesn't, rundbt deps
Step 2: Classify the Error
| Error Type | Symptom | Jump To |
|---|---|---|
| Compilation Error | Jinja/YAML parse failure | references/compilation-errors.md |
| Runtime/Database Error | SQL execution failure | references/runtime-errors.md |
| Test Failure | Tests return failing rows | references/test-failures.md |
| Wrong Data | Model builds but data is incorrect | Step 3 below |
Step 3: Isolate the Problem
# Compile only — catches Jinja errors without hitting the database
altimate-dbt compile --model <name>
# If compile succeeds, try building
altimate-dbt build --model <name>
# Probe the data directly
altimate-dbt execute --query "SELECT count(*) FROM {{ ref('<name>') }}" --limit 1
altimate-dbt execute --query "SELECT * FROM {{ ref('<name>') }}" --limit 5
Step 3b: Offline SQL Analysis
Before hitting the database, analyze the compiled SQL offline:
# Check for semantic issues (wrong joins, cartesian products, NULL comparisons)
altimate_core_semantics --sql <compiled_sql>
# Trace column lineage to find where wrong data originates
altimate_core_column_lineage --sql <compiled_sql>
# Auto-suggest fixes for SQL errors
altimate_core_correct --sql <compiled_sql>
Quick-fix tools — use these when the error type is clear:
# Schema-based fix: fuzzy-matches table/column names against schema to fix typos and wrong references
altimate_core_fix(sql: <compiled_sql>, schema_context: <schema_object>)
# Error-message fix: given a failing query + database error, analyzes root cause and proposes corrections
sql_fix(sql: <compiled_sql>, error_message: <error_message>, dialect: <dialect>)
altimate_core_fix is best for compilation errors (wrong names, missing objects). sql_fix is best for runtime errors (the database told you what's wrong). Use altimate_core_correct for iterative multi-round correction when the first fix doesn't resolve the issue.
Common findings:
- Wrong join type:
INNER JOINdropping rows that should appear → switch toLEFT JOIN - Fan-out: One-to-many join inflating row counts → add deduplication or aggregate
- Column mismatch: Output columns don't match schema.yml definition → reorder SELECT
- NULL comparison: Using
= NULLinstead ofIS NULL→ silent data loss
Step 3c: Wrong Data Diagnosis — Deep Data Exploration
When a model builds but produces wrong results, the bug is almost always in the data assumptions, not the SQL syntax. You must explore the actual data to find it.
# 1. Check the output for unexpected NULLs
altimate-dbt execute --query "SELECT count(*) as total, count(<col>) as non_null, count(*) - count(<col>) as nulls FROM {{ ref('<name>') }}" --limit 1
# 2. Check value ranges — are metrics within expected bounds?
altimate-dbt execute --query "SELECT min(<metric>), max(<metric>), avg(<metric>) FROM {{ ref('<name>') }}" --limit 1
# 3. Check distinct values for key columns — do they look right?
altimate-dbt execute --query "SELECT <col>, count(*) FROM {{ ref('<name>') }} GROUP BY 1 ORDER BY 2 DESC" --limit 20
# 4. Compare row counts between model output and parent tables
altimate-dbt execute --query "SELECT count(*) FROM {{ ref('<parent>') }}" --limit 1
Common wrong-data root causes:
- Fan-out from joins: If row count is higher than expected, a join key isn't unique — check with
SELECT key, count(*) ... GROUP BY 1 HAVING count(*) > 1 - Missing rows from INNER JOIN: If row count is lower than expected, switch to LEFT JOIN and check for NULL join keys
- Date spine issues: If using
current_dateordbt_utils.date_spine, output changes daily — check min/max dates
Step 4: Check Upstream
Most errors cascade from upstream models:
altimate-dbt parents --model <name>
Read the parent models. Build them individually. Query the parent data — don't assume it's correct:
altimate-dbt execute --query "SELECT count(*), count(DISTINCT <pk>) FROM {{ ref('<parent>') }}" --limit 1
altimate-dbt execute --query "SELECT * FROM {{ ref('<parent>') }}" --limit 5
Step 5: Fix and Verify
After applying a fix:
altimate-dbt build --model <name> --downstream
Always build with --downstream to catch cascading impacts.
Then verify the fix with data queries — don't just trust the build:
altimate-dbt execute --query "SELECT count(*) FROM {{ ref('<name>') }}" --limit 1
altimate-dbt execute --query "SELECT * FROM {{ ref('<name>') }}" --limit 10
# Check the specific metric/column that was wrong:
altimate-dbt execute --query "SELECT min(<col>), max(<col>), count(*) - count(<col>) as nulls FROM {{ ref('<name>') }}" --limit 1
Rationalizations to Resist
| You're Thinking... | Reality |
|---|---|
| "Just make the test pass" | The test is telling you something. Investigate first. |
| "Let me delete this test" | Ask WHY it exists before removing it. |
| "It works on my machine" | Check the adapter, Python version, and profile config. |
| "I'll fix it later" | Later never comes. Fix it now. |
Common Mistakes
| Mistake | Fix |
|---|---|
| Changing tests before understanding failures | Read the error. Query the data. Understand the root cause. |
| Fixing symptoms instead of root cause | Trace the problem upstream. The bug is often 2 models back. |
| Not checking upstream models | Run altimate-dbt parents and build parents individually |
| Ignoring warnings | Warnings often become errors. Fix them proactively. |
| Not running offline SQL analysis | Use altimate_core_semantics before building to catch join issues |
| Column names/order don't match schema | Use altimate_core_column_lineage to verify output columns match schema.yml |
| Not querying the actual data when debugging wrong results | Always run data exploration queries — check NULLs, value ranges, distinct values |
| Trusting build success as proof of correctness | Build only checks syntax and constraints — wrong values pass silently |
Reference Guides
| Guide | Use When |
|---|---|
| references/altimate-dbt-commands.md | Need the full CLI reference |
| references/compilation-errors.md | Jinja, YAML, or parse errors |
| references/runtime-errors.md | Database execution errors |
| references/test-failures.md | Understanding and fixing test failures |
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核