Autoresearch Agent
by @alirezarezvani
Autonomous experiment loop that optimizes any file by a measurable metric. Inspired by Karpathy's autoresearch. The agent edits a target file, runs a fixed e...
clawhub install autoresearch-agentπ About This Skill
name: "autoresearch-agent" description: "Autonomous experiment loop that optimizes any file by a measurable metric. Inspired by Karpathy's autoresearch. The agent edits a target file, runs a fixed evaluation, keeps improvements (git commit), discards failures (git reset), and loops indefinitely. Use when: user wants to optimize code speed, reduce bundle/image size, improve test pass rate, optimize prompts, improve content quality (headlines, copy, CTR), or run any measurable improvement loop. Requires: a target file, an evaluation command that outputs a metric, and a git repo." license: MIT metadata: version: 2.0.0 author: Alireza Rezvani category: engineering updated: 2026-03-13
Autoresearch Agent
> You sleep. The agent experiments. You wake up to results.
Autonomous experiment loop inspired by Karpathy's autoresearch. The agent edits one file, runs a fixed evaluation, keeps improvements, discards failures, and loops indefinitely.
Not one guess β fifty measured attempts, compounding.
Slash Commands
| Command | What it does |
|---------|-------------|
| /ar:setup | Set up a new experiment interactively |
| /ar:run | Run a single experiment iteration |
| /ar:loop | Start autonomous loop with configurable interval (10m, 1h, daily, weekly, monthly) |
| /ar:status | Show dashboard and results |
| /ar:resume | Resume a paused experiment |
When This Skill Activates
Recognize these patterns from the user:
If the user describes a target file + a way to measure success β this skill applies.
Setup
First Time β Create the Experiment
Run the setup script. The user decides where experiments live:
Project-level (inside repo, git-tracked, shareable with team):
python scripts/setup_experiment.py \
--domain engineering \
--name api-speed \
--target src/api/search.py \
--eval "pytest bench.py --tb=no -q" \
--metric p50_ms \
--direction lower \
--scope project
User-level (personal, in ~/.autoresearch/):
python scripts/setup_experiment.py \
--domain marketing \
--name medium-ctr \
--target content/titles.md \
--eval "python evaluate.py" \
--metric ctr_score \
--direction higher \
--evaluator llm_judge_content \
--scope user
The --scope flag determines where .autoresearch/ lives:
project (default) β .autoresearch/ in the repo root. Experiment definitions are git-tracked. Results are gitignored.user β ~/.autoresearch/ in the home directory. Everything is personal.What Setup Creates
.autoresearch/
βββ config.yaml β Global settings
βββ .gitignore β Ignores results.tsv, *.log
βββ {domain}/{experiment-name}/
βββ program.md β Objectives, constraints, strategy
βββ config.cfg β Target, eval cmd, metric, direction
βββ results.tsv β Experiment log (gitignored)
βββ evaluate.py β Evaluation script (if --evaluator used)
results.tsv columns: commit | metric | status | description
commit β short git hashmetric β float value or "N/A" for crashesstatus β keep | discard | crashdescription β what changed or why it crashedDomains
| Domain | Use Cases |
|--------|-----------|
| engineering | Code speed, memory, bundle size, test pass rate, build time |
| marketing | Headlines, social copy, email subjects, ad copy, engagement |
| content | Article structure, SEO descriptions, readability, CTR |
| prompts | System prompts, chatbot tone, agent instructions |
| custom | Anything else with a measurable metric |
If program.md Already Exists
The user may have written their own program.md. If found in the experiment directory, read it. It overrides the template. Only ask for what's missing.
Agent Protocol
You are the loop. The scripts handle setup and evaluation β you handle the creative work.
Before Starting
1. Read.autoresearch/{domain}/{name}/config.cfg to get:
- target β the file you edit
- evaluate_cmd β the command that measures your changes
- metric β the metric name to look for in eval output
- metric_direction β "lower" or "higher" is better
- time_budget_minutes β max time per evaluation
2. Read program.md for strategy, constraints, and what you can/cannot change
3. Read results.tsv for experiment history (columns: commit, metric, status, description)
4. Checkout the experiment branch: git checkout autoresearch/{domain}/{name}Each Iteration
1. Review results.tsv β what worked? What failed? What hasn't been tried? 2. Decide ONE change to the target file. One variable per experiment. 3. Edit the target file 4. Commit:git add {target} && git commit -m "experiment: {description}"
5. Evaluate: python scripts/run_experiment.py --experiment {domain}/{name} --single
6. Read the output β it prints KEEP, DISCARD, or CRASH with the metric value
7. Go to step 1What the Script Handles (you don't)
git reset --hard HEAD~1)Starting an Experiment
# Single iteration (the agent calls this repeatedly)
python scripts/run_experiment.py --experiment engineering/api-speed --singleDry run (test setup before starting)
python scripts/run_experiment.py --experiment engineering/api-speed --dry-run
Strategy Escalation
Self-Improvement
After every 10 experiments, review results.tsv for patterns. Update the Strategy section of program.md with what you learned (e.g., "caching changes consistently improve by 5-10%", "refactoring attempts never improve the metric"). Future iterations benefit from this accumulated knowledge.Stopping
Rules
evaluate.py is the ground truth. Modifying it invalidates all comparisons. Hard stop if you catch yourself doing this.Evaluators
Ready-to-use evaluation scripts. Copied into the experiment directory during setup with --evaluator.
Free Evaluators (no API cost)
| Evaluator | Metric | Use Case |
|-----------|--------|----------|
| benchmark_speed | p50_ms (lower) | Function/API execution time |
| benchmark_size | size_bytes (lower) | File, bundle, Docker image size |
| test_pass_rate | pass_rate (higher) | Test suite pass percentage |
| build_speed | build_seconds (lower) | Build/compile/Docker build time |
| memory_usage | peak_mb (lower) | Peak memory during execution |
LLM Judge Evaluators (uses your subscription)
| Evaluator | Metric | Use Case |
|-----------|--------|----------|
| llm_judge_content | ctr_score 0-10 (higher) | Headlines, titles, descriptions |
| llm_judge_prompt | quality_score 0-100 (higher) | System prompts, agent instructions |
| llm_judge_copy | engagement_score 0-10 (higher) | Social posts, ad copy, emails |
LLM judges call the CLI tool the user is already running (Claude, Codex, Gemini). The evaluation prompt is locked inside evaluate.py β the agent cannot modify it. This prevents the agent from gaming its own evaluator.
The user's existing subscription covers the cost:
Custom Evaluators
If no built-in evaluator fits, the user writes their own evaluate.py. Only requirement: it must print metric_name: value to stdout.
#!/usr/bin/env python3
My custom evaluator β DO NOT MODIFY after experiment starts
import subprocess
result = subprocess.run(["my-benchmark", "--json"], capture_output=True, text=True)
Parse and output
print(f"my_metric: {parse_score(result.stdout)}")
Viewing Results
# Single experiment
python scripts/log_results.py --experiment engineering/api-speedAll experiments in a domain
python scripts/log_results.py --domain engineeringCross-experiment dashboard
python scripts/log_results.py --dashboardExport formats
python scripts/log_results.py --experiment engineering/api-speed --format csv --output results.csv
python scripts/log_results.py --experiment engineering/api-speed --format markdown --output results.md
python scripts/log_results.py --dashboard --format markdown --output dashboard.md
Dashboard Output
DOMAIN EXPERIMENT RUNS KEPT BEST Ξ FROM START STATUS
engineering api-speed 47 14 185ms -76.9% active
engineering bundle-size 23 8 412KB -58.3% paused
marketing medium-ctr 31 11 8.4/10 +68.0% active
prompts support-tone 15 6 82/100 +46.4% done
Export Formats
Proactive Triggers
Flag these without being asked:
git init && git add . && git commit -m 'initial' first.Installation
One-liner (any tool)
git clone https://github.com/alirezarezvani/claude-skills.git
cp -r claude-skills/engineering/autoresearch-agent ~/.claude/skills/
Multi-tool install
./scripts/convert.sh --skill autoresearch-agent --tool codex|gemini|cursor|windsurf|openclaw
OpenClaw
clawhub install cs-autoresearch-agent
Related Skills
βοΈ Configuration
First Time β Create the Experiment
Run the setup script. The user decides where experiments live:
Project-level (inside repo, git-tracked, shareable with team):
python scripts/setup_experiment.py \
--domain engineering \
--name api-speed \
--target src/api/search.py \
--eval "pytest bench.py --tb=no -q" \
--metric p50_ms \
--direction lower \
--scope project
User-level (personal, in ~/.autoresearch/):
python scripts/setup_experiment.py \
--domain marketing \
--name medium-ctr \
--target content/titles.md \
--eval "python evaluate.py" \
--metric ctr_score \
--direction higher \
--evaluator llm_judge_content \
--scope user
The --scope flag determines where .autoresearch/ lives:
project (default) β .autoresearch/ in the repo root. Experiment definitions are git-tracked. Results are gitignored.user β ~/.autoresearch/ in the home directory. Everything is personal.What Setup Creates
.autoresearch/
βββ config.yaml β Global settings
βββ .gitignore β Ignores results.tsv, *.log
βββ {domain}/{experiment-name}/
βββ program.md β Objectives, constraints, strategy
βββ config.cfg β Target, eval cmd, metric, direction
βββ results.tsv β Experiment log (gitignored)
βββ evaluate.py β Evaluation script (if --evaluator used)
results.tsv columns: commit | metric | status | description
commit β short git hashmetric β float value or "N/A" for crashesstatus β keep | discard | crashdescription β what changed or why it crashedDomains
| Domain | Use Cases |
|--------|-----------|
| engineering | Code speed, memory, bundle size, test pass rate, build time |
| marketing | Headlines, social copy, email subjects, ad copy, engagement |
| content | Article structure, SEO descriptions, readability, CTR |
| prompts | System prompts, chatbot tone, agent instructions |
| custom | Anything else with a measurable metric |
If program.md Already Exists
The user may have written their own program.md. If found in the experiment directory, read it. It overrides the template. Only ask for what's missing.
π Constraints
evaluate.py is the ground truth. Modifying it invalidates all comparisons. Hard stop if you catch yourself doing this.