Managed Airflow Dag Authoring
GoogleOfficialPublished by Google
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to developing Apache Airflow DAGs specifically for Managed Service for Apache Airflow (MSAA). It covers the entire lifecycle from environment context discovery and version compatibility checks to best practices for DAG structure and multi-stage validation processes. It emphasizes performance by discouraging top-level code execution and ensures reliability through local linting and remote deployment verification.
What it does
- Guides users through discovering environment constraints and Airflow versions.
- Provides best practices for writing idempotent and performant DAG code.
- Outlines steps for local static analysis and linting of DAG files.
- Details the process for deploying DAGs to GCS buckets.
- Provides commands to verify DAG parsing and identify import errors in the target environment.
- Includes instructions for monitoring runtime parsing errors via Cloud Logging.
When to use it
- When you are creating a new Apache Airflow DAG for a Managed Service for Apache Airflow environment.
- When you need to update or extend an existing DAG while maintaining compatibility.
- When you need to validate that your DAG code will parse correctly in a managed environment.
- When you need to ensure your DAG follows standard performance and reliability patterns.
Advantages
- Reduces common DAG parsing errors through structured validation steps.
- Promotes consistent coding standards like idempotency and avoiding top-level code.
- Provides clear commands for interacting with Google Cloud Composer environments.
- Helps bridge the gap between local development and managed production environments.
Usage examples
- “Help me write a new DAG for my Composer environment.”
- The agent will ask for your environment details, guide you through setting up the DAG structure following best practices, and help you validate it locally before deployment.
- “Why is my DAG failing to parse in Cloud Composer?”
- The agent will guide you through checking for import errors using the Airflow CLI and inspecting Cloud Logging to identify the specific cause of the parsing failure.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/google/managed-airflow-dag-authoring/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip managed-airflow-dag-authoring.zip -d .agents/skills
Documentation by Google
GCP Managed Airflow DAG Authoring Guide
This skill guides you through authoring and validating Apache Airflow DAGs for Managed Service for Apache Airflow (MSAA; formerly Cloud Composer) environments.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:managed-airflow-dag-authoring)"
and append agent-skills/1.0 (skill:managed-airflow-dag-authoring) to User-Agent headers.
Phase 1: Context Discovery
Before writing any DAG code, you MUST understand the constraints (e.g. version of Airflow) and capabilities of your target environment if user is willing to provide them.
1.1 Identify Target Environment & Access
Determine if you have direct access to the target Managed Airflow environment, local development environment or if you are working offline (only changing local files without validation).
If environment access is available: Use
gcloudto inspect the environment (see Section 1.3).If offline: Rely on user provided details.
1.2 Identify Development Environment
Determine if a local development environment is available.
Check if
composer-devCLI is installed.Check if a local Python environment with
airflowis available.
1.3 Inspect Target Environment (if available and requested)
Run the following commands to discover version constraints:
Get Airflow/Image Version:
gcloud composer environments describe {env_name} \ --location {region} \ --format="value(config.softwareConfig.imageVersion)"Get Installed Packages (Versions):
gcloud composer environments describe {env_name} \ --location {region} \ --format="value(config.softwareConfig.pypiPackages)"Get DAGs GCS Bucket:
gcloud composer environments describe {env_name} \ --location {region} \ --format="value(config.dagGcsPrefix)"
Phase 2: DAG Authoring Best Practices
2.1 General Airflow Best Practices
Idempotency: Every task SHOULD be idempotent. Running it multiple times with the same inputs (e.g., execution date) SHOULD produce the same result and not duplicate data.
No Top-Level Code Execution: Do NOT execute database queries, external API calls, or heavy computations at the top level of the DAG file (outside of tasks/operators). This code runs every few seconds during DAG parsing and will degrade performance.
Explicit Catchup: Always set
catchup=Falsein the DAG definition unless historical backfilling is explicitly required.Use Airflow Variables/Connections: Never hardcode credentials or environment-specific configs. Use
Variable.get()(withdeserialize_json=Trueif applicable) andBaseHook.get_connection(). Access variables via Jinja templates (e.g.,{{ var.value.my_var }}) to avoid database calls during DAG parsing.
2.2 Airflow 2 vs Airflow 3 Compatibility
Use managed-airflow-migrations skill to navigate adjusting the code to specific target Airflow version.
Phase 3: Validation Process
You MUST validate DAGs before concluding your task.
3.1 Local Validation (Offline/Pre-deployment)
3.1.1 Static Analysis & Linting
Use ruff or pylint if available.
ruff check path/to/dag.pyIf targeting Airflow 3, check with Airflow 3 rules if rulesets are available.
3.1.2 Local Dev Environment (composer-dev)
If the user has composer-dev configured:
Copy the DAG to the local directory with DAGs:
cp path/to/dag.py $(composer-dev describe {local_env} --format="value(dags_directory)")Verify parsing:
composer-dev run-airflow-cmd {local_env} dags list-import-errors
3.2: Target Environment Validation
Only perform these steps if you have GCP access and are authorized to deploy to a target environment.
3.2.1 Deploy to GCS
Upload the DAG to the target environment's GCS bucket:
gcloud storage cp path/to/dag.py gs://{target_bucket}/dags/3.2.2 Verify via Airflow CLI
Wait 1-2 minutes for the scheduler to parse the file, then run:
Check for Import Errors:
gcloud composer environments run {env_name} \ --location {region} \ dags list-import-errors
Pass Criteria: Output should be "No data found" or empty.
Verify DAG is Listed:
gcloud composer environments run {env_name} \ --location {region} \ dags list | grep {dag_id}
3.2.3 Monitor Cloud Logging
Check for runtime parsing errors in Cloud Logging:
resource.type="cloud_composer_environment"
resource.labels.environment_name="{env_name}"
log_id("airflow-scheduler")
severity>=ERROR
textPayload:"{dag_file_name}"Definition of Done
DAG code adheres to Airflow version constraints of the target environment.
DAG code follows best practices (no top-level execution, idempotent if possible).
DAG parses locally without import errors.
(If environment is available) DAG is deployed to the target environment and verified to have no import errors.
Files
- ATTRIBUTION.mdAdded by AutoGineer876 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md6.2 KiB
- references/attribution.md1.9 KiB
references/attribution.md
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
gcloudCLI Commands: Prefix everygcloudinvocation, whatever the subcommand, with the metrics environment variable. Set it inline on each command because shell state may not persist between commands:CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:managed-airflow-dag-authoring)" \ gcloud <command> [flags]Do not use
gcloud config setfor this: it would persist beyond the current task and mislabel unrelated usage.Direct HTTP, REST, and MCP Requests: On direct HTTP calls to Google Cloud APIs (for example with
curl) or HTTP requests to a remote MCP server, includeagent-skills/1.0 (skill:managed-airflow-dag-authoring)in theUser-Agentheader. If aUser-Agentheader is already specified, append this string to the end of it rather than overwriting existingUser-Agentdata — the collection pipeline parses theagent-skills/<version>andskill:<name>tokens, so any rewording breaks attribution:User-Agent: <existing_user_agent> agent-skills/1.0 (skill:managed-airflow-dag-authoring)Constraint for Generated Code: The tracking prefix is strictly for commands you execute directly in the terminal. Do NOT include this tracking prefix in generated scripts, Terraform templates, or code provided to the user for their own repositories.
User Opt-Out: If the user asks to disable or remove tracking or attribution tags, omit the
CLOUDSDK_METRICS_REQUEST_ATTRIBUTIONvariable and customUser-Agentsuffix from all commands.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/managed-airflow-dag-authoring · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google or Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download managed-airflow-dag-authoring.zip