---
name: "apache-airflow-dag-authoring-taskflow"
description: "Author modular, type-safe data pipelines using the modern Airflow 2.x TaskFlow API."
metadata:
  author: "Apache Software Foundation"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write airflow taskflow dag"
  - "airflow dynamic task mapping"
  - "test airflow dag pytest"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Apache Airflow DAG Authoring & TaskFlow API

Constructs data workflows in Apache Airflow: defining DAGs with @dag and @task decorators, XCom data passing with typing, dynamic task mapping (.expand()), SLA alerting, and testing DAGs with pytest.

## When to Invoke
Invoke this skill whenever you need to:
- write airflow taskflow dag
- airflow dynamic task mapping
- test airflow dag pytest

## Execution SOP & Rules
1. Define DAG using @dag(schedule='@daily', start_date=datetime(2025, 1, 1), catchup=False) decorator.
2. Use @task decorator on pure Python functions; return values automatically serialize into XCom.
3. Fan out tasks dynamically over lists using task.expand(arg=list_of_items).
4. Verify DAG structure locally with python dag_file.py before deploying to the Airflow cluster.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
