If that definition is new to you, read fly.io’s guide on writing agents or ampcode’s guide and try building your own micro-agent first before continuing. It’s a worthwhile exercise.
What is this loop you speak of?
Consider this prompt asking Claude Code to write agenerateSlug function:
It’s all the agent loop
The key difference is this phrase from the second prompt:“run them, watch them fail, implement the slug generator until they all pass”This gives the agent a loop condition — a test to run repeatedly while iterating. Without it, the agent takes one shot and stops. With it, the agent keeps working until satisfied. The agent loop is the mechanism that transforms a language model from “a thing that predicts text” into “a thing that actually solves problems.” When you give an agent a concrete, runnable validation condition, you’re engaging the loop. When you don’t, you’re just asking for a first draft.
Common loop condition patterns
The pattern is always the same: describe the work, specify the validation, then tell the agent to iterate until the validation passes. Here are three templates you can adapt directly.For new features
For new features
formatCurrency function to utils.ts, write tests covering negative numbers, zero, large values, and locale formatting, run them, fix until they all pass.”For bug fixes
For bug fixes
For build and compile issues
For build and compile issues