From spml
Creates detailed ML experiment implementation plans with atomic subtasks, validation criteria, and revision support. Use before writing code for multi-step ML tasks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spml:experiment-planningThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Write comprehensive ML experiment plans assuming the engineer has zero context for the codebase and limited ML debugging experience. Document everything: which files to touch, what to implement, what to test, how to validate, what the expected outcomes are. Break into atomic subtasks. YAGNI. Code separation. Frequent commits.
Write comprehensive ML experiment plans assuming the engineer has zero context for the codebase and limited ML debugging experience. Document everything: which files to touch, what to implement, what to test, how to validate, what the expected outcomes are. Break into atomic subtasks. YAGNI. Code separation. Frequent commits.
Assume the implementer is a skilled developer but may not recognize when ML code "runs but is wrong."
Announce at start: "I'm using the experiment-planning skill to create the implementation plan."
Save plans to: <experiment_dir>/plans/YYYY-MM-DD-<experiment-name>.md (use the experiment directory from the brainstorm design doc)
When the orchestrator passes existing plan content AND a revised design with "## Impact on Plan" section, you are in revision mode.
In revision mode, you MUST edit the existing plan file in place. Do NOT create a new plan file. Preserve subtask numbering for unaffected subtasks.REMOVED: [reason] (don't delete — human needs to see what was dropped)"experiment: revise plan — [what changed]"Unchanged subtasks that already passed VP keep their results:
- [x] Task 1: ... (unchanged, VP passed)
- [ ] Task 2: ... (REVISED — needs re-execution)
- [ ] Task 5: ... (NEW)
spml:ml-subagent-dev for execution of changed/new subtasks onlyCRITICAL: Core code (model, training, data) must never import from test/validation code or toolkit. Validation scripts observe core code externally via hooks/wrappers. After development, core code can be extracted and deployed to production as-is.
The agent determines where to place test and validation code based on the user's existing project structure.
Each experiment lives in a single directory. All artifacts — core code, tests, training outputs, and handoff files — are co-located under this directory. This makes experiments self-contained and easy to find.
[experiment-dir]/
├── plans/
│ ├── YYYY-MM-DD-<topic>-design.md # brainstorm design doc
│ └── YYYY-MM-DD-<experiment-name>.md # implementation plan
├── train.py # training script
├── model.py # model code (if separate)
├── data.py # data loading (if separate)
├── experiment-context.md # handoff artifact
├── watchdog-prompt.md # handoff artifact
├── outputs/
│ ├── train.log # training log
│ └── ckpt.pt # checkpoint(s)
└── tests/
├── test_model.py # unit tests
└── test_train.py # validation scripts
The top-level directory name is flexible — use whatever fits the user's existing project structure (e.g., experiments/seq_tower/). The key rule: one directory per experiment, everything inside it.
Every plan MUST start with this header:
# [Experiment Name] Implementation Plan
> **For Claude:** REQUIRED SUB-SKILL: Use spml:ml-subagent-dev to implement this plan task-by-task.
**Goal:** [One sentence]
**Experiment directory:** [Path from brainstorm design doc, e.g. `experiments/my-experiment/`]
**Hypothesis:** [Doing X is expected to cause Y] (if applicable)
**Validation scope:** [Reference validation scope from brainstorm design doc — which levels enabled (L0/L1), data flow choice, baselines]
**Evaluation design:** [Whether evaluation is required, step-based cadence, default/full validation scope or explicit override, both entry modes, observability requirements, failure-handling expectations]
**Architecture:** [2-3 sentences about approach]
---
Plans have two sections: shared scaffold, then atomic subtasks.
## Shared Scaffold
### Existing infra (don't touch, advise if problems found)
- Data pipeline: `path/to/data_loader.py`
- Training loop: `path/to/trainer.py`
- [list all existing infra identified in brainstorm]
### Needs setup
- Experiment directory: `[experiment-dir]/`
- [Only what's missing, with exact file paths and implementation]
Each subtask = one functional change that can be independently tested and committed. A subtask always contains BOTH the code change AND its tests.
Split by functional boundary (model, training loop, data pipeline), NOT by artifact type (all tests, all implementation, all scripts).
Wrong (split by artifact type):
Right (split by functional unit, with INTEGRATION marker):
[INTEGRATION] (assembles model + evaluator + trainer + logging into runnable train.py)If evaluation is part of the experiment, the plan should normally decompose into at least:
[INTEGRATION] (assembles all of the above)Trainer logic (which decides when evaluation fires) lives inside the integration subtask. Evaluator logic (which decides how evaluation runs) is its own code subtask. Do not hide evaluation inside the integration trainer code.
If the experiment ends in a training run, the integration subtask is mandatory — spml:ml-subagent-dev's Plan Gate will reject plans missing it or with multiple.
Use this template for any subtask that is NOT marked [INTEGRATION]. Code subtasks are validated by TDD + Spec Review + Quality Review only. They do NOT run L0 or L1.
## Subtask N: [Component Name]
**Role:** [What this component contributes to the integration]
**Implementation:** [What to change, which files]
**Unit Tests:** [Which custom functions need deterministic tests]
**Expected Conclusion:** "Implemented + N unit tests passing"
### Step 1: Write unit tests for custom functions
```python
def test_custom_loss_basic():
pred = torch.tensor([0.5, 0.3, 0.2])
target = torch.tensor([1.0, 0.0, 0.0])
loss = custom_loss(pred, target)
assert loss.shape == ()
assert not torch.isnan(loss)
```
### Step 2: Run unit tests to verify they fail
Run: `pytest tests/path/test_custom_loss.py -v`
Expected: FAIL (function not defined)
### Step 3: Implement core code
[Exact code, exact file paths. This code goes in the core/src directory — no test/validation imports.]
### Step 4: Run unit tests to verify they pass
Run: `pytest tests/path/test_custom_loss.py -v`
Expected: PASS
### Step 5: Commit
```bash
git add [specific files]
git commit -m "experiment: [subtask description]"
```
Use this template for the one [INTEGRATION] subtask. This is the only subtask that runs the Validation Pyramid.
## Subtask N: [Final Training Pipeline] [INTEGRATION]
**Hypothesis:** [Restate the experiment's overall hypothesis — this is what the assembled pipeline tests]
**Components consumed:** [list of upstream code subtasks the integration depends on, with file paths]
**Implementation:** [Wire components into train.py; add logging, MFU, checkpoint save/resume, fixed seeds; match production-training requirements]
**Integration Tests:** [End-to-end smoke test: data → model → loss → backward → step on a tiny shape]
**Validation Pyramid:** L0 + L1 (mandatory) — [specific metrics + baselines from brainstorm]
**Evaluation contract:** [Step-based cadence, default/full validation scope or explicit override, checkpoint-based + in-memory entry modes, observability requirements, failure-handling requirements]
**Expected Conclusion:** [What success means in terms of L1 metrics / what failure means]
### Step 1: Write integration tests
[End-to-end smoke test that exercises the full pipeline on a tiny shape.]
### Step 2: Run integration tests to verify they fail
Run: `pytest tests/path/test_integration.py -v`
Expected: FAIL (pipeline not assembled)
### Step 3: Assemble the training pipeline
[Wire components, write train.py, add production-training requirements. No test/validation imports in core code.]
### Step 4: Run integration tests to verify they pass
Run: `pytest tests/path/test_integration.py -v`
Expected: PASS
### Step 5: Write validation scripts
[Scripts that observe core code externally. Import toolkit if needed; use hooks/wrappers, never modify core.]
### Step 6: Run Validation Pyramid (L0 → L1, orchestrator-driven)
L0 (ml-static-checks): runs as a subagent — no manual command.
L1 (ml-runtime-validator):
Run: `[project-specific training command, limited to ~5 min via config/CLI flags]`
Expected: MFU >= [baseline from brainstorm], no NaN/Inf, loss decreasing, all 6 pipeline stages pass
### Step 7: Record full conclusion (with L1 metrics)
[What the results mean for the hypothesis. Include actual L1 metric values.]
### Step 8: Commit
```bash
git add [specific files]
git commit -m "experiment: integration training pipeline"
```
Each step should be one action. Code subtasks have ~5 steps (test → fail → implement → pass → commit). Integration subtasks have ~8 (the same plus validation scripts, VP, conclusion).
If the experiment will need a long-running training phase (hours/days), include these requirements in the [INTEGRATION] subtask spec so the implementer builds them when assembling the training pipeline. Do NOT leave them for training-handoff to patch later.
Required in the [INTEGRATION] subtask:
These requirements are also what L0 (ml-static-checks) verifies on the integration subtask, so omitting them produces L0 failures.
If the experiment has a validation or evaluation phase, plans are incomplete unless they explicitly state:
every 500 stepsfull validation unless explicitly overriddenFinal-epoch-only evaluation is not an acceptable default for long-running training.
These enable the Watchdog to monitor training and the user to track progress. Without them, training-handoff will flag gaps and potentially need to modify VP-validated code.
After saving the plan, offer execution choice:
"Plan complete and saved to <experiment_dir>/plans/<filename>.md. Two execution options:
1. Subagent-Driven (this session) — I dispatch fresh subagent per subtask, review between subtasks, fast iteration
2. Parallel Session (separate) — Open new session with superpowers:executing-plans, batch execution with checkpoints
Which approach?"
If Subagent-Driven chosen:
If Parallel Session chosen:
npx claudepluginhub qqhard/superpowers-mlGuides ML experiment design by exploring ideas, collecting context, and confirming validation scope before implementation.
Converts approved deep learning experiment designs into concrete multi-step execution plans with code changes, sanity checks, runs, and artifact capture.
Generates validated, runnable implementation plans for ML pipelines, architecture designs, and multi-step projects grounded in official framework documentation.