Agentic loop

The core execution cycle of an AI agent: receive a goal, plan a step, use a tool, observe the result, plan the next step, repeat until the goal is reached or the agent decides to ask for help. Claude Code runs an agentic loop on every non-trivial task - it does not just write code and stop; it runs the tests, reads the error output, fixes the failures, and checks the result again. Understanding the agentic loop helps you write tasks that play to this strength: describe an outcome you want checked, not just a change you want made.

The agentic loop is the core cycle an AI agent runs: receive a goal, plan a step, use a tool, observe the result, decide the next step, and repeat until the goal is met or the agent needs to ask for help. It is what makes an agent different from a one-shot generator. A plain model answers once and stops; an agent keeps going, using each result to inform what it does next, the same way a person works through a problem by trying something, seeing what happened, and adjusting.

Claude Code runs this loop on every non-trivial task. Ask it to add a feature and it does not just write code and walk away - it makes the change, runs your tests, reads the failures, fixes them, and checks again, looping until the thing actually works. That self-correction is why Claude Code can finish real tasks rather than handing you a plausible-looking draft that breaks on the first run. The loop is also where tool use and subagents fit: each pass through the loop is a tool call, and heavy sub-investigations can be delegated.

Understanding the loop changes how you write tasks. Because the agent is strongest when it can act, observe, and verify, the best instructions describe an outcome that can be checked, not just a change to make. 'Make the checkout flow pass its tests' gives the loop a clear target and a way to know it succeeded; 'edit the checkout file' does not. When you phrase work as a verifiable goal, you let the agentic loop do what it does best - keep working until the result is right.

Related terms

Put it to work

Learn it by building it

Definitions get you oriented. The club gets you shipping. Join Claude Code Club for $9/month.

Related: the full glossary, the learn hub, and our guides.