Build production Apache Airflow DAGs with best practices

Apache Airflow DAG Patterns

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Apache Airflow DAG Patterns cover

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 Codenpx skills add wshobson/agents --skill airflow-dag-patterns -g -a claude-code
Claude 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-patterns
Windows (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" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md3.1 KB
  • references/1 file · 11.1 KB
Read the files here
wshobson/4236bb92 files
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---
2name: airflow-dag-patterns
3description: 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 
8Production-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```python
33# Linear
34task1 >> task2 >> task3
35 
36# Fan-out
37task1 >> [task2, task3, task4]
38 
39# Fan-in
40[task1, task2, task3] >> task4
41 
42# Complex
43task1 >> task2 >> task4
44task1 >> task3 >> task4
45```
46 
47## Quick Start
48 
49```python
50# dags/example_dag.py
51from datetime import datetime, timedelta
52from airflow import DAG
53from airflow.operators.python import PythonOperator
54from airflow.operators.empty import EmptyOperator
55 
56default_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 
67with 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 
97Detailed 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 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillTranslates Snowflake dbt SQL models to Standardized BigQuerydbt Snowflake to BigQuery Translatorgoogle/skills · by googleTranslates Snowflake dbt SQL models to Standardized BigQuery SQL. Handles SQL compilation, Jinja macro placeholder masking, BigQuery Translation Service migration workflows, AST-based config transformations, explicit type casting, JSON extraction standardization, and deduplication. Use when migrating Snowflake dbt pipelines or models to Google Cloud BigQuery. Don't use for generic BigQuery queries or non-Snowflake SQL migrations.★ 20.9k GitHub starsSkillAnswering business analytics, RevOps, GTM metric, pipelineDeepline analyticsgetaero-io/gtm-eng-skills · by getaero-ioUse this skill when answering business analytics, RevOps, GTM metric, pipeline, revenue, funnel, customer, or warehouse questions with Deepline. Triggers on phrases like 'query Snowflake', 'analyze pipeline', 'total ACV', 'break down by quarter', 'use the semantic layer', 'run a semantic query', or any use of snowflake_get_semantic_layer / snowflake_run_semantic_query. Skip prospecting, enrichment, contact finding, outbound, or personalization workflows; use deepline-gtm for those.★ 66 GitHub starsSkillOptimize Apache Spark jobs with partitioning, cachingApache Spark Optimizationwshobson/agents · by wshobsonOptimize Apache Spark jobs with partitioning, caching, shuffle optimization, and memory tuning. Use when improving Spark performance, debugging slow jobs, or scaling data processing pipelines.★ 39.9k GitHub starsSkillImplement data quality validation with Great ExpectationsData quality frameworkswshobson/agents · by wshobsonImplement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.★ 39.9k GitHub starsSkillMaster dbt for analytics engineering with model organizationDbt transformation patternswshobson/agents · by wshobsonMaster dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.★ 39.9k GitHub starsSkillAudit datasets for completeness, consistency, accuracyData quality auditoralirezarezvani/claude-skills · by alirezarezvaniAudit datasets for completeness, consistency, accuracy, and validity. Profile data distributions, detect anomalies and outliers, surface structural issues, and produce an actionable remediation plan. Use when the user asks to check data quality, profile a dataset, hunt outliers or missing values, or validate data before analysis or model training.★ 26.3k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillOptimize Apache Spark jobs with partitioning, cachingApache Spark Optimizationwshobson/agents · by wshobsonOptimize Apache Spark jobs with partitioning, caching, shuffle optimization, and memory tuning. Use when improving Spark performance, debugging slow jobs, or scaling data processing pipelines.★ 39.9k GitHub stars