Etl pipelines

From j4flmao/agent-skills · View interactive version

Etl pipelines is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks to run dbt from Airflow, Astronomer Cosmos, DbtCloudRunJobOperator, dbt in an Airflow 3 DAG, Asset-based scheduling or orchestrate a daily ETL with Airflow and dbt. Produces the integration pattern, DAG code, model-level retries and CI. Not for general ETL architecture (use da

How to use this skill

Skill file

Airflow + dbt Orchestration

Purpose

Run dbt transformations on a schedule or when upstream data lands, with retries, alerting and lineage, without turning Airflow into a compute engine. Airflow decides when and in what order; the warehouse does the work; dbt defines the SQL models and tests. The main design decision is how much of the dbt graph Airflow should see.

Agent Protocol

Trigger

"airflow dbt", "run dbt from airflow", "cosmos", "DbtCloudRunJobOperator", "dbt task group", "dbt in dag", "airflow 3 migration dbt", "orchestrate dbt".

Input Context

Output Artifact

Integration choice + DAG code + dbt selectors/tests + CI steps. No file unless requested.

Response Format

Pattern: {Cosmos per-model|dbt Cloud job|single dbt build task|KubernetesPodOperator}
Schedule: {cron|Asset-triggered}
Selectors: {dbt --select ...}
Failure handling: {retries, alerts, partial reruns}

Completion Criteria

Integration Patterns

| Pattern | Pros | Cons | Use when |

|---------|------|------|----------|

| Astronomer Cosmos (DbtDag / DbtTaskGroup) | One Airflow task per model/test: retries, lineage, timing per model | Large projects create big DAGs; parse time | dbt Core, < ~1000 models, want model-level visibility |

| dbt Cloud job (DbtCloudRunJobOperator) | dbt platform handles environments, docs, state | Opaque inside Airflow; extra cost | Team already on dbt Cloud |

| Single dbt build task (Bash/Kubernetes pod) | Simplest, one container image | All-or-nothing retry; less visibility | Small projects, early stage |

| KubernetesPodOperator with dbt image | Isolated deps, scalable | Pod startup overhead | dbt deps conflict with Airflow deps |

Keep dbt and Airflow Python dependencies isolated (separate virtualenv or container); they conflict frequently.

Airflow 3 Essentials

Example: Cosmos (dbt Core, model-level tasks)

from datetime import datetime
from pathlib import Path

from cosmos import DbtDag, ExecutionConfig, ProfileConfig, ProjectConfig
from cosmos.profiles import PostgresUserPasswordProfileMapping

DBT_PROJECT = Path("/usr/local/airflow/dbt/analytics")

profile_config = ProfileConfig(
    profile_name="analytics",
    target_name="prod",
    profile_mapping=PostgresUserPasswordProfileMapping(
        conn_id="warehouse_postgres",           # Airflow connection holds credentials
        profile_args={"schema": "analytics"},
    ),
)

analytics_dbt = DbtDag(
    dag_id="analytics_dbt",
    project_config=ProjectConfig(DBT_PROJECT),
    profile_config=profile_config,
    execution_config=ExecutionConfig(dbt_executable_path="/usr/local/airflow/dbt_venv/bin/dbt"),
    schedule="0 5 * * *",
    start_date=datetime(2026, 1, 1),
    catchup=False,
    default_args={"retries": 2},
)

Check the Cosmos release notes for the minimum version that supports your Airflow version.

Example: dbt Cloud Job Triggered by an Upstream Asset

from datetime import datetime

from airflow.sdk import Asset, dag
from airflow.providers.dbt.cloud.operators.dbt import DbtCloudRunJobOperator

raw_orders = Asset("s3://lake/raw/orders/")       # produced by the ingestion DAG

@dag(schedule=[raw_orders], start_date=datetime(2026, 1, 1), catchup=False)
def dbt_cloud_orders():
    DbtCloudRunJobOperator(
        task_id="run_orders_job",
        dbt_cloud_conn_id="dbt_cloud",
        job_id=12345,                              # dbt Cloud job id
        wait_for_termination=True,
        check_interval=30,
        timeout=3600,
    )

dbt_cloud_orders()

The ingestion task declares outlets=[raw_orders]; when it succeeds, this DAG runs.

Example: Single `dbt build` Task

from datetime import datetime

from airflow.sdk import dag
from airflow.providers.standard.operators.bash import BashOperator

@dag(schedule="@daily", start_date=datetime(2026, 1, 1), catchup=False)
def dbt_build_daily():
    BashOperator(
        task_id="dbt_build",
        bash_command=(
            "cd /opt/dbt/analytics && "
            "dbt build --target prod --select tag:daily --fail-fast"
        ),
        retries=1,
    )

dbt_build_daily()

dbt Practices That Matter for Orchestration

CI

dbt build --select state:modified+ --defer --state ./prod-manifest --target ci   # slim CI: changed models + children
ruff check dags/ --select AIR                                                  # Airflow upgrade/lint rules
python -c "from airflow.models import DagBag; db = DagBag('dags/', include_examples=False); assert not db.import_errors, db.import_errors"

Anti-Patterns

References

Shared References

Additional reference material for this skill, stored outside its own references/ folder.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.