Learning paths / Vibe coding to production / How coding agents work

How coding agents actually work

Reading · 5 min · Module 1, lesson 1 of 315 min left in this module

Module 1 · How coding agents workLesson 1 of 3

Goal: Describe the plan, edit, run and observe loop a coding agent follows, and why its confident answers still need checking.

3:51 · captions and chapters · narrated with an AI-generated voice
Transcript

Narration uses an AI-generated voice.

[00:00] Where we're going

By the end of this video, you'll know the loop every coding agent follows. And why an agent saying it's done isn't the same as the job being right.

[00:10] Chat or agent

Start with the difference. A chat assistant writes code into a conversation, and you copy it out. An agent works inside your project. It opens files, changes them, and runs commands in a terminal. Agents in your editor, your terminal, or an app builder all work this way.

[00:30] The loop

So what does an agent actually do? It goes round a loop. First, plan. It decides what to change, from your request and the files it thinks matter. Then, edit. It writes that change into your files. Then, run. The tests, a build, the app, a linter. Whatever it can. And observe. It reads what came back. An error sends it round again. Clean output ends the loop.

Observing is where the power comes from. An agent that can run your tests fixes its own typos and wrong imports, without you. It's also the limit. The agent only sees what it runs.

[01:14] What it can't see

Here's the starter app's test suite. Seven tests, and they all pass. They check date formats, counting days, and validating and storing tasks. None of them checks how overdue dates work. So a wrong rule for overdue dates passes quietly, and the agent reports success.

[01:34] Confidently wrong

Why does that happen? The model predicts code that looks likely, from patterns in a huge amount of code. Likely and correct overlap most of the time. That's why agents are useful. When they don't, the wrong answer reads exactly as fluently as a right one.

[01:53] Three shapes

You'll meet three shapes of this again and again. The wrong problem. It solves what it inferred from your request, not what you meant. An unchecked claim. All tests pass, when none of them cover the change. And a plausible gap-filler. A function or package that sounds right, and doesn't exist. So read done, in an agent's summary, as: the loop stopped. Treat it like a colleague saying, should work. A claim you check before it ships.

[02:28] Context

One more thing shapes all of this. An agent works from its context. Your request, and the files it opened. The output of commands it ran, and any instruction files in the project. Anything else doesn't exist for it. Last week's session, a meeting, a file it never opened. That's why the same agent can be sharp on one task, and lost on the next.

[02:53] Your gates

So where do you sit? This path adds gates the agent can't skip. You approve the plan before it edits. You read the diff. And you decide when it's done, not the loop. The agent does the typing. You decide what ships.

[03:10] Recap

To recap. An agent plans, edits, runs and observes, until nothing it runs fails. It only sees what it runs, and what's in its context. Its confident answers still need checking. Done means the loop stopped. Right is for you to check.

Here's a question to check yourself. Your agent says it fixed the overdue bug, and all tests pass. But no test covers overdue dates. What do you know? Only that nothing it ran failed. The fix is still a claim. Next, check what you've learned. I'll see you there.

Key idea

A coding agent is a language model working in a loop: it plans, edits files, runs a command, observes the output, and goes round again. It stops when it believes the job is done, which isn't the same as the job being right.

Chat assistant or agent

A chat assistant writes code into a conversation and you copy it out. An agent works inside your project: it opens files, changes them and runs commands in a terminal.

Claude Code, Cursor, Copilot's agent mode, Codex and Windsurf all work this way. App builders such as Lovable, Bolt, v0 and Replit run a similar loop behind a friendlier screen. Everything in this path applies to all of them.

The loop

It plans from your request and the files it thinks matter, and it runs whatever it can: the tests, a build, the app, a linter. An error sends it round again; clean output ends the loop.

Observing is where the power comes from. An agent that can run your tests fixes its own typos and wrong imports without you.

It's also the limit. The agent only sees what it runs. If no test checks how overdue dates work, a wrong rule for overdue dates passes quietly, and the agent reports success.

Why agents are confidently wrong

The model predicts code that looks likely, based on patterns from a huge amount of code. Likely and correct overlap most of the time, which is why agents are useful. When they don't overlap, the wrong answer reads exactly as fluently as a right one.

You'll meet three shapes of this again and again:

  • The wrong problem. It solves what it inferred from your request, not what you meant.
  • An unchecked claim. "All tests pass" when it ran some of them, or none that cover the change.
  • A plausible gap-filler. A function, setting or package that sounds right and doesn't exist.

So read "Done" in an agent's summary as "the loop stopped". Treat it like a colleague saying "should work": a claim you check before it ships.

Where you sit in the loop

The diagram's three gates are where you check each loop: you approve the plan, you read the diff, you decide when it's done. This path builds the habits behind them: a written brief to approve the plan against (module 3), reading every diff (module 4), running the tests yourself before you call it done (module 5), and approving anything that touches your live app (modules 8 and 9). The agent does the typing; you decide what ships.

What the agent can actually see

An agent works from its context: your request, the files it opened, the output of commands it ran, and any instruction files in the project. Anything else, such as last week's session, a decision you made in a meeting, or a file it never opened, doesn't exist for it.

That's why the same agent can be sharp on one task and lost on the next. Module 7 covers giving it the context it needs on purpose.

Check yourself

Your agent says 'Fixed the overdue bug, all tests pass.' The project has no test for overdue dates. What do you know?
Which step of the loop lets an agent correct its own mistakes?