Build production Apache Airflow DAGs with best practices
Apache Airflow DAG Patterns

Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.
--- name: airflow-dag-patterns description: Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs. --- # Apache Airflow DAG Patterns Production-ready patterns for Apache Airflow including DAG design, operators, sensors, testing, and deployment strategies. ## When to Use This Skill - Creating data pipeline orchestration with Airflow - Designing DAG structures and dependencies - Implementing custom operators and sensors - Testing Airflow DAGs locally - Setting up Airflow in production - Debugging failed DAG runs
Overview
Production-ready patterns for Apache Airflow including DAG design, operators, sensors, testing, and deployment strategies.
Manual install (npx, ZIP)
Claude Code
npx skills add wshobson/agents --skill airflow-dag-patterns -g -a claude-codeClaude Code (manual)
mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/data-engineering/skills/airflow-dag-patternsWindows (PowerShell)
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/70242978976a669ea8fe/airflow-dag-patterns.zip" -OutFile "$env:TEMP\airflow-dag-patterns.zip"; Expand-Archive "$env:TEMP\airflow-dag-patterns.zip" -DestinationPath "$HOME\.claude\skills" -ForceClaude.ai / desktop
Codex, Cursor, other agents
Connects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md3.1 KBreferences/1 file · 11.1 KB
Read the files here
SKILL.md
Show the full text116 lines
Apache Airflow DAG Patterns
Production-ready patterns for Apache Airflow including DAG design, operators, sensors, testing, and deployment strategies.
When to Use This Skill
- Creating data pipeline orchestration with Airflow
- Designing DAG structures and dependencies
- Implementing custom operators and sensors
- Testing Airflow DAGs locally
- Setting up Airflow in production
- Debugging failed DAG runs
Core Concepts
1. DAG Design Principles
| Principle | Description |
|---|---|
| Idempotent | Running twice produces same result |
| Atomic | Tasks succeed or fail completely |
| Incremental | Process only new/changed data |
| Observable | Logs, metrics, alerts at every step |
2. Task Dependencies
# Linear
task1 >> task2 >> task3
# Fan-out
task1 >> [task2, task3, task4]
# Fan-in
[task1, task2, task3] >> task4
# Complex
task1 >> task2 >> task4
task1 >> task3 >> task4
Quick Start
# dags/example_dag.py
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.operators.empty import EmptyOperator
default_args = {
'owner': 'data-team',
'depends_on_past': False,
'email_on_failure': True,
'email_on_retry': False,
'retries': 3,
'retry_delay': timedelta(minutes=5),
'retry_exponential_backoff': True,
'max_retry_delay': timedelta(hours=1),
}
with DAG(
dag_id='example_etl',
default_args=default_args,
description='Example ETL pipeline',
schedule='0 6 * * *', # Daily at 6 AM
start_date=datetime(2024, 1, 1),
catchup=False,
tags=['etl', 'example'],
max_active_runs=1,
) as dag:
start = EmptyOperator(task_id='start')
def extract_data(**context):
execution_date = context['ds']
# Extract logic here
return {'records': 1000}
extract = PythonOperator(
task_id='extract',
python_callable=extract_data,
)
end = EmptyOperator(task_id='end')
start >> extract >> end
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
Do's
- Use TaskFlow API - Cleaner code, automatic XCom
- Set timeouts - Prevent zombie tasks
- Use
mode='reschedule'- For sensors, free up workers - Test DAGs - Unit tests and integration tests
- Idempotent tasks - Safe to retry
Don'ts
- Don't use
depends_on_past=True- Creates bottlenecks - Don't hardcode dates - Use
{{ ds }}macros - Don't use global state - Tasks should be stateless
- Don't skip catchup blindly - Understand implications
- Don't put heavy logic in DAG file - Import from modules
| 1 | |
| 2 | name airflow-dag-patterns |
| 3 | description Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs. |
| 4 | |
| 5 | |
| 6 | # Apache Airflow DAG Patterns |
| 7 | |
| 8 | Production-ready patterns for Apache Airflow including DAG design, operators, sensors, testing, and deployment strategies. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | Creating data pipeline orchestration with Airflow |
| 13 | Designing DAG structures and dependencies |
| 14 | Implementing custom operators and sensors |
| 15 | Testing Airflow DAGs locally |
| 16 | Setting up Airflow in production |
| 17 | Debugging failed DAG runs |
| 18 | |
| 19 | ## Core Concepts |
| 20 | |
| 21 | ### 1. DAG Design Principles |
| 22 | |
| 23 | | Principle | Description | |
| 24 | | --------------- | ----------------------------------- | |
| 25 | | **Idempotent** | Running twice produces same result | |
| 26 | | **Atomic** | Tasks succeed or fail completely | |
| 27 | | **Incremental** | Process only new/changed data | |
| 28 | | **Observable** | Logs, metrics, alerts at every step | |
| 29 | |
| 30 | ### 2. Task Dependencies |
| 31 | |
| 32 | |
| 33 | # Linear |
| 34 | task1 >> task2 >> task3 |
| 35 | |
| 36 | # Fan-out |
| 37 | task1 >> [task2, task3, task4] |
| 38 | |
| 39 | # Fan-in |
| 40 | [task1, task2, task3] >> task4 |
| 41 | |
| 42 | # Complex |
| 43 | task1 >> task2 >> task4 |
| 44 | task1 >> task3 >> task4 |
| 45 | |
| 46 | |
| 47 | ## Quick Start |
| 48 | |
| 49 | |
| 50 | # dags/example_dag.py |
| 51 | from datetime import datetime, timedelta |
| 52 | from airflow import DAG |
| 53 | from airflow.operators.python import PythonOperator |
| 54 | from airflow.operators.empty import EmptyOperator |
| 55 | |
| 56 | default_args = { |
| 57 | 'owner': 'data-team', |
| 58 | 'depends_on_past': False, |
| 59 | 'email_on_failure': True, |
| 60 | 'email_on_retry': False, |
| 61 | 'retries': 3, |
| 62 | 'retry_delay': timedelta(minutes=5), |
| 63 | 'retry_exponential_backoff': True, |
| 64 | 'max_retry_delay': timedelta(hours=1), |
| 65 | } |
| 66 | |
| 67 | with DAG( |
| 68 | dag_id='example_etl', |
| 69 | default_args=default_args, |
| 70 | description='Example ETL pipeline', |
| 71 | schedule='0 6 * * *', # Daily at 6 AM |
| 72 | start_date=datetime(2024, 1, 1), |
| 73 | catchup=False, |
| 74 | tags=['etl', 'example'], |
| 75 | max_active_runs=1, |
| 76 | ) as dag: |
| 77 | |
| 78 | start = EmptyOperator(task_id='start') |
| 79 | |
| 80 | def extract_data(**context): |
| 81 | execution_date = context['ds'] |
| 82 | # Extract logic here |
| 83 | return {'records': 1000} |
| 84 | |
| 85 | extract = PythonOperator( |
| 86 | task_id='extract', |
| 87 | python_callable=extract_data, |
| 88 | ) |
| 89 | |
| 90 | end = EmptyOperator(task_id='end') |
| 91 | |
| 92 | start >> extract >> end |
| 93 | |
| 94 | |
| 95 | ## Detailed patterns and worked examples |
| 96 | |
| 97 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 98 | |
| 99 | ## Best Practices |
| 100 | |
| 101 | ### Do's |
| 102 | |
| 103 | **Use TaskFlow API** - Cleaner code, automatic XCom |
| 104 | **Set timeouts** - Prevent zombie tasks |
| 105 | **Use `mode='reschedule'`** - For sensors, free up workers |
| 106 | **Test DAGs** - Unit tests and integration tests |
| 107 | **Idempotent tasks** - Safe to retry |
| 108 | |
| 109 | ### Don'ts |
| 110 | |
| 111 | **Don't use `depends_on_past=True`** - Creates bottlenecks |
| 112 | **Don't hardcode dates** - Use `{{ ds }}` macros |
| 113 | **Don't use global state** - Tasks should be stateless |
| 114 | **Don't skip catchup blindly** - Understand implications |
| 115 | **Don't put heavy logic in DAG file** - Import from modules |
| 116 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillTranslates Snowflake dbt SQL models to Standardized BigQuerydbt Snowflake to BigQuery Translator
SkillAnswering business analytics, RevOps, GTM metric, pipelineDeepline analytics
SkillOptimize Apache Spark jobs with partitioning, cachingApache Spark Optimization
SkillImplement data quality validation with Great ExpectationsData quality frameworks
SkillMaster dbt for analytics engineering with model organizationDbt transformation patterns
SkillAudit datasets for completeness, consistency, accuracyData quality auditorMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillOptimize Apache Spark jobs with partitioning, cachingApache Spark Optimization