Skip to content

AI, decoded

How do AI coding agents like Claude Code work?

An AI coding agent is a language model running in a loop with tools to read and search files, edit them and run commands such as the test suite. Its available tools and permissions depend on the harness; some can also open pull requests. The model picks a tool, reads what comes back, and decides the next step until the task is done, a limit is reached or it needs a person. Anthropic describes the Claude Code loop as gather context, take action and verify results. Vercel's Malte Ubl told Chain of Thought that this simple architecture, an LLM with a few plain tools, is why Claude Code works as well as it does.

· Chain of Thought

Level 4: How AI systems are built · 4.3 Tools, MCP and agent architecture

AI AgentsAI Coding

  • 2 episodes
  • 3 guest clips
  • 3 common questions
  • 8 glossary terms

In detail

A model, a loop and a few tools

A coding agent is a language model wrapped in a program, often called an agent harness, that gives it tools and runs it in a loop. Without tools, the model can only reply with text. With them, it can read a repository, change files and run commands.

Malte Ubl of Vercel recommends the simplest architecture and credits it for how well Claude Code works. Something triggers the agent, it gets input data and a prompt, and it has a set of tools that should be relatively simple. For a coding agent, he lists reading files, listing files, editing files and creating pull requests, “nothing crazy,” just enough for the agent to go figure out what is in the repository (20:48). You describe to the model what each tool is for and what the goal is, and let it work.

Anthropic’s Claude Code documentation, checked October 25, 2026, describes the same shape as three phases: gather context, take action and verify results. Asked to fix failing tests, it says the agent might run the test suite, read the error output, search for the relevant source files, read them, edit them and run the tests again. Each tool result gives it new information for the next step. How a model chooses and calls a tool is covered in how AI agents use tools.

Why it works on code first

Code gives an agent a way to check its own work. A test suite, a compiler or a linter gives it feedback, so the agent can try an edit, see the result and try again without a person judging each step. A passing check covers what that check measures; weak or incomplete tests can still miss a broken change.

The same property helps in training. Ubl says the agreed-upon reason agents are so effective in software engineering, and not yet in other disciplines, is that you can apply reinforcement learning to this valuable, open-ended problem in a way that is harder for work with no source code to run unit tests on. He hedges it: it is a little easier to make agents good at software engineering than at anything else, and he expects the pattern to spread to other fields. The training side is in how reinforcement learning improves AI coding models. Public benchmarks lean on the same check: SWE-bench gives a model a codebase and a real GitHub issue. Its evaluation harness counts a task as fully resolved only when the designated failing tests now pass and the previously passing tests still clear its regression checks.

What fills its context

Everything the agent reads goes into its context window: the conversation, file contents, command output and the project instructions it loads. Claude Code’s documentation says context fills up as you work, that it compacts automatically near the limit, and that instructions from early in a session can get lost. A new session starts with a fresh window and none of the previous conversation, which is why project instruction files such as CLAUDE.md or AGENTS.md exist.

Where people stay in charge

The documentation names two safety mechanisms. Checkpoints let you undo the agent’s file edits, but files changed only through shell commands aren’t tracked, so version control is still the backstop. Permission modes and rules control what the agent may do without asking. Anything that reaches a remote system, such as a database, an API or a deployment, can’t be undone by a checkpoint, so those actions depend on permissions, as with any human-in-the-loop control.

The other check is review. Graphite’s Greg Foster says you don’t want Claude Code, Cursor or similar tools to produce 2,000- or 3,000-line pull requests and hope they pass review and CI. He says Graphite’s data shows that longer changes get fewer review comments per line, and recalls research he thinks included a Google study. That research reference is his recollection, not a study independently checked here. His advice is many small, dependent changes, which he says both people and AI handle better. What happens to review when agents write most of the code is in code review is the new bottleneck.

Disclosure: Episodes 39 and 40 were sponsored by Galileo, where Conor then worked; in episode 40 he points listeners to Galileo’s LinkedIn page at 2:05.

How an AI coding agent works: a model in a loop with simple tools A task goes to a model inside an agent harness. The harness runs a loop of three steps: gather context by listing, searching and reading files; take action by editing files and running commands; and verify results by running tests, the compiler or a linter. Results feed back to the model; passing tests cover only what they check. If the harness can open a pull request, it stays small and goes to human review. Greg Foster of Graphite, in episode 40, says longer changes receive fewer review comments per line. A side panel lists the controls: checkpoints undo the agent's file edits, though not files changed only through shell commands, permissions decide what runs without asking, and remote actions such as deployments cannot be undone by a checkpoint. A model in a loop with simple tools Each tool result informs the next step. Passing tests cover only what they check. task fix failing test AGENT HARNESS model picks next tool 1. gather context list, search, read files 2. take action edit files, run commands 3. verify tests, compiler, linter results feed back Everything read goes into the context window. review the result small PR, if available longer changes get fewer comments per line, says Greg Foster, Graphite · episode 40 CONTROLS Checkpoints undo edits, not shell-only changes. Permissions decide what runs without asking. Deployments, APIs and databases can't be checkpointed. The loop, commands and checks follow Anthropic's Claude Code docs. File tools follow Malte Ubl's examples, episode 39.
The loop, commands, checks and controls follow Anthropic’s Claude Code documentation, checked October 25, 2026. File reading, listing and editing follow Malte Ubl’s examples, episode 39; small-PR advice and the comment-density observation are Greg Foster’s, episode 40. Download the image

Hear it from the guest

“So for a coding agent, would be read files, list files, edit files, create pull requests.”
“In the software engineering area, you can reinforcement learn on this very valuable, open ended problem”
“You don't want Claude Code or Cursor or any of these tools to go and create 2,000 lines, 3,000 line PRs.”

Quotes lightly edited to remove filler words.

Go deeper

Common questions

What is the difference between a coding assistant and a coding agent?
An assistant suggests code that a person accepts or rejects line by line, such as autocomplete in an editor. An agent takes a task, runs the tools itself, reads the results and keeps going across many steps, such as running the tests, reading the failure, editing the file and running the tests again.
How does a coding agent know about my project?
It reads it, the same way a new engineer would: listing and searching files and reading the ones that look relevant. Many agents also load a project instructions file at the start of each session. Claude Code reads a CLAUDE.md file, and its documentation, checked October 25, 2026, says it can read an AGENTS.md written for other coding agents in its place.
Can a coding agent break things?
Yes, which is why the tools come with limits. Claude Code's documentation describes checkpoints that let you undo the agent's file edits, though not files changed only through shell commands, and permission modes that control what it can do without asking. It also notes that actions affecting remote systems, such as databases, APIs and deployments, can't be checkpointed, so those depend on permissions and review.

From the conversation

This explainer is drawn from these episodes — each carries its full transcript.

Concepts in this explainer

Coding AgentHuman in the LoopAgent HarnessReinforcement LearningAgent Instruction FileAI AgentContext WindowLarge Language Model