Skip to content

Building with agents, lesson 1.2

The core tools, and how a task flows through them

A coding agent does most of its work with four tools: search, read, edit and run. This lesson follows one bug through all four, and shows why the last one is what makes the fix real.

What do you run?

Every example below changes to fit what you pick. The businesses are made up for teaching.

The picture, one step at a time

Each box is one stage. The picture lights up as you scroll.

Step 1 of 6

From the loop to the tools

Lesson 1.1 built the loop: the model asks for a tool, your code runs it, and the result goes back in. A coding agent runs that same loop with a small set of tools. Four of them do most of the work: search, read, edit and run.

Claude Code's docs group its built-in tools into five kinds (as of November 2026): file operations, search, execution, web, and code intelligence. Search, read, edit and run cover the first three.

Step 2 of 6

Search: find where to look

The agent starts knowing nothing about your code. For the discount box that turns down codes typed in small letters, it first searches: for files by name, then for lines that contain the words that matter. Search turns a whole project into a short list of places to look.

Step 3 of 6

Read: look before touching

Read opens a file and hands back what is in it, with line numbers. It changes nothing, so it is safe to do often. A good agent reads far more than it writes.

Claude Code's tools reference marks Read as needing no permission, and Edit, Write and Bash (its run tool) as needing it (as of November 2026).

Step 4 of 6

Edit: change exact text

Edit swaps an exact piece of old text for new text. If the old text is not in the file exactly as given, the edit fails rather than guessing. That is why the agent reads the file first: it needs the exact words to replace.

Claude Code's docs say its Edit tool does exact replacement with no fuzzy matching, and that Claude normally reads a file before editing it.

The agent tries to edit a file without reading it, guessing at the old text. What happens?

Step 5 of 6

Run: the check on its own work

Run types a command, as you would in a terminal: run the tests, start the app, use git. It is the most useful tool and the riskiest, because anything you could type, it could type. It is also how the agent shows a fix works instead of claiming it does.

Claude Code's docs walk through "fix the failing tests" in six moves: run the tests, read the error, search for the files, read them, edit them, run the tests again.

The agent says the bug is fixed, but it never ran anything. What is missing?

Step 6 of 6

Round again, then report

The flow is not a straight line. A failed test sends the agent back to read the error, search again and edit again. It goes round until the check passes or it runs out of tries, then reports what changed and how it was checked.

Claude Code's docs name the three phases gather context, take action and verify results, and say you can interrupt at any point to steer.

Which tool next?

Here are four moments from an agent fixing a bug in your business. Pick the tool it should reach for next.

  1. 1It has found the file that handles discount codes and needs to see how codes are compared.

  2. 2It has changed the line. Nothing has proved the fix works yet.

  3. 3It knows nothing yet about where discount codes are handled in the code.

  4. 4It has read the line that compares codes letter for letter, capitals included.

0 of 4 right so far, 4 to go.

The four tools card

This is what you keep: the four tools on one card, the order a task flows through them, and the rule for when a fix is done.

The four tools card

  1. Search finds where to look: files by name, lines by the words in them.
  2. Read shows a file and changes nothing. Read before you edit.
  3. Edit swaps exact old text for new. If the old text is not there, it fails rather than guesses.
  4. Run does anything a terminal can: tests, the app, git. The most useful tool, and the riskiest.
  5. The flow: gather context, take action, check the result, and go round until it passes.

No fix is done until a run has checked it: the tests pass, or the app does what was asked.

Next: Lesson 1.3: How coding agents structure system prompts and tools. What the model is told before your first word, and how a tool definition is written.