Receber por email
← Voltar para o catálogo

autoresearch

Autonomous experiment loop: edit code, commit, run benchmark, extract metrics, keep improvements or revert, repeat forever. Use this skill when the user asks to "run autoresearch", "start an experiment loop", "optimize a metric autonomously", "autonomous experiments", "autoresearch setup", "benchmark loop", "keep/discard experiments", "optimize test speed", "optimize bundle size", "optimize build

12estrelas
Atualizado há 6 meses

Ver no GitHub ↗ Licença: MIT

Como adicionar

/plugin marketplace add proyecto26/autoresearch-ai-plugin

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/autoresearch-proyecto26/svg)](https://www.skillteca.com.br/skills/autoresearch-proyecto26)

Skills relacionadas

Ver todas de Pesquisa e Web →

Alerta por categoria

Receba novas skills de Pesquisa e Web toda segunda

1 email curto, só com as skills novas de Pesquisa e Web. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Autoresearch: Autonomous Experiment Loop

An autonomous optimization loop where Claude edits code, runs a benchmark, measures a metric, and keeps improvements or reverts — repeating forever until stopped.

Core Concept

The loop is simple: edit → commit → run → measure → keep or discard → repeat.

  • Primary metric is king. Lower (or higher, depending on direction) is better. Improved → keep the commit. Equal or worse → git revert.
  • State survives context resets via autoresearch.jsonl (append-only log) and autoresearch.md (living session document).
  • Domain-agnostic. Works for any measurable target: test speed, bundle size, LLM training loss, Lighthouse scores, build times, etc.
  • Be careful not to overfit to the benchmarks and do not cheat on the benchmarks. Optimize the real workload, not the measurement harness.

Setup Phase

When the user triggers autoresearch, gather the following (ask if not provided):

  1. Goal — what to optimize (e.g., "reduce unit test runtime")
  2. Command — the benchmark to run (e.g., pnpm test, uv run train.py)
  3. Primary metric — name, unit, and direction (lower or higher is better)
  4. Secondary metrics — optional additional metrics to track for tradeoff monitoring (e.g., memory, compile time)
  5. Files in scope — which files can be modified
  6. Constraints — time budget, off-limits files, correctness requirements

Optionally check for .claude/autoresearch-ai-plugin.local.md in the project root for persistent configuration:

---
enabled: true
max_iterations: 50
working_dir: "/path/to/project"
benchmark_timeout: 600
checks_timeout: 300
---

# Autoresearch Configuration

Additional context or notes for this project's autoresearch setup.
  • enabled — whether autoresearch is active (default: true)
  • max_iterations — stop after N experiments (default: 0 = unlimited)
  • working_dir — override directory for experiment files (default: current directory)
  • benchmark_timeout — benchmark timeout in seconds (default: 600)
  • checks_timeout — correctness checks timeout in seconds (default: 300)

If the file doesn't exist, use defaults. The file should be added to .gitignore (.claude/*.local.md).

Then execute these setup steps:

  1. Create a branch: git checkout -b autoresearch/<goal>-<date>
  2. Ensure session files are gitignored (critical — git revert will fail if autoresearch.jsonl is tracked):

``bash echo -e "autoresearch.jsonl\nrun.log" >> .gitignore git add .gitignore && git commit -m "autoresearch: add session files to gitignore" ``

  1. Read all files in scope thoroughly to understand the codebase
  2. Write autoresearch.md — the session document (see examples/autoresearch.md)
  3. Write autoresearch.sh — the benchmark script (see examples/autoresearch.sh)
  4. Optionally write autoresearch.checks.sh — correctness checks (tests, lint, types)
  5. Commit session files
  6. Run baseline: bash autoresearch.sh
  7. Parse metrics from output (lines matching METRIC name=value)
  8. Record baseline in autoresearch.jsonl (with "type":"config" header first, then baseline result)
  9. Begin the experiment loop

The Experiment Loop

LOOP FOREVER. Never ask "should I continue?" — just keep going.

The user might be asleep, away from the computer, or expects you to work indefinitely. If each experiment takes ~5 minutes, you can run ~12/hour, ~100 overnight. The loop runs until the user interrupts you, period.

Each iteration:

1. Read current git state and autoresearch.md
2. Choose an experimental change (informed by past results and ASI notes)
3. Edit files in scope
4. git add <files> && git commit -m "experiment: <description>"
5. Run: bash autoresearch.sh > run.log 2>&1
6. Parse METRIC lines from output
7. If autoresearch.checks.sh exists, run it (separate timeout, default 300s)
8. Decide: keep or discard
9. Log result to autoresearch.jsonl (include ASI annotations)
10. If discard/crash: git revert $(git rev-parse HEAD) --no-edit
11. Update autoresearch.md with learnings (every few experiments)
12. Repeat

Decision Rules

  • Metric improved → keep (commit stays, branch advances)
  • Metric equal or worse → discard (run git revert $(git rev-parse HEAD) --no-edit)
  • Crash or checks failed → discard (revert, note the failure in ASI)
  • Simpler code for equal perf → keep (removing complexity is a win)
  • Catastrophic secondary metric regression → consider discard even if primary improved (e.g., 1% speed gain but 10x memory usage)
  • If stuck → think deeper, try a different approach. Consult autoresearch.ideas.md if it exists. Re-read source files for new angles. Try combining previous near-misses. Try more radical changes. Read any papers or docs referenced in the code.

Simplicity Criterion

All else being equal, simpler is better. Weigh complexity cost against improvement magnitude:

  • A 0.001 improvement that adds 20 lines of hacky code? Probably not worth it.
  • A 0.001 improvement from deleting code? Definitely keep.
  • Equal performance with much simpler code? Keep.

Handling User Messages During Experiments

If the user sends a message while the loop is running:

  1. Finish the current experiment cycle (don't abandon mid-run)
  2. Address the user's feedback or question
  3. Resume the loop immediately after — do not wait for permission

Benchmark Timeout

  • Default benchmark timeout: 600 seconds (10 minutes)
  • If a run exceeds the timeout, kill it and treat as a crash
  • Checks timeout: 300 seconds (5 minutes), separate from benchmark

Don't Thrash

If 3 consecutive experiments fail or get discarded:

  1. Stop and think about why
  2. Re-read the source files for new angles
  3. Try a fundamentally different approach
  4. Consult autoresearch.ideas.md for untried ideas

Metric Output Format

Benchmark scripts output metrics as structured lines:

METRIC total_time=4.23
METRIC memory_mb=512
METRIC val_bpb=1.042

Parse these with the helper script at ${CLAUDE_SKILL_DIR}/scripts/parse-metrics.sh:

bash autoresearch.sh 2>&1 | bash ${CLAUDE_SKILL_DIR}/scripts/parse-metrics.sh

Secondary Metrics

Beyond the primary metric, output additional METRIC lines for tradeoff monitoring:

METRIC total_ms=4230        # primary
METRIC compile_ms=1200      # secondary — helps identify bottlenecks
METRIC memory_mb=512        # secondary — monitors resource usage
METRIC cache_hit_rate=0.85  # secondary — instrumentation data

Secondary metrics are tracked in the JSONL log and help guide future experiments, but they rarely affect keep/discard decisions (only discard if a catastrophic secondary regression accompanies a marginal primary improvement).

Output instrumentation data — phase timings, error counts, cache rates, domain-specific signals. This data guides the next iteration and helps identify where optimization effort should focus.

Actionable Side Information (ASI)

ASI is structured annotation per experiment that survives reverts. When code changes are discarded, only the description and ASI remain — making them the only structured memory of what happened.

Record ASI for every experiment:

{
  "hypothesis": "Reducing loop iterations by breaking early",
  "result": "Marginal speedup but code readability suffered",
  "next_action_hint": "Try vectorization instead of loop unrolling",
  "bottleneck": "Memory bandwidth on L2 cache misses"
}

ASI fields are free-form — use whatever keys are useful:

  • hypothesis — what you expected
  • result — what actually happened
  • next_action_hint — guidance for the next experiment
  • bottleneck — identified performance bottleneck
  • error_details — crash/failure diagnostics
  • Any other domain-specific observations

Logging to autoresearch.jsonl

Config Header (written once at setup)

{"type":"config","name":"Optimize unit test runtime","metricName":"total_ms","metricUn
Compartilhar X LinkedIn