managed-airflow-dag-authoring
できること
このスキルは、Managed Service for Apache Airflow(旧 Cloud Composer)で動くワークフローを作成し、テストする手助けをします。Airflow でジョブをスケジュールするデータチームやエンジニアリングチーム向けです。
使う場面
- ✓Google Cloud の Managed Airflow 向けに、Airflow DAG を作成または拡張したいとき。
- ✓DAG のコードが Airflow 2 と Airflow 3 のどちらで動くかを確認したいとき。
- ✓展開の前に、DAG のコードをローカルまたは本番環境で検証したいとき。
スキルのリンク
https://github.com/google/skills/blob/main/skills/cloud/managed-airflow-dag-authoring/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“毎晩、Cloud Storage の CSV を BigQuery に読み込む Airflow DAG を書き、展開前に確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
まず環境と Airflow のバージョンを確認し、ベストプラクティスに沿って DAG を書きます。アクセスできる場合は、ローカルまたは対象環境でコードを検証します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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.py
- If 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 t
よくある質問
Airflow 以外の Python コードにも使えますか?
いいえ。Airflow の DAG 作成だけが対象です。
どの Airflow のバージョンに対応しますか?
Airflow 2 と Airflow 3 の両方に対応し、それぞれの互換性を確認します。
オフラインで作業する場合はどうなりますか?
あなたが伝えた情報に頼り、オンラインでの検証は省略します。
詳細
作者による元の説明
Provides guidance for authoring Apache Airflow DAGs in Managed Service for Apache Airflow (MSAA; formerly Cloud Composer). Covers environment context discovery, Airflow 2 vs 3 compatibility, authoring best practices, and local/remote validation processes. Use when creating or extending an Airflow DAG. Don't use when authoring Python code unrelated to Airflow DAGs.
repo: google/skills
人気
- GitHubのスター
- 22k
- ランキング
- #10342
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
finding-google-skills
22kセットアップ作業に合うGoogleの公式ガイドを探すようエージェントを支援します。ホスティング、データベース、ストレージ、サインイン、AIモデルの提供などが対象です。
gcloud
22kエージェントが、Google CloudのgcloudコマンドについてWeb検索に頼らず、正確な構文を確かめてから書いたり確認したりできるよう支援します。
google-cloud-recipe-auth
22kエージェントが、Google Cloudのアイデンティティとアクセス(人やサービスがどうサインインし、どの権限を得るか)について、手順を案内できるよう支援します。
google-cloud-recipe-onboarding
22k新しい開発者が、プロジェクトの選択、請求の設定、最初のリソースのデプロイなど、Google Cloudの最初の手順を進められるよう案内します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。