Optimize code through an automated falsifiable-hypothesis loop
An agent skill profiles code, proposes and tests optimization hypotheses in a loop, keeps verified improvements in version control, and writes a PDF report; it sped up KaHIP 3.9x and VieCut 8.9x. · Nov 23, 2026
- What They Did
- The skill runs in Claude Code or Codex. During setup you and the agent agree on the benchmark, the metric, the correctness assertions and the budget, and then it works alone. For each idea it writes a falsifiable hypothesis with a predicted effect, makes a minimal Git commit, and runs the benchmark. It keeps the change only if it is faster and still correct, and otherwise reverts it.
- How It Went
- On KaHIP kaffpa, one session ran 122 experiments across 69 hypotheses and kept 41 patches, for 3.9x overall. VieCut got 8.9x with every cut unchanged. Each kept change was checked against the original output.
- Worth Knowing
- You define the correctness assertions up front, such as bit-identical output, and the agent checks only those. A 10-minute quick-start example is provided if you want to try it first.
In my repository at [path or repo], profile [program or benchmark command] and find the biggest performance bottlenecks. Then loop: state a falsifiable hypothesis for a speedup, implement it, run [test command] to confirm correctness and re-run the benchmark, and commit only changes that are verified faster, reverting the rest. Stop after [number] hypotheses or when gains flatten, then write a short PDF report with the baseline, each hypothesis and its result, and the final speedup. Do not push to any remote or delete branches without showing me first.