authoring-dags

Geführter Workflow zur Erstellung von Apache Airflow DAGs mit Validierungs- und Testintegration. Strukturierter Sechs-Phasen-Ansatz: Umgebung und bestehende Muster erkunden, DAG-Struktur planen, Implementierung nach Best Practices, Validierung mit af CLI-Befehlen, Testen mit Benutzereinwilligung und Iteration über Fehlerbehebungen. CLI-Befehle zur Erkundung (af config connections, af config providers, af dags list) und Validierung (af dags errors, af dags get, af dags explore) bieten sofortiges Feedback zu DAG...

npx skills add https://github.com/astronomer/agents --skill authoring-dags

DAG Authoring Skill

This skill guides you through creating and validating Airflow DAGs using best practices and af CLI commands.

For testing and debugging DAGs, see the testing-dags skill which covers the full test -> debug -> fix -> retest workflow.


Running the CLI

These commands assume af is on PATH. Run via astro otto to get it automatically, or install standalone with uv tool install astro-airflow-mcp.


Workflow Overview

+-----------------------------------------+
| 1. DISCOVER                             |
|    Understand codebase & environment    |
+-----------------------------------------+
                 |
+-----------------------------------------+
| 2. PLAN                                 |
|    Propose structure, get approval      |
+-----------------------------------------+
                 |
+-----------------------------------------+
| 3. IMPLEMENT                            |
|    Write DAG following patterns         |
+-----------------------------------------+
                 |
+-----------------------------------------+
| 4. VALIDATE                             |
|    Check import errors, warnings        |
+-----------------------------------------+
                 |
+-----------------------------------------+
| 5. TEST (with user consent)             |
|    Trigger, monitor, check logs         |
+-----------------------------------------+
                 |
+-----------------------------------------+
| 6. ITERATE                              |
|    Fix issues, re-validate              |
+-----------------------------------------+

Phase 1: Discover

Before writing code, understand the context.

Explore the Codebase

Use file tools to find existing patterns:

  • Glob for **/dags/**/*.py to find existing DAGs
  • Read similar DAGs to understand conventions
  • Check requirements.txt for available packages

Query the Airflow Environment

Use af CLI commands to understand what's available:

CommandPurpose
af config connectionsWhat external systems are configured
af config variablesWhat configuration values exist
af config providersWhat operator packages are installed
af config versionVersion constraints and features
af dags listExisting DAGs and naming conventions
af config poolsResource pools for concurrency

Example discovery questions:

  • "Is there a Snowflake connection?" -> af config connections
  • "What Airflow version?" -> af config version
  • "Are S3 operators available?" -> af config providers

Phase 2: Plan

Based on discovery, propose:

  1. DAG structure - Tasks, dependencies, schedule
  2. Operators to use - Based on available providers
  3. Connections needed - Existing or to be created
  4. Variables needed - Existing or to be created
  5. Packages needed - Additions to requirements.txt

Get user approval before implementing.


Phase 3: Implement

Write the DAG following best practices (see below). Key steps:

  1. Create DAG file in appropriate location
  2. Update requirements.txt if needed
  3. Save the file

Phase 4: Validate

Use af CLI as a feedback loop to validate your DAG.

Step 1: Check Import Errors

After saving, check for parse errors (Airflow will have already parsed the file):

af dags errors
  • If your file appears -> fix and retry
  • If no errors -> continue

Common causes: missing imports, syntax errors, missing packages.

Step 2: Verify DAG Exists

af dags get <dag_id>

Check: DAG exists, schedule correct, tags set, paused status.

Step 3: Check Warnings

af dags warnings

Look for deprecation warnings or configuration issues.

Step 4: Explore DAG Structure

af dags explore <dag_id>

Returns in one call: metadata, tasks, dependencies, source code.

On Astro

If you're running on Astro, you can also validate locally before deploying:

  • Parse check: Run astro dev parse to catch import errors and DAG-level issues without starting a full Airflow environment
  • DAG-only deploy: Once validated, use astro deploy --dags for fast DAG-only deploys that skip the Docker image build — ideal for iterating on DAG code

Phase 5: Test

See the testing-dags skill for comprehensive testing guidance.

Once validation passes, test the DAG using the workflow in the testing-dags skill:

  1. Get user consent -- Always ask before triggering
  2. Trigger and wait -- af runs trigger-wait <dag_id> --timeout 300
  3. Analyze results -- Check success/failure status
  4. Debug if needed -- af runs diagnose <dag_id> <run_id> and af tasks logs <dag_id> <run_id> <task_id>

Quick Test (Minimal)

# Ask user first, then:
af runs trigger-wait <dag_id> --timeout 300

For the full test -> debug -> fix -> retest loop, see testing-dags.


Phase 6: Iterate

If issues found:

  1. Fix the code
  2. Check for import errors: af dags errors
  3. Re-validate (Phase 4)
  4. Re-test using the testing-dags skill workflow (Phase 5)

CLI Quick Reference

PhaseCommandPurpose
Discoveraf config connectionsAvailable connections
Discoveraf config variablesConfiguration values
Discoveraf config providersInstalled operators
Discoveraf config versionVersion info
Validateaf dags errorsParse errors (check first!)
Validateaf dags get <dag_id>Verify DAG config
Validateaf dags warningsConfiguration warnings
Validateaf dags explore <dag_id>Full DAG inspection

Testing commands -- See the testing-dags skill for af runs trigger-wait, af runs diagnose, af tasks logs, etc.


Best Practices & Anti-Patterns

For code patterns and anti-patterns, see reference/best-practices.md.

Read this reference when writing new DAGs or reviewing existing ones. It covers what patterns are correct (including Airflow 3-specific behavior) and what to avoid.


Related Skills

  • testing-dags: For testing DAGs, debugging failures, and the test -> fix -> retest loop
  • debugging-dags: For troubleshooting failed DAGs
  • deploying-airflow: For deploying DAGs to production (Astro or open-source)
  • migrating-airflow-2-to-3: For migrating DAGs to Airflow 3

Mehr Skills von astronomer

airflow
astronomer
Apache Airflow-DAGs, Ausführungen, Aufgaben und Systemkonfiguration abfragen, verwalten und Fehler beheben. Unterstützt über 30 Befehle für DAG-Inspektion, Ausführungsverwaltung, Aufgabenprotokollierung, Konfigurationsabfragen und direkten REST-API-Zugriff. Mehrere Airflow-Instanzen mit persistenter Konfiguration verwalten; lokale und Astro-Bereitstellungen automatisch erkennen. DAG-Ausführungen synchron (warten auf Abschluss) oder asynchron auslösen, Fehler diagnostizieren, Ausführungen für Wiederholungen löschen und Aufgabenprotokolle mit Wiederholungs-/Kartenindex-Filterung abrufen. Ausgabe...
official
airflow-hitl
astronomer
Menschliche Genehmigungstore, Formulareingaben und Verzweigungen in Airflow-DAGs unter Verwendung von aufschiebbaren Operatoren. Vier Operatortypen: ApprovalOperator für Genehmigen/Ablehnen-Entscheidungen, HITLOperator für Mehrfachauswahl mit Formularen, HITLBranchOperator für menschlich gesteuerte Aufgabenweiterleitung und HITLEntryOperator für Formulardatenerfassung. Alle Operatoren sind aufschiebbar und geben Worker-Slots frei, während sie auf menschliche Antworten über den Bereich "Erforderliche Aktionen" der Airflow-Benutzeroberfläche oder die REST-API warten. Unterstützt optionale Funktionen einschließlich benutzerdefinierter...
official
airflow-plugins
astronomer
Erstellen Sie Airflow 3.1+-Plugins, die FastAPI-Apps, benutzerdefinierte UI-Seiten, React-Komponenten, Middleware, Makros und Operator-Links direkt in die Airflow-Oberfläche einbetten. Verwenden Sie…
official
analyzing-data
astronomer
Fragen Sie Ihr Data Warehouse, um Geschäftsfragen mit zwischengespeicherten Mustern und Konzeptzuordnungen zu beantworten. Unterstützt Mustersuche und Zwischenspeicherung für wiederkehrende Fragetypen, mit Aufzeichnung der Ergebnisse zur Verbesserung zukünftiger Abfragen. Enthält eine Konzept-zu-Tabelle-Zuordnungs-Cache und Tabellenschema-Erkennung über INFORMATION_SCHEMA oder Codebase-Grep. Bietet run_sql()- und run_sql_pandas()-Kernel-Funktionen, die Polars- oder Pandas-DataFrames für Analysen zurückgeben. CLI-Befehle zur Verwaltung von Konzept-, Muster- und Tabellen-Caches, plus...
official
annotating-task-lineage
astronomer
Annotieren von Airflow-Tasks mit Data Lineage mithilfe von Inlets und Outlets. Unterstützt OpenLineage-Dataset-Objekte, Airflow-Assets und Airflow-Datasets zur Definition von Ein- und Ausgaben über Datenbanken, Data Warehouses und Cloud-Speicher hinweg. Verwenden Sie es als Fallback, wenn Operatoren keine integrierten OpenLineage-Extraktoren besitzen; folgt einem vierstufigen Prioritätssystem, bei dem benutzerdefinierte Extraktoren und OpenLineage-Methoden Vorrang haben. Enthält Dataset-Namenshilfen für Snowflake, BigQuery, S3 und PostgreSQL, um eine konsistente...
official
blueprint
astronomer
Wiederverwendbare Airflow-Task-Gruppen-Vorlagen mit Pydantic-Validierung definieren und DAGs aus YAML zusammenstellen. Verwenden beim Erstellen von Blueprint-Vorlagen, Zusammenstellen von DAGs aus…
official
checking-freshness
astronomer
Überprüft die Datenaktualität durch Abgleich von Tabellenzeitstempeln und Aktualisierungsmustern mit einer Veraltungsskala. Identifiziert Zeitstempelspalten anhand gängiger ETL-Benennungsmuster (_loaded_at, _updated_at, created_at usw.) und fragt deren Maximalwerte ab, um das Alter zu bestimmen. Klassifiziert Daten in vier Aktualitätsstatus: Frisch (< 4 Stunden), Veraltet (4–24 Stunden), Stark veraltet (> 24 Stunden) oder Unbekannt (kein Zeitstempel gefunden). Stellt SQL-Vorlagen zur Überprüfung der letzten Aktualisierungszeit und der Zeilenanzahltrends der letzten Tage bereit, um...
official
cosmos-dbt-core
astronomer
Konvertieren Sie dbt Core-Projekte mit Astronomer Cosmos in Airflow-DAGs oder TaskGroups. Unterstützt drei Assembly-Muster: eigenständigen DbtDag, DbtTaskGroup innerhalb bestehender DAGs und einzelne Cosmos-Operatoren für feingranulare Steuerung. Wählen Sie aus acht Ausführungsmodi (WATCHER, LOCAL, VIRTUALENV, KUBERNETES, AIRFLOW_ASYNC und andere) basierend auf Isolations- und Leistungsanforderungen. Bietet drei Parsing-Strategien (dbt_manifest, dbt_ls, dbt_ls_file, automatisch), um Geschwindigkeit und Selektorkomplexität auszugleichen...
official