| name | autoresearch-loop |
| description | Domain-agnostic autonomous optimization loop. Try ideas, measure results, keep what works, discard what doesn't, repeat forever. Works for any quantifiable metric — ML training, build speed, bundle size, test performance, etc. Use when asked to "optimize X in a loop", "autoresearch for X", or "autonomous optimization". |
Autoresearch Loop — Autonomous Optimization
Adapted from davebcn87/pi-autoresearch. A domain-agnostic optimization loop that works for any quantifiable metric.
Core Concept
Try an idea → measure it → keep what works → discard what doesn't → repeat forever.
Unlike the ML-specific autoresearch skill, this works for any optimization target: build times, bundle size, test speed, inference latency, memory usage, code quality metrics, etc.
Setup
-
Ask or infer from the user:
- Goal: What to optimize (e.g., "reduce build time")
- Command: How to measure it (e.g.,
npm run build)
- Metric: What number to track + direction (e.g., "build time in seconds, lower is better")
- Files in scope: What files the agent may modify
- Constraints: Hard rules (e.g., "tests must pass", "no new dependencies")
-
Create branch: git checkout -b autoresearch/<goal>-<date>
-
Read source files deeply before writing anything.
-
Create autoresearch.md — the heart of the session:
# Autoresearch: <goal>
## Objective
<Specific description of what we're optimizing and the workload.>
## Metrics
- **Primary**: <name> (<unit>, lower/higher is better)
- **Secondary**: <name>, <name>, ...
## How to Run
`./autoresearch.sh` — outputs METRIC name=number lines.
## Files in Scope
<Every file the agent may modify, with a brief note on what it does.>
## Off Limits
<What must NOT be touched.>
## Constraints
<Hard rules: tests must pass, no new deps, etc.>
## What's Been Tried
<Update this section as experiments accumulate. Note key wins, dead ends,
and architectural insights so the agent doesn't repeat failed approaches.>
-
Create autoresearch.sh — benchmark script:
#!/bin/bash
set -euo pipefail
<syntax/lint check>
<actual benchmark command>
echo "METRIC build_time=12.3"
echo "METRIC bundle_size=450"
-
Optional: Create autoresearch.checks.sh — correctness validation:
#!/bin/bash
set -euo pipefail
npm test --run 2>&1 | tail -50
-
Run baseline → log results → start looping immediately.
The Experiment Loop
LOOP FOREVER:
- Review
autoresearch.md and past results.
- Modify files in scope with an optimization idea.
git commit the change.
- Run
./autoresearch.sh and capture output.
- Parse
METRIC lines from output.
- If
autoresearch.checks.sh exists, run it. Failed → log as checks_failed, revert.
- If primary metric improved → keep (commit stands).
- If primary metric equal/worse → discard (
git reset --hard HEAD~1).
- Update
autoresearch.md "What's Been Tried" section periodically.
Rules
- LOOP FOREVER. Never ask "should I continue?" — the user expects autonomous work.
- Primary metric is king. Improved → keep. Worse/equal → discard.
- Simpler is better. Removing code for equal perf = keep.
- Don't thrash. Repeatedly reverting the same idea? Try something structurally different.
- Think longer when stuck. Re-read source files, study profiling data, reason deeply.
- Crashes: fix trivial issues, otherwise log and move on.
- Resuming: if
autoresearch.md exists, read it + git log, continue looping.
State Files
| File | Purpose | Committed? |
|---|
autoresearch.md | Living document: goals, constraints, what's been tried | Yes |
autoresearch.sh | Benchmark script | Yes |
autoresearch.checks.sh | Correctness checks (optional) | Yes |
autoresearch.jsonl | Append-only experiment log (one JSON per run) | No |
JSONL Log Format
Each line in autoresearch.jsonl:
{"run": 1, "commit": "a1b2c3d", "status": "keep", "metrics": {"build_time": 12.3}, "description": "baseline"}
{"run": 2, "commit": "b2c3d4e", "status": "keep", "metrics": {"build_time": 11.1}, "description": "enable parallel compilation"}
{"run": 3, "commit": "c3d4e5f", "status": "discard", "metrics": {"build_time": 13.0}, "description": "switch to esbuild"}
Reference
For the original implementation: third-party/pi-autoresearch/skills/autoresearch-create/SKILL.md