Let Claude Code improve its own bug-fix instructions

AICodeKing runs AutoResearch with Claude Code: a frozen evaluator and three Python bug tasks score each change to a bug-fix skill, keeping only edits that solve more, then checks on held-out tasks.

AICodeKing · YouTube · published Oct 11, 2026 · Software & DevOps

Let Claude Code improve its own bug-fix instructions — video by AICodeKing▶ Watch on YouTube
Prompt
/autoresearch Improve [bug-fix skill file]. Change one thing per iteration, run the frozen evaluator on [tasks folder], keep the change only if the score rises. Stop after [3] iterations or $[budget].

Sponsored

Advertise here →

Visual breakdown

Borrowing Andrej Karpathy's autoresearch loop, the video lets Claude Code rewrite its own bug-fix skill, score each version on frozen Python bug tasks with fresh Claude sessions, keep only changes that raise the pass rate, then check the winner on tasks the optimizer never saw. The model stays the same; only the instructions around it change.

The problem: We spend a lot of time telling Claude Code how to work, but there's no way to know which instructions actually make it fix bugs better, and longer instructions don't automatically mean a smarter agent.

The instruction-improvement loop

  1. Bug-fix skillA reasonable baseline SKILL.md, saved and committed so there's something to compare against
  2. Frozen evaluatorClean broken project per trial, fixed grading tests, results log; tested itself first
  3. Fresh worker trialsclaude -p in bare mode with the instructions appended; 3 attempts per task
    Dropped: Patches that break tests, touch forbidden files or time out
  4. Autoresearch optimizerProposes one focused instruction change per candidate, 3 iterations
    Dropped: Candidates that don't improve the score
  5. Held-out checkOriginal vs best version on tasks kept out of the search, alternating order
  6. Reviewed new skillAdopt only if it helps on fresh tasks; keep the original available
Starting pointFixed harnessClaude runsResult

What the autoresearch loop needs

  1. A goal: solve more frozen bug-fix tasks under the same limits
  2. An editable scope: only the bug-fix skill file
  3. A metric: development pass percentage, higher is better
  4. A verify command that runs the evaluator

By the numbers

3development bug tasks
3attempts per task, per candidate
36trial runs for baseline + 3 candidates
48coding trials including the held-out check

Run the experiment yourself

You need Claude Code, git, Python and Node.js. Work in a separate folder with a clean git repo, away from your real projects.

  1. Add the community autoresearch plugin with /plugin marketplace add, then /plugin install, and start a new session
  2. Create .claude/skills/bugfix/SKILL.md with sensible baseline instructions; save a copy and record its commit
  3. Have Claude build an evaluation helper: task fixtures, fixed grading tests, a results log
  4. Test the evaluator: broken code fails, a correct patch passes, deleting a test is rejected
  5. Run one unscored smoke trial, then give autoresearch the goal, scope, metric, verify command and 3 iterations
  6. Compare original vs best on held-out tasks, review the diff, and remove anything tied to practice tasks

Bare mode doesn't use your Claude subscription; it bills an API key. Set max budget, max turns and an external timeout.

Gotchas he warns about

  • Defining what a good result means is the most important part; "make Claude better at coding" has no finish line.
  • If the loop can rewrite the answer key, a higher score tells you very little. Keep the grader fixed.
  • A development gain can just be overfitting to three examples; only held-out results show transfer.
  • Decide the number of attempts up front and count timeouts as failures; never rerun one version until it gets lucky.
  • Plugin scope and iteration settings aren't a sandbox or a spending limit; the controller needs its own stops.

Distilled from the video’s captions

How to try it

  1. Open Claude Code.
  2. Copy the prompt and fill in the [placeholders].
  3. Watch AICodeKing's video for the full walkthrough and setup.

Related use cases

Share