Skip to content

How AI coding tools work

Foundations

Every AI tool in these guides (a terminal agent, an in-editor assistant, a chat window) runs the same loop underneath the buttons. Once you can see it, every tool stops feeling like magic and starts feeling like something you can steer.

Behind the chat box, the tool repeats a simple cycle:

  1. Gather context. It reads what it needs: your message, files in the project, the output of a command, a page on the web.
  2. Act. It does one thing: writes code, edits a file, runs a test, answers a question.
  3. Verify. It checks the result: reads the error, re-runs the build, looks at what changed.
  4. Repeat. It feeds the result back in and goes again, until the task is done or it gets stuck.

The important word is you. The loop runs on its own, but you set the direction at every turn: you write the first instruction, approve or reject each action, and correct course when it drifts. The model is the accelerator; it has no opinion about where you’re going. You supply that. That idea runs through everything else here; see Context engineering.

Two different things are at work, and people mix them up constantly.

  • The model is the reasoning engine: Claude, GPT, and so on. It turns text in into text out. On its own it can’t touch a file or run anything.
  • The harness is the program wrapped around the model: Claude Code, Cursor, GitHub Copilot, a chat app. It decides which files and instructions the model sees, gives it the ability to act, and runs the loop above.

The same model behaves very differently in two harnesses, because each one feeds it different context and hands it different tools. When a tool feels smart or dumb, it is usually the harness (the context it gathered), not the raw model.

A bare model can only produce text. It becomes an agent when the harness gives it tools, concrete actions it can choose to take:

ToolWhat it lets the model do
Read filePull a file into context so it can reason over real code
Edit / write fileMake an actual change on disk
Run commandExecute a build, a test, a script, and read the output
SearchLook across the codebase or the web for what it doesn’t already know

More tools mean more the model can do without you in the loop for every keystroke. It also means more it can get wrong, which is why every serious harness asks you to approve risky actions and why Verification matters so much.

This is the rule that surprises people most: the model only knows what is in front of it right now. It cannot see your screen, your other browser tabs, the rest of your repo, or a file it hasn’t opened. It knows three things:

  1. Whatever you typed.
  2. Whatever the harness loaded for it: files, instructions, command output.
  3. Whatever it learned during training, which may be months out of date.

Everything else is invisible. When a tool “forgets” a detail or invents a file that doesn’t exist, it is almost always because that information was never actually in front of it. The space where all of this lives is finite, which is the next thing to understand: The context window.

The loop, the harness, and tool use show up most clearly in the terminal and in-editor tools: