agent-autoresearch
Skill11 starsChanged 14 days agoMITView on GitHub
Autoresearch loop for any coding agent harness (Claude Code, Codex, pi, others with a shell) - repeatedly edit, measure, keep or revert, and log experiments that push one numeric metric (speed, size, score, loss, error count) toward a goal, unattended for hours if needed. Use to start an autoresearch or overnight optimization run, or to check, resume, or report an existing one. Not for grading or optimizing SKILL.md files; use darwin-skill for that.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- obsidian-skills/AGENTS.mdAGENTS.md
- add-just-doctorSkill
- agent-harness-repairSkill
- change-evidenceSkill
- ci-speedSkill
- verifySkill
- deck-style-gallerySkill
- doneSkill
- longform-fictionSkill
- loop-kitSkill
- loop-nightly-reviewSkill
- loop-triage-githubSkill
- loop-watch-socialSkill
- orch-claude-pi-codexSkill
- skills-doctorSkill
- tdd-pstackSkill
- teach-pstackSkill
- windows-leftover-cleanupSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Initialize: Commit or stash unrelated work, then:
- Very specific: line 71
Noise: When a keep's gain is within about twice the noise floor, run ar recheck before building on it.
- Very specific: line 74
Long measurements: When a trial would outlast your shell tool's timeout, run ar trial ...
- Distinctive: line 78
When the session stops or completes, or the user asks for results:
- Very specific: line 80
Run .autoresearch/ar report to write report.html and summary.md.
- Distinctive: line 92
Read references/harnesses.md before launching a relay, when running under a harness you have not used with this skill, or when tuning …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.
Files
Agent Autoresearch
Karpathy-style autoresearch that runs the same way in every harness. You are the researcher: you choose hypotheses and edit code. The bundled controller (scripts/autoresearch.py, Python 3 standard library) owns everything that must be trustworthy: measurement, the keep-or-revert decision, git commits, and the experiment log. The best result is a ratchet: a trial is kept only when the metric improves and the checks pass; every other trial is reverted with its patch saved.
hypothesis -> edit -> trial (measure, gate, keep or revert, log) -> learn -> repeat<skill-dir> is the directory containing this file. Before init, call the controller as python3 <skill-dir>/scripts/autoresearch.py <command> from inside the target repository. init writes a launcher: on Windows the ar launcher is a POSIX shell script, so run sh .autoresearch/ar <command> (Git Bash's sh works; WSL's does not share the filesystem) or call the .py directly; everywhere else call .autoresearch/ar <command> from the repository root (or by its absolute path from anywhere). The launcher also works from a fresh context that never saw this skill. Session hooks also run through sh on Windows. Measure and checks commands run through the platform shell (cmd.exe on Windows), so keep them single-line or prefix them with sh -c. <command> --help lists every flag.
Route the request
- Status or results of an existing session (
.autoresearch/exists): run.autoresearch/ar status,log, orreportand answer. Start no experiments. - Resume:
.autoresearch/ar status, then.autoresearch/ar resume(add--more Nor--budget-minutes Mwhen a limit stopped it), then go to Experiment loop. - New session: Set up, then Experiment loop.
Set up
Define the experiment. Settle the goal, the primary metric and its direction, the measure command, the correctness checks, the editable scope, the protected paths (the evaluator, its data, the tests), and the stopping rule (target, trial limit, time budget, or run until stopped). Infer what the repository and request already answer; ask only for decisions that change the experiment. Unless the user said to just go, show one confirmation:
Goal: ... Metric: <name> (<lower|higher> is better), measured by `<command>` Checks: `<command>` | none Scope: <paths> Protected: <paths> Stop: <target | N trials | M minutes | until stopped>Done when every line has a value.
- Make the measurement trustworthy. The measure command prints
METRIC <name>=<number>lines (a final numeric line also works), exits 0 when it measured, holds the workload and compute budget fixed, and leaves the working tree untouched. When nothing suitable exists, write a measure script outside the scope and protect it. Read references/measurement.md when you write a measure or checks script, when the metric is noisy (timings), or when the experiments could overfit the benchmark. Done when one manual run prints the metric. Initialize. Commit or stash unrelated work, then:
python3 <skill-dir>/scripts/autoresearch.py init --goal "..." --metric NAME --direction lower \ --measure "CMD" --checks "CMD" --scope PATH --protect PATH \ --max-iterations N --budget-minutes M --target XDrop the flags that do not apply; on Windows run this as one line. The time budget starts at
init; once any limit is hit the controller refuses new trials and printsnext: STOP.initcreates the branchautoresearch/<tag>-<date>, measures the baseline (probing noise on fast benchmarks), and writes the git-ignored.autoresearch/:log.jsonl(source of truth),program.md(the brief),ideas.md(the backlog), andar. If it reports a noisy metric, apply its rebaseline suggestion. Done when it prints the baseline.- Write the brief. Fill in Constraints and Strategy notes in
.autoresearch/program.md: what produces the metric, where the cost or error comes from (profile it or read the measure output), and the first hypotheses ranked by expected gain. A fresh context resumes from this file. Done when a stranger could start the loop from it.
Experiment loop
Keep looping without asking whether to continue; the human may be asleep. The loop ends only when the controller prints next: STOP (or refuses a trial because the session is stopped or complete) or the user interrupts. In a headless run (claude -p, codex exec, pi -p) a reply without a tool call ends the run, so keep acting until STOP, and get the first trial on the board early. After a context reset, re-orient with .autoresearch/ar status and program.md before the next trial.
- Choose one hypothesis from evidence: the measure output, profiles, the code,
ideas.md, earlier verdicts and notes. One coherent idea per trial keeps its effect attributable. When the latest keep removes the reason an earlier discard failed, that discard is a candidate again. - Edit inside the scope. When a mistake would waste a long measurement, sanity-check cheaply first (compile, one unit test). Screening several variants on a fast private probe is fine, but only
trialadopts a change, and what the screening ruled out goes intoprogram.mdorar noteso the notebook keeps the dead ends. Run the trial:
.autoresearch/ar trial --description "what changed" --hypothesis "why it should help"Add
--simplificationwhen the change removes complexity and deserves a keep at equal metric, and--revisits Nwhen it retries discard #N because an assumption changed. The verdict belongs to the controller: KEEP commits; DISCARD, CRASH, TIMEOUT, and CHECKS_FAILED revert. The controller owns git, so commits, resets, stashes, and branch switches go through it.- Learn from the verdict. Write down why a trial lost or surprised you:
.autoresearch/ar note "...". When a crashed idea still has merit,ar restore N, fix it, and trial again. Park good ideas for later inideas.md. Every few trials, and after each keep, update "What's been tried" inprogram.mdwith wins and with dead ends plus the reason they failed. - Go to 1.
Research judgment:
- Simplicity criterion. Weigh complexity against gain. A tiny gain that adds hacky code is not worth keeping (
ar undo --reason "..."drops the last keep); equal metric with less code is a win. - When stuck (the controller warns after three trials without a keep): re-read the measure output and the code to find where the metric really comes from, combine near-misses, try a structurally different approach, or take a bold swing. Variations of a failed idea are the slowest path.
- Noise. When a keep's gain is within about twice the noise floor, run
ar recheckbefore building on it. - Integrity. Gains come from the system under test; the measurement, its data, and protected files stay as they are. When the benchmark itself looks wrong, stop and tell the user. Changing the measurement needs the user's agreement and starts a new segment:
ar init --rebaseline .... - Context hygiene. Work from the controller's summaries; open full logs in
.autoresearch/logs/only to diagnose. - Long measurements. When a trial would outlast your shell tool's timeout, run
ar trial ... --detach, thenar waituntil the verdict prints.
Finish
When the session stops or completes, or the user asks for results:
- Run
.autoresearch/ar reportto writereport.htmlandsummary.md. - Tell the user: baseline to best (with percent), trial and keep counts, the top wins, notable dead ends, open ideas, the branch name, and how to land it (commands are in
summary.md). Merging and branch cleanup stay with the user unless asked.
Unattended runs
Over many hours a single session can stall, end its turn early, or exhaust its context. The controller can relay instead: it launches a fresh headless agent for each batch of trials until the session stops. Prefer it for unattended headless runs, especially with models that tend to end their turn early; it resumes any existing session.
.autoresearch/ar relay --agent claude # or codex, pi; --model M; --trials-per-worker 5
.autoresearch/ar relay --agent-cmd 'your-agent-cli -p {prompt_file}'Read references/harnesses.md before launching a relay, when running under a harness you have not used with this skill, or when tuning permissions, tool timeouts, hooks, or parallel sessions.
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
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.

