Community연구 & 데이터 분석github.com

Unknown-333/data-contract-design

데이터 프로듀서와 컨슈머 간의 명시적인 스키마, 의미, 소유권, SLA 및 버전 관리를 통해 상류 변경이 하류 파이프라인을 손상시키는 것을 방지합니다.

data-contract-design란 무엇인가요?

이 스킬은 팀/서비스 간 인터페이스 정의, 웨어하우스와의 데이터 교환, 또는 수집 시점에 스키마 및 품질 제약을 적용해야 하는 상황에서 사용됩니다. 핵심은 데이터 계약(Data Contract)을 코드 형태로 버전 관리하고, 수집 경계에서 이를 강제(enforce)하여 오염된 데이터가 시스템 내부로 전파되는 것을 차단하는 것입니다. 스킬의 워크플로는 계약 작성 → 수집 경계에서 검증 → 변경 유형 분류(안전한 추가 vs. 호환을 깨는 변경) → 위반 시 격리 및 경고 → 사전 통보를 통한 버전 관리 순서로 진행됩니다. JSON Schema, Avro/Protobuf 스키마 또는 YAML 명세를 통해 계약을 명문화하고, Kafka/Avro Schema Registry 같은 도구를 사용해 게시 시점에 하위 호환성을 강제하는 패턴을 제시합니다. 또한 문서로만 남아 실효성을 잃거나, 웨어하우스 깊숙한 곳에서 제약을 적용하여 나쁜 데이터가 퍼지는 것을 막지 못하는 일반적인 함정들을 지적합니다. 이 스킬은 Claude Code, Cursor, Codex 등 다양한 AI 에이전트 및 개발 환경에서 활용 가능하며, 팀 간 데이터 의존성을 명확히 하고 변경 충돌을 최소화하는 데 기여합니다.

지원 대상~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을 사용).

계약이 명시하는 사항

  • 스키마: 필드, 타입, 널 허용 여부, 허용 값
  • 의미: 각 필드가 의미하는 것과 단위/세분성
  • 보장 사항: 신선도/SLA, 볼륨 예상치, 키의 고유성
  • 소유권: 누가 생산하는지와 연락처
  • 버전 관리 + 변경 정책: 호환을 깨는 변경이 어떻게 전달되는지

워크플로

- [ ] 계약을 버전 관리되고 체크인된 스키마로 작성(구전 지식 금지)
- [ ] 수집 경계에서 강제 실행(도착 시 검증)
- [ ] 변경 분류: 추가(안전) 대 호환 깨짐(새 버전 필요)
- [ ] 위반 시 거부/격리하고 프로듀서에게 경고
- [ ] 호환을 깨는 변경을 사전에 버전 관리하고 전달
  1. 명시적으로 만들고 버전 관리하세요. 계약을 코드(JSON Schema, Avro/Protobuf 스키마 또는 YAML 명세)로 파이프라인 옆에 저장하고, API처럼 리뷰합니다.
  2. 경계에서 강제하세요. 들어오는 데이터가 도착 시 계약에 부합하는지 검증하고, 위반 사항은 로드하지 말고 거부하거나 격리합니다.
  3. 변경을 분류하세요. 추가/선택적 필드 = 하위 호환 가능. 필드 제거, 이름 변경, 타입/널 허용 여부 강화 = 호환 깨짐 → 새 버전.
  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.

관련 스킬