技能 airflow-dag-patterns
🌀

airflow-dag-patterns

安全 🌐 網路存取⚡ 包含腳本⚙️ 外部命令

使用經過驗證的模式建構生產級 Airflow DAG

當結構和重試不一致時,Airflow DAG 可能會失敗。本技能提供清晰的設計感測器、測試和警報模式,以提高管線的可靠性。

支援: Claude Codex Code(CC)
📊 69 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「airflow-dag-patterns」。 Give me a safe pattern for a daily ETL DAG with retries, testing, and a failure callback.

預期結果:

  • Use default_args with retries, retry_delay, and exponential backoff
  • Define a linear start -> extract -> load -> end structure
  • Add a task failure callback to report errors
  • Create DagBag tests for load errors, task count, and dependencies

正在使用「airflow-dag-patterns」。 How do I create DAGs dynamically from configuration?

預期結果:

  • Define a PIPELINE_CONFIGS list with name, schedule, and source fields
  • Create a create_dag factory function that takes a config parameter
  • Use globals()[f"dag_{name}"] to register each DAG dynamically
  • Apply the same pattern for customers, orders, and products pipelines

正在使用「airflow-dag-patterns」。 Show me how to wait for external dependencies before running tasks.

預期結果:

  • Use S3KeySensor to wait for files in S3 buckets
  • Use ExternalTaskSensor to wait for upstream DAG completion
  • Set mode='reschedule' to free workers while waiting
  • Combine multiple sensors with dependencies before processing

安全審計

安全
v4 • 1/17/2026

Pure documentation skill containing only Airflow patterns and example code. No executable scripts, network calls, filesystem access, or environment variable reads. All code in SKILL.md is illustrative documentation for building data pipelines.

2
已掃描檔案
701
分析行數
3
發現項
4
審計總數
審計者: claude 查看審計歷史 →

品質評分

38
架構
100
可維護性
85
內容
22
社群
100
安全
87
規範符合性

你能建構什麼

標準化 ETL DAG

為每日和每小時管線建立一致的 DAG 結構、重試和排程。

新增操作防護措施

套用感測器、警報和失敗回調以提高管線可靠性。

測試 DAG 完整性

撰寫單元測試以確保 DAG 能正確載入、沒有迴圈並遵守依賴關係。

試試這些提示

啟動簡單的 DAG
使用 PythonOperator 和基本 default_args 建立具有開始、擷取和結束任務的每日 Airflow DAG。
使用 TaskFlow API
草擬一個 TaskFlow API DAG,包含擷取、轉換和載入任務,並在它們之間安全地傳遞資料。
新增感測器和等待
展示在處理前等待 S3 資料和上游 DAG 的模式。
強化錯誤處理
為關鍵 DAG 新增失敗回調、重試和在失敗時執行的清理任務。

最佳實務

  • 保持任務冪等性,避免在 DAG 檔案中使用大量邏輯
  • 使用 TaskFlow API 和感測器重新排程模式以提高效率
  • 為 DAG 載入、結構和迴圈新增單元測試

避免

  • 對大多數任務使用 depends_on_past
  • 硬編碼日期而非使用 Airflow 巨集
  • 在 DAG 檔案中儲存可變的全域狀態

常見問題

這是否相容於 Airflow 2.x?
是的,這些模式針對 Airflow 2.x,並包含 TaskFlow API 範例。
範例的限制是什麼?
範例是模板,需要適配路徑、憑證和環境。
它可以與我現有的 DAG 整合嗎?
是的,您可以將這些模式套用至現有的 DAG 檔案並安全地重構。
它會存取或儲存我的資料嗎?
不,它僅提供指導,不會讀取或傳輸資料。
如果我的 DAG 匯入失敗怎麼辦?
使用 DagBag 測試來識別匯入錯誤並修復缺失的依賴。
與一般的程式碼輔助相比有何不同?
它專注於 Airflow 特定的模式、感測器、測試和操作安全性。

開發者詳情

檔案結構

📄 SKILL.md