$npx -y skills add astronomer/agents --skill blueprintDefine reusable Airflow task group templates with Pydantic validation and compose DAGs from YAML. Use when creating blueprint templates, composing DAGs from YAML, validating configurations, or enabling no-code DAG authoring for non-engineers.
| 1 | # Blueprint Implementation |
| 2 | |
| 3 | You are helping a user work with Blueprint, a system for composing Airflow DAGs from YAML using reusable Python templates. Execute steps in order and prefer the simplest configuration that meets the user's needs. |
| 4 | |
| 5 | > **Package**: `airflow-blueprint` on PyPI |
| 6 | > **Repo**: https://github.com/astronomer/blueprint |
| 7 | > **Requires**: Python 3.10+, Airflow 2.5+, Blueprint 0.3.0+ |
| 8 | |
| 9 | ## Before Starting |
| 10 | |
| 11 | Confirm with the user: |
| 12 | 1. **Airflow version** ≥2.5 |
| 13 | 2. **Python version** ≥3.10 |
| 14 | 3. **Use case**: Blueprint is for standardized, validated templates. If user needs full Airflow flexibility, suggest writing DAGs directly or using DAG Factory instead. |
| 15 | |
| 16 | --- |
| 17 | |
| 18 | ## Determine What the User Needs |
| 19 | |
| 20 | | User Request | Action | |
| 21 | |--------------|--------| |
| 22 | | "Create a blueprint" / "Define a template" | Go to **Creating Blueprints** | |
| 23 | | "Build a template from other templates" | Go to **Composing Templates** | |
| 24 | | "Create a DAG from YAML" / "Compose steps" | Go to **Composing DAGs in YAML** | |
| 25 | | "Use a blueprint in an existing Python DAG" / "Generate DAGs in a loop" | Go to **Blueprints in Python DAGs** | |
| 26 | | "Customize DAG args" / "Add tags to DAG" | Go to **Customizing DAG-Level Configuration** | |
| 27 | | "Override config at runtime" / "Trigger with params" | Go to **Runtime Parameter Overrides** | |
| 28 | | "Post-process DAGs" / "Add callback" | Go to **Post-Build Callbacks** | |
| 29 | | "Validate my YAML" / "Lint blueprint" | Go to **Validation Commands** | |
| 30 | | "Set up blueprint in my project" | Go to **Project Setup** | |
| 31 | | "Version my blueprint" | Go to **Versioning** | |
| 32 | | "Generate schema" / "Astro IDE setup" | Go to **Schema Generation** | |
| 33 | | Blueprint errors / troubleshooting | Go to **Troubleshooting** | |
| 34 | |
| 35 | --- |
| 36 | |
| 37 | ## Project Setup |
| 38 | |
| 39 | If the user is starting fresh, guide them through setup: |
| 40 | |
| 41 | ### 1. Install the Package |
| 42 | |
| 43 | ```bash |
| 44 | # Add to requirements.txt |
| 45 | airflow-blueprint>=0.3.0 |
| 46 | |
| 47 | # Or install directly |
| 48 | pip install airflow-blueprint |
| 49 | ``` |
| 50 | |
| 51 | ### 2. Create the Loader |
| 52 | |
| 53 | Create `dags/loader.py`: |
| 54 | |
| 55 | ```python |
| 56 | from blueprint import build_all_dags |
| 57 | |
| 58 | build_all_dags() |
| 59 | ``` |
| 60 | |
| 61 | > **Use `build_all_dags`, not `build_all`.** The function was renamed in 0.3.0 so the loader's import line contains the substring `dag`, which Airflow's safe-mode DAG file processor requires — otherwise the file is silently skipped and no DAGs appear. `build_all` still works as a deprecated alias (emits `DeprecationWarning`); migrate existing loaders. |
| 62 | |
| 63 | DAG-level configuration (schedule, description, tags, default_args, etc.) is handled via YAML fields and `BlueprintDagArgs` templates — see **Customizing DAG-Level Configuration**. |
| 64 | |
| 65 | ### 3. Verify Installation |
| 66 | |
| 67 | ```bash |
| 68 | uvx --from airflow-blueprint blueprint list |
| 69 | ``` |
| 70 | |
| 71 | If no blueprints found, user needs to create blueprint classes first. |
| 72 | |
| 73 | > **Provider operators in the CLI.** The `uvx --from airflow-blueprint` environment is isolated and does **not** include the Airflow provider packages your Astro Runtime project has. If your templates import provider operators (BigQuery, Snowflake, etc.), add `--with` so the CLI can import them — otherwise `list`/`lint`/`schema` fail with `ModuleNotFoundError: No module named 'airflow.providers.X'`: |
| 74 | > |
| 75 | > ```bash |
| 76 | > uvx --from airflow-blueprint --with apache-airflow-providers-google blueprint list --template-dir dags/templates |
| 77 | > ``` |
| 78 | |
| 79 | --- |
| 80 | |
| 81 | ## Creating Blueprints |
| 82 | |
| 83 | When user wants to create a new blueprint template: |
| 84 | |
| 85 | ### Blueprint Structure |
| 86 | |
| 87 | ```python |
| 88 | # dags/templates/my_blueprints.py |
| 89 | from airflow.operators.bash import BashOperator |
| 90 | from airflow.utils.task_group import TaskGroup |
| 91 | from blueprint import Blueprint, BaseModel, Field |
| 92 | |
| 93 | class MyConfig(BaseModel): |
| 94 | # Required field with description (used in CLI output and JSON schema) |
| 95 | source_table: str = Field(description="Source table name") |
| 96 | # Optional field with default and validation |
| 97 | batch_size: int = Field(default=1000, ge=1) |
| 98 | |
| 99 | class MyBlueprint(Blueprint[MyConfig]): |
| 100 | """Docstring becomes blueprint description.""" |
| 101 | |
| 102 | def render(self, config: MyConfig) -> TaskGroup: |
| 103 | with TaskGroup(group_id=self.step_id) as group: |
| 104 | BashOperator( |
| 105 | task_id="my_task", |
| 106 | bash_command=f"echo '{config.source_table}'" |
| 107 | ) |
| 108 | return group |
| 109 | ``` |
| 110 | |
| 111 | ### Key Rules |
| 112 | |
| 113 | | Element | Requirement | |
| 114 | |---------|-------------| |
| 115 | | Config class | Must inherit from `BaseModel` | |
| 116 | | Blueprint class | Must inherit from `Blueprint[ConfigClass]` | |
| 117 | | `render()` method | Must return `TaskGroup` or `BaseOperator` | |
| 118 | | Task IDs | Use `self.step_id` for the group/task ID | |
| 119 | | Field types | Must be single-typed and YAML-compatible (see below) | |
| 120 | |
| 121 | ### Config Field Types Must Be YAML-Compatible |
| 122 | |
| 123 | As of 0.3.0, config fields must be single-typed. Multi-type unions like `str | int` or `Union[ |