Udit Goenka's AutoResearch

Autonomous goal-directed iteration for Claude Code
Inspired by Karpathy's autoresearch -- generalized to every domain

1.7k
GitHub Stars
9
Commands
v1.8
Current Release

github.com/uditgoenka/autoresearch

ELI5

Explain Like I'm Five: the simple version

The Robot Chef Analogy

Imagine you have a robot chef that keeps trying to make your cookie recipe better:

1. You set the goal

"Make the cookies taste better" -- you give the robot a clear target

2. It tries ONE change

A little more sugar, a little less flour -- one thing at a time

3. It tastes the result

Better? Keep it. Worse? Undo it. Then try something new.

That's AutoResearch in a nutshell: Set a goal, let the AI try thousands of tiny improvements, keep the wins, throw away the fails -- all while you sleep.

Where Did This Idea Come From?

In March 2026, Andrej Karpathy (famous AI researcher) showed the world something cool:

Karpathy's Version

  • One Python file (630 lines)
  • AI trains neural networks overnight
  • 700 experiments, 20 discoveries, 11% speedup
  • Needs expensive GPU hardware
  • Only works for AI training

Udit's AutoResearch

  • Claude Code skill (9 commands)
  • AI improves anything measurable
  • Code, docs, security, marketing, SEO...
  • No special hardware needed
  • Works for any domain

Karpathy proved the concept works. Udit made it work everywhere.

The Magic Formula

"Set the GOAL --> Claude runs the LOOP --> You wake up to results"
Modify
→
Verify
→
Keep or Discard
→
Repeat
↺

The secret sauce: constraints enable autonomy. By narrowing what the AI can change and giving it a clear number to optimize, it can safely experiment forever without breaking things.

What Can You Actually Do With It?

Improve Code
Test coverage, performance, bundle size
Find Bugs
Systematic scientific debugging
Security Audit
STRIDE threats, OWASP Top 10
Ship Products
PRs, deploys, content, campaigns
Write Docs
Auto-generate, validate, maintain
Predict Issues
Multi-expert analysis with debate

If you can measure it, AutoResearch can improve it. Tests pass/fail? A score going up? Errors going down? That's enough.

Full Technical Deep Dive

Architecture, protocols, code patterns, and implementation details

Repository Architecture

autoresearch/
  claude-plugin/
    commands/
      autoresearch.md      # core loop
      autoresearch/
        debug.md           # 8 subcommands
        fix.md
        learn.md
        plan.md
        predict.md
        scenario.md
        security.md
        ship.md
    skills/
      autoresearch/
        SKILL.md           # main skill def
        references/
          autonomous-loop-protocol.md
          results-logging.md
          core-principles.md
          *-workflow.md    # 8 workflows
  guide/                   # docs + walkthroughs
  scripts/                 # release tooling

Key Design Decisions

  • Pure Markdown -- the entire system is defined in .md files, no compiled code
  • Claude Code Skill -- installs via plugin marketplace or manual copy
  • Reference separation -- core protocol, logging spec, and workflows are isolated reference docs
  • Language: Shell -- only scripting is for release automation

Total code: ~0 lines of traditional code. The "program" is a set of markdown instructions that Claude Code interprets as behavior.

The Core Equation

AGENT + CONSTRAINED_SCOPE + SCALAR_METRIC + FAST_VERIFICATION
  = AUTONOMOUS_IMPROVEMENT

Seven Universal Principles

  • Constraints enable -- limits create focus
  • Strategy != tactics -- humans set direction; AI executes
  • Mechanical metrics -- numbers, never feelings
  • Fast verification -- enables bold exploration
  • Iteration costs shape behavior
  • Git = memory -- commits encode experiments
  • Honest limits -- system knows its boundaries

Required Configuration

FieldPurpose
GoalWhat to optimize
ScopeFile globs to modify
MetricNumber to track
DirectionHigher or lower = better
VerifyShell cmd producing metric
Guard(optional) Regression check

The 8-Phase Iteration Loop

Phase 0
Prechecks
→
Phase 1
Review
→
Phase 2
Ideate
→
Phase 3
Modify
→
Phase 4
Commit
→
Phase 5
Verify
→
Phase 6
Decide
→
Phase 7
Log

Phase 0: Precondition Checks

  • Clean git working tree?
  • No lock files or detached HEAD?
  • No interfering hooks?
  • Baseline metric established (iteration #0)

Phase 1: Rebuild Awareness

  • Read all in-scope files
  • Parse git log --oneline -20
  • Read results log for pattern recognition

Phase 2: Strategic Selection

Priority order when choosing next experiment:

  • Crash fixes -- highest priority
  • Success exploitation -- extend what worked
  • Exploration -- try untested approaches
  • Combination -- merge successful changes
  • Simplification -- less code, same result
  • Radical experiments -- last resort

Git as Memory

The most elegant insight: git history IS the agent's brain. No database, no vector store -- just commits.

Commit = Experiment

# Every change gets committed BEFORE verify
git add <specific-files>  # never git add -A
git commit -m "experiment: add batch norm"

# On failure: revert preserves history
git revert HEAD  # NOT git reset --hard

# Reading memory before each iteration
git log --oneline -20
git show <commit-hash> --stat

Why Revert, Not Reset?

  • git revert preserves the failed attempt in history
  • Agent can later read why something failed
  • git reset --hard destroys the lesson
  • Pattern recognition across 100s of commits

Key rule: "Git IS the memory. After rollbacks, state may differ from what you expect." -- The agent always re-reads before acting.

Results Logging Protocol

Every experiment is tracked in autoresearch-results.tsv (gitignored):

# direction: higher
iteration	commit	metric	delta	guard	status	description
0	a1b2c3d	72.3	-	pass	baseline	Initial measurement
1	e4f5g6h	74.1	+1.8	pass	keep	Add caching to hot path
2	-	71.9	-0.4	-	discard	Inline function calls
3	i7j8k9l	76.5	+2.4	pass	keep	Batch DB queries
4	-	76.5	+0.0	-	discard	Add connection pooling
5	-	ERR	-	-	crash	Async refactor (syntax)

Status Categories

keepMetric improved, guard passed
discardSame/worse, reverted
crashVerification failed entirely
no-opNo measurable change
hook-blockedPre-commit hook rejected

Pattern Recognition

  • Summary every 10 iterations
  • Cross-references keeps with descriptions
  • 5 consecutive discards triggers stuck-state escalation
  • Agent reads log in Phase 1 to avoid repeating failures

Safety Mechanisms

Guard Commands

Optional parallel check that prevents regressions:

# Metric improves BUT guard fails?
# System tries to rework (max 2 attempts)

if metric_improved && guard_failed:
    # Attempt 1: modify implementation
    # (NEVER modify tests/guard)
    rework_change()
    if guard_still_fails:
        # Attempt 2: different approach
        rework_change()
        if guard_still_fails:
            git_revert()  # discard entirely

Atomicity Enforcement

  • One logical change per iteration
  • Must pass the "one-sentence test"
  • Changes spanning 5+ files trigger re-evaluation

Crash Recovery

  • Syntax errors: 3 auto-fix attempts
  • Runtime exceptions: revert + retry differently
  • Resource exhaustion: graceful degradation
  • Infinite loops: timeout detection
  • Dependency failures: revert + skip

Noisy Metric Handling

For volatile metrics (benchmarks, Lighthouse):

  • Multi-run verification with median
  • Minimum delta thresholds
  • Confirmation runs after improvements
  • Environment pinning

Stuck-State Escalation

After 5 consecutive discards, the agent enters recovery mode with an escalating strategy:

Level 1: Re-read Everything

Fresh read of all in-scope files, review the goal, analyze result log patterns

Level 2: Combine Successes

Merge successful prior changes from history that may compound together

Level 3: Try the Opposite

Invert assumptions -- if adding complexity failed, try simplifying

Level 4: Radical Architecture

Attempt fundamentally different approaches -- structural redesign

Unbounded mode rule: "NEVER STOP. NEVER ASK IF YOU SHOULD CONTINUE." -- the loop only ends via user interrupt or iteration limit.

The 9 Commands

CommandPurposeKey Feature
/autoresearchCore autonomous loopUnbounded or N iterations
:planGoal-to-config wizard7 interactive gates with validation
:securitySTRIDE + OWASP auditRed-team personas, code evidence
:shipUniversal shipping8-phase deploy for any deliverable
:debugScientific bug-hunting7 investigation techniques
:fixError repair loopLoops until 0 errors remain
:scenarioEdge-case exploration12 dimensions of scenario analysis
:predictMulti-persona analysis5 experts debate with anti-herd safeguards
:learnDocumentation engineScout, generate, validate-fix cycle

Commands are chainable: --chain debug,fix,ship lets predict hand off findings to debug, then fix, then ship.

/autoresearch:security

Comprehensive autonomous security audit using industry frameworks:

STRIDE Threat Model

  • Spoofing identity
  • Tampering with data
  • Repudiation of actions
  • Information disclosure
  • Denial of service
  • Elevation of privilege

Red-Team Personas

  • Security Adversary
  • Supply Chain Attacker
  • Insider Threat
  • Infrastructure Attacker

Composite Metric

score = (owasp_tested/10) * 50
      + (stride_tested/6)  * 30
      + min(findings, 20)

Output Structure

security/YYMMDD-HHMM-slug/
  overview.md
  threat-model.md
  attack-surface-map.md
  findings.md
  owasp-coverage.md
  dependency-audit.md
  recommendations.md
  security-audit-results.tsv

Flags

--diff delta mode | --fix auto-fix critical | --fail-on CI gate

/autoresearch:predict

Multi-persona swarm analysis: independent experts debate and reach consensus.

Recon
→
Personas
→
Independent
Analysis
→
Structured
Debate
→
Consensus
→
Report

Expert Personas

  • Architect -- system design perspective
  • Security Analyst -- threat surface
  • Performance Engineer -- bottlenecks
  • Reliability Engineer -- failure modes
  • Devil's Advocate -- mandatory dissent

Anti-herd mechanism: mandatory dissent + flip-rate monitoring + entropy detection prevent groupthink.

Adversarial Variant

With --adversarial flag:

  • Red Team vs Blue Team
  • Insider Threat persona
  • Supply Chain attacker
  • Judge synthesizer

Chaining

# Predict finds issues, debug hunts them,
# fix resolves them
/autoresearch:predict \
  --chain debug,fix \
  --depth deep

Ship, Debug, and Fix Workflows

/autoresearch:ship

8-phase universal shipping workflow:

Identify Inventory Checklist Prepare Dry-run Ship Verify Log

Supports: code PRs, releases, deployments, content, marketing emails, campaigns, sales, research, design

ship_score = (passing/total)*80
  + (dry_run_passed? 15:0)
  + (no_blockers?    5:0)
# Score 100 = ready; <80 = not shippable

/autoresearch:debug

7 investigation techniques:

  • Binary search isolation
  • Differential analysis
  • Minimal reproduction
  • Trace execution
  • Pattern matching
  • Backward reasoning
  • Collaborative problem-solving

/autoresearch:fix

Iterative repair loop that auto-detects broken states (tests, types, lint, builds). Loops until zero errors remain. Prioritizes blockers first.

Scenario & Learn Commands

/autoresearch:scenario

Explores edge cases across 12 dimensions:

1. Happy path7. Temporal 2. Error conditions8. Data variation 3. Edge cases9. Permissions 4. Abuse vectors10. Integrations 5. Scale behavior11. Recovery 6. Concurrency12. State transitions
metric = scenarios*10 + edge_cases*15
       + (dimensions/12)*30
       + unique_actors*5

Flags: --domain --depth --focus --format

/autoresearch:learn

Autonomous documentation engine with 4 modes:

initGenerate all docs from scratch
updateRefresh for code changes
checkRead-only health assessment
summarizeQuick inventory + summary

Lifecycle: Scout → Analyze → Map → Generate → Validate → Fix (max 3 retries) → Finalize → Log

Fully dynamic: no hardcoded doc list. Scans for existing docs, detects project type, only generates relevant files (e.g., deploy guide only if deploy config exists).

The Plan Wizard

/autoresearch:plan converts a plain-language goal into a validated, executable config through 7 mechanical gates:

Goal
Capture
→
Analyze
Codebase
→
Scope
Globs
→
Metric
Define
→
Direction
↑ or ↓
→
Verify
Dry-run
→
Launch

Critical Validation Gates

  • Scope must resolve to at least 1 real file
  • Metric must be mechanical (numeric output)
  • Verify command must pass a dry-run on current codebase
  • No subjective assessments allowed

Example Session

# User types:
/autoresearch:plan
Goal: Reduce bundle size below 200KB

# Wizard auto-detects:
Stack: React + Webpack
Scope: src/**/*.{ts,tsx}
Metric: Bundle size (KB)
Direction: lower
Verify: npm run build && stat dist/
Guard: npm test

Karpathy vs Claude AutoResearch

Both implement the same core equation. The divergence is depth vs. breadth:

DimensionKarpathyClaude AutoResearch
ScopeSingle file (train.py, 630 LOC)Any file pattern via glob
DomainML training onlyCode, content, security, marketing...
Commands1 (run the script)9 specialized subcommands
HardwareNVIDIA GPU + CUDA requiredNo special hardware
Metricsval_bpb (fixed)User-defined, unlimited
SetupManual program.md editingInteractive 7-step wizard
RollbackDestructive (git reset)Preserves history (git revert)
SafetyNoneGuard cmds, crash recovery, rework
Speed~12 experiments/hour (5 min train)Up to ~360/hour (fast verifiers)
Stars26,000 (1 week)1,700 (9 days)

Domain Adaptations

The same loop pattern, configured differently for each domain:

DomainScopeMetricVerify Command
Backendsrc/**/*.tsTest coverage %npm test
Frontendsrc/components/**Lighthouse scorenpx lighthouse
ML Trainingtrain.pyval_loss / bpbuv run train.py
PerformanceTarget filesBenchmark (ms)npm run bench
Content/SEOcontent/*.mdReadability scoreCustom script
SecurityAPI/auth/middlewareOWASP + STRIDE + findings:security
RefactoringModuleTests + LOC reducednpm test && wc -l
Documentationdocs/*.mdValidation %:learn

The insight: any domain with a constrained scope and a mechanical metric can be autonomously improved. The framework is the same; only the config changes.

Getting Started

Installation

# Option 1: Plugin marketplace
/plugin marketplace add uditgoenka/autoresearch
/plugin install autoresearch@autoresearch

# Option 2: Manual
git clone github.com/uditgoenka/autoresearch
cp -r claude-plugin/* .claude/

Quick Start Examples

# Improve test coverage overnight
/autoresearch
Goal: Increase test coverage to 90%
Scope: src/**/*.ts
Verify: npm test -- --coverage

# Security audit with auto-fix
/autoresearch:security --diff --fix
Iterations: 15

# Debug a flaky endpoint
/autoresearch:debug
Issue: API returns 500 intermittently
Scope: src/api/**

Real-World Scenario Walkthroughs

The repo includes 10 detailed guides in guide/scenario/:

  • Healthcare scheduling optimization
  • Real-time messaging platform
  • Multi-tenant SaaS onboarding
  • Fintech transaction processing
  • IoT device management
  • E-commerce recommendation engine
  • Social media content pipeline
  • And more...

CI/CD integration: GitHub Actions and GitLab CI templates are included. Use --fail-on critical as a pipeline gate.

The Big Ideas

  • Constraints enable autonomy -- narrowing scope lets the agent run safely forever
  • Git is memory -- commits encode experiments; reverts encode lessons
  • Mechanical metrics only -- if a human has to judge it, the loop breaks
  • Atomic changes -- one experiment per iteration preserves causality
  • Domain-agnostic -- same loop for code, content, security, shipping, docs
"If you can measure it, AutoResearch can improve it."

github.com/uditgoenka/autoresearch · MIT License · v1.8.2