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

ml-pipeline-design

Skill1 starsChanged 6 days agoMITView on GitHub

Design reproducible ML training and data pipelines — ingestion, validation, feature engineering, training, evaluation, continuous training orchestration. Analytics/BI ELT and dbt warehouse pipelines → data-pipeline-design; refactoring general analysis/reporting notebooks (no model training) to production code → notebook-to-production.

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every ML pipeline follows this general DAG (Directed Acyclic Graph):

    line 31
  2. Distinctive:

    Use frameworks like Great Expectations, Pandera, or TensorFlow Data Validation.

    line 56
  3. Distinctive:

    Document every transformation (input → output, rationale)

    line 60
  4. Distinctive:

    Ensure transformations are deterministic and reproducible

    line 61
  5. Distinctive:

    Consider a feature store for features reused across models (Feast, Tecton)

    line 62
  6. Distinctive:

    Critical: Use the same feature code for training and serving to prevent training-serving skew

    line 63
  7. Distinctive:

    Document the split ratios and method

    line 69
  8. Distinctive:

    Check for fairness across segments if applicable

    line 80
  9. Distinctive:

    Gate: Only promote models that beat the baseline by a defined threshold

    line 81
  10. Distinctive:

    No prediction anomalies on a validation dataset

    line 86
  11. Distinctive:

    Start simple: scripts + cron or GitHub Actions for early-stage ML.

    line 100
  12. Distinctive:

    Write each pipeline stage as an independent, testable component:

    line 104
  13. Distinctive:

    KISS: Start with a linear script, refactor into a DAG when complexity demands it.

    line 163
  14. Distinctive:

    YAGNI: Don't build a feature store for 3 features.

    line 164

≈ “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

ML Pipeline Design

Design reproducible, automated ML pipelines that transform training notebooks into production-grade workflows. A pipeline is the difference between "I ran this notebook and got good results" and "this system produces, validates, and deploys models automatically."

Scope check first: if the notebook does NOT train a model — it's analysis, KPIs, or reporting — this is not a training pipeline; use the notebook-to-production skill (modules, tests, parameterization, scheduling) instead.

Why Pipelines Matter

Manual ML workflows break in predictable ways:

  • Undocumented steps: "You need to run cell 7 before cell 3, but skip cell 5"
  • Hidden state: Notebook variables carry state between cells that isn't captured
  • No validation: Bad data enters silently and produces silently bad models
  • No automation: Retraining requires a human to re-run the notebook
  • No lineage: "Which data produced this model?" becomes unanswerable

Pipelines solve all of these by making each step explicit, validated, and reproducible.

Workflow

Step 1: Map the Pipeline Stages

Every ML pipeline follows this general DAG (Directed Acyclic Graph):

Data Ingestion → Data Validation → Feature Engineering → Data Split
                                                            ↓
Model Evaluation ← Model Training ← Hyperparameter Config
      ↓
Model Validation → Model Registration → (Optional) Deployment

Identify which stages the user's workflow needs. Not every project needs every stage — a simple model might skip feature stores and hyperparameter tuning.

Step 2: Design Each Stage

Data Ingestion:

  • Where does raw data come from? (Database, API, files, streaming)
  • How is it versioned? (DVC, Delta Lake, immutable snapshots)
  • What's the trigger? (Schedule, event, data arrival)

Data Validation:

  • Schema validation: Do columns exist? Are types correct?
  • Statistical validation: Are distributions within expected ranges?
  • Freshness checks: Is the data recent enough?
  • Completeness checks: Missing value rates within tolerance?

Use frameworks like Great Expectations, Pandera, or TensorFlow Data Validation. See references/pipeline-components.md.

Feature Engineering:

  • Transform raw data into model-ready features
  • Document every transformation (input → output, rationale)
  • Ensure transformations are deterministic and reproducible
  • Consider a feature store for features reused across models (Feast, Tecton)
  • Critical: Use the same feature code for training and serving to prevent training-serving skew

Data Split:

  • Train/validation/test split with consistent strategy
  • Time-based splits for temporal data (no future leakage)
  • Stratified splits for imbalanced classes
  • Document the split ratios and method

Model Training:

  • Parameterized: hyperparameters passed as config, not hardcoded
  • Tracked: all runs logged to experiment tracker (use ml-experiment-tracking skill)
  • Resource-aware: specify compute requirements (GPU type, memory)

Model Evaluation:

  • Evaluate on held-out test set (never used during training or tuning)
  • Compute all relevant metrics (not just accuracy)
  • Compare against baseline model (the one currently in production)
  • Check for fairness across segments if applicable
  • Gate: Only promote models that beat the baseline by a defined threshold

Model Validation (pre-deployment):

  • Inference latency meets SLA
  • Model size fits the deployment target
  • No prediction anomalies on a validation dataset
  • Input/output schema matches the serving contract

Step 3: Choose the Orchestrator

ToolBest ForComplexity
Simple scripts + cronSingle-model, small teamLow
Airflow / DagsterData engineering teams, complex DAGsMedium
Kubeflow PipelinesKubernetes-native, large scaleHigh
Vertex AI / SageMaker PipelinesCloud-native, managedMedium
PrefectPython-native, modern alternative to AirflowMedium
GitHub ActionsSimple CI/CD-triggered trainingLow

Start simple: scripts + cron or GitHub Actions for early-stage ML. Move to Airflow/Dagster when you have multiple pipelines and complex dependencies.

Step 4: Implement

Write each pipeline stage as an independent, testable component:

# Each stage is a function with clear inputs and outputs
def ingest_data(source_config: dict) -> pd.DataFrame:
    """Ingest data from configured source."""
    ...

def validate_data(df: pd.DataFrame, schema: Schema) -> ValidationResult:
    """Validate data against expected schema and statistics."""
    ...

def engineer_features(df: pd.DataFrame, feature_config: dict) -> pd.DataFrame:
    """Apply feature transformations."""
    ...

def train_model(X_train, y_train, hyperparams: dict) -> Model:
    """Train model with given hyperparameters."""
    ...

def evaluate_model(model: Model, X_test, y_test) -> dict:
    """Evaluate model and return metrics dict."""
    ...

This pattern makes each stage unit-testable, composable, and replaceable.

Step 5: Add Data Validation Gates

Data validation is the most overlooked and most valuable pipeline component. Bad data in → bad model out, silently.

import pandera as pa

# Define expected schema
schema = pa.DataFrameSchema({
    "user_id": pa.Column(int, nullable=False),
    "amount": pa.Column(float, pa.Check.in_range(0, 100000)),
    "category": pa.Column(str, pa.Check.isin(["A", "B", "C"])),
    "timestamp": pa.Column(pd.Timestamp, nullable=False),
})

# Validate before training
validated_df = schema.validate(raw_df)  # Raises on failure

Step 6: Validate and Document

  • Pipeline runs end-to-end from raw data to registered model
  • Each stage can be run independently for debugging
  • Data validation catches bad data before training
  • Experiment tracking captures all runs
  • Model evaluation gates prevent worse models from being promoted
  • Pipeline configuration is version-controlled (not hardcoded)
  • Feature transformations are shared between training and serving

Principles Applied

  • DRY: Share feature engineering code between training pipeline and serving. One transformation definition, used everywhere.
  • KISS: Start with a linear script, refactor into a DAG when complexity demands it. Don't adopt Kubeflow for one model.
  • YAGNI: Don't build a feature store for 3 features. Build it when you have 50+ features shared across multiple models.
  • Functional Independence: Each pipeline stage is an independent component with defined inputs and outputs. Replace any stage without rewriting the pipeline.
  • Fail fast: Validate data at ingestion, not after 2 hours of training.

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.