AI Infra

Loop Engineering for LLM Code

Playbook AI Infra 12 min read Updated JUN 30, 2026
#claude#loops#code-generation#testing#ai-infra

The 5-loop system that takes LLM-generated code from 76% to 90% correct, rebuilt into a drop-in harness for any language.

Most people accept an LLM’s first answer. It writes the code, you skim it, you paste it, and you find out later it does not compile or quietly does the wrong thing. The first answer was never meant to be the final one.

A 2025 research paper (ICSME, by a team at Auckland, the JRC, and King’s College London) measured what happens when you stop trusting that first answer. They wrapped the model in five feedback loops and ran the output through real tools: a compiler, a test runner, a static analyzer, a mutation tester. Each tool’s complaints get fed back to the model as a fix request, and it iterates until the tools are satisfied.

The result: correctness rose from 76% to over 90%.

What you get

The complete loop-engineering system, translated from the paper and rebuilt to run on any stack.

  • The five loops, written out in full. Compile, given-tests, static analysis, test generation, and mutation hardening, with the exact order and the rules that make each one safe.
  • A stack-agnostic tool table. The paper was locked to Java and Maven. This maps every loop to Python, TypeScript, Go, and Rust, so the loops run wherever your code lives.
  • The machinery that makes it reliable. Adaptive temperature, retry caps, sandboxed execution, and a structured generation contract.
  • A copy-paste prompt. Paste it into Claude Code and it reads your repo, detects your stack, wires the loops, and smoke-tests one task end to end.

Who this is for

Builders who generate code with an LLM and are tired of playing compiler by hand. If you find yourself pasting errors back into the chat one at a time, this turns that whole grind into a system that runs on its own.

You do not need the research background. The paper did the measuring; this is the version you can plug in today.

The point

The leverage is not a better single prompt. It is a loop that proves the work before it reaches you. The tools do the checking, the model does the fixing, and what lands in your lap is code that already passed.

Drop your email and we will send the playbook to your inbox.

← Back to all resources JUN 30, 2026 · AI Infra