$npx -y skills add astronomer/agents --skill airflowQueries, manages, and troubleshoots Apache Airflow using the af CLI. Use when working with anything related to Airflow - a DAG, a DAG run, a task log, an import or parse error, a broken DAG, or any Airflow operation. Covers listing and triggering DAGs, retrying runs, reading ta
| 1 | # Airflow Operations |
| 2 | |
| 3 | Use `af` commands to query, manage, and troubleshoot Airflow workflows. |
| 4 | |
| 5 | ## Astro CLI |
| 6 | |
| 7 | The [Astro CLI](https://www.astronomer.io/docs/astro/cli/overview) is the recommended way to run Airflow locally and deploy to production. It provides a containerized Airflow environment that works out of the box: |
| 8 | |
| 9 | ```bash |
| 10 | # Initialize a new project |
| 11 | astro dev init |
| 12 | |
| 13 | # Start local Airflow (webserver at http://localhost:8080) |
| 14 | astro dev start |
| 15 | |
| 16 | # Parse DAGs to catch errors quickly (no need to start Airflow) |
| 17 | astro dev parse |
| 18 | |
| 19 | # Run pytest against your DAGs |
| 20 | astro dev pytest |
| 21 | |
| 22 | # Deploy to production |
| 23 | astro deploy # Full deploy (image + DAGs) |
| 24 | astro deploy --dags # DAG-only deploy (fast, no image build) |
| 25 | ``` |
| 26 | |
| 27 | For more details: |
| 28 | - **New project?** See the **setting-up-astro-project** skill |
| 29 | - **Local environment?** See the **managing-astro-local-env** skill |
| 30 | - **Deploying?** See the **deploying-airflow** skill |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Running the CLI |
| 35 | |
| 36 | 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`. |
| 37 | |
| 38 | ## Instance Configuration |
| 39 | |
| 40 | Manage multiple Airflow instances with persistent configuration: |
| 41 | |
| 42 | ```bash |
| 43 | # Add a new instance |
| 44 | af instance add prod --url https://airflow.example.com --token "$API_TOKEN" |
| 45 | af instance add staging --url https://staging.example.com --username admin --password admin |
| 46 | |
| 47 | # List and switch instances |
| 48 | af instance list # Shows all instances in a table |
| 49 | af instance use prod # Switch to prod instance |
| 50 | af instance current # Show current instance |
| 51 | af instance delete old-instance |
| 52 | |
| 53 | # Auto-discover instances (use --dry-run to preview first) |
| 54 | af instance discover --dry-run # Preview all discoverable instances |
| 55 | af instance discover # Discover from all backends (astro, local) |
| 56 | af instance discover astro # Discover Astro deployments only |
| 57 | af instance discover astro --all-workspaces # Include all accessible workspaces |
| 58 | af instance discover local # Scan common local Airflow ports |
| 59 | af instance discover local --scan # Deep scan all ports 1024-65535 |
| 60 | |
| 61 | # IMPORTANT: Always run with --dry-run first and ask for user consent before |
| 62 | # running discover without it. The non-dry-run mode creates API tokens in |
| 63 | # Astro Cloud, which is a sensitive action that requires explicit approval. |
| 64 | |
| 65 | # Show where an instance came from (file path + scope) |
| 66 | af instance show prod |
| 67 | |
| 68 | # Override instance for a single command via env vars |
| 69 | AIRFLOW_API_URL=https://staging.example.com AIRFLOW_AUTH_TOKEN=$STG af dags list |
| 70 | |
| 71 | # Or switch persistently |
| 72 | af instance use staging |
| 73 | ``` |
| 74 | |
| 75 | Config layout (mirrors `git config` system/global/local): |
| 76 | |
| 77 | | Scope | File | Committed? | |
| 78 | |---|---|---| |
| 79 | | Global | `~/.astro/config.yaml` | n/a (per-user) | |
| 80 | | Project shared | `<root>/.astro/config.yaml` | yes | |
| 81 | | Project local | `<root>/.astro/config.local.yaml` | no (gitignored) | |
| 82 | |
| 83 | `<root>` is found by walking up from cwd looking for `.astro/`. Default write routing inside a project: `add`/`discover` → project-shared, `use` → project-local. Override with `--global` / `--project` / `--local`. Set `AF_CONFIG=<path>` to bypass layering and use a single file. |
| 84 | |
| 85 | Migrate from the legacy `~/.af/config.yaml` with `af migrate` (idempotent; renames the old file to `.bak`). |
| 86 | |
| 87 | Tokens in config can reference environment variables using `${VAR}` syntax: |
| 88 | ```yaml |
| 89 | instances: |
| 90 | - name: prod |
| 91 | url: https://airflow.example.com |
| 92 | auth: |
| 93 | token: ${AIRFLOW_API_TOKEN} |
| 94 | ``` |
| 95 | |
| 96 | Or use environment variables directly (no config file needed): |
| 97 | |
| 98 | ```bash |
| 99 | export AIRFLOW_API_URL=http://localhost:8080 |
| 100 | export AIRFLOW_AUTH_TOKEN=your-token-here |
| 101 | # Or username/password: |
| 102 | export AIRFLOW_USERNAME=admin |
| 103 | export AIRFLOW_PASSWORD=admin |
| 104 | ``` |
| 105 | |
| 106 | Or CLI flags: `af --airflow-url http://localhost:8080 --token "$TOKEN" <command>` |
| 107 | |
| 108 | ## Quick Reference |
| 109 | |
| 110 | | Command | Description | |
| 111 | |---------|-------------| |
| 112 | | `af health` | System health check | |
| 113 | | `af dags list` | List all DAGs | |
| 114 | | `af dags get <dag_id>` | Get DAG details | |
| 115 | | `af dags explore <dag_id>` | Full DAG investigation | |
| 116 | | `af dags source <dag_id>` | Get DAG source code | |
| 117 | | `af dags pause <dag_id>` | Pause D |