
Autoresearch
- 2 installs
- 5 repo stars
- Updated August 4, 2026
- paulrberg/dot-agents
Runs an autonomous experiment loop that tries ideas, measures a metric, keeps what works and discards the rest, for any optimization target.
About
Sets up and runs an autonomous experiment loop that benchmarks a command, logs results and keeps only improvements toward a chosen metric. A developer uses it to optimize test speed, bundle size, build times, latency or similar targets unattended.
- Creates autoresearch.md/.sh session files with baseline and loop
- Resumes from existing session files and keeps improvements on a branch
Autoresearch by the numbers
- 2 all-time installs (skills.sh)
- +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #1,839 of 2,715 Automation & Workflows skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/paulrberg/dot-agents --skill autoresearchAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 5 |
| Last updated | August 4, 2026 |
| Repository | paulrberg/dot-agents ↗ |
What it does
Runs an autonomous experiment loop that tries ideas, measures a metric, keeps what works and discards the rest, for any optimization target.
Files
Autoresearch
Autonomous experiment loop: try ideas, measure results, keep what works, discard what doesn't, never stop.
Works for any optimization target: test speed, bundle size, LLM training, build times, Lighthouse scores, binary size, latency, memory usage.
Setup
If autoresearch.md already exists in the working directory, skip setup and resume the loop — read autoresearch.md, autoresearch.jsonl, and git log, then continue experimenting.
Otherwise:
1. Gather context: Ask (or infer from $ARGUMENTS and conversation) the Goal, Command to benchmark, Primary metric (name + direction), Files in scope, and Constraints. 2. Create branch: git checkout -b autoresearch/<goal>-<date> (e.g. autoresearch/test-speed-2026-03-21). 3. Read source files: Understand the workload deeply before writing anything. Read every file in scope. 4. Write session files: Create autoresearch.md and autoresearch.sh (see templates below). If constraints require correctness validation (tests must pass, types must check), also create autoresearch.checks.sh. Commit all. 5. Run baseline: Execute the first experiment with no changes to establish the baseline metric. 6. Start looping: Begin the experiment loop immediately after the baseline is logged.
autoresearch.md
The heart of the session. A fresh agent with no context should be able to read this file alone and run the loop effectively. Invest time making it excellent.
# 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=value` 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 — evaluation harness, data prep, etc.>
## Constraints
<Hard rules: tests must pass, no new deps, fixed time budget, 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.>Update autoresearch.md periodically — especially "What's Been Tried" — so resuming agents have full context.
autoresearch.sh
Bash script that runs the benchmark and outputs structured metrics.
#!/bin/bash
set -euo pipefail
# Pre-checks (fast, <1s — catch syntax errors early)
python3 -c "import ast; ast.parse(open('train.py').read())"
# Run benchmark
uv run train.py > /tmp/autoresearch-output.log 2>&1
# Extract and output metrics as METRIC lines
val_bpb=$(grep "^val_bpb:" /tmp/autoresearch-output.log | awk '{print $2}')
echo "METRIC val_bpb=$val_bpb"Rules:
- Use
set -euo pipefail. - Output
METRIC name=valuelines to stdout (one per metric). The primary metric name must match what's documented inautoresearch.md. - Metric names: word chars, dots, or
µ(e.g.val_bpb,total_µs,bundle.size_kb). - Keep the script fast — every second is multiplied by hundreds of runs.
- For fast/noisy benchmarks (<5s), run multiple times inside the script and report the median.
- Update the script during the loop as needed.
autoresearch.checks.sh (optional)
Backpressure checks: tests, types, lint. Only create when constraints require correctness validation.
#!/bin/bash
set -euo pipefail
pnpm test --run --reporter=dot 2>&1 | tail -50
pnpm typecheck 2>&1 | grep -i error || trueWhen this file exists:
- Run it after every passing benchmark (exit 0).
- If checks fail, log the experiment as
checks_failedand revert. - Check execution time does NOT affect the primary metric.
- Keep output minimal — suppress verbose progress, only show errors.
When this file does not exist, skip checks entirely.
The Experiment Loop
LOOP FOREVER. Never ask "should I continue?" — the user expects autonomous work.
Each iteration:
1. Formulate hypothesis: Based on prior results, source code understanding, and any ideas in autoresearch.ideas.md, choose what to try next. 2. Edit code: Modify the in-scope files. Make a single, focused change per experiment. 3. Commit: git add -A && git commit -m "<short description of what this experiment tries>" 4. Run benchmark:
timeout 600 ./autoresearch.sh > run.log 2>&1If the command times out or crashes, treat it as a failure. 5. Parse metrics: Extract METRIC lines from the output:
grep '^METRIC ' run.logIf no METRIC lines found, the run crashed — read tail -50 run.log for the error. 6. Run checks (if autoresearch.checks.sh exists and benchmark passed):
timeout 300 ./autoresearch.checks.sh > checks.log 2>&17. Evaluate and log:
- Improved (primary metric better than best so far) → status
keep. The commit stays. - Worse or equal → status
discard. Revert: stage autoresearch files first, then reset. - Crash (benchmark failed) → status
crash. Fix if trivial, otherwise revert and move on. - Checks failed → status
checks_failed. Revert.
8. Log to JSONL: Append one line to autoresearch.jsonl:
{"run":1,"commit":"a1b2c3d","metric":0.9979,"metrics":{"val_bpb":0.9979,"peak_vram_mb":45060.2},"status":"keep","description":"baseline","timestamp":1711036800000,"confidence":null}9. On discard/crash/checks_failed — revert code changes:
# Preserve autoresearch session files, revert everything else
git add autoresearch.jsonl autoresearch.md autoresearch.sh autoresearch.ideas.md autoresearch.checks.sh 2>/dev/null || true
git checkout -- .
git clean -fd10. Check confidence: After 3+ runs, run the confidence script from the skill's installation directory:
bash "$(dirname "$(readlink -f "$0")")/scripts/confidence.sh"Or locate it via the skill path and run it directly. Interpret the score:
- >= 2.0x: Improvement is likely real (green).
- 1.0-2.0x: Above noise but marginal (yellow).
- < 1.0x: Within noise — consider re-running to confirm (red).
11. Update session: Periodically update autoresearch.md "What's Been Tried" section and run the summary script to review progress.
Repeat forever until interrupted.
JSONL Schema
Each line in autoresearch.jsonl is a JSON object:
| Field | Type | Description |
|---|---|---|
run | number | 1-indexed experiment count |
commit | string | Short git SHA (7 chars) |
metric | number | Primary metric value |
metrics | object | All metrics dict (primary + secondary) |
status | string | keep, discard, crash, or checks_failed |
description | string | What this experiment tried |
timestamp | number | Unix timestamp (ms) |
confidence | number or null | MAD-based confidence score (null if <3 runs) |
Resuming
When autoresearch.md exists in the working directory:
1. Read autoresearch.md for full context (objective, what's been tried, constraints). 2. Read autoresearch.jsonl to reconstruct state (best metric, run count, last segment). 3. Read git log --oneline -20 for recent commit history. 4. Check autoresearch.ideas.md if it exists — prune stale entries, experiment with promising ones. 5. Continue the loop from where it left off. Do not re-run the baseline.
Ideas Backlog
When you discover complex but promising optimizations you won't pursue right now, append them as bullets to autoresearch.ideas.md. Don't let good ideas get lost.
On resume, check this file — prune stale/tried entries, experiment with the rest. When all paths are exhausted, delete the file and write a final summary to autoresearch.md.
Loop Rules
See references/loop-rules.md for the full reference. Key rules:
- Primary metric is king. Improved → keep. Worse/equal → discard.
- Simpler is better. Remove code for equal perf = keep. Ugly complexity for tiny gain = discard.
- Don't thrash. Repeatedly reverting the same idea? Try something structurally different.
- Think longer when stuck. Re-read source files, reason about what the CPU/compiler/runtime is actually doing. Deep understanding beats random variation.
- Crashes: fix if trivial (typo, missing import), otherwise log and move on. Don't over-invest.
- NEVER STOP. The user may be away for hours. Keep going until interrupted.
User Messages During Experiments
If the user sends a message while an experiment is running, finish the current run-evaluate-log cycle first, then incorporate their feedback in the next iteration.
Loop Rules Reference
Core Principles
1. Autonomy: Never ask "should I continue?" or "is this a good stopping point?". The user expects you to run indefinitely until manually interrupted. They may be asleep, away, or working on something else.
2. Primary metric is king: The single primary metric (defined in autoresearch.md) determines keep/discard. Secondary metrics are logged for context but rarely affect the decision.
3. Simplicity criterion: All else being equal, simpler is better.
- Removing code for equal or better performance → always keep.
- Ugly complexity for a tiny gain → probably discard.
- A 0.001 improvement that adds 20 lines of hacky code? Not worth it.
- A 0.001 improvement from deleting code? Definitely keep.
Keep vs Discard Decisions
| Situation | Decision | Rationale |
|---|---|---|
| Metric improved | keep | Primary metric is king |
| Metric equal | discard | No improvement = no reason to keep complexity |
| Metric slightly worse but code much simpler | discard (usually) | Simplicity matters but metric still wins |
| Metric improved but confidence <1.0x | Re-run to confirm | May be noise, not real improvement |
| Crash (OOM, bug) | crash + revert | Log it and move on |
| Checks failed (tests, types) | checks_failed + revert | Correctness is a hard constraint |
| Metric improved but VRAM/memory exploded | Use judgment | Some increase is acceptable for meaningful gains |
Confidence Score Interpretation
After 3+ experiments, the confidence score compares the best improvement to the session noise floor using Median Absolute Deviation (MAD).
| Score | Meaning | Action |
|---|---|---|
| >= 2.0x | Improvement is likely real | Keep with confidence |
| 1.0-2.0x | Above noise but marginal | Keep, but note it's marginal |
| < 1.0x | Within noise | Re-run the same experiment to confirm before keeping |
| null | Insufficient data (<3 runs) | Keep/discard based on metric alone |
The score is advisory — it never auto-discards. Use it to decide whether to re-run for confirmation.
Crash Handling
- Trivial fix (typo, missing import, wrong variable name): Fix and re-run. Count as the same experiment.
- Fundamental issue (OOM, incompatible architecture, dependency missing): Log as
crash, revert, move on. - Repeated crashes on same idea: The idea is probably broken. Log it in "What's Been Tried" and try something different.
- Don't over-invest: More than 2-3 attempts to fix the same crash? Give up and move on.
When You're Stuck
Getting stuck is normal. The easy wins get found first; the remaining improvements require deeper insight.
1. Re-read the source files. You may have missed something on the first pass. 2. Study the profiling data. If the benchmark outputs timing breakdowns, analyze where time is actually spent. 3. Reason about fundamentals. What is the CPU/GPU/runtime actually doing? Where are the bottlenecks? What does the memory access pattern look like? 4. Review the git log. What combinations haven't been tried? What near-misses could be combined? 5. Check `autoresearch.ideas.md`. Are there complex ideas you deferred earlier? 6. Try radical changes. If incremental tweaks aren't working, consider architectural changes. 7. Read related code. Look at dependencies, similar implementations, papers referenced in comments.
Do NOT just try random variations. The best experiments come from understanding, not from brute force.
Don't Thrash
If you've reverted the same category of change 3+ times, stop trying that approach. Signs of thrashing:
- Toggling the same parameter back and forth.
- Making the same architectural change with minor variations.
- Repeatedly hitting the same OOM/crash.
When thrashing, step back and try something structurally different.
Resume Protocol
When resuming from a context reset or new conversation:
1. Read autoresearch.md — this has the full session context. 2. Read autoresearch.jsonl — reconstruct run count, best metric, what's been tried. 3. Read git log --oneline -20 — see recent commits and their status. 4. Check autoresearch.ideas.md — prune stale entries, queue promising ones. 5. Do NOT re-run the baseline. Continue from the current best. 6. Update autoresearch.md "What's Been Tried" if the previous agent left it stale.
Ideas Backlog Management
autoresearch.ideas.md is an append-only scratchpad for promising but complex ideas.
- When to add: You discover an optimization that needs more than a simple code edit (multi-step refactor, needs profiling data first, requires understanding a dependency).
- When to prune: On resume, delete entries that have already been tried or are no longer relevant.
- When to delete the file: All ideas exhausted. Write a final summary to
autoresearch.mdinstead.
Session File Protection
These files must NEVER be reverted during a discard/crash:
autoresearch.jsonl— append-only experiment logautoresearch.md— session documentautoresearch.sh— benchmark scriptautoresearch.checks.sh— correctness checksautoresearch.ideas.md— ideas backlog
Always stage these files before running git checkout -- . to revert.
Experiment Pacing
- One focused change per experiment. Don't combine unrelated changes — if the result improves, you won't know which change helped.
- Exception: If two changes are tightly coupled (e.g. changing model width requires adjusting learning rate), combine them.
- Batch reverts are OK: If 3 consecutive experiments all discard, that's fine. Each was a valid hypothesis that didn't pan out.
#!/bin/bash
# Compute MAD-based confidence score from autoresearch.jsonl
# Usage: confidence.sh [path/to/autoresearch.jsonl]
# Exit codes: 0 = success, 1 = insufficient data, 2 = file not found
set -euo pipefail
JSONL_FILE="${1:-autoresearch.jsonl}"
if [ ! -f "$JSONL_FILE" ]; then
echo "Error: $JSONL_FILE not found" >&2
exit 2
fi
python3 -c "
import json, sys, statistics
jsonl_file = sys.argv[1]
# Parse all experiment results (skip config lines)
results = []
with open(jsonl_file) as f:
for line in f:
line = line.strip()
if not line:
continue
obj = json.loads(line)
if 'status' not in obj:
continue
results.append(obj)
if len(results) < 3:
print(f'Insufficient data: {len(results)} runs (need >= 3)')
sys.exit(1)
# Find the current segment (highest segment number, or 0 if no segment field)
max_segment = max((r.get('segment', 0) for r in results), default=0)
segment_results = [r for r in results if r.get('segment', 0) == max_segment]
if len(segment_results) < 3:
print(f'Insufficient data in current segment: {len(segment_results)} runs (need >= 3)')
sys.exit(1)
# Extract metric values (exclude <= 0 for crash entries)
values = [r['metric'] for r in segment_results if r['metric'] > 0]
if len(values) < 3:
print(f'Insufficient non-zero metric values: {len(values)} (need >= 3)')
sys.exit(1)
# Compute MAD
median_val = statistics.median(values)
deviations = [abs(v - median_val) for v in values]
mad = statistics.median(deviations)
if mad == 0:
print('MAD is zero — no measurable noise in the data')
sys.exit(0)
# Find baseline (first run in segment) and best kept result
baseline = segment_results[0]
baseline_metric = baseline['metric']
# Determine direction from whether kept results improve up or down
kept = [r for r in segment_results if r['status'] == 'keep' and r['metric'] > 0]
if not kept:
print(f'No kept results in current segment')
print(f'Baseline: {baseline_metric}')
print(f'MAD: {mad:.6f}')
sys.exit(0)
# Infer direction: if best kept < baseline, lower is better; otherwise higher
best_kept = min(kept, key=lambda r: r['metric'])
worst_kept = max(kept, key=lambda r: r['metric'])
if best_kept['metric'] < baseline_metric:
# Lower is better
direction = 'lower'
best = best_kept
else:
# Higher is better
direction = 'higher'
best = worst_kept
best_metric = best['metric']
delta = abs(best_metric - baseline_metric)
confidence = delta / mad
# Color interpretation
if confidence >= 2.0:
level = 'LIKELY REAL'
elif confidence >= 1.0:
level = 'MARGINAL'
else:
level = 'WITHIN NOISE'
total = len(segment_results)
kept_count = len(kept)
discarded = sum(1 for r in segment_results if r['status'] == 'discard')
crashed = sum(1 for r in segment_results if r['status'] in ('crash', 'checks_failed'))
print(f'Confidence: {confidence:.2f}x ({level})')
print(f'Baseline: {baseline_metric}')
print(f'Best: {best_metric} ({direction} is better)')
print(f'Delta: {delta:.6f}')
print(f'MAD: {mad:.6f}')
print(f'Runs: {total} total, {kept_count} kept, {discarded} discarded, {crashed} crashed')
" "$JSONL_FILE"
#!/bin/bash
# Print autoresearch experiment summary dashboard
# Usage: summary.sh [path/to/autoresearch.jsonl]
# Exit codes: 0 = success, 1 = no data, 2 = file not found
set -euo pipefail
JSONL_FILE="${1:-autoresearch.jsonl}"
if [ ! -f "$JSONL_FILE" ]; then
echo "Error: $JSONL_FILE not found" >&2
exit 2
fi
python3 -c "
import json, sys, datetime
jsonl_file = sys.argv[1]
results = []
with open(jsonl_file) as f:
for line in f:
line = line.strip()
if not line:
continue
obj = json.loads(line)
if 'status' not in obj:
continue
results.append(obj)
if not results:
print('No experiment results found.')
sys.exit(1)
# Find current segment
max_segment = max((r.get('segment', 0) for r in results), default=0)
segment_results = [r for r in results if r.get('segment', 0) == max_segment]
# Stats
total = len(segment_results)
kept = [r for r in segment_results if r['status'] == 'keep']
discarded = sum(1 for r in segment_results if r['status'] == 'discard')
crashed = sum(1 for r in segment_results if r['status'] == 'crash')
checks_failed = sum(1 for r in segment_results if r['status'] == 'checks_failed')
# Baseline and best
baseline = segment_results[0] if segment_results else None
baseline_metric = baseline['metric'] if baseline else 0
if kept:
# Infer direction
best_low = min(kept, key=lambda r: r['metric'])
best_high = max(kept, key=lambda r: r['metric'])
if best_low['metric'] < baseline_metric:
best = best_low
direction = 'lower'
else:
best = best_high
direction = 'higher'
best_metric = best['metric']
if baseline_metric != 0:
pct = ((best_metric - baseline_metric) / abs(baseline_metric)) * 100
pct_str = f'{pct:+.2f}%'
else:
pct_str = 'N/A'
else:
best_metric = baseline_metric
direction = 'N/A'
pct_str = 'N/A'
# Header
print('=' * 72)
print('AUTORESEARCH SUMMARY')
print('=' * 72)
print(f'Runs: {total} total | {len(kept)} kept | {discarded} discarded | {crashed} crashed | {checks_failed} checks_failed')
print(f'Baseline: {baseline_metric}')
print(f'Best: {best_metric} ({pct_str}, {direction} is better)')
print('-' * 72)
# Table header
print(f'{\"#\":>4} {\"Commit\":>7} {\"Metric\":>12} {\"Status\":<14} Description')
print(f'{\"─\"*4} {\"─\"*7} {\"─\"*12} {\"─\"*14} {\"─\"*30}')
for r in segment_results:
run = r.get('run', '?')
commit = r.get('commit', '???????')[:7]
metric = r['metric']
status = r['status']
desc = r.get('description', '')[:40]
# Mark best with star
marker = ''
if kept and r.get('commit') == best.get('commit') and r.get('run') == best.get('run'):
marker = ' *'
print(f'{run:>4} {commit:>7} {metric:>12.6f} {status:<14} {desc}{marker}')
print('-' * 72)
# Confidence (if enough data)
if len(segment_results) >= 3:
import statistics
values = [r['metric'] for r in segment_results if r['metric'] > 0]
if len(values) >= 3:
median_val = statistics.median(values)
deviations = [abs(v - median_val) for v in values]
mad = statistics.median(deviations)
if mad > 0 and kept and baseline_metric > 0:
delta = abs(best_metric - baseline_metric)
conf = delta / mad
if conf >= 2.0:
level = 'LIKELY REAL'
elif conf >= 1.0:
level = 'MARGINAL'
else:
level = 'WITHIN NOISE'
print(f'Confidence: {conf:.2f}x ({level})')
elif mad == 0:
print('Confidence: N/A (zero noise)')
else:
print('Confidence: N/A')
else:
print('Confidence: N/A (insufficient non-zero values)')
else:
print(f'Confidence: N/A (need >= 3 runs, have {len(segment_results)})')
print('=' * 72)
" "$JSONL_FILE"