Community研究&データ分析github.com

設計データ契約の作成

データプロデューサとコンシューマ間の明示的なスキーマ、セマンティクス、所有権、SLA、バージョン管理を定義し、上流の変更が下流パイプラインを破損するのを防ぎます。プロデューサのスキーマ変更がコンシューマを壊す可能性がある場合や、チーム/サービス間およびウェアハウスとのインターフェースを定義する場合、またはデータ取り込み時のスキーマ適用を追加する場合に使用します。

設計データ契約の作成 とは?

このスキルは、データ契約の設計と適用を通じて、上流の変更が下流パイプラインを静かに破損する問題を解決します。具体的には、JSON Schema、Avro/Protobufスキーマ、YAML仕様として契約をコード化し、取り込み境界で検証を実施して違反を拒否または隔離します。ワークフローは契約のバージョン管理、変更の分類(追加的 vs 破壊的)、そしてプロデューサへの即時通知を含みます。このスキルは多様なプラットフォーム(例えばKafka/AvroスキーマレジストリやJSON Schemaベースのシステム)に対応可能で、データの整合性とチーム間のコミュニケーションを強化します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Unknown-333/awesome-data-engineering-skills/tree/main/skills/designing-data-contracts

Installed? Explore more 研究&データ分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

設計データ契約の作成 は何をしますか?

使用するタイミング

  • 上流(サービス、イベント、API、ファイル)が下流パイプラインにデータを供給しており、その変更が静かにパイプラインを破損する可能性がある場合
  • プロデューシングチーム/システムとウェアハウスとの間のインターフェースを定義する場合
  • データ取り込み境界でスキーマ/品質の適用を追加する場合
  • 単一のdbtプロジェクト内での内部モデル間変更には使用しないでください(代わりにテスト+ handling-schema-evolution を使用)

契約で指定するもの

  • スキーマ: フィールド、型、null許容性、許容値
  • セマンティクス: 各フィールドの意味、単位/粒度
  • 保証: 鮮度/SLA、ボリュームの期待値、キーの一意性
  • 所有権: 誰がプロデュースしているか、連絡先
  • バージョン管理 + 変更ポリシー: 破壊的変更がどのように伝達されるか

ワークフロー

- [ ] 契約をバージョン管理された、チェックインされたスキーマとして記述する(暗黙の知識ではなく)
- [ ] 取り込み境界で契約を適用する(到着時に検証する)
- [ ] 変更を分類する:追加的(安全) vs 破壊的(新しいバージョンが必要)
- [ ] 違反があった場合、拒否/隔離し、プロデューサに警告する
- [ ] 破壊的変更を事前にバージョン管理し伝達する
  1. 明示的かつバージョン管理可能にする。 契約をコードとして(JSON Schema、Avro/Protobufスキーマ、またはYAML仕様)パイプラインの隣に保存し、APIと同じようにレビューします。
  2. 境界で適用する。 到着した受信データを契約に対して検証し、違反はロードする代わりに拒否または隔離します。
  3. 変更を分類する。 追加的/オプションフィールドは後方互換性あり。フィールドの削除、名前変更、型/null許容性の厳格化は破壊的 → 新しいバージョンが必要。
  4. プロデューサに即座に(静かに下流でなく)失敗を知らせる。

パターン

JSON Schemaとしての契約(取り込み時に適用):

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["order_id", "amount", "ordered_at"],
  "properties": {
    "order_id": { "type": "string" },
    "amount": { "type": "number", "minimum": 0 },
    "ordered_at": { "type": "string", "format": "date-time" },
    "coupon": { "type": ["string", "null"] }
  },
  "additionalProperties": false
}

適用ポイント — 各レコードを取り込み時に検証し、失敗を quarantine 位置に理由とともにルーティングし、プロデューシングチームに警告します。これにより、下流での静かな破損が、発生源で即座に制御された信号に変わります。

スキーマレジストリ(Kafka/Avro)— 公開時に互換性(BACKWARD)を適用し、プロデューサが互換性のないスキーマを送信できないようにします。

よくある落とし穴

  • 契約をドキュメントのみにする — コードで適用されないと、契約は乖離し静かに破損します。
  • ウェアハウスの深部で適用する — 境界で違反を捕捉し、悪いデータが拡散する前に防ぎます。
  • バージョン管理がない — すべての変更が緊急事態になります。適切にバージョン管理し、段階的に廃止します。
  • 厳密性が必要なときに additionalProperties を制限しない — 予期しないフィールドがすり抜けます。適切な場合は false に設定します。
  • 所有者がいない — 拒否されたバッチに連絡する相手がおらず、パイプラインが停滞します。
  • 破壊的変更にリードタイムがない — バージョン管理されたスキーマと廃止ウィンドウを通じてプロデューサ/コンシューマ間で調整します。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

Unknown-333/authoring-airflow-dags

Write production-grade Apache Airflow DAGs using the TaskFlow API — idempotent tasks, correct scheduling and catchup, retries/SLAs, connections/variables, and avoiding top-level code. Use when creating or reviewing Airflow DAGs, scheduling pipelines, wiring task dependencies, configuring retries/backfills, or fixing non-idempotent tasks.

Unknown-333/building-dagster-assets

Build Dagster pipelines using software-defined assets — asset dependencies, partitions, resources and IO managers, asset checks, and schedules/sensors. Use when creating Dagster assets or jobs, modeling data as assets, adding partitions or backfills, wiring resources/IO managers, or migrating from task-based orchestration to assets.

Unknown-333/building-dbt-models

Build well-structured dbt models — staging/intermediate/marts layers, ref() and source(), materializations, and incremental models with the right strategy. Use when creating or refactoring dbt models, choosing table vs view vs incremental, structuring a dbt project, or writing incremental logic.

Unknown-333/building-feature-pipelines

Build ML feature pipelines and feature stores — point-in-time-correct joins to avoid label leakage, offline/online parity, feature freshness and backfills, and materialization with tools like Feast. Use when engineering features for ML, preventing train/serve skew or data leakage, building a feature store, or backfilling historical features for training.

Unknown-333/building-iceberg-tables

Design and operate Apache Iceberg tables — partitioning and hidden partitioning, partition/schema evolution, snapshots and time travel, compaction and small-file cleanup, and MERGE/upsert for lakehouse tables on Spark, Flink, Trino, or Snowflake. Use when creating or maintaining Iceberg tables, choosing partitioning, evolving schema/partitions, or fixing small-file and metadata bloat.

Unknown-333/building-ingestion-pipelines

Build batch and incremental data ingestion (extract-load) pipelines — full vs incremental extraction, change data capture (CDC), watermarks and high-water marks, API pagination and rate limits, and choosing managed EL tools (Fivetran, Airbyte) vs custom code. Use when ingesting data from databases, APIs, files, or SaaS into a warehouse/lake, or designing incremental extraction and CDC.

Unknown-333/building-kafka-consumers

Build reliable Apache Kafka consumers and producers — consumer groups and partition assignment, offset commit strategy, at-least-once vs exactly-once, idempotent/transactional producers, rebalancing, and dead-letter handling. Use when writing Kafka consumers/producers, configuring offset commits or consumer groups, tuning throughput, or handling rebalances and poison messages.

Unknown-333/debugging-data-pipelines

Systematically root-cause data pipeline failures and data incidents — job errors, wrong or missing data, duplicates, and freshness misses — by tracing lineage upstream, isolating the failing stage, reconciling against source, and planning a safe fix and backfill. Use when a pipeline fails, numbers look wrong, data is missing or duplicated, a dashboard is stale, or a stakeholder reports a data discrepancy.

Unknown-333/designing-backfills-and-replays

Plan and run safe data backfills and replays — idempotent reprocessing of historical windows, partition-by-partition execution, isolating backfill compute from production, verifying results, and avoiding double-counting or changed history. Use when backfilling a new or fixed model, reprocessing after a bug, replaying events, or loading history for a new pipeline without corrupting existing data.

関連スキル