What a coding agent really does when you press Enter

Day 1, 25 minutes · advanced

Goal of this lessonExplain the agent loop (read the context, pick a tool, act, check, repeat) and trace one real task step by step.

Why it matters

On site you have to predict what a coding agent will do before the client watches it do it. Someone in the room will want to know what it can touch, what it reads, and who said yes to each command. If the honest answer is "I am not sure", you lose the room.

A coding agent is a model, a set of tools and a loop that keeps going until the task is done. Once you can see that loop, you can predict it, slow it down and explain it in plain words to a client who has never used one.

In this lesson you give an agent one small task, a single failing test in a throwaway folder, and you watch every turn of the loop. At the end you have a one-page trace: every step, the tool it used, what it read or ran, and where it stopped to ask you. You also decide which permission setting you would use on a client laptop, and why.

The loop in plain words

The agent loop works like this. A model reads what it has. It picks a tool: read a file, run a command, edit a file. It looks at the result and decides the next step. It repeats until it thinks the task is done, or until it needs you.

A chat assistant has the same model but no hands in your project. It can read what you paste and answer. So in a chat tool you do the running yourself, and you become part of the loop.

What is sent on every turn

The context window is everything the model can see at one moment. It is put together again on every turn of the loop, and it holds:

  • the system instructions of the tool, with the list of tools the agent may use
  • the project instruction file, if the folder has one: a file of rules for the project that the agent reads at the start
  • the conversation so far
  • the results of earlier tool calls: file contents, command output, errors

So the agent does not remember your project between turns. It sees it again, through this list.

Permissions

A permission mode decides what the agent may do without asking you. Every coding tool in this course has one, with its own names and its own default. On your own laptop a mode that never asks feels fast. On a client laptop the agent runs with your access: their network, their repositories, and anything in your environment. This course uses one rule: on a client machine, start in the mode that asks, and allow a command only after you have read it.

The steps

  1. Make a throwaway folder called agent-trace/ with the two files below. They are small on purpose, so you can also paste them into a chat tool.
import re

ORDER_ID = re.compile(r"WH-\d{5}")


def find_order_id(text):
    """Return the first order id in the text, or None."""
    match = ORDER_ID.search(text)
    return match.group(0) if match else None

Save that as orders.py. Save this as test_orders.py:

import unittest

from orders import find_order_id


class FindOrderIdTest(unittest.TestCase):
    def test_finds_id_in_a_sentence(self):
        self.assertEqual(find_order_id("Where is order WH-10432?"), "WH-10432")

    def test_accepts_lower_case(self):
        self.assertEqual(find_order_id("status of wh-10432 please"), "WH-10432")

    def test_returns_none_without_id(self):
        self.assertIsNone(find_order_id("Where is my order?"))


if __name__ == "__main__":
    unittest.main()
  1. Run python -m unittest once yourself (use python3 if python is not found). Three tests run and one fails: test_accepts_lower_case. Now you know what the agent should find.
  2. Pick the permission mode before you start: the one that asks before edits and commands. You want to see each step, not only the result.
  3. Give the task: make the failing test pass by changing the code, never the test. Ask the agent to say each step before it takes it. Pick your tool below and follow the steps. A word on cost before you pick: the Claude Code, OpenAI Codex and Gemini CLI tabs are written for a paid plan, a company licence or a paid key, in every lesson. In this lesson the Cursor and GitHub Copilot tabs work on a free plan with limited usage. From day 2 on, each guide says where a feature may need a paid plan.
  4. Write a row for every step while it runs. Every permission prompt gets a row, also the ones you said no to.
  5. Read the transcript afterwards: the full record of the session, which usually shows more than the screen did. Fill the gaps in your notes.
  6. Write trace.md. One page, one row per step:
| Step | Tool        | What it read or ran     | Asked permission |
|------|-------------|-------------------------|------------------|
| 1    | read file   | test_orders.py          | no               |
| 2    | run command | python -m unittest      | yes, I said yes  |
| 3    | edit file   | orders.py               | yes, I said yes  |

In a chat tool the Tool column often says "me": you ran the test and pasted the result.

Check your trace

  • All three tests pass in the last row, and test_orders.py is unchanged.
  • Every command the agent ran is in the trace, with its result.
  • For each row without a permission prompt, you can say why the tool did not ask.

That last point is the question a client will ask first.

Same loop, different defaults

  • Claude Code: recent versions start in auto mode. Manual mode asks before most edits, shell commands and network access.
  • OpenAI Codex: recommends the Auto preset in a Git folder and read-only in a folder without version control. Read Only asks before edits and commands.
  • Gemini CLI: Default mode asks before every shell command and most write tools. Since 18 June 2026 Google sends free and Google AI Pro or Ultra users to Antigravity CLI, so Gemini CLI needs a company licence or a paid API key.
  • Cursor: Auto-review is the default since version 3.6 and lets allowed calls run without asking. Allowlist with an empty list asks first, though with sandboxing on some commands can still run without a prompt.
  • GitHub Copilot CLI: asks you to trust the folder, then asks before commands. Yes allows one command once.

On a client laptop

Write down the mode you would use there, what it may do without asking, and who approves the rest. Keep to the client rules from the first minute: made-up data only, no secret in a prompt, a file or the repository, and a person approves every write.

Keep trace.md. When a client asks what the agent will do, show the trace before you show the agent. The next six days build on this loop: a prototype in the first meeting, project instructions, skills and hooks, connections to client systems, evals, and a run that works without you.

Deeper dive

Today's actions

Ticks are not saved without an account

Do it in your tool

Claude

  1. Run python -m unittest once in agent-trace/ and copy the output. One of the three tests fails.
  2. Start a new chat in Claude. Paste the prompt below and paste the text of orders.py, test_orders.py and the test output under the matching lines. The upload list names no .py files, so paste them as text.
    Here is a failing test, the function it tests and the test output. Explain in three sentences why the test fails. Then show the smallest change to orders.py that fixes it. Do not change the test. Tell me the exact command I should run to check it. Do not claim the test passes: I will run it and tell you.
    
    orders.py:
    
    test_orders.py:
    
    Test output:
  3. Note in your trace what Claude read (only what you pasted) and what it said is wrong.
  4. Apply the change to orders.py in your own copy. Leave test_orders.py as it is.
  5. Run python -m unittest yourself and paste the output back into the chat. You are the hands of the loop, so this row in your trace gets the tool "me".
  6. Write trace.md when all three tests pass, with one row per step: Step, Tool, What it read or ran, Asked permission.
  7. Hand off to Claude Code to let an agent run the test itself: it reads your codebase, edits files and runs commands. First put the original orders.py back from the lesson text, so one test fails again. Then do the same task in the same folder with the Claude Code tab of this lesson.

Note: We found no Claude help page that shows chat running a project's tests, so you run them. The chat part works on the Free plan. The Claude Code tab needs a paid plan (Pro, Max, Ultra, Team or Enterprise) or a Console account.

Checked on 28 November 2026 · Source: Claude Help Center: Upload files to Claude (opens in a new tab)

Create a free account to save your progress. Sign in or sign up