Airflow DAG Orchestrator
Design and operate Apache Airflow DAGs for reliable data pipeline orchestration with proper dependency management, SLAs, and monitoring.
Activation Triggers
Activate on: "Airflow", "DAG", "operator", "sensor", "scheduler", "task dependency", "SLA", "backfill", "XCom", "TaskFlow API", "MWAA", "Cloud Composer"
NOT for: dbt model execution → dbt-analytics-engineer (though Airflow can trigger dbt) | Stream processing → streaming-pipeline-architect | Workflow engine (Temporal) → distributed-transaction-manager
Quick Start
- Define DAG — use TaskFlow API (
@dag, @task decorators) for Python-native DAGs
- Set schedule — cron or timetable, with
catchup=False unless backfill is intentional
- Configure retries —
retries=2, retry_delay=timedelta(minutes=5) on every task
- Add SLAs —
sla=timedelta(hours=2) on critical path tasks
- Test locally —
airflow dags test my_dag 2026-01-01 before deploying
Core Capabilities
| Domain |
Technologies |
| Airflow |
Apache Airflow 2.10+, MWAA, Cloud Composer 3 |
| Operators |
BashOperator, PythonOperator, KubernetesPodOperator |
| Providers |
apache-airflow-providers-{snowflake, google, aws, dbt-cloud} |
| Executors |
CeleryExecutor, KubernetesExecutor, LocalExecutor |
| Monitoring |
SLA misses, task duration, Airflow metrics → Prometheus |
Architecture Patterns
TaskFlow API DAG
from airflow.decorators import dag, task
from datetime import datetime, timedelta
@dag(
schedule="0 6 * * *", # daily at 6am UTC
start_date=datetime(2026, 1, 1),
catchup=False,
default_args={
"retries": 2,
"retry_delay": timedelta(minutes=5),
"sla": timedelta(hours=2),
},
tags=["finance", "daily"],
)
def daily_revenue_pipeline():
@task()
def extract_payments() -> dict:
"""Extract from Stripe API"""
data = stripe_client.list_payments(date=today())
return {"count": len(data), "path": "s3://raw/payments/"}
@task()
def extract_orders() -> dict:
"""Extract from Shopify API"""
data = shopify_client.list_orders(date=today())
return {"count": len(data), "path": "s3://raw/orders/"}
@task()
def transform(payments: dict, orders: dict) -> str:
"""Join and transform in DuckDB"""
result_path = run_duckdb_transform(payments["path"], orders["path"])
return result_path
@task()
def load(path: str):
"""Load to Snowflake"""
snowflake_copy_into("fct_revenue", path)
# Define dependencies via function calls
payments = extract_payments()
orders = extract_orders()
transformed = transform(payments, orders)
load(transformed)
daily_revenue_pipeline()
Dynamic Task Mapping (Fan-Out/Fan-In)
@task()
def get_partitions() -> list[str]:
return ["2026-01-01", "2026-01-02", "2026-01-03"]
@task()
def process_partition(partition_date: str) -> dict:
"""Runs in parallel for each partition"""
return {"date": partition_date, "rows": process(partition_date)}
@task()
def aggregate(results: list[dict]):
"""Fan-in: receives all partition results"""
total = sum(r["rows"] for r in results)
log.info(f"Processed {total} total rows")
# Dynamically maps process_partition across all partitions
partitions = get_partitions()
results = process_partition.expand(partition_date=partitions)
aggregate(results)
dbt + Airflow Integration
from airflow.operators.bash import BashOperator
from cosmos import DbtDag, ProjectConfig, ProfileConfig
# Option 1: cosmos (recommended)
dbt_dag = DbtDag(
project_config=ProjectConfig("/opt/airflow/dbt/"),
profile_config=ProfileConfig(
profile_name="default",
target_name="prod",
),
schedule="@daily",
dag_id="dbt_daily",
)
# Option 2: BashOperator (simple)
dbt_run = BashOperator(
task_id="dbt_run",
bash_command="cd /opt/airflow/dbt && dbt build --select tag:daily",
)
Anti-Patterns
- Fat tasks — tasks should be atomic units; do not put extract+transform+load in one task
- XCom for large data — XCom is for metadata (paths, counts); pass data via S3/GCS, not XCom pickles
- catchup=True by accident — unless you want backfill, set
catchup=False; otherwise Airflow runs every missed interval
- No retries — transient failures are common; always set
retries >= 1 with a delay
- Top-level code in DAG files — DAG files are parsed every 30s; heavy imports or API calls at module level slow the scheduler
Quality Checklist
1---
2license: Apache-2.0
3name: airflow-dag-orchestrator
4description: 'Apache Airflow DAGs, operators, SLA monitoring, and workflow orchestration. Activate on: Airflow, DAG, operator, sensor, scheduler, task dependency, SLA, backfill, XCom. NOT for: dbt transformations (use dbt-analytics-engineer), streaming pipelines (use streaming-pipeline-architect).'
5allowed-tools: Read,Write,Edit,Bash(npm:*,npx:*,python:*,airflow:*)
6category: Agent & Orchestration
7tags:
8 - airflow
9 - orchestration
10 - dag
11 - scheduling
12 - workflow
13pairs-with:
14 - skill: dbt-analytics-engineer
15 reason: Airflow commonly orchestrates dbt runs
16 - skill: data-quality-guardian
17 reason: Quality checks run as Airflow tasks
18 - skill: streaming-pipeline-architect
19 reason: Batch orchestration complements streaming pipelines
20metadata:
21 source: https://skillmd.com/skills/curiositech/airflow-dag-orchestrator
22---
23
24# Airflow DAG Orchestrator
25
26Design and operate Apache Airflow DAGs for reliable data pipeline orchestration with proper dependency management, SLAs, and monitoring.
27
28## Activation Triggers
29
30**Activate on:** "Airflow", "DAG", "operator", "sensor", "scheduler", "task dependency", "SLA", "backfill", "XCom", "TaskFlow API", "MWAA", "Cloud Composer"
31
32**NOT for:** dbt model execution → `dbt-analytics-engineer` (though Airflow can trigger dbt) | Stream processing → `streaming-pipeline-architect` | Workflow engine (Temporal) → `distributed-transaction-manager`
33
34## Quick Start
35
361. **Define DAG** — use TaskFlow API (`@dag`, `@task` decorators) for Python-native DAGs
372. **Set schedule** — cron or timetable, with `catchup=False` unless backfill is intentional
383. **Configure retries** — `retries=2`, `retry_delay=timedelta(minutes=5)` on every task
394. **Add SLAs** — `sla=timedelta(hours=2)` on critical path tasks
405. **Test locally** — `airflow dags test my_dag 2026-01-01` before deploying
41
42## Core Capabilities
43
44| Domain | Technologies |
45|--------|-------------|
46| **Airflow** | Apache Airflow 2.10+, MWAA, Cloud Composer 3 |
47| **Operators** | BashOperator, PythonOperator, KubernetesPodOperator |
48| **Providers** | apache-airflow-providers-{snowflake, google, aws, dbt-cloud} |
49| **Executors** | CeleryExecutor, KubernetesExecutor, LocalExecutor |
50| **Monitoring** | SLA misses, task duration, Airflow metrics → Prometheus |
51
52## Architecture Patterns
53
54### TaskFlow API DAG
55
56```python
57from airflow.decorators import dag, task
58from datetime import datetime, timedelta
59
60@dag(
61 schedule="0 6 * * *", # daily at 6am UTC
62 start_date=datetime(2026, 1, 1),
63 catchup=False,
64 default_args={
65 "retries": 2,
66 "retry_delay": timedelta(minutes=5),
67 "sla": timedelta(hours=2),
68 },
69 tags=["finance", "daily"],
70)
71def daily_revenue_pipeline():
72
73 @task()
74 def extract_payments() -> dict:
75 """Extract from Stripe API"""
76 data = stripe_client.list_payments(date=today())
77 return {"count": len(data), "path": "s3://raw/payments/"}
78
79 @task()
80 def extract_orders() -> dict:
81 """Extract from Shopify API"""
82 data = shopify_client.list_orders(date=today())
83 return {"count": len(data), "path": "s3://raw/orders/"}
84
85 @task()
86 def transform(payments: dict, orders: dict) -> str:
87 """Join and transform in DuckDB"""
88 result_path = run_duckdb_transform(payments["path"], orders["path"])
89 return result_path
90
91 @task()
92 def load(path: str):
93 """Load to Snowflake"""
94 snowflake_copy_into("fct_revenue", path)
95
96 # Define dependencies via function calls
97 payments = extract_payments()
98 orders = extract_orders()
99 transformed = transform(payments, orders)
100 load(transformed)
101
102daily_revenue_pipeline()
103```
104
105### Dynamic Task Mapping (Fan-Out/Fan-In)
106
107```python
108@task()
109def get_partitions() -> list[str]:
110 return ["2026-01-01", "2026-01-02", "2026-01-03"]
111
112@task()
113def process_partition(partition_date: str) -> dict:
114 """Runs in parallel for each partition"""
115 return {"date": partition_date, "rows": process(partition_date)}
116
117@task()
118def aggregate(results: list[dict]):
119 """Fan-in: receives all partition results"""
120 total = sum(r["rows"] for r in results)
121 log.info(f"Processed {total} total rows")
122
123# Dynamically maps process_partition across all partitions
124partitions = get_partitions()
125results = process_partition.expand(partition_date=partitions)
126aggregate(results)
127```
128
129### dbt + Airflow Integration
130
131```python
132from airflow.operators.bash import BashOperator
133from cosmos import DbtDag, ProjectConfig, ProfileConfig
134
135# Option 1: cosmos (recommended)
136dbt_dag = DbtDag(
137 project_config=ProjectConfig("/opt/airflow/dbt/"),
138 profile_config=ProfileConfig(
139 profile_name="default",
140 target_name="prod",
141 ),
142 schedule="@daily",
143 dag_id="dbt_daily",
144)
145
146# Option 2: BashOperator (simple)
147dbt_run = BashOperator(
148 task_id="dbt_run",
149 bash_command="cd /opt/airflow/dbt && dbt build --select tag:daily",
150)
151```
152
153## Anti-Patterns
154
1551. **Fat tasks** — tasks should be atomic units; do not put extract+transform+load in one task
1562. **XCom for large data** — XCom is for metadata (paths, counts); pass data via S3/GCS, not XCom pickles
1573. **catchup=True by accident** — unless you want backfill, set `catchup=False`; otherwise Airflow runs every missed interval
1584. **No retries** — transient failures are common; always set `retries >= 1` with a delay
1595. **Top-level code in DAG files** — DAG files are parsed every 30s; heavy imports or API calls at module level slow the scheduler
160
161## Quality Checklist
162
163- [ ] TaskFlow API used for Python-native DAGs (not legacy operator chaining)
164- [ ] `catchup=False` unless backfill is intentional
165- [ ] Retries configured on all tasks (minimum 1 retry)
166- [ ] SLA set on critical path tasks
167- [ ] XCom passes references (S3 paths), not data payloads
168- [ ] Dynamic task mapping used for fan-out parallelism
169- [ ] DAG tested locally with `airflow dags test` before deployment
170- [ ] Task idempotency: re-running a task produces the same result
171- [ ] Alerting configured for task failures and SLA misses
172- [ ] DAG tags applied for filtering in Airflow UI