AgentSkillsCN

dbt-ci

当您需要为 dbt 生成 GitHub Actions 工作流、添加 dbt 构建/测试/文档步骤,或通过 --select state:modified+ 配置基于状态的选择时,可选用此功能。它同时提供完整构建(CD)与增量构建(CI)的模板。

SKILL.md
--- frontmatter
name: dbt-ci
description: >
  Use when generating GitHub Actions workflows for dbt, adding dbt build/test/docs steps,
  or configuring state-based selection with --select state:modified+.
  Provides templates for both full builds (CD) and incremental builds (CI).

dbt CI

GitHub Actions Steps

Full Build (CD / Production Baseline)

Use for production baseline workflows where you build everything:

If uv:

yaml
- name: Run dbt
  run: |
    uv run dbt deps
    uv run dbt build --target {TARGET}
    uv run dbt docs generate --target {TARGET}

If pip:

yaml
- name: Run dbt
  run: |
    source .venv/bin/activate
    dbt deps
    dbt build --target {TARGET}
    dbt docs generate --target {TARGET}

Incremental Build (CI / Pull Requests)

Use --state for state-based selection when comparing against a baseline:

If uv:

yaml
- name: Run dbt (modified models only)
  run: |
    uv run dbt deps
    uv run dbt build --target {TARGET} --select state:modified+ --state {STATE_PATH}
    uv run dbt docs generate --target {TARGET} --select state:modified+ --state {STATE_PATH}

If pip:

yaml
- name: Run dbt (modified models only)
  run: |
    source .venv/bin/activate
    dbt deps
    dbt build --target {TARGET} --select state:modified+ --state {STATE_PATH}
    dbt docs generate --target {TARGET} --select state:modified+ --state {STATE_PATH}

Variables

VariableDescriptionExample
{TARGET}dbt target/profile nameprod, ci, dev
{STATE_PATH}Path to baseline manifest for comparisontarget-base

State-Based Selection

  • state:modified - Only models with code changes
  • state:modified+ - Modified models + downstream dependencies
  • +state:modified+ - Upstream + modified + downstream

Requires --state <path> pointing to a directory with baseline manifest.json.

Best Practices

  • Use state:modified+ in CI to only rebuild what changed
  • Always run dbt docs generate to create artifacts for comparison tools
  • Match --target to your profiles.yml environment (prod, ci, dev)
  • Ensure baseline manifest exists before using --state flag

Related Skills

  • Use python-uv-ci skill for Python/uv environment setup steps
  • Use python-pip-ci skill for Python/pip environment setup steps
  • Use recce-cloud-ci skill for Recce Cloud upload/download steps