Give a coding agent enough repository context to trace the requested behavior from its entry point to its implementation, contract, and verification. Start with the task and the repository’s applicable instructions. Then follow evidence: a failing input, an exported symbol, a route, a caller, or a test. Add files because they answer a question the change raises.
The goal is a defensible working set. An agent fixing CSV output needs to know who produces the bytes, what consumers expect, and how the result is checked. It does not automatically need the payment service, deployment history, or every file containing the word “export.”
This guide develops a navigation method with a small, locally executed example. It is a way to organize investigation, not a measured claim about model accuracy or token savings.
Begin with a behavior you can locate
“Fix exports” is difficult to investigate because several different failures could satisfy that description. A more useful starting point is:
When there are no orders, the CSV download is empty. It should still contain the existing header. Preserve the field names and integer-cent values for nonempty exports.
That gives the agent three questions: where empty input is handled, where the header is defined, and which checks protect existing output.
Before searching, establish the working directory and current Git state. Read applicable repository instructions and identify the supported test command. Existing uncommitted changes matter: they can explain a failing test, and they belong in the change’s context even when they are outside its intended scope. Do not overwrite them to manufacture a clean starting point.
An initial file list helps orient the investigation. Search the relevant folders for a distinctive symbol or data field, then inspect complete functions and their callers. A matching line identifies a location; it rarely establishes the surrounding contract.
Follow one path through a synthetic repository
The example repository contains eight files. Its instruction file points export work to docs/export.md. That contract says empty exports retain the header, and money is represented in integer cents.
These commands were executed in a disposable fixture:
rg --files
rg -n 'export_csv|total_cents' src tests docs
The search found the serializer, its CLI caller, the export contract, and a documented nonempty example. Reading the serializer exposed this early return:
def export_csv(rows):
if not rows:
return ""
return "order_id,total_cents\n" + "".join(
f"{r[0]},{r[1]}\n" for r in rows
)
Calling export_csv([]) returned ''. The contract expected 'order_id,total_cents\n'. That is enough to locate a concrete mismatch, without assuming a browser or database defect.
The caller imports the serializer and passes its output through. This makes it relevant even though it needs no edit: a caller that prepended its own header would change the proposed fix. The nonempty example establishes the existing field order and representation. In this fixture it is a comment, not an executable test; it supplies an expectation but no passing test evidence.
The resulting working set is small for a reason:
| File | Question it answers | Treatment |
|---|---|---|
AGENTS.md |
Which local instructions apply? | Read first. |
docs/export.md |
What does empty output mean? | Keep the specific contract available. |
src/export.py |
Where is the output produced? | Read the entire function. |
src/cli.py |
Does a caller transform the result? | Read the call site and output path. |
tests/test_export.py |
What existing behavior is described? | Note that the fixture contains an example comment, not a runnable test. |
web/export-button.ts |
Does the UI serialize CSV? | Exclude after observing that it delegates the job. |
generated/catalog.json |
Does generated content own the field contract? | Exclude: this file describes display labels. |
docs/payments.md |
Does settlement affect serialization? | Exclude from this task; no evidence of a dependency. |
“Excluded” means unnecessary for the current investigation. If the serializer later proves to receive transformed values, the investigation should expand to that transformation. The file selection is a revisable conclusion.
Give each retained item a role
A useful context packet explains why the files are present. For this example:
Task: preserve the CSV header for empty order exports.
Contract: docs/export.md; order_id,total_cents, integer cents.
Implementation: src/export.py::export_csv.
Caller: src/cli.py passes the result through unchanged.
Observed: export_csv([]) returns an empty string.
Verification gap: the nonempty example is only a comment.
Next: add executable empty/nonempty checks, then change serialization.
Excluded: UI delegation, generated labels, payment settlement.
The packet separates the requirement, the observed behavior, and work still to do. It does not say tests passed when a file merely contains an expected value. That distinction is as important as which paths were selected.
Keep precise references to long material instead of pasting it wholesale. The agent can retrieve a contract section when needed, provided its tools can actually access that path. Anthropic describes this use of lightweight references and on-demand retrieval in its context engineering guidance. The method above is an application of that idea, with explicit questions determining what to read.
Expand at boundaries, not at random
Follow a value across a boundary when a plausible explanation remains unresolved. For an API field rename, inspect the serializer, schema, client decoder, and relevant compatibility tests. For a permission change, inspect where identity is established and where resource ownership is checked. For a slow query, inspect the query, its inputs, relevant indexes, and actual measurement before attributing the delay to a particular layer.
A semantic search result can suggest a location when terminology is unfamiliar. Exact search is useful when the failing symbol, endpoint, or error is known. Neither method removes the need to check complete code. In VS Code, for example, the documented context model distinguishes search and workspace indexing from information actually included in a model request. An index is a retrieval aid; it is not proof that the agent has read every relevant file.
If search returns nothing, vary the vocabulary and trace entry points. Record the places searched. “No match in these directories” is narrower and more useful than “the repository has no implementation.” Generated code, ignored files, other services, and runtime configuration may sit outside the search’s scope.
Stop when the change and its checks are explainable
Before editing, the agent should be able to state where behavior originates, which contract constrains it, what may be affected, and how a change will be verified. An unresolved question that could alter the fix warrants another targeted read.
After editing, refresh the working set around the actual diff. If the fix touches a shared helper, callers outside the original path may now matter. If the tests expose a second behavior, preserve that new evidence rather than continuing from the original assumption.
The local exercise verified navigation and the empty-output mismatch using Python 3.14.2 and ripgrep 15.2.0. It did not implement a production fix or compare agents. Its useful artifact is the trace: every included file answered a concrete question, and every exclusion carried a reason that could be revisited.
Documentation checked October 28, 2026. Paths and data in the worked example are synthetic.