Section650

Writing

TopicAI
Reading10 min

Loop Engineering: The Feedback Loop Matters More Than the Code

A look at what it takes to turn faster code generation into faster feedback, with a workflow that separates testing from acceptance.

By Ka Lun Chan · Cloud & AI · AI / Delivery / Leadership

What is loop engineering?

Loop engineering is building software around short, repeatable feedback loops: understand the problem, plan, build, test, review, learn, and repeat. With AI coding agents, the engineer’s main job becomes designing the feedback the agent works against.

“Loop engineering” is a label for designing feedback into software work. Give each check a question, an owner and a consequence when it fails.

Fig. 707-1 The engineering loop, and the signal that closes each stepDashed steps are the inner loop an agent can repeat on its own. Solid steps are where a person decides whether to go on.
  1. 01 UnderstandThe problem, in the user’s words, agreed with whoever asked for itPerson
  2. 02 PlanA small plan someone has read before any code existsPerson, agent drafts
  3. 03 BuildOne small change against the planAgent
  4. 04 TestTests written from the acceptance criteria, run by CIAgent and CI
  5. 05 ReviewA person reads the change and tries the behaviorPerson
  6. 06 LearnProduction errors, usage, support ticketsPerson, agent summarizes

Repeat: what Learn finds becomes the next Understand. A failed test goes back to Build; a failed review usually goes back to Plan.

Asking an agent to write code and accepting what comes back is one pass through the middle of that loop, with nothing at either end. Nobody checked the problem going in, and nobody checked the result coming out. Loop engineering puts both ends back and makes each step produce a signal you can act on.

The important part is the quality of that signal. An agent that iterates ten times against a weak test suite gets very good at passing weak tests.

Feedback loops before AI

Software delivery has feedback loops at several speeds, from local tests to customer feedback.

  • Test-driven development: seconds to minutes. Does the function return the specified result?
  • Continuous integration: minutes. Does the change work with the rest of the codebase?
  • Code review: hours. Does another engineer understand it and agree with the approach?
  • Agile iterations: a week or two. Does the increment solve the business problem?
  • Monitoring and observability: continuous. Is it working for real users right now?
  • Incident reviews: after an incident. Which earlier check missed the problem?
  • Customer feedback: weeks to months. Did it solve the problem?

Feedback belongs in design and requirements as well as implementation. See Forward Engineering Isn’t New.

How AI changes the loop

The traditional loop looks like this:

Engineer → write code → run tests → debug → review → deploy

With an agent like Claude Code or Codex, it looks more like this:

Engineer defines the outcome → AI plans → AI implements → automated validation → AI fixes → human reviews → deploy

The engineer has moved to both ends. More of the time goes into defining the outcome, the constraints and the checks up front, and into reviewing behavior at the end. The middle runs faster than any person could run it.

Fig. 707-3 Traditional and agentic development, side by side
DimensionTraditionalAgentic
Who writes the codeThe engineerThe agent, against a plan the engineer approved
Where engineers spend timeImplementing and debuggingDefining outcomes, constraints and checks, then reviewing
Cost of one iterationHours to daysMinutes
What limits speedTyping and debuggingReview capacity and test quality
Main failure modeSlow delivery, bugs found lateFast delivery of the wrong thing
What a passing build provesRoughly what the engineer meant to testOnly what the tests check, which the agent may have written

The last row matters most. When the same agent writes the code and the tests, a green build tells you the two agree with each other. It doesn’t tell you either one matches what the customer needed. That’s why an agent shouldn’t be allowed to keep changing code without checks it can’t influence and a limit on how long it can keep trying.

Vibe coding, agentic engineering and loop engineering

Vibe Coding vs. Agentic Engineering compares the first two approaches. Here the emphasis is how each stage gets checked.

Fig. 707-2 Three ways of working with AI, by what each optimizes and how each fails
ApproachPrimary focusMain risk
Vibe codingGenerate working code quicklyLittle understanding or validation of what was built
Agentic engineeringDelegate implementation tasks to AI agentsThe wrong outcome, delivered by a run that succeeded
Loop engineeringValidate and improve the outcome on every passPoor feedback that reinforces a wrong assumption
These overlap. Loop engineering is the discipline that makes agentic engineering trustworthy.

Agentic engineering assigns the work. Loop engineering specifies the feedback and what happens when the result fails.

When the feedback is wrong

Fast feedback can still lead a team in the wrong direction. Common failure modes include:

  • The agent fixes symptoms. A test fails, it adds a special case, the test passes, and the bug underneath stays.
  • Tests pass but check the implementation, not the business requirement.
  • The agent changes unrelated code to make its change fit.
  • Each fix adds a layer, and the solution keeps getting more complicated.
  • Acceptance criteria were vague, so the agent built a reasonable reading of them that nobody wanted.
  • The agent grades its own work, with no independent check.
  • An engineer sees green checks and merges without trying the feature.

Here’s a hypothetical that combines several of these. An agent builds appointment booking for a business with customers in more than one time zone. It stores every slot in UTC, and its tests confirm that a booking for 9:00 UTC is saved as 9:00 UTC. Every test passes. The review looks clean. But the booking page shows available slots in the server’s time zone, so a customer three hours away picks “9:00,” thinking it’s their morning, and arrives at the wrong time.

The code did what the tests said. The tests checked storage, and nobody had written down that customers must see slots in their own time zone. A successful execution loop doesn’t mean a successful engineering outcome. The fix starts with an acceptance criterion and a test written from the customer’s side of the screen.

Smaller loops, smaller changes

Small stories and pull requests keep the time between a decision and feedback short. Larger changes take longer to understand, review and undo.

  • Feedback in minutes or hours instead of at the end of a sprint
  • Reviews someone can read carefully
  • Less risk per deployment
  • Debugging where the cause is one of a few changed lines
  • Rollback that undoes one thing
  • A team that knows what changed

An agent can produce a diff too large to review carefully. Split the work around separately verifiable behaviors.

What humans still own

AI can help with every item on this list. Accountability for each one stays with the engineering team:

  • Understanding the actual business problem
  • Architecture decisions, including the ones to not build at all
  • Security and compliance
  • Acceptance criteria
  • Weighing tradeoffs
  • Production readiness
  • Deciding when a solution is good enough

The last one is easy to miss. An agent will keep improving something as long as you let it. Someone has to decide that the change does what it needs to, at a cost that makes sense, and stop.

A practical loop engineering workflow

The hypothetical appointment-booking feature below illustrates a proposed workflow with Claude Code or Codex.

Fig. 707-4 A loop engineering workflow for one featureDashed steps can repeat without a person. Solid steps need someone to approve before the next one starts.
  1. 01 Define the expected behaviorWhat a customer can do, written as acceptance criteriaHuman gate
  2. 02 List constraints and edge casesTime zones, double booking, cancellations, permissions. The agent can suggest moreHuman gate
  3. 03 Agent proposes a small planFiles it will touch, data changes, tests it will addAgent
  4. 04 Review the planApprove, narrow or reject before code existsHuman gate
  5. 05 Implement one pieceOne slice, inside the approved filesAgent loop
  6. 06 Run unit, integration and E2E testsIn CI, against tests the agent cannot editAgent loop
  7. 07 Analyze failures, propose fixesUp to three attempts per failure, then stop and reportAgent loop
  8. 08 Human acceptance testingSomeone books, moves and cancels a real appointment on a previewHuman gate
  9. 09 Deploy with monitoringBehind a flag, with alerts on booking errorsHuman gate
  10. 10 Evaluate production feedbackErrors, abandoned bookings, support ticketsHuman gate

Three failed attempts at step 7 send the work back to step 3 with a person.

People approve the direction in steps 1 to 4. Steps 5 to 7 can use automated checks and bounded retries.

Set these limits before step 5:

  • Three attempts at the same failure, then the agent stops and reports what was tried. Repeated failure usually means the plan is wrong, and more attempts won’t fix a plan.
  • The plan names the files and directories the agent may change. Anything outside that is a new conversation.
  • Tests come from the acceptance criteria and the agent can’t edit them without approval. CI runs them, not the agent’s own report.
  • When the agent hits a limit, touches authentication or payments, or wants to change a test, a person decides.
  • Project rules live in a CLAUDE.md or AGENTS.md file, so every session starts with the same constraints.

Match review to risk. A copy edit can lean on automated checks. Permissions, payments and customer data need closer human verification. See How to Verify AI-Generated Code.

What this means for engineering leaders

If AI cuts implementation time, the bottleneck moves somewhere else. On most teams it moves to:

  • How clear the requirements are
  • Architecture decisions
  • Review capacity
  • Test quality
  • Deployment safety
  • Coordination across teams

That changes what to invest in. A team that doubles its code output without improving its tests or adding review capacity has built a bigger queue in front of review.

Lines added and agent iterations are easy to inflate. Track whether changes land, remain correct and reach users.

  • Lead time to deliver useful functionality
  • Change failure rate, how often a release causes a problem
  • Time to recover when one does
  • Escaped defects that customers find after release
  • Rework, changes that exist to fix recent changes
  • Customer outcomes, whether the feature solved the problem it was built for

The first three come from DORA’s delivery metrics. Use the combined picture to check whether faster drafting improved delivery.

Short answers

What is loop engineering?

Loop engineering is a feedback-driven way to build software: understand the problem, plan, build a small change, test it, review it, learn from the result, and repeat. With AI coding agents, it means designing the checks an agent runs against, so each iteration is judged by evidence that the outcome is right. It is a practical framework, not a formal methodology.

What is the difference between loop engineering and agentic engineering?

Agentic engineering is delegating implementation work to AI agents inside a structured lifecycle. Loop engineering is the discipline of designing the feedback those agents work against: acceptance criteria, independent tests, review points, iteration limits and production signals. Loop engineering is what makes agentic engineering reliable.

Do more AI iterations produce better code?

No. An agent that keeps iterating against weak tests gets better at passing those tests, not at solving the problem. The quality of the feedback decides whether iterations move toward the right outcome, so improving the checks is usually worth more than adding attempts.

How do you stop an AI coding agent from looping forever?

Give it an iteration limit (for example, three attempts at the same failure), a defined set of files it may change, tests it is not allowed to edit, and a rule to stop and report when it hits the limit. Repeated failure usually means the plan or the requirement is wrong, which is a decision for a person.

How should engineering leaders measure productivity with AI agents?

Measure outcomes at the team level: lead time to useful functionality, change failure rate, time to recover from failures, escaped defects, rework and customer outcomes. Lines of code, pull request counts and agent iterations measure activity and are easy to inflate with AI.

Check the result before adding more code

AI has reduced the cost of writing code. The cost of building the wrong thing is still there, and it shows up later and bigger when the feedback is weak.

Give each loop a specific question about the software and use the answer to decide whether more work is warranted.

Discuss your team’s use of AI agents Vibe coding vs. agentic engineering