npx skills add ...
npx skills add astronomer/agents --skill blueprint
npx skills add astronomer/agents --skill blueprint
Define 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.
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.
Package:
airflow-blueprinton PyPI Repo: https://github.com/astronomer/blueprint Requires: Python 3.10+, Airflow 2.5+, Blueprint 0.3.0+
Confirm with the user:
| User Request | Action |
|---|---|
| "Create a blueprint" / "Define a template" | Go to Creating Blueprints |
| "Build a template from other templates" | Go to Composing Templates |
| "Create a DAG from YAML" / "Compose steps" | Go to Composing DAGs in YAML |
| "Use a blueprint in an existing Python DAG" / "Generate DAGs in a loop" | Go to Blueprints in Python DAGs |
| "Customize DAG args" / "Add tags to DAG" | Go to Customizing DAG-Level Configuration |
| "Override config at runtime" / "Trigger with params" | Go to Runtime Parameter Overrides |
| "Post-process DAGs" / "Add callback" | Go to Post-Build Callbacks |
| "Validate my YAML" / "Lint blueprint" | Go to Validation Commands |
| "Set up blueprint in my project" | Go to Project Setup |
| "Version my blueprint" | Go to Versioning |
| "Generate schema" / "Astro IDE setup" | Go to Schema Generation |
| Blueprint errors / troubleshooting | Go to Troubleshooting |
If the user is starting fresh, guide them through setup:
Create dags/loader.py:
Use
build_all_dags, notbuild_all. The function was renamed in 0.3.0 so the loader's import line contains the substringdag, which Airflow's safe-mode DAG file processor requires — otherwise the file is silently skipped and no DAGs appear.build_allstill works as a deprecated alias (emitsDeprecationWarning); migrate existing loaders.
DAG-level configuration (schedule, description, tags, default_args, etc.) is handled via YAML fields and BlueprintDagArgs templates — see Customizing DAG-Level Configuration.
If no blueprints found, user needs to create blueprint classes first.
Provider operators in the CLI. The
uvx --from airflow-blueprintenvironment 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--withso the CLI can import them — otherwiselist/lint/schemafail withModuleNotFoundError: No module named 'airflow.providers.X':
When user wants to create a new blueprint template:
| Element | Requirement |
|---|---|
| Config class | Must inherit from BaseModel |
| Blueprint class | Must inherit from Blueprint[ConfigClass] |
render() method | Must return TaskGroup or BaseOperator |
| Task IDs | Use self.step_id for the group/task ID |
| Field types | Must be single-typed and YAML-compatible (see below) |
As of 0.3.0, config fields must be single-typed. Multi-type unions like str | int or Union[A, B] are rejected at class-definition time (raises TypeError) because they produce ambiguous YAML parsing and anyOf schemas. The check recurses through nested models, list items, and dict values.
str, int, float, bool), Literal[...], list[X], dict[str, V], nested BaseModel, and Optional[X] / X | None (the nullable pattern).str | int, Union[A, B], or any union with more than one non-None arm. Bare Any and dict[str, Any] are rejected for the same reason — use an explicit single type for the value.Use Field(default=..., init=False) for fields used inside render() that should not be overridable from YAML. They are excluded from the constructor (always use their default) and omitted from JSON Schema output:
Suggest adding extra="forbid" to catch YAML typos:
A blueprint can instantiate and render other blueprints inside its render() method, letting you build higher-level templates from lower-level building blocks while exposing a single, flat config to YAML authors.
Inside render(), instantiate each child blueprint, set its step_id, call render(...) with a config you construct, and wire the results together inside a parent TaskGroup:
YAML authors then see a single step with a flat config:
When user wants to create a DAG from blueprints:
By default, only schedule and description are supported as DAG-level fields (via the built-in DefaultDagArgs). For other fields like tags, default_args, catchup, etc., see Customizing DAG-Level Configuration.
| Key | Purpose |
|---|---|
blueprint | Template name (required) |
depends_on | List of upstream step names |
version | Pin to specific blueprint version |
trigger_rule | Airflow trigger rule for the step (e.g. all_done, one_success); validated against the installed Airflow version |
Everything else passes to the blueprint's config.
Use trigger_rule to control when a step runs relative to its upstream dependencies — for example, to run a notification step even if an upstream step failed:
Valid values are validated dynamically against the installed Airflow's TriggerRule enum (all_success, all_done, one_success, none_failed, etc.). When the step's blueprint renders a TaskGroup, the rule is applied only to the group's root tasks (those with no internal upstream), preserving the blueprint author's internal wiring.
YAML supports Jinja2 templating with access to environment variables, Airflow variables/connections, and runtime context:
Available template variables:
env — environment variablesvar — Airflow Variablesconn — Airflow Connectionscontext — proxy that generates Airflow template expressions for runtime macros (e.g. context.ds_nodash, context.dag_run.conf, context.task_instance.xcom_pull(...))Blueprints aren't tied to the YAML composition flow. Two patterns (both 0.3.0) let you use them from Python — useful for incremental adoption or data-driven DAG generation.
To drop a blueprint-rendered step into an existing Python DAG, instantiate the Blueprint class, set its step_id, call render(), and wire it in with >>:
The step_id you set determines the task_id / group_id the blueprint renders under.
Builder / DAGConfigFor data-driven DAG generation (one DAG per region, tenant, etc.), build DAGs in a loop with Builder and DAGConfig, then register each in globals() so Airflow discovers them:
DAGConfig accepts the same fields you would write in YAML (dag_id, steps, plus any fields your BlueprintDagArgs consumes). Builder, DAGConfig, and StepConfig are all exported from blueprint. See examples/advanced/dags/programmatic_dags.py in the repo.
By default, Blueprint supports schedule and description as DAG-level YAML fields. To use other DAG constructor arguments (tags, default_args, catchup, etc.), define a BlueprintDagArgs subclass.
tags, default_args, catchup, start_date, or any other DAG kwargs in YAMLThen in YAML, the extra fields are validated by the config model:
BlueprintDagArgs subclass per project (raises MultipleDagArgsError if more than one exists)render() method returns a dict of kwargs passed to the Airflow DAG() constructorDefaultDagArgs is used (supports only schedule and description)Blueprint config fields can be overridden at DAG trigger time using Airflow params. This enables users to customize behavior when manually triggering DAGs from the Airflow UI.
supports_params = TrueA blueprint must set the class attribute supports_params = True for its config fields to register as Airflow params (namespaced as {step}__{field}). Without it, self.param() / self.resolve_config() do nothing and no fields appear in the trigger form. Only opt in for blueprints that actually use those methods — otherwise dead params clutter the form with no effect.
self.param() in Template FieldsUse self.param("field") in operator template fields to make a config field overridable at runtime. Airflow renders the actual value at execution time:
self.resolve_config() in Python CallablesFor @task or PythonOperator callables, use self.resolve_config() to merge runtime params into config. It returns a new validated config instance:
Use self.param() for operators with template fields and self.resolve_config() for Python logic in @task functions; both can be combined in one blueprint.
step_name__field)ValidationError at execution timePydantic field schema flows through to Airflow's trigger form. Control how each field renders with json_schema_extra:
Supported format values include "multiline" (textarea), "date", "date-time", and "time" (pickers). Also usable: examples (dropdown with free text), values_display (human-readable labels for enum/example values), and description_md (Markdown descriptions).
Validation nuance: only Field constraints that map to JSON Schema (ge, le, pattern, min_length, max_length, Literal enums) are enforced in the trigger form. Custom @field_validator / @model_validator logic does not map to JSON Schema, so it runs only at build time and inside resolve_config() — not in the form. If custom validators enforce important constraints, call self.resolve_config() in your @task function so they run on overridden values.
Override params via the Airflow UI trigger form, or via the API using conf with the namespaced names:
Use on_dag_built to post-process DAGs after they are constructed. This is useful for adding tags, access controls, audit metadata, or any cross-cutting concern.
The callback receives:
dag — the constructed Airflow DAG object (mutable)yaml_path — the Path to the YAML file that defined the DAGRun CLI commands with uvx:
| Command | When to Use |
|---|---|
blueprint list | Show available blueprints |
blueprint describe <name> | Show config schema for a blueprint |
blueprint describe <name> -v N | Show schema for specific version |
blueprint lint | Validate all *.dag.yaml files |
blueprint lint <path> | Validate specific file |
blueprint schema <name> | Generate JSON schema for a blueprint (step template) |
blueprint schema --dag-args | Generate JSON schema for DAG-level YAML fields |
blueprint new | Interactive DAG YAML creation |
When user needs to version blueprints for backwards compatibility:
MyBlueprint (no suffix)MyBlueprintV2MyBlueprintV3As an alternative to the class name convention, blueprints can set name and version directly:
This is useful when the class name doesn't follow the NameV{N} convention or when you want clearer control.
1..N sequence. A gap (e.g. v1 and v3 with no v2) raises NonContiguousVersionError during discovery.InvalidVersionError.Generate JSON schemas for editor autocompletion or external tooling:
Use --dag-args (with no blueprint name) to generate the schema for DAG-level YAML fields — dag_id, steps, and any fields your custom BlueprintDagArgs exposes — rather than a single step template's config.
As of 0.3.0, each emitted schema includes a top-level templateType field — "blueprint" for a step template, "dag_args" for DAG-level fields — so consumers can tell them apart. The command emits raw JSON when piped or written via -o/--output (and pretty, syntax-highlighted JSON when run interactively), so > redirection produces valid JSON.
After creating or modifying a blueprint, automatically check if the project is an Astro project by looking for a .astro/ directory (created by astro dev init).
If the project is an Astro project, automatically regenerate schemas without prompting:
The Astro IDE reads blueprint/generated-schemas/ to render configuration forms. Keeping schemas in sync ensures the visual builder always reflects the latest blueprint configs.
If you cannot determine whether the project is an Astro project, ask the user once and remember for the rest of the session.
Cause: Blueprint class not in Python path.
Fix: Check template directory or use --template-dir:
Cause: YAML field name typo with extra="forbid" enabled.
Fix: Run uvx --from airflow-blueprint blueprint describe <name> to see valid field names.
Cause: Missing or broken loader — including a loader that imports the deprecated build_all, which Airflow safe-mode may skip.
Fix: Ensure dags/loader.py exists and calls build_all_dags():
blueprint list/lint/schemaCause: The standalone uvx --from airflow-blueprint CLI environment doesn't include Airflow provider packages that your Astro Runtime project has. A template importing provider operators can't be imported by the CLI. This is the CLI's isolated environment, not your project.
Fix: Add --with apache-airflow-providers-X to the uvx invocation (common: apache-airflow-providers-standard, -google, -snowflake):
As of v0.2.0, Pydantic validation errors are surfaced as Airflow import errors with actionable messages instead of being silently swallowed. The error message includes details on missing fields, unexpected fields, and type mismatches, along with guidance to run blueprint lint or blueprint describe.
Cause: Circular depends_on references.
Fix: Review step dependencies and remove cycles.
Cause: More than one BlueprintDagArgs subclass discovered in the project.
Fix: Only one BlueprintDagArgs subclass is allowed. Remove or merge duplicates.
Cause: A blueprint's versions don't form a contiguous 1..N sequence (NonContiguousVersionError), or YAML pins a version that doesn't exist (InvalidVersionError).
Fix: Ensure versions increment by one with no gaps; run uvx --from airflow-blueprint blueprint list to see available versions.
Cause: A config field uses a type Blueprint rejects since 0.3.0 — a multi-type union (e.g. str | int), bare Any, or dict[str, Any].
Fix: Use a single, explicit type. Optional[X] / X | None is still allowed. See Creating Blueprints → Config Field Types Must Be YAML-Compatible.
Every Blueprint task has extra fields in Rendered Template:
blueprint_step_config - resolved YAML configblueprint_step_code - Python source of blueprintBefore finishing, verify with user:
blueprint list shows their templatesblueprint lint passes (run it bare to scan all *.dag.yaml recursively, or pass a specific file — passing a directory path fails with Is a directory)dags/loader.py exists with build_all_dags()