Data Transformation & ETL
Use this skill for data ingestion, cleanup, normalization, migration, and loading workflows.
Priorities
- Correctness of data
- Repeatability
- Observability
- Recovery from partial failure
- Performance at scale
Core Rules
1. Validate at every boundary
- Validate file shape, schema, headers, and required fields before heavy processing.
- Parse untrusted input defensively.
- Distinguish malformed rows from recoverable business-rule failures.
2. Normalize before business logic
- Convert transport formats into stable internal records first.
- Normalize casing, whitespace, null conventions, timestamps, units, and IDs before downstream logic.
- Keep raw input and normalized output conceptually separate.
3. Make pipelines idempotent
- Re-running the same batch should not duplicate or corrupt data.
- Prefer deterministic keys, upserts, checkpoints, or watermarks.
- Avoid pipelines that are safe only if they run exactly once.
4. Handle partial failure deliberately
- Decide whether the unit of failure is row, file, batch, or whole run.
- Log and count rejected records explicitly.
- If partial success is allowed, make the boundary visible in metrics and outputs.
5. Keep transforms readable
- Prefer a sequence of named transformation steps over one giant pipeline.
- Separate parsing, validation, enrichment, deduplication, and loading.
- Avoid clever one-liners that make data loss hard to detect.
6. Preserve provenance
- Keep enough metadata to trace where a record came from.
- Include source file, batch ID, import timestamp, or checkpoint when the system needs auditability.
- Never destroy raw provenance before the load is verified.
7. Design for scale without hiding semantics
- Stream or chunk large inputs when full in-memory processing is risky.
- Parallelize only when ordering, deduplication, and side effects remain correct.
- Optimize the hot path after correctness and restart safety are established.
Parsing Rules
- Fail fast on missing required structure.
- Be explicit about encoding, delimiter, locale, and timestamp assumptions.
- Treat schema drift as a first-class risk.
- Prefer typed records or schema validation where the stack supports it.
Transformation Rules
- Make field derivations explicit.
- Keep unit conversions centralized.
- Deduplicate using business keys, not incidental row order.
- Flag suspicious records instead of silently coercing them into validity.
Loading Rules
- Define transaction boundaries intentionally.
- Use staging tables or temporary sinks when the load must be validated before publish.
- Prefer bulk operations when they preserve correctness and failure visibility.
- Avoid per-row write loops for large imports unless the scale is genuinely small.
Incremental Sync Rules
- Use durable checkpoints or watermarks.
- Handle late-arriving and out-of-order data intentionally.
- Decide what happens when a source mutates historical data.
- Document replay strategy.
Observability
Every meaningful ETL job should expose:
- records read
- records written
- records rejected
- batches retried
- time spent per stage
- checkpoint / watermark used
Log enough context to debug a bad batch without dumping sensitive data.
Review Heuristics
Look for:
- hidden schema assumptions
- non-idempotent inserts
- silent row drops
- transforms that mix parsing with business logic
- missing checkpoints or replay strategy
- poor failure visibility
- memory-heavy processing where streaming/chunking is safer
Anti-Patterns
Avoid:
- loading raw external data straight into domain tables
- silently coercing bad records into "valid" values
- pipelines that cannot be rerun safely
- giant monolithic transform functions
- success reports that ignore rejected rows
- batch jobs with no checkpoint or audit trail
Quick Checklist
1---2name: data-transformation-etl3description: Practical ETL rules for parsing, validation, transformation, and safe loading.4license: See repository LICENSE5---67# Data Transformation & ETL89Use this skill for data ingestion, cleanup, normalization, migration, and loading workflows.1011## Priorities12131. **Correctness of data**142. **Repeatability**153. **Observability**164. **Recovery from partial failure**175. **Performance at scale**1819## Core Rules2021### 1. Validate at every boundary2223- Validate file shape, schema, headers, and required fields before heavy processing.24- Parse untrusted input defensively.25- Distinguish malformed rows from recoverable business-rule failures.2627### 2. Normalize before business logic2829- Convert transport formats into stable internal records first.30- Normalize casing, whitespace, null conventions, timestamps, units, and IDs before downstream logic.31- Keep raw input and normalized output conceptually separate.3233### 3. Make pipelines idempotent3435- Re-running the same batch should not duplicate or corrupt data.36- Prefer deterministic keys, upserts, checkpoints, or watermarks.37- Avoid pipelines that are safe only if they run exactly once.3839### 4. Handle partial failure deliberately4041- Decide whether the unit of failure is row, file, batch, or whole run.42- Log and count rejected records explicitly.43- If partial success is allowed, make the boundary visible in metrics and outputs.4445### 5. Keep transforms readable4647- Prefer a sequence of named transformation steps over one giant pipeline.48- Separate parsing, validation, enrichment, deduplication, and loading.49- Avoid clever one-liners that make data loss hard to detect.5051### 6. Preserve provenance5253- Keep enough metadata to trace where a record came from.54- Include source file, batch ID, import timestamp, or checkpoint when the system needs auditability.55- Never destroy raw provenance before the load is verified.5657### 7. Design for scale without hiding semantics5859- Stream or chunk large inputs when full in-memory processing is risky.60- Parallelize only when ordering, deduplication, and side effects remain correct.61- Optimize the hot path after correctness and restart safety are established.6263## Parsing Rules6465- Fail fast on missing required structure.66- Be explicit about encoding, delimiter, locale, and timestamp assumptions.67- Treat schema drift as a first-class risk.68- Prefer typed records or schema validation where the stack supports it.6970## Transformation Rules7172- Make field derivations explicit.73- Keep unit conversions centralized.74- Deduplicate using business keys, not incidental row order.75- Flag suspicious records instead of silently coercing them into validity.7677## Loading Rules7879- Define transaction boundaries intentionally.80- Use staging tables or temporary sinks when the load must be validated before publish.81- Prefer bulk operations when they preserve correctness and failure visibility.82- Avoid per-row write loops for large imports unless the scale is genuinely small.8384## Incremental Sync Rules8586- Use durable checkpoints or watermarks.87- Handle late-arriving and out-of-order data intentionally.88- Decide what happens when a source mutates historical data.89- Document replay strategy.9091## Observability9293Every meaningful ETL job should expose:9495- records read96- records written97- records rejected98- batches retried99- time spent per stage100- checkpoint / watermark used101102Log enough context to debug a bad batch without dumping sensitive data.103104## Review Heuristics105106Look for:107108- hidden schema assumptions109- non-idempotent inserts110- silent row drops111- transforms that mix parsing with business logic112- missing checkpoints or replay strategy113- poor failure visibility114- memory-heavy processing where streaming/chunking is safer115116## Anti-Patterns117118Avoid:119120- loading raw external data straight into domain tables121- silently coercing bad records into "valid" values122- pipelines that cannot be rerun safely123- giant monolithic transform functions124- success reports that ignore rejected rows125- batch jobs with no checkpoint or audit trail126127## Quick Checklist128129- [ ] Input schema is validated130- [ ] Raw and normalized records are separated131- [ ] Pipeline is idempotent132- [ ] Failure boundary is explicit133- [ ] Checkpoints/watermarks are defined where needed134- [ ] Metrics and rejection counts are visible135- [ ] Loading strategy is safe for reruns and partial failures