AGR: Artificial General Research

VerifiedCaution

Autonomous iterative optimization framework for Claude Code. Generalizes Karpathy's autoresearch to any measurable problem with variance-aware acceptance and fresh-context-per-iteration.

Sby Skills Guide Bot
DevelopmentAdvanced
7/27/2026
Claude Code
#autonomous-optimization#autoresearch#optimization-loop#benchmarking#claude-code

Recommended for

Automated summary

An autonomous iterative optimization framework that runs successive headless Claude Code instances to improve any measurable metric, with correctness verification and variance handling.

Strengths

  • A fresh Claude Code instance per iteration (Ralph Loop), preventing context degradation across long sessions
  • Variance-aware acceptance: each sub-benchmark is checked independently, so any improvement above 5% is accepted as long as others do not regress
  • Artifact detection catches cases where every experiment shows the same "gain", revealing system noise instead of real optimization
  • Exhausted-approaches registry, supervisor audit of discarded runs, and progress visualization with per-component breakdown

Limitations

  • Requires Claude Code v2.1.72+ with the claude CLI in PATH and headless mode, so it does not work with other agents
  • Only applies to problems with a parseable numeric metric, a correctness guard, and modifiable code
  • Model invocation is disabled, so the skill must be triggered explicitly via /agr
When to use it

Use it when a goal reduces to a number to minimize or maximize and you want an autonomous loop to explore experiments over many hours.

When not to use it

Avoid it when the outcome cannot be reduced to a parseable metric with a correctness guard, or when the work is exploratory and qualitative.

Security analysis

Caution
Quality score84/100

The skill is a legitimate autonomous optimization framework and does not contain explicit destructive, exfiltration, or obfuscated payload instructions. However, it relies on powerful tools, headless agent spawning, git reset behavior, and long-running unattended execution, so it should be listed with caution and clear sandboxing/permission guidance.

Findings
  • •Autonomous loop spawns fresh `claude -p` instances with Bash, Write, Edit, and Agent permissions, allowing unattended command execution and code modification.
  • •The workflow uses git commit/reset to discard experiments; misconfiguration or running in a dirty repo could lose uncommitted work.
  • •The skill encourages an open-ended "Never stop" loop and supervisor pattern without explicit sandboxing, permission boundaries, or stop conditions beyond human interruption.
  • •Setup generates and executes benchmark and launcher scripts (`run_agr.sh`, `run_agr.ps1`) whose safety depends on user-provided metric/guard commands.
How this analysis is made

Examples

Speed optimization loop
/agr speed
Bundle size reduction
/agr "bundle size"
Latency with correctness guard
Set up an AGR optimization loop to minimize p95 latency of the search endpoint, keeping the full test suite passing as the guard.

name: agr description: "AGR: Artificial General Research — autonomous iterative optimization framework for Claude Code. Generalizes Karpathy's autoresearch to any measurable problem with variance-aware acceptance, correctness verification, and fresh-context-per-iteration (Ralph Loop). Use when setting up autoresearch, creating optimization loops, or autonomous research. Triggers on: autoresearch, AGR, auto research, optimization loop, auto optimize, artificial general research." argument-hint: [metric-to-optimize] disable-model-invocation: true allowed-tools: Bash, Read, Write, Edit, Glob, Grep, Agent

AGR: Artificial General Research

Autonomous iterative optimization for any measurable problem. Powered by Claude Code. Inspired by Karpathy's autoresearch.

Thank you Andrej Karpathy for everything you do for open source and the AI community. Your autoresearch showed that AI agents can run experiments overnight and wake up to a better system. AGR generalizes that vision beyond ML to any domain.

Also inspired by uditgoenka/autoresearch for the Guard/Metric separation and rework-on-failure patterns.

Requires: Claude Code v2.1.72+ (claude CLI in PATH)

What Is AGR?

AGR uses Claude Code's headless mode (claude -p) to run an autonomous optimization loop. Each iteration is a fresh Claude Code instance (no context degradation) that:

  1. Reads state from files (what's been tried, what worked, what's next)
  2. Picks ONE experiment to try
  3. Implements the change
  4. Measures Metric (the number to optimize) + checks Guard (must not break)
  5. Keeps if improved, reworks if guard failed, discards if no improvement
  6. Logs everything, updates strategy document
  7. Dies — next iteration starts with fresh context

Works for any problem where you can: measure a number + verify correctness + modify code.

Quick Start

/agr speed                    # set up speed optimization
/agr accuracy                 # set up accuracy optimization
/agr "bundle size"            # set up bundle size optimization

What Makes AGR Different

vs Karpathy's autoresearch

| Feature | Karpathy | AGR | |---|---|---| | Domain | ML training only | Any measurable problem | | Context | One long session (degrades) | Fresh per iteration (Ralph Loop) | | Correctness | Not verified | Checksums + guard command | | Variance handling | Not addressed | Per-benchmark variance analysis | | Failed ideas | Not tracked | Exhausted Approaches registry |

vs uditgoenka/autoresearch

| Feature | Udit | AGR | |---|---|---| | Variance analysis | Not explicit | Per-benchmark with artifact detection | | Context management | Long session | Fresh per iteration (Ralph Loop) | | Progress visualization | Not included | progress.png with breakdown chart | | Supervisor pattern | Not included | Audit discards, adjust strategy between batches | | Templates | Pure instructions | Generates benchmark.py, analysis.py, etc. |

Unique to AGR

  • Variance-aware acceptance: measurement noise in dominant benchmarks can mask real improvements. AGR checks each sub-benchmark independently and accepts if ANY improves >5% without others regressing.
  • Artifact detection: if ALL experiments show the same "improvement", it's system noise, not optimization.
  • Supervisor pattern: a parent agent or human monitors results.tsv, audits discards for hidden improvements, and adjusts strategy between batches.
  • Multi-benchmark visualization: progress.png shows total metric + per-component breakdown.

Setup Wizard

When invoked, follow these steps:

Step 1: Understand the Project

Ask the user:

  1. What to optimize? (speed, accuracy, size, cost, latency, score...)
  2. How to measure it? (Metric — must output a parseable number)
  3. How to verify correctness? (Guard — tests, checksums, golden outputs)
  4. What can the agent modify? (files, directories)
  5. What MUST NOT change? (benchmark, tests, data)
  6. Build step needed? (compile, bundle, deploy)
  7. Runtime path? (especially on Windows with multiple Pythons)

Step 2: Generate Files

See references/templates.md for complete templates.

{project}/
├── benchmark.py              ← Metric + Guard verification
├── baseline_checksums.json   ← Guard ground truth
├── program.md                ← Agent instructions (one iteration)
├── STRATEGY.md               ← Persistent brain
├── results.tsv               ← Experiment log (append-only)
├── analysis.py               ← Generates progress.png
├── run_agr.sh                ← Loop launcher (bash)
└── run_agr.ps1               ← Loop launcher (PowerShell)

Step 3: Baseline

  1. Run benchmark.py --save to establish baseline + save checksums
  2. Record baseline in results.tsv
  3. Mandatory dry-run validation: confirm benchmark produces parseable number
  4. Generate initial progress.png

Step 4: Launch

bash run_agr.sh --max 3   # start with 3 to validate

Core Principles

From Karpathy

  • Single metric — one number, lower (or higher) is better
  • Fixed benchmark — NEVER modified by the agent
  • Git keep/discard — commit before running, reset if no improvement
  • Log everything — failures prevent re-trying bad ideas
  • Never stop — runs until human interrupts
  • Simplicity criterion — complexity needs proportional improvement

From AGR

  • Fresh context per iteration (Ralph Loop) — no quality degradation
  • Metric + Guard separation — optimize speed without breaking tests
  • Rework before discard — if guard fails but metric improved, fix implementation (2 attempts)
  • Variance-aware acceptance — per-benchmark analysis beats total-only
  • Stuck detection (>5 discards) — re-read everything, try opposites, combine successes
  • Persistent strategy — STRATEGY.md with exhausted approaches registry
  • Supervisor audit — review discards for hidden improvements

Decision Logic

1. GUARD FAILED + Metric improved?   → REWORK (max 2 attempts)
2. GUARD FAILED + Metric didn't?     → DISCARD
3. GUARD PASSED + Metric improved?   → KEEP
4. GUARD PASSED + benchmark >5% up?  → KEEP (noise-masked improvement)
5. GUARD PASSED + code simpler?      → KEEP (simplification win)
6. None of above?                    → DISCARD
7. Build crashed?                    → Fix (3 attempts) or CRASH
8. Benchmark timeout?                → CRASH

Claude Code Flags

claude -p "$(cat program.md)" \
    --dangerously-skip-permissions \
    --max-turns 100 \
    --effort high

| Flag | Purpose | Recommendation | |---|---|---| | -p | Headless mode (fresh context) | Always use | | --dangerously-skip-permissions | Full autonomy | Required | | --max-turns 100 | Safety limit | 50 simple / 100 compiled | | --effort high | Deep reasoning | Use for optimization | | --max-budget-usd N | Cost cap | Optional | | -w / --worktree | Parallel experiments | Advanced |

See references/guide.md for complete documentation.

Compatibility

Designed for Claude Code (Anthropic CLI). Expanding to other AI coding agents (OpenCode, Cursor CLI, Aider) is pending — the core architecture is agent-agnostic, only loop scripts and CLI flags need adaptation.

Credits

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/agr-artificial-general-research-ms2s7by2' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/agr-artificial-general-research-ms2s7by2/download' --output '.skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md.part' && mv '.skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md.part' '.skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Bash, Read, Write, Edit, Glob, Grep, Agent

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md' && test -s '.skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/agr' && cp -R '.skill-downloads/agr-artificial-general-research-ms2s7by2' '.claude/skills/agr'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/agr-artificial-general-research-ms2s7by2'

openskills read 'agr-artificial-general-research-ms2s7by2'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/agr-artificial-general-research-ms2s7by2/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills