Scaffold an idempotent DAG from the template
Generate a new pipeline from the Airflow DAG template and keep its guarantees — an idempotent skeleton with task groups, retries and backoff, SLA, pools, and a reschedule-mode sensor — then make catchup a deliberate choice and every write partition-keyed or a MERGE.
At a glance
| When | A new pipeline DAG is being created and must be idempotent from day one; A team wants a standard layout with DAG-integrity tests included |
|---|---|
| Where | Airflow / Orchestration |
| Why | A skeleton with retries, backoff, SLA, pools and reschedule sensors built in is cheaper than un-duplicating rows after the first retry. |
Learning objectives
- Scaffold a DAG project with tests and a Dockerfile from the template
- Write tasks that are safe to re-run from day one
- Set catchup, retries and sensor modes as deliberate choices
What you need
- An Airflow development environment
- [object Object]
- A pipeline to model, such as a daily orders job
Steps
- Run amp template new de-agent/airflow-dag ./dags. (from tpl-airflow-dag )
- Work in the generated layout: dags/orders_pipeline.py, plugins/, tests/test_dag_integrity.py, Dockerfile. (from tpl-airflow-dag )
- Keep the skeleton's guarantees — task groups, retries and backoff, SLA, pools, and a sensor using reschedule mode. (from tpl-airflow-dag )
- Every task writes to a partition keyed by the logical date, or uses MERGE. (from skill-airflow-dag-reviewer )
- Set `catchup` as a deliberate choice, not a default. (from skill-airflow-dag-reviewer )
Check yourself
- The generated project matches the template layout — dags/orders_pipeline.py, plugins/, tests/test_dag_integrity.py and a Dockerfile are all present.
- Asking the idempotency question of each task — same logical date, same output? — every task answers yes.
Worked example
Scaffold the DAG project — from tpl-airflow-dag
amp template new de-agent/airflow-dag ./dags
Generated project layout — from tpl-airflow-dag
airflow-dag/
dags/orders_pipeline.py
plugins/
tests/test_dag_integrity.py
Dockerfile
Guarantees the scaffold must keep — from skill-airflow-dag-reviewer
1. Every task writes to a partition keyed by the logical date, or uses MERGE.
2. `catchup` is a deliberate choice, not a default.
3. Retries have a backoff; a task that retries instantly will hammer a downstream.
4. `max_active_runs` and pool limits prevent a backfill from starving the daily run.
5. Sensors use `reschedule`, not `poke`, so they don't hold a worker slot.
Sourced from
Security scan
Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.
Common gotchas
- `max_active_runs` and pool limits prevent a backfill from starving the daily run.
- Sensors use `reschedule`, not `poke`, so they don't hold a worker slot.
- Never overlap the production window; never backfill without a rollback path.
Production considerations
- The template ships tests/test_dag_integrity.py — run DAG-integrity tests in CI.
- Pair the scaffold with skill-airflow-dag-reviewer and pattern-backfill-safety, the template's declared related resources.
Diagram
scaffold dag
|
|- amp template new --> orders_pipeline.py + tests + Dockerfile
|
|- keep guarantees --> retries/backoff, SLA, pools, reschedule sensor
|
|- partition or MERGE writes --> deliberate catchup --> review with idempotency test
Registry stats
| Verification | community · Oct 21, 2026 |
|---|---|
| Completeness | 81 |
| Trust multiplier | ×1.25 |
| Composite | 34.15 · adequate |
| Freshness | 3 days since last source check |
| Difficulty | beginner |
| Version | 0.1.0 |
| License | CC-BY-4.0 |
| Security flags | none |
Did this solve your problem?
Scaffold an idempotent DAG from the template