agentleFS
SWEStashSWEStash/swe-workflow-skills/skills/data-pipeline-design/SKILL.md

data-pipeline-design

Skill1 starsChanged 5 days agoMITView on GitHub

Design batch and streaming data pipelines — ELT into a warehouse/lakehouse, dbt and analytics engineering (staging/intermediate/marts layers), orchestration with Airflow or Dagster, idempotent loads, incremental models, backfills, CDC ingestion. Triggers: data pipeline, ELT, ETL, dbt models, data warehouse, Snowflake, BigQuery, ingest into the warehouse, Airflow DAG, Dagster, Kafka streaming, backfill, incremental load, nightly job duplicates rows. ML training/feature pipelines → ml-pipeline-design; validating the data → data-quality.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every run processes an explicit logical window passed in by the orchestrator (WHERE event_date = {{ ds }}) — never CURRENT_DATE - 1 inside …

    line 84
  2. Very specific:

    YAGNI: no lakehouse/streaming/metadata-platform buildout for a stack whose consumers refresh dashboards daily.

    line 115

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Pipeline Design

Design pipelines that move and transform data for analytics — and stay correct when they fail, rerun, and backfill, because they will. The two design properties that separate a pipeline from a script: idempotency (any run can be repeated safely) and parameterization (any time window can be processed by the same code). Boundaries: pipelines feeding model training (features, point-in-time correctness) belong to ml-pipeline-design; validating the data this pipeline moves belongs to data-quality.

Workflow

Step 1: Map Sources, Consumers, and Freshness

List each source (databases, SaaS APIs, event streams), each consumer (dashboards, reverse ETL, downstream teams), and the freshness each consumer actually needs. Freshness drives everything: daily batch is an order of magnitude cheaper to build and operate than streaming — don't buy streaming because "real-time" sounds better; buy it when a consumer decision genuinely changes within minutes.

If the ask arrives with a bill attached, separate the two questions. Changing what work runs each night — full refreshes to incremental, narrower scans, fewer rebuilds — is this skill's, and the steps below do it. What that work is charged at, and how much of the invoice this job even accounts for, is finops-cost-optimization's. Find out this job's share of the spend before promising a number: a rewrite that halves a job responsible for a fifth of the bill moves the total by a tenth.

Step 2: Choose ELT (and Say Why)

For a cloud warehouse (Snowflake, BigQuery, Redshift, Databricks), default to ELT: land raw data unchanged, transform inside the warehouse with SQL/dbt. The reasons are operational, not fashionable — raw history means transform bugs are fixed by re-running transforms, not re-extracting from sources; the warehouse scales the compute; transformations become versioned, testable SQL. Classic ETL survives where data must be cleaned/redacted before it may land (PII, compliance) or the target isn't a warehouse.

Step 3: Don't Hand-Roll Extraction

Ingestion is undifferentiated heavy lifting with long tail of pain (API pagination, rate limits, schema changes, backpressure):

  • SaaS/DB sources: managed or open connectors first — Fivetran/Airbyte/dlt. Hand-write only when no connector exists or volume/cost forces it.
  • Operational DBs at scale: CDC (Debezium or the warehouse-native equivalent) instead of daily full dumps or fragile updated_at queries.
  • Events: land the stream (Kafka → object storage/warehouse) raw; process micro-batch unless Step 1 proved sub-minute freshness is needed.

Step 4: Layer the Transforms (dbt)

  • Staging — 1:1 with sources: rename, cast, deduplicate. No business logic.
  • Intermediate — joins and business logic, composable, not exposed to BI.
  • Marts — consumer-facing facts/dimensions, one per business domain.

Each layer only reads from the one below; BI tools read only marts. This is SRP for SQL: when a number is wrong, the layer tells you where to look. Schema design for the marts themselves is data-modeling's domain.

Step 5: Make Every Run Idempotent

The Iron Rule of pipelines: a rerun must produce the same result as one run. Append-only loads fail this and produce the classic duplicate-rows- after-retry incident. Choose a write pattern per table:

  • Delete + insert by partition (or INSERT OVERWRITE): simplest, right default for date-partitioned facts.
  • Merge/upsert on a unique key: for mutable entities and late updates — requires a true unique key (enforce it via data-quality tests).
  • Full refresh: fine while small; flip to incremental on cost, not pride.

In dbt: incremental materialization with unique_key set — and always define the full-refresh path (--full-refresh must work, or you can't recover from a logic bug).

Step 6: Parameterize Time — Backfill Is a First-Class Case

Every run processes an explicit logical window passed in by the orchestrator (WHERE event_date = {{ ds }}) — never CURRENT_DATE - 1 inside the SQL, which makes yesterday's failure unreproducible today. Then backfill is not a special script: it's the same job over a range, natively supported by the orchestrator (Airflow backfill, Dagster partitioned assets). If backfilling means hand-editing dates, Steps 5–6 were skipped.

Handle late-arriving data explicitly: reprocess a trailing lookback window (e.g. the last 3 days) each run, or track a watermark — pick per source based on how late its data actually arrives.

Step 7: Orchestrate and Operate

Pick one orchestrator and make a recommendation, not a brochure: Dagster for a dbt-centric greenfield stack (asset/partition model matches warehouse thinking, first-class dbt integration); Airflow where the org already runs it or needs its ecosystem breadth (comparison and managed options: references/orchestration.md). Then wire in operations: retries, and an alert on final failure that names who receives it — a load that fails silently is the failure this step exists to prevent, so the alert is part of the pipeline design, not a monitoring afterthought. (SLOs, error budgets and instrumentation depth are observability-design's; deciding that a failed run pages someone is not.) Alongside it, quality checks between layers (data-quality), and cost visibility per model — warehouses make it very easy to spend quietly.

Principles Applied

  • KISS: batch over streaming, connectors over custom extractors, SQL over a framework — until a measured requirement says otherwise.
  • DRY: one parameterized job for daily runs and backfills; logic lives once, in the transform layer, not copied into extraction scripts.
  • YAGNI: no lakehouse/streaming/metadata-platform buildout for a stack whose consumers refresh dashboards daily.

Cross-Skill References

  • finops-cost-optimization — warehouse sizing, spend attribution, and whether this job is actually driving the bill
  • data-quality — tests, contracts, and freshness checks between the layers
  • data-modeling — the schema design of the marts this pipeline produces
  • ml-pipeline-design — when the consumer is model training, not BI
  • observability-design — pipeline SLOs, alerting, run-level monitoring
  • architecture-design — ADRs for the costly-to-reverse platform choices

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.