Sub topic 5
Let the agent read before it plans
This chapter assumes you have used a coding agent on a repository, can read a diff, and can run the project's tests. It covers the read-only exploration step: the agent inspects your code before it proposes anything.
Why reading comes first
A plan written without reading the code is a guess. The agent may name files that do not exist, invent a helper that the project already has, or pick a pattern that conflicts with your conventions. Reading first lets the plan refer to real files and real functions.
Exploration is read-only. The agent opens files, searches for text, and lists directories. It does not create, edit, or delete anything. This is why the planning request in the previous chapter includes the line "Do not edit any files yet."
What the agent reads
For the /login rate limiting example, a careful agent usually looks at these things:
- The route that handles
/login, to see where a check would fit. - How errors are returned, so the new response matches the existing format.
- Existing configuration, to find where limit values belong.
- Related code that already counts, caches, or stores per-client data.
- The existing tests, to see how new tests should be written and run.
You can steer this. If you know where the relevant code lives, say so. If you know of a trap, such as a legacy module that looks relevant but is being removed, name it.
Start by reading `auth/routes.py` and `tests/test_auth.py`.
Ignore `auth/legacy_login.py`; it is being removed.
Do not edit any files. Tell me what you found before you propose a plan.Ask for a report of findings
Reading is only useful if you can see what it produced. Ask the agent to summarize what it found before it writes the plan. A short findings report lets you catch a wrong turn early, for example when the agent has read the wrong module.
The sequence below shows where exploration sits in the workflow.
Check that exploration was read-only
Do not assume. After the agent finishes reading, confirm that nothing changed in your working tree:
git status --shortEmpty output means no files were modified or created. If you see changes, the agent edited something despite the instruction. Review them with git diff and revert what you did not want before continuing.
Common errors
| Problem | Sign | Fix |
|---|---|---|
| Agent reads too little | The plan names no real functions or line-level details | Point it at specific files and ask it to cite what it read |
| Agent reads too much | Long exploration of unrelated directories | Name the area to focus on and the areas to skip |
| Agent reads the wrong code | Findings describe a module you did not mean | Correct it before it plans |
| Agent starts editing | `git status` shows changes | Restate the no-edits rule and revert the changes |
Exercise
You asked an agent to plan a change and told it not to edit files. After it finishes reading, what command do you run to confirm nothing was modified, and what output do you expect?
Show answer
Run git status --short. Empty output means the working tree is unchanged. Any listed file means the agent modified or created something, and you should inspect it with git diff and revert unwanted changes.