Skip to content

claude code loops

A learner invited you

Covers What Is the Claude Code Agent Loop?, Agent Loop Lifecycle: Start to Finish, Tools and Tool Calls Inside the Loop and more.

Lessons6 lessons
Media
Quiz
Final assessmentAfter the last lesson, for your diploma
About

“claude code loops” is a 6-lesson course at Teen level, created with soclever, a personal AI teacher. Each lesson takes a few minutes and ends with a check-in question; finish the curriculum and you can take a certificate test to earn a diploma. Try the first lesson without an account — or make your own course on any topic.

What you'll learn

  1. What Is the Claude Code Agent Loop?. When you write code yourself, you follow a familiar rhythm: you write some lines, run them, look at what happens, fix what broke, write more.
  2. Agent Loop Lifecycle: Start to Finish. You've given Claude Code a task: "Find me a recipe that uses only ingredients in my pantry." Here's what happens next, step by step.
  3. Tools and Tool Calls Inside the Loop. Think of a carpenter working on a repair. She looks at the problem, picks up a tool, uses it, checks what happened, and then decides what to do next.
  4. How the Loop Decides to Keep Going. Think about baking a cake with a recipe card. You mix, check the oven, taste a crumb, and decide whether it needs more time.
  5. Pausing and Interrupting the Agent Loop. Think of a helpful house sitter who works through a to-do list: look at the next task, do it, check how it went, then pick the next one. Claude Code works much the same way.
  6. Customizing Agent Loop Behavior via the SDK. Think of hiring a helpful house sitter. Before you leave, you tell them who they are for the week, which rooms they may enter, and when to stop and call you.

Lesson 1: What Is the Claude Code Agent Loop?

When you write code yourself, you follow a familiar rhythm: you write some lines, run them, look at what happens, fix what broke, write more. You're in control the whole time, deciding what to try next based on what you see.

Claude Code works differently. Instead of you steering each step, the Claude Code agent loop lets Claude take the wheel. It runs code, watches the result, reasons about whether it worked, and decides what to do next—all without waiting for you to intervene. That's the core of what makes it "agentic."

Here's the loop itself. Claude starts by looking at your task. It writes a block of code meant to move toward solving it. The code runs. Claude then reads the output—whether it succeeded, what error appeared, what data came back. Based on that result, Claude asks itself: did this get me closer? Do I need to try something different? Should I write more code, or am I done? Then it loops back and writes the next block of code, or stops. This cycle repeats until the task is complete.

The difference matters. You asking Claude to run one command and waiting for you to type the next is not a loop—it's just conversation. But Claude automatically writing code, running it, reading the result, and deciding what code to write next without asking you in between—that's the agent loop at work. It's what lets Claude tackle multi-step problems on its own.

Questions this course answers

  • What's the key difference between you telling Claude "run this code" and waiting for the result, versus the Claude Code agent loop?
  • What makes Claude Code decide to loop back and call another tool instead of stopping and returning an answer?
  • What are the main ideas behind Tools and Tool Calls Inside the Loop?
  • What are the two main reasons an agent loop stops, and why might a loop that stopped still not have finished the job?
  • If you press Escape while Claude Code is partway through a task, what happens to the file edits it already finished, and how can you continue afterward?
  • If you wanted an unattended agent to review files without changing them and to stop after a reasonable number of steps, which two settings would you adjust?

More courses to explore

Or browse all public courses.