
When you type a request into a chat window, one thing happens: the model reads it and writes a reply. When you type the same request into an agent, something different happens. The agent reads it, goes and looks at your files, makes a change, checks whether the change worked, and goes round again until it can show you that it did. That cycle is called the agent loop, and the software that runs it is the harness. This lesson takes one turn of that loop apart, step by step, in the two harnesses most people meet first: Claude Code and Cursor's agent.
You do not need to be a programmer to follow it. I am a counselor who builds software, and the loop is the single idea that made agents make sense to me. Once you can picture it, you can tell when an agent is doing good work, when it is lost, and when to put your hand up and stop it.

The harness, one more time
In the lesson on five words I called the model an engine and the harness the workshop around it. Anthropic's own documentation puts it almost the same way. Claude Code, it says, "is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to."
That sentence holds two jobs. The harness hands the model its tools, the things it can actually do in the world. And it decides what the model can see at each moment: your request, the files it has opened, the results of the last command, the house rules you wrote down. The model itself never touches your computer. It writes a request ("read this file", "run this test"), the harness carries it out, and the result goes back into what the model sees next.
Cursor describes its agent in the same three parts: instructions, tools and a model. Different company, same shape. That is good news for you, because what you learn about one harness carries over to the next.
One turn, step by step
Claude Code's documentation describes the loop in three phases: "gather context, take action, and verify results." It adds a line I find honest: "These phases blend together." The agent does not march through them once. It moves back and forth, the way you do when you fix something around the house.
The documentation walks through a plain example, fixing tests that fail. Here it is in everyday words:
- Run the tests to see what is actually broken, rather than guessing.
- Read the error message the tests print.
- Search the project for the files that error points to.
- Read those files to understand the code around the problem.
- Edit the file that needs to change.
- Run the tests again to see whether the fix worked.
Notice where it starts and where it ends. It starts by checking, and it ends by checking. The middle is the part people picture when they imagine AI writing code, and it is the smallest part. If the second run of the tests still fails, the agent does not stop and announce success. It reads the new error and goes round again.
Each pass through the loop is cheap for the agent and slow for a person. A human developer might take an afternoon to do six rounds of read, change, check. An agent can do them in a few minutes. That speed is the whole appeal, and it is also why the checking step matters so much: an agent that skips it can produce a lot of confident, broken work very quickly.
What the model can touch: tools
A tool is one specific thing the harness lets the model do. Claude Code groups its built-in tools into five kinds:
- File operations: read a file, edit it, create a new one.
- Search: find files by name, or find every place a word appears.
- Execution: run a command in the terminal, such as a test or a build.
- Web: search the web and fetch a page.
- Code intelligence: follow how pieces of code connect to each other.
Cursor's list reads much the same: run terminal commands and watch the output, suggest edits and apply them, search for files and read folders. Cursor also says plainly that "there is no limit on the number of tool calls Agent can make during a task." That is worth sitting with. The loop runs until the job is done or someone stops it. Nothing inside the model decides it has done enough work for one day.
Tools are also where the risk lives. Reading a file changes nothing. Running a command can change almost anything. A good harness treats those differently, which is the subject of the last lesson in this level, Trust, then verify.
What the model can see: context
The model has no memory of its own between sessions. Everything it knows about your project in a given moment sits in its context window, the working space I compared to a desk in lesson 2. The harness fills that desk. It puts your request there, the files the agent opened, the output of each command, and any standing instructions.
Standing instructions live in a plain text file. In Claude Code it is called CLAUDE.md, and the harness loads it at the start of every session. Mine says things like "test on the local copy before anything goes live" and "never paste client information into a prompt." Cursor has its own rules files that do the same job. Think of it as the note you leave for a new assistant on their first morning.
A long session fills the desk. When it gets full, Claude Code compacts it: it replaces the older conversation with a summary to make room. The documentation warns that detailed instructions from early in a session can get lost this way, and suggests putting the rules that must last into CLAUDE.md, where they are loaded fresh. Typing /context shows how full the desk is. I check it the way you might glance at the clock in a long session with a client.
Where you come in
An agent loop is not a closed box. Both harnesses build in places for a person to step in.
You can stop it. The Claude Code documentation is direct: "You can interrupt at any point." Pressing Esc stops the current action. If you type a message while it is working, the agent reads it once the tool it is running finishes. Cursor works the same way, saying your message "is delivered at the agent's next tool call." So you can steer mid-task: "stop, you are in the wrong file," or "check the phone layout too."
You can rewind. Before Claude Code edits a file, it takes a snapshot, called a checkpoint. Pressing Esc twice lets you go back to an earlier one. Cursor makes checkpoints too, "before making significant changes." There is one limit worth memorising, and Anthropic states it outright: actions that reach outside your computer, such as a database, a payment service or a deploy, "can't be checkpointed." A rewind can restore a file. It cannot unsend an email.
You can choose how much it may do on its own. Claude Code has permission modes. In Plan mode it reads and proposes but changes nothing. In Manual mode (called default in settings) it asks before each edit and each command. New terminal and VS Code sessions start in auto mode, so switch on purpose. In accept-edits mode it may edit files without asking. In auto mode a separate classifier decides which actions are safe enough to run. Shift+Tab cycles through them. For a first week with any agent, I would stay in Plan mode and Manual mode.
A turn from my own week
Here is a real turn, with the project details left out. A page on one of my sites had a row of buttons that overlapped the footer on phones. I opened Claude Code in that project and typed: "The buttons at the bottom overlap the footer on a phone-sized screen. Fix it, and show me a screenshot at phone width before and after."
Then I watched the loop. It gathered context first: it searched for the footer's styles, read two files and took a screenshot of the page on my local copy at phone width, so it could see the problem rather than imagine it. It acted: it changed four lines of styling. It verified: it took the screenshot again. The buttons still touched the footer, by a few pixels. So it went round. It read the page once more, found a second rule that pushed the buttons down, changed it and took a third screenshot. That one was clean, and it showed me both pictures.
Three things in that turn were mine, not the agent's. I said what done looked like (a screenshot at phone width). I ran it on a local copy, never the live site. And I looked at the final picture myself before anything went anywhere. The agent did the rounds. I set the goal and checked the result.
What this means for a private practice
You may never fix a website footer, but the loop shows up in every agent you will use, including the ones built into email and document tools. Three habits carry over.
- Give it a way to check. "Draft a reply" gives the agent nothing to verify. "Draft a reply under 150 words that answers both of her questions" does.
- Start it on copies. Point a new agent at a folder of copies, not your only version of anything. Checkpoints help with files, but they are not a backup.
- Keep client information out. An agent reads whatever you point it at, and what it reads may go to the company that runs the model. The rules in HIPAA-safe AI tools apply to agents just as they do to chat.
Try it
If you have Claude Code or Cursor, make a new folder with three short text files in it: a made-up practice newsletter, a list of office hours and a welcome note. Open the agent in that folder, switch to Plan mode and ask: "Read these three files and tell me where the office hours disagree with each other." Watch what it does before it answers. Count the times it reads a file. Then ask it to fix the disagreement in Manual mode, so it asks you before each edit, and approve the changes one at a time.
You will have watched the full loop: gather, act, verify. The next lesson is about making that last step stronger, so the loop checks its own work against something real.
Further reading
- How Claude Code works, Anthropic. The loop, the tools, checkpoints and permission modes, in the vendor's words.
- Agent overview, Cursor. The same loop in a different harness.
- Building effective agents, Anthropic. Why simple loops beat clever frameworks.
- Claude Code in Action, Anthropic Academy. A free course that runs the loop on a real project.
- Model, company, app, agent, harness. The vocabulary this lesson builds on.
Facts in this lesson checked November 24, 2026.
This lesson's video has its own page
Sources
- “How Claude Code works.” Anthropic. The three phases ("gather context, take action, and verify results"), the harness definition, the five tool categories, the fix-failing-tests example, interrupting, checkpoints, and "can't be checkpointed" for remote actions. https://code.claude.com/docs/en/how-claude-code-works (accessed Nov 24, 2026).
- “Agent overview.” Cursor. Instructions, tools and model; "no limit on the number of tool calls"; checkpoints "before making significant changes"; messages delivered "at the agent's next tool call.". https://cursor.com/docs/agent/overview (accessed Nov 24, 2026).
- “Configure permissions.” Anthropic. Permission modes: default, accept edits, plan, auto and others; Shift+Tab to cycle. https://code.claude.com/docs/en/permissions (accessed Nov 24, 2026).
- “Best practices for Claude Code.” Anthropic. CLAUDE.md as standing instructions; give the agent a check that comes back pass or fail. https://code.claude.com/docs/en/best-practices (accessed Nov 24, 2026).
- “Building effective agents.” Anthropic, Dec 19, 2024. Agents as models directing their own tool use in a loop; start simple. https://www.anthropic.com/engineering/building-effective-agents (accessed Nov 24, 2026).
- “Effective context engineering for AI agents.” Anthropic, Sep 29, 2025. Why a full context window degrades, and how compaction and notes help. https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents (accessed Nov 24, 2026).
- “Building more effective AI agents.” Anthropic (YouTube), Oct 17, 2025. The video on this lesson. https://www.youtube.com/watch?v=uhJJgc-0iTQ (accessed Nov 24, 2026).
- “Claude Code in Action.” Anthropic Academy. Free course. https://anthropic.skilljar.com/claude-code-in-action (accessed Nov 24, 2026).
Study guide
Key terms
- Agent loop: gather context, take action, verify results, and go round again until done
- Harness: the layer around the model that provides tools and manages what it sees (Claude Code, Cursor's agent)
- Tool: one action the harness lets the model take: read, edit, search, run a command, fetch a page
- Context window: everything the model can see right now; the harness fills it
- CLAUDE.md: standing instructions loaded at the start of every Claude Code session
- Compaction: replacing older conversation with a summary when the context fills up
- Checkpoint: a snapshot of files before an edit, so you can rewind
- Permission mode: how much the agent may do without asking (plan, default, accept edits, auto)
Facts that move (checked November 24, 2026)
- Claude Code's five tool kinds: file operations, search, execution, web, code intelligence (Anthropic)
- Esc stops the agent; Esc twice opens checkpoints; Shift+Tab cycles permission modes (Anthropic)
- Remote actions such as databases, APIs and deploys cannot be checkpointed (Anthropic)
- Cursor's agent has no limit on tool calls per task and checkpoints before significant changes (Cursor)
Your first week with an agent
- Work in a folder of copies
- Start in Plan mode, then Manual mode, which asks before each change
- Say what done looks like in a way it can check
- Watch the first minute; press Esc the moment it drifts
- Keep every client detail out
Check what you learned
10 questions from this lesson. Answers are checked as you go; nothing is recorded.
1 / 10
What are the three phases of the agent loop in Claude Code's documentation?
Hint
Look, do, check.
Anthropic describes the loop as gather context, take action and verify results, and notes that the phases blend together.
2 / 10
What is the harness?
Hint
The workshop around the engine.
Anthropic: the harness is "the layer around the model that provides the tools and manages the context the model sees."
3 / 10
In the fix-failing-tests example, what does the agent do first?
Hint
It starts the way it ends.
It starts by running the tests, so it works from the real error instead of a guess.
4 / 10
Which of these is a tool, in the agent sense?
Hint
Something it can do, not something it knows.
A tool is an action the harness lets the model take, such as running a command, reading a file or searching.
5 / 10
What does Cursor say about the number of tool calls its agent can make in one task?
Hint
Nothing inside it says "enough".
Cursor's documentation: "There is no limit on the number of tool calls Agent can make during a task." That is why stopping rules and checks matter.
6 / 10
Why put a rule in CLAUDE.md rather than just typing it early in a session?
Hint
The desk gets cleared.
Compaction summarizes older conversation, which can drop details. CLAUDE.md is loaded at the start of every session.
7 / 10
You type a message while the agent is in the middle of running a command. When does it read it?
Hint
Between steps.
Both harnesses read your message after the current tool call finishes, so you can steer mid-task.
8 / 10
Which of these can a checkpoint NOT undo?
Hint
Outside your computer.
Anthropic: actions that affect remote systems "can't be checkpointed." A rewind restores files, not sent messages.
9 / 10
Which permission mode lets an agent read and propose but change nothing?
Hint
Think before doing.
Plan mode reads and proposes only. It is the safest place to start with any agent.
10 / 10
In my footer example, which part of the turn was mine rather than the agent's?
Hint
The goal and the last look.
The agent did the rounds. I set the goal, kept it on a local copy and looked at the result before anything went live.
Worth another look