/sage:autoresearchfrom sage
Autonomously iterates toward a measurable outcome through repeated modify-verify cycles. Optimizes numeric metrics like bundle size, test coverage, or query time.
Ships in sage. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Autonomous iteration toward a measurable outcome. The agent modifies code, commits, runs a verify command, keeps improvements, reverts regressions — repeating until a target is hit, a budget is exhausted, or the user interrupts.
Core principles (from Karpathy's autoresearch pattern):
Before the loop can start, capture these (skip if already provided):
| Field | Required | Example |
|---|---|---|
| Goal | Yes | "Reduce bundle below 200KB" |
| Metric name | Yes | bundle_kb |
| Direction | Yes | lower or higher |
| Target | Optional | 200 |
| Verify command | Yes | pnpm build && measure.sh |
| Writable scope | Recommended | src/**/*.ts |
| Frozen scope | Recommended | package.json, *.lock |
| Per-run budget | Yes (default 120s) | 120 seconds |
| Max iterations | Optional | 100 |
| Termination | Auto | target if target given, else interrupt |
Present as a brief for user approval:
Sage: Autoresearch session configured.
Goal: [goal statement]
Metric: [name] ([direction]), target: [target or "none — runs until interrupted"]
Verify: [command]
Scope: writable [globs], frozen [globs]
Budget: [seconds]s per run, [max iterations or "unlimited"]
[A] Start — begin autonomous iteration
[R] Revise — change configuration
Each iteration follows 8 phases. Read references/loop-protocol.md
for per-phase detail.
| # | Phase | Actor | What happens |
|---|---|---|---|
| 1 | REVIEW | agent | Read current state, recent history (last 20 iterations from JSONL) |
| 2 | IDEATE | agent | Propose ONE change, ≤1 sentence. If stuck, load references/stuck-recovery.md |
| 3 | MODIFY | agent | Make the change. Stay within writable scope. |
| 4 | COMMIT | runtime | git add -A && git commit on autoresearch/<slug> branch |
| 5 | VERIFY | runtime | Run verify command with wall-clock budget |
| 6 | DECIDE | runtime | Parse METRIC, compare to best → keep / discard / crash |
| 7 | LOG | runtime+agent | Append JSONL, rebuild TSV, agent updates living doc |
| 8 | REPEAT | runtime | Check termination → loop or exit |
Decision rules (Phase 6):
crash, reset to HEADcrash, resetcrash, resetkeep, advance branchdiscard, resetAn optional Python runtime handles the deterministic phases (COMMIT, VERIFY,
DECIDE, LOG, REPEAT); the agent handles the creative phases (REVIEW, IDEATE,
MODIFY). The runtime was extracted from core into its own package in Phase 3
(like sage-memory) — install it with sage add xoai/sage-autoresearch.
Running the runtime — probe first, and degrade LOUDLY if it is absent (announce + log to decisions.md; never silently skip):
if python3 -c 'import autoresearch' 2>/dev/null; then
python3 -m autoresearch run --brief .sage/work/<slug>/brief.md --project .
else
echo "Sage: autoresearch runtime not installed — running in degraded (manual)"
echo "mode. For the deterministic runtime: sage add xoai/sage-autoresearch"
fi
Harness contract: The verify command must print METRIC name=number
to stdout. See references/harness-conventions.md.
All state lives in .sage/work/<YYYYMMDD-slug>/:
| File | Role |
|---|---|
brief.md | Configuration (goal, metric, scope, budget) |
autoresearch.md | Living doc — ideas tried, wins, dead ends |
autoresearch.jsonl | Structured log (one line per iteration) |
results.tsv | Human-readable view (derived from JSONL) |
runs/NNNN-*.log | Per-iteration stdout+stderr |
.autoresearch-state.json | Crash recovery state (not committed) |
On resume (new session, context reset, platform switch):
autoresearch.md for high-level contextautoresearch.jsonl for recent historygit log on the branchSee references/session-continuity.md for full protocol.
Session end: Store a structured summary in sage-memory:
Session start: Search sage-memory for priors on this repo + metric. Inject into IDEATE as "known-good starting points" and "known dead ends."
| Gate | When | Check |
|---|---|---|
| scope | After MODIFY | Changed files ⊆ writable, frozen untouched |
| pre-verify | After COMMIT | git status is clean |
| metric-parseable | After VERIFY | At least one METRIC line in stdout |
| budget | During VERIFY | Wall-clock ≤ per_run_seconds |
Gates are enforced by the runtime, not by prose. The agent cannot bypass them.
references/loop-protocol.md — per-phase inputs, outputs, failure modesreferences/metric-design.md — what makes a good metricreferences/harness-conventions.md — METRIC line contractreferences/stuck-recovery.md — escape local minimareferences/crash-handling.md — retry vs skip decision treereferences/session-continuity.md — resume protocolexamples/bundle-size/README.md (opens in a new tab)examples/bundle-size/autoresearch.sh (opens in a new tab)examples/bundle-size/brief.md (opens in a new tab)examples/prose-readability/README.md (opens in a new tab)examples/prose-readability/autoresearch.sh (opens in a new tab)examples/prose-readability/brief.md (opens in a new tab)examples/test-coverage/README.md (opens in a new tab)examples/test-coverage/autoresearch.sh (opens in a new tab)examples/test-coverage/brief.md (opens in a new tab)references/crash-handling.md (opens in a new tab)references/harness-conventions.md (opens in a new tab)references/loop-protocol.md (opens in a new tab)references/metric-design.md (opens in a new tab)references/session-continuity.md (opens in a new tab)references/stuck-recovery.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (xoai/sage) — no native marketplace selected
npx claudepluginhub p/xoai-sage33 skills in this plugin
/apiUse when designing, reviewing, or changing an HTTP, REST, or GraphQL API — endpoints, resource naming, error responses, pagination, versioning, idempotency, or API contracts between services./baasUse when building on Firebase, Supabase, or a similar Backend-as-a-Service — writing security rules, modeling data for client queries, deciding whether logic needs a serverless function, or wiring real-time and client-direct access./flutterUse when writing or reviewing Flutter or Dart code — widget structure, state management, rendering performance on Impeller, or adapting a screen to iOS and Android./mobileUse when building or reviewing a mobile app on any framework — offline behavior, scrolling and animation smoothness, touch targets, battery use, or platform conventions./nextjsUse when writing or reviewing a Next.js App Router project — choosing server or client components, fetching and caching data, server actions, or route handlers./reactUse when writing or reviewing React components — hooks, effects, component boundaries, state placement, or re-render problems in React 18 or 19.Other plugins' skills for the same job