skills/astronomer/authoring-dags/SKILL.md
Workflow and best practices for writing Apache Airflow DAGs. Use when the user wants to create a new DAG, write pipeline code, or asks about DAG patterns and conventions. For testing and debugging DAGs, see the testing-dags skill.
npx skillsauth add rory-data/copilot authoring-dagsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Run all af commands using uvx (no installation required):
uvx --from astro-airflow-mcp af <command>
Throughout this document, af is shorthand for uvx --from astro-airflow-mcp af.
+-----------------------------------------+
| 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 |
+-----------------------------------------+
Before writing code, understand the context.
Use file tools to find existing patterns:
Glob for **/dags/**/*.py to find existing DAGsRead similar DAGs to understand conventionsrequirements.txt for available packagesUse af CLI commands to understand what's available:
| Command | Purpose |
|---------|---------|
| af config connections | What external systems are configured |
| af config variables | What configuration values exist |
| af config providers | What operator packages are installed |
| af config version | Version constraints and features |
| af dags list | Existing DAGs and naming conventions |
| af config pools | Resource pools for concurrency |
Example discovery questions:
af config connectionsaf config versionaf config providersBased on discovery, propose:
Get user approval before implementing.
Write the DAG following best practices (see below). Key steps:
requirements.txt if neededUse af CLI as a feedback loop to validate your DAG.
After saving, check for parse errors (Airflow will have already parsed the file):
af dags errors
Common causes: missing imports, syntax errors, missing packages.
af dags get <dag_id>
Check: DAG exists, schedule correct, tags set, paused status.
af dags warnings
Look for deprecation warnings or configuration issues.
af dags explore <dag_id>
Returns in one call: metadata, tasks, dependencies, source code.
If you're running on Astro, you can also validate locally before deploying:
astro dev parse to catch import errors and DAG-level issues without starting a full Airflow environmentastro deploy --dags for fast DAG-only deploys that skip the Docker image build — ideal for iterating on DAG codeSee the testing-dags skill for comprehensive testing guidance.
Once validation passes, test the DAG using the workflow in the testing-dags skill:
af runs trigger-wait <dag_id> --timeout 300af runs diagnose <dag_id> <run_id> and af tasks logs <dag_id> <run_id> <task_id># Ask user first, then:
af runs trigger-wait <dag_id> --timeout 300
For the full test -> debug -> fix -> retest loop, see testing-dags.
If issues found:
af dags errors| Phase | Command | Purpose |
|-------|---------|---------|
| Discover | af config connections | Available connections |
| Discover | af config variables | Configuration values |
| Discover | af config providers | Installed operators |
| Discover | af config version | Version info |
| Validate | af dags errors | Parse errors (check first!) |
| Validate | af dags get <dag_id> | Verify DAG config |
| Validate | af dags warnings | Configuration warnings |
| Validate | af 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.
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.
tools
Queries, manages, and troubleshoots Apache Airflow using the af CLI. Covers listing DAGs, triggering runs, reading task logs, diagnosing failures, debugging DAG import errors, checking connections, variables, pools, and monitoring health. Also routes to sub-skills for writing DAGs, debugging, deploying, and migrating Airflow 2 to 3. Use when user mentions "Airflow", "DAG", "DAG run", "task log", "import error", "parse error", "broken DAG", or asks to "trigger a pipeline", "debug import errors", "check Airflow health", "list connections", "retry a run", or any Airflow operation. Do NOT use for warehouse/SQL analytics on Airflow metadata tables — use analyzing-data instead.
tools
Build Airflow 3.1+ plugins that embed FastAPI apps, custom UI pages, React components, middleware, macros, and operator links directly into the Airflow UI. Use this skill whenever the user wants to create an Airflow plugin, add a custom UI page or nav entry to Airflow, build FastAPI-backed endpoints inside Airflow, serve static assets from a plugin, embed a React app in the Airflow UI, add middleware to the Airflow API server, create custom operator extra links, or call the Airflow REST API from inside a plugin. Also trigger when the user mentions AirflowPlugin, fastapi_apps, external_views, react_apps, plugin registration, or embedding a web app in Airflow 3.1+. If someone is building anything custom inside Airflow 3.1+ that involves Python and a browser-facing interface, this skill almost certainly applies.
data-ai
Use when the user needs human-in-the-loop workflows in Airflow (approval/reject, form input, or human-driven branching). Covers ApprovalOperator, HITLOperator, HITLBranchOperator, HITLEntryOperator, HITLTrigger. Requires Airflow 3.1+. Does not cover AI/LLM calls (see airflow-ai).
development
Detects and fixes common code smells during review or refactoring. Invoke whenever reviewing code for quality issues, before merging a PR, when refactoring legacy code, or when the user asks about code quality, anti-patterns, or technical debt. Detects: over-abstraction, complex inheritance, large functions, tight coupling, hidden dependencies, magic numbers, boolean traps, swallowed exceptions, global state, and duplicate code. Provides specific fixes with before/after examples. Also invoke when someone says "review this code", "is this clean?", "can I improve this?", "this feels messy", or "find problems in my code".