Udit Goenka's Autoresearch Brings the Karpathy Loop to Any Codebase
uditgoenka/autoresearch brings Karpathy's overnight ML loop to any codebase, adding 13 commands, a 9-hook safety system, and a 95% token reduction in v2.1.
ProTakeaways
- What it is: uditgoenka/autoresearch is a Claude Code skill that brings Karpathy's autonomous ML improvement loop to any codebase or domain.
- The loop: Modify one thing, verify with a mechanical metric, keep if improved, auto-revert if worse, log everything to TSV, repeat up to N iterations.
- 13 commands: Core loop plus subcommands for planning, debugging, fixing, security audits, shipping, scenario generation, adversarial reasoning, and product improvement.
- v2.1 architecture: Monolithic 813-line SKILL.md replaced with a 41-line router + 12 self-contained files — a 95% token reduction per invocation.
- Safety system: 9 hooks fire on every session, blocking dangerous commands, credential reads, and context-flooding directories by default.
- Free and open source: MIT license; install with
npx skills add uditgoenka/autoresearch; works with Claude Code, OpenCode, and OpenAI Codex.
Earlier this year, Andrej Karpathy dropped a 630-line Python script on GitHub and the ML world lost its mind. He turned a familiar machine-learning workflow into a tight, measurable, automatable loop: an agent edits a single training script, runs a time-boxed experiment, measures performance, and either keeps or discards the change , then repeats, potentially all night. The project picked up 21,000+ GitHub stars and 8.6 million views on Karpathy's announcement within days. Fortune called it "The Karpathy Loop." Shopify CEO Tobi Lutke pointed it at Shopify's templating engine and got 53% faster rendering from 93 automated commits.
The catch: Karpathy's original tool was purpose-built for ML training on GPUs. If you can define a numerical objective that a training run produces, the loop applies. If your task can't be reduced to a measurable scalar, it doesn't. Developer Udit Goenka saw the pattern and asked: what if the loop could run on anything? The result is uditgoenka/autoresearch , a Claude Code skill that generalizes the Karpathy Loop to any codebase, any domain, any metric you can measure.
The loop, explained
The core mechanic is deliberately simple. Every iteration follows the same ratchet:
- Review current state, git history, and the results log
- Pick the next change based on what worked, what failed, and what's untried
- Make one focused change
- Git commit (before verification, so you always have a rollback point)
- Run mechanical verification , tests, benchmarks, a score
- If improved: keep. If worse:
git revert. If crashed: fix or skip. - Log the result to TSV and repeat
Every improvement stacks. Every failure auto-reverts. Karpathy's original ran 700 autonomous experiments in 48 hours, discovering 20 training optimizations that transferred from small to large models , achieving an 11% speed improvement that human researchers had missed. The Claude Autoresearch skill applies that same pressure to test coverage, bundle size, API latency, documentation quality, or anything else with a number attached.
13 commands, not one
Where Karpathy's original is a single loop, autoresearch ships a full command suite. The core /autoresearch command runs the improve loop, but 12 subcommands extend it into adjacent workflows:
- /autoresearch:plan , converts a plain-language goal into a validated config with a dry-run verify command. Useful when you don't know what metric to use.
- /autoresearch:debug , runs the scientific method as a loop. Generates falsifiable hypotheses, tests one per iteration, logs confirmed and disproven findings equally.
- /autoresearch:fix , auto-detects broken state (tests, types, lint, build), prioritizes blockers, fixes one thing per iteration, stops when error count hits zero.
- /autoresearch:security , read-only STRIDE threat modeling + OWASP Top 10 sweep with four adversarial red-team personas. Use
--fixto opt into auto-remediation. - /autoresearch:ship , routes code PRs, deployments, blog posts, email campaigns, or sales decks through an 8-phase checklist with domain-specific verification.
- /autoresearch:reason , for decisions with no objective metric. Competing answers are generated, critiqued, synthesized, and blind-judged over multiple rounds until convergence.
- /autoresearch:probe , eight adversarial personas interrogate requirements until constraints saturate, then emit a
handoff.jsonfor downstream commands. - /autoresearch:improve , researches what to build next: ICP challenges, competitor gaps, market trends, then generates ranked PRDs with evidence chains.
- /autoresearch:evals , analyzes
*-results.tsvfiles from any run, surfaces plateau detection and convergence signals, and recommends continue/stop/change strategy.
Commands chain together via --chain. A common pipeline: /autoresearch:probe --chain plan,autoresearch interrogates requirements, converts them to a validated config, then launches the improvement loop automatically.
The v2.1 architecture rebuild
The most significant engineering decision in v2.1 isn't a new command , it's how the skill is packaged. The original monolithic SKILL.md was 813 lines and consumed roughly 100,000 tokens on every invocation. That's expensive and slow. v2.1 replaces it with a 41-line routing file and 12 self-contained command files of 94–120 lines each, consuming 5,000–8,000 tokens per invocation. That's a 95% token reduction with the same capability surface.
This matters practically. Claude Code's context window is finite. A skill that burns 100K tokens on load competes with your actual codebase for attention. The modular architecture means only the command you invoke is loaded , the rest stays on disk.
Here's the minimal invocation to start a loop:
/autoresearch
Goal: Increase test coverage from 72% to 90%
Scope: src/**/*.test.ts, src/**/*.ts
Metric: coverage % (higher is better)
Verify: npm test -- --coverage | grep "All files"
Iterations: 25Claude reads all in-scope files, establishes a baseline at iteration #0, and starts iterating. You can add a Guard field , a second command that must always pass , to prevent regressions while optimizing the primary metric.
9 safety hooks that run whether you ask or not
Autonomous agents that modify code and run shell commands need guardrails. autoresearch ships a 9-hook safety system that fires on every Claude Code session, not just during autoresearch commands:
- scout-block , prevents
node_modules/,.git/, and__pycache__/from flooding context - privacy-block , blocks
.envfiles, SSH keys, and credentials from being read - dangerous-cmd-block , blocks force-push,
rm -rf, andgit reset --hard - simplify-gate , warns at 400 lines of code added, blocks at 800 before shipping
- iteration-context , re-injects recent TSV iteration data after context compaction so the agent doesn't lose its memory of what it already tried
- stop-notify , fires a terminal notification and optional webhook when a session ends
All hooks are on by default. Disable individually with environment variables like export AR_DISABLE_PRIVACY_BLOCK=1. You can also point AR_NOTIFY_WEBHOOK at a Slack endpoint to get pinged when an overnight run finishes.
What it's good at , and where it hits limits
The loop excels when your verification command is fast, deterministic, and produces a single number. Test coverage, bundle size, benchmark latency, lint error count , these are ideal. The agent can run 25 iterations in a reasonable session and make compounding progress.
It struggles in a few predictable places:
- Slow verify commands. If each verification takes 10 minutes, 25 iterations means 4+ hours of wall time. The loop is only as fast as your test suite.
- Fuzzy goals. "Make the code better" isn't a metric. You need a number.
/autoresearch:planexists specifically to help you find one. - Subjective domains. The
/autoresearch:reasoncommand addresses this with blind judging, but it's a workaround , the core loop needs mechanical verification. - Context window pressure. Very large codebases can exhaust context even with the modular architecture. The
scout-blockhook helps, but scoping your target files carefully is still important.
Installation takes one command
autoresearch works with Claude Code, OpenCode, and OpenAI Codex. For Claude Code, the fastest path is:
npx skills add uditgoenka/autoresearchRestart Claude Code and all 13 commands appear in the slash menu. For OpenCode, commands use underscore naming (/autoresearch_debug, /autoresearch_fix, etc.). For Codex, invoke via $autoresearch mention syntax. The repo is MIT-licensed and free , the only cost is your Claude API usage during runs.
The broader significance here is less about autoresearch specifically and more about what it demonstrates: the broader significance is not about benchmarks. It is about establishing what researchers are now calling the "Karpathy Loop" , a paradigm where AI agents autonomously improve the systems that build AI. Goenka's contribution is making that paradigm accessible to any project with a measurable goal, not just ML researchers with H100s. If you can define a numerical objective that a repeatable process produces, the loop applies , and that covers a lot more ground than overnight GPU runs.