experiment-looplisted
Install: claude install-skill pfangueiro/claude-code-agents
# Experiment Loop Pattern
## Overview
The experiment loop is a systematic approach to iterative code improvement where each change is measured against a baseline metric and kept only if it improves the result. Inspired by [karpathy/autoresearch](https://github.com/karpathy/autoresearch) and generalized for any measurable code quality metric.
## The Core Pattern
```
0. VALIDATE → Prove the tool exists and actually RAN. No valid run, no metric.
1. DEFINE → Choose a measurable metric, its noise floor, and constraints
2. BASELINE → Measure current state; pin tool path + version + accepted exit codes
3. MODIFY → Make one targeted change
4. MEASURE → Re-run step 0 FIRST, then re-evaluate the metric
5. GUARD → Run build + tests. If they fail → REVERT, whatever the metric says
6. DECIDE → Keep only if the gain EXCEEDS the noise floor; otherwise revert
7. LOG → Record the change, the metric, and BOTH gate results
8. REPEAT → Go to step 3 (until done or plateau)
```
Steps 0, 5 and 6 are the difference between an improvement loop and a loop that
optimizes for breaking the toolchain. They are specified in
**Mandatory Preconditions** below and are not optional.
## When to Use This Pattern
**Good fit:**
- Reducing lint warnings or type errors in a codebase
- Improving test coverage for a module
- Reducing bundle size or build time
- Optimizing database query performance (measurable via EXPLAIN ANALYZE)
- Improving accessibility scores (Lighthouse, axe)
- Re