Plain-language explainer
AI coding agents, and what actually happens in the loop
How do AI coding agents work?
A coding agent is a language model wrapped in a loop with tools: read a file, search the codebase, edit, run the tests, read the output, decide again. The model never edits your project directly. It proposes a tool call, the harness runs it, and the result comes back as text the model reads on the next turn. Almost everything that separates a good agent from a bad one lives in that harness: which tools exist, what context is gathered, and where a human is asked to confirm.
Last reviewed
Do not just read it. Operate the mechanism yourself in a short interactive lesson.
See it work: The harness: the loop, made real βFree, no code, no signup.
What people get wrong
- It understands your whole codebase. It sees whatever the harness fetched into the context this turn, which is usually a handful of files.
- Passing tests means the change is right. Tests only prove what they check. Agents are good at satisfying a check and missing the intent.
- A better model is the whole answer. Tool design, retrieval and a tight feedback loop change results at least as much as the model does.
Where you see it in real products
- Terminal and IDE agents such as Claude Code and Cursor.
- Automated pull request review and fix suggestions on a repository.
- Background agents that pick up an issue and open a draft pull request.
Common questions
- Why does an agent work better on a small, well-tested repository?
- Because its feedback loop is the test suite. When a change can be checked in seconds, a wrong step gets caught and corrected on the next turn. Without that signal the agent is guessing, and guesses compound across steps.
- How do I get better results from a coding agent?
- Give it a way to check itself and a narrow task. A runnable test, a clear acceptance criterion and a small scope beat a long prompt. Pointing it at the two or three relevant files also beats hoping its search finds them.
- Is it safe to let an agent run commands?
- It depends what the command can reach. Run it in a project directory with version control, keep production credentials out of the environment, and require confirmation for anything that pushes, deploys or deletes. The model can be talked into things by text it reads, so the boundary has to be enforced outside it.
Related explainers
More in Agents and tools
Part of See How AI Works, a free interactive course, where you learn how modern AI works by operating it, not watching videos.