Agent skill
autoresearch
Run or resume an autonomous benchmark loop for perf, size, quality, or any metric-driven optimization in OpenCode.
Install this agent skill to your Project
npx add-skill https://github.com/gmcabrita/dotfiles/tree/main/.config/opencode/skills/autoresearch
SKILL.md
Autoresearch
Autonomous experiment loop: try ideas, measure, keep wins, discard misses, keep going.
Tools
scaffold_autoresearch- create canonical files underautoresearch/init_experiment- set session name, primary metric, unit, directionrun_experiment- run benchmark command, parseMETRIC name=value, cache resultlog_experiment- log cached run, auto-commitkeep, appendautoresearch/autoresearch.jsonlautoresearch_status- summarize current segment and cached run
run_experiment always adds wall_clock_s if the command does not emit it.
Folder Layout
Always keep autoresearch artifacts under autoresearch/.
Create the directory first if missing.
autoresearch/autoresearch.mdautoresearch/autoresearch.shautoresearch/autoresearch.checks.shautoresearch/autoresearch.ideas.mdautoresearch/autoresearch.jsonlautoresearch/autoresearch.last-run.json
Do not create root-level autoresearch.* files.
Safety First
This loop discards losing changes. Only run it in a clean, disposable branch/worktree.
- First check
git status --short. - If dirty, do not start in place unless user explicitly wants that risk.
- Prefer a dedicated branch like
autoresearch/<goal>-<date>.
Setup
- Infer or gather:
- goal
- benchmark command
- primary metric name
- direction (
lowerorhigher) - files in scope
- hard constraints
- Read the relevant files before changing anything.
- Call
scaffold_autoresearchto createautoresearch/autoresearch.md,autoresearch/autoresearch.sh, and optional extras. - If constraints require correctness gates, include
checks_commandso the tool also createsautoresearch/autoresearch.checks.sh. - Call
init_experiment. - Run the baseline with
run_experiment. - Log it with
log_experiment. - Start looping immediately.
Do not hand-write the initial scaffold when the tool can create it.
If autoresearch/autoresearch.jsonl and autoresearch/autoresearch.md already exist, resume instead of reinitializing unless the target changed.
Required Files
autoresearch/autoresearch.md
Keep it strong enough that a fresh agent can resume from it alone.
Include:
- objective
- primary + secondary metrics
- exact benchmark command
- files in scope
- off-limits files
- constraints
- what has been tried
Update it as the loop learns.
autoresearch/autoresearch.sh
Use set -euo pipefail.
Rules:
- keep it fast
- fail fast on obvious setup issues
- emit
METRIC name=valuelines - emit the primary metric name exactly as configured in
init_experiment - keep output lean; errors matter more than chatter
Example:
#!/usr/bin/env bash
set -euo pipefail
value=$(pnpm test --run --reporter=dot >/tmp/autoresearch.out 2>&1; python3 scripts/extract_metric.py /tmp/autoresearch.out)
printf 'METRIC wall_clock_s=%s\n' "$value"
autoresearch/autoresearch.checks.sh
Optional backpressure checks.
Use when the user cares about tests, types, lint, correctness, or quality gates.
Rules:
set -euo pipefail- keep success output short
- fail loudly enough to debug
- do not print giant logs unless needed
If checks fail, log_experiment must use checks_failed.
Loop Rules
- Never stop to ask "should I continue?"
- Read
autoresearch/autoresearch.mdat session start and after compaction - Prefer structural ideas over random micro-tweaks
- Keep primary metric first; secondary metrics are guardrails
- If a run passes and improves materially, use
keep - If a run passes but loses, use
discard - If the benchmark crashes or times out, use
crash - If checks fail or time out after a passing benchmark, use
checks_failed - Do not invent metrics in
log_experiment; it uses the cachedrun_experimentresult keepauto-commits; do not manual-commit beforelog_experiment
Resume Flow
When resuming:
- call
autoresearch_status - read
autoresearch/autoresearch.md - skim recent
git log --oneline -10 - continue the loop
Reverting Losers
log_experiment does not revert files for you.
After discard, crash, or checks_failed, restore the worktree back to HEAD before the next attempt. Only do this in the clean dedicated branch/worktree from the safety step. Remove any untracked loser files you created.
Ideas Backlog
If you find promising but deferred ideas, append bullets to autoresearch/autoresearch.ideas.md.
On resume:
- prune stale ideas
- keep good ones
- delete the file when exhausted
Monitoring
There is no live Pi-style widget here.
Use:
autoresearch_statusautoresearch/autoresearch.jsonlautoresearch/autoresearch.md
When To Reinitialize
Call init_experiment again only when the target changed enough that the baseline should reset:
- new benchmark
- new primary metric
- new direction
- new optimization domain
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
autoresearch-finalize
Finalize an autoresearch session into clean, reviewable branches. Use when asked to "finalize autoresearch", "clean up experiments", or "prepare autoresearch for review".
autoresearch-create
Set up and run an autonomous experiment loop for any optimization target. Gathers what to optimize, then starts the loop immediately. Use when asked to "run autoresearch", "optimize X in a loop", "set up autoresearch for X", or "start experiments".
update-changelog
Read this skill before updating changelogs
web-browser
Allows to interact with web pages by performing actions such as clicking buttons, filling out forms, and navigating links. It works by remote controlling Google Chrome or Chromium browsers using the Chrome DevTools Protocol (CDP). When Claude needs to browse the web, it can use this skill to do so.
summarize
Fetch a URL or convert a local file (PDF/DOCX/HTML/etc.) into Markdown using `uvx markitdown`, optionally it can summarize
commit
Read this skill before making git commits
Didn't find tool you were looking for?