Data Pipeline Design
Choose the smallest pipeline shape that can be rerun, recovered, observed, and reconciled safely.
Boundary
Use this skill after the source has a credible assessment. Use dbt-development for dbt project implementation and data-pipeline-testing for executable verification strategy.
Inputs
Establish:
- Source and target systems.
- Source and target grain.
- Natural, primary, and deduplication keys.
- Volume, cadence, latency, and retention.
- Insert, update, delete, and late-arrival behavior.
- Backfill and replay requirements.
- Failure, cost, security, and compliance constraints.
Workflow
1. Write the pipeline contract
Define:
- source object and target object
- grain at every stage
- field mapping and semantic transformations
- cursor or change token
- target write behavior
- delete handling
- validation boundaries
- publication condition
- ownership and service level
Do not implement incrementality before identifying reliable change semantics.
2. Choose a load strategy
| Source behavior |
Initial strategy |
| Small, stable, safely replaceable dataset |
Full refresh with atomic publication |
| Reliable ordered cursor with updates |
Incremental extraction with overlap and idempotent upsert |
| Durable ordered change log |
CDC with offset management and delete handling |
| Immutable events |
Append with deduplication and reconciliation |
| No trustworthy change signal |
Full refresh or snapshot comparison |
Treat row-count thresholds as workload-specific, not universal constants.
3. Design reliability
Use reliability-patterns.md. Specify:
- idempotency key
- checkpoint location and commit point
- transaction or atomic publication boundary
- retryable error classes
- bad-record path
- duplicate-delivery behavior
- partial-failure recovery
- structured run metadata
Never advance the checkpoint before durable target publication and required validation succeed.
4. Design incrementality and backfills
Use incremental-loads.md. Cover:
- overlap window
- timestamp tie-breaker
- late updates
- deletes and tombstones
- initial history load
- historical correction
- concurrent live loads
- replay isolation
- reconciliation after backfill
Build backfill behavior before relying on the ongoing schedule.
5. Choose storage layout
For file-backed stages, use parquet-storage.md. Define schema, partition keys, file sizing, compression, publication, and evolution.
Avoid high-cardinality partitioning and uncontrolled small files. A file format does not provide transaction semantics by itself.
6. Define transformation boundaries
Keep raw ingestion reproducible. Separate:
- raw preservation
- parsing and normalization
- validation and quarantine
- business transformation
- publication
Name each stage and its grain. Avoid destructive cleanup before raw evidence is retained.
7. Design PostgreSQL operations when relevant
Use postgresql-patterns.md only for PostgreSQL targets or sources. Keep dialect-specific behavior out of the generic pipeline contract.
8. Add observability and reconciliation
Record per run:
- run and batch identifiers
- source cursor range
- extracted, accepted, rejected, inserted, updated, and deleted counts
- validation result
- checkpoint before and after
- duration, retries, and error class
- output partition or version
Define reconciliation equations and control totals. Row counts alone are rarely sufficient.
9. Plan rollback and recovery
State how to:
- retry a failed batch
- replay a cursor range
- replace a bad publication
- pause live loads during repair
- restore or compensate destructive writes
- resume without duplication
Deliverable
Return:
- Pipeline contract
- Load-strategy decision
- Stage and grain diagram
- Checkpoint and idempotency design
- Late-data, delete, and backfill behavior
- Storage and schema-evolution plan
- Validation and reconciliation controls
- Failure, rollback, and replay plan
- Observability fields
- Implementation slices
Quality Gate
- Grain and keys are explicit at every stage.
- Reruns cannot silently duplicate or corrupt data.
- Checkpoints follow durable validated publication.
- Deletes, late data, and backfills are designed.
- Counts and control totals reconcile.
- Recovery is described before scheduling.
1---2name: data-pipeline-design3description: Design reliable batch or incremental data pipelines with explicit grain, load strategy, idempotency, checkpoints, late-data handling, backfills, storage layout, and reconciliation. Use when planning ETL, ELT, CDC, file-based, or PostgreSQL-backed data movement before implementation.4---56# Data Pipeline Design78Choose the smallest pipeline shape that can be rerun, recovered, observed, and reconciled safely.910## Boundary1112Use this skill after the source has a credible assessment. Use `dbt-development` for dbt project implementation and `data-pipeline-testing` for executable verification strategy.1314## Inputs1516Establish:17181. Source and target systems.192. Source and target grain.203. Natural, primary, and deduplication keys.214. Volume, cadence, latency, and retention.225. Insert, update, delete, and late-arrival behavior.236. Backfill and replay requirements.247. Failure, cost, security, and compliance constraints.2526## Workflow2728### 1. Write the pipeline contract2930Define:3132- source object and target object33- grain at every stage34- field mapping and semantic transformations35- cursor or change token36- target write behavior37- delete handling38- validation boundaries39- publication condition40- ownership and service level4142Do not implement incrementality before identifying reliable change semantics.4344### 2. Choose a load strategy4546| Source behavior | Initial strategy |47| --- | --- |48| Small, stable, safely replaceable dataset | Full refresh with atomic publication |49| Reliable ordered cursor with updates | Incremental extraction with overlap and idempotent upsert |50| Durable ordered change log | CDC with offset management and delete handling |51| Immutable events | Append with deduplication and reconciliation |52| No trustworthy change signal | Full refresh or snapshot comparison |5354Treat row-count thresholds as workload-specific, not universal constants.5556### 3. Design reliability5758Use [reliability-patterns.md](references/reliability-patterns.md). Specify:5960- idempotency key61- checkpoint location and commit point62- transaction or atomic publication boundary63- retryable error classes64- bad-record path65- duplicate-delivery behavior66- partial-failure recovery67- structured run metadata6869Never advance the checkpoint before durable target publication and required validation succeed.7071### 4. Design incrementality and backfills7273Use [incremental-loads.md](references/incremental-loads.md). Cover:7475- overlap window76- timestamp tie-breaker77- late updates78- deletes and tombstones79- initial history load80- historical correction81- concurrent live loads82- replay isolation83- reconciliation after backfill8485Build backfill behavior before relying on the ongoing schedule.8687### 5. Choose storage layout8889For file-backed stages, use [parquet-storage.md](references/parquet-storage.md). Define schema, partition keys, file sizing, compression, publication, and evolution.9091Avoid high-cardinality partitioning and uncontrolled small files. A file format does not provide transaction semantics by itself.9293### 6. Define transformation boundaries9495Keep raw ingestion reproducible. Separate:9697- raw preservation98- parsing and normalization99- validation and quarantine100- business transformation101- publication102103Name each stage and its grain. Avoid destructive cleanup before raw evidence is retained.104105### 7. Design PostgreSQL operations when relevant106107Use [postgresql-patterns.md](references/postgresql-patterns.md) only for PostgreSQL targets or sources. Keep dialect-specific behavior out of the generic pipeline contract.108109### 8. Add observability and reconciliation110111Record per run:112113- run and batch identifiers114- source cursor range115- extracted, accepted, rejected, inserted, updated, and deleted counts116- validation result117- checkpoint before and after118- duration, retries, and error class119- output partition or version120121Define reconciliation equations and control totals. Row counts alone are rarely sufficient.122123### 9. Plan rollback and recovery124125State how to:126127- retry a failed batch128- replay a cursor range129- replace a bad publication130- pause live loads during repair131- restore or compensate destructive writes132- resume without duplication133134## Deliverable135136Return:1371381. Pipeline contract1392. Load-strategy decision1403. Stage and grain diagram1414. Checkpoint and idempotency design1425. Late-data, delete, and backfill behavior1436. Storage and schema-evolution plan1447. Validation and reconciliation controls1458. Failure, rollback, and replay plan1469. Observability fields14710. Implementation slices148149## Quality Gate150151- Grain and keys are explicit at every stage.152- Reruns cannot silently duplicate or corrupt data.153- Checkpoints follow durable validated publication.154- Deletes, late data, and backfills are designed.155- Counts and control totals reconcile.156- Recovery is described before scheduling.