AGR runs autonomous optimization loops to improve systems, performance, or code through iterative experimentation.

Install

mkdir -p .claude/skills/agr && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11230" && unzip -o skill.zip -d .claude/skills/agr && rm skill.zip

Installs to .claude/skills/agr

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

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.
458 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Run autonomous optimization loops
  • Measure performance metrics
  • Verify correctness with guards
  • Log experiment results

How it works

It uses a headless Claude Code loop to iteratively test, measure, and improve a system based on a defined metric and guard.

Inputs & outputs

You give it
Metric to optimize
You get back
Optimized system performance

When to use agr

  • Automating code optimization experiments
  • Iteratively improving a system metric
  • Running autonomous research tasks
  • Optimizing performance benchmarks

About this skill

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

FeatureKarpathyAGR
DomainML training onlyAny measurable problem
ContextOne long session (degrades)Fresh per iteration (Ralph Loop)
CorrectnessNot verifiedChecksums + guard command
Variance handlingNot addressedPer-benchmark variance analysis
Failed ideasNot trackedExhausted Approaches registry

vs uditgoenka/autoresearch

FeatureUditAGR
Variance analysisNot explicitPer-benchmark with artifact detection
Context managementLong sessionFresh per iteration (Ralph Loop)
Progress visualizationNot includedprogress.png with breakdown chart
Supervisor patternNot includedAudit discards, adjust strategy between batches
TemplatesPure instructionsGenerates 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
FlagPurposeRecommendation
-pHeadless mode (fresh context)Always use
--dangerously-skip-permissionsFull autonomyRequired
--max-turns 100Safety limit50 simple / 100 compiled
--effort highDeep reasoningUse for optimization
--max-budget-usd NCost capOptional
-w / --worktreeParallel experimentsAdvanced

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

When not to use it

  • When metrics cannot be measured
  • When correctness cannot be verified

Prerequisites

Claude Code

Limitations

  • Requires measurable metric
  • Requires correctness guard

How it compares

It uses fresh context per iteration to prevent degradation, unlike long-session agents.

Compared to similar skills

agr side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
agr (this skill)05moReviewAdvanced
opencode-cli147moReviewAdvanced
computer-use-agents106moReviewAdvanced
crewai-developer28moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

opencode-cli

SpillwaveSolutions

This skill should be used when configuring or using the OpenCode CLI for headless LLM automation. Use when the user asks to "configure opencode", "use opencode cli", "set up opencode", "opencode run command", "opencode model selection", "opencode providers", "opencode vertex ai", "opencode mcp servers", "opencode ollama", "opencode local models", "opencode deepseek", "opencode kimi", "opencode mistral", "fallback cli tool", or "headless llm cli". Covers command syntax, provider configuration, Vertex AI setup, MCP servers, local models, cloud providers, and subprocess integration patterns.

14174

computer-use-agents

davila7

Build AI agents that interact with computers like humans do - viewing screens, moving cursors, clicking buttons, and typing text. Covers Anthropic's Computer Use, OpenAI's Operator/CUA, and open-source alternatives. Critical focus on sandboxing, security, and handling the unique challenges of vision-based control. Use when: computer use, desktop automation agent, screen control AI, vision-based agent, GUI automation.

1040

crewai-developer

smallnest

Comprehensive CrewAI framework guide for building collaborative AI agent teams and structured workflows. Use when developing multi-agent systems with CrewAI, creating autonomous AI crews, orchestrating flows, implementing agents with roles and tools, or building production-ready AI automation. Essential for developers building intelligent agent systems, task automation, and complex AI workflows.

213

autonomous-loops

Rajbharti06

Self-improvement loop patterns — eval → learn → improve cycles running without human input

00

extra-rlhf

veceno

Use for anything about the ExtraArena RLHF data-collection & training-orchestration environment (rlhf_env, port 8090, MCP stdio): running semi-synthetic battles, generating training traces, orchestrating the Extra-LR training pipeline, or playing battles as a sub-agent. Routes to three sub-skills —

00

npc

pipecat-ai

Runs an autonomous AI task agent as a game character. Resolves a character name to its UUID, then launches the `npc-run` script which connects to the game server and executes the given task using a Pipecat + Gemini LLM pipeline.

00

Search skills

Search the agent skills registry