Most teams hand an agent a repository and a change request in the same breath. That works on greenfield code and fails on old systems, for a structural reason: the legacy system is the thing nobody fully understands, which is why documentation is stale and the original authors are gone. A consultancy evaluating a 3 to 4 million line .NET codebase described the problem plainly, asking "who knows what's in there?", and wanted three to four weeks of assessment before committing a dozen people to the engagement (Driver.ai).
The cost of skipping that step is measurable. A team running a 12-week modernization on a 10 million line Java ERP adopted an agent without any context infrastructure; the changes created additional technical debt, the agents went down rabbit holes, and the project was stuck for over nine months. Four developers independently generated markdown documentation and cross-checked it against each other, and still found errors. The consultant's summary: the model "has no chance" on 10 million lines without pre-computed context (Driver.ai).
Michael Feathers frames the same constraint from the testing side: legacy code is code without tests, and code with a good test suite is relatively easy to change while code without one puts you in serious trouble (Tech Lead Journal). Mapping is the companion discipline. Tests tell you whether you broke something; a map tells you what "something" could possibly be, and which files an agent should never open.
There is also a cognitive reason. Programmers spend a substantial share of their time just comprehending code, and a study of professional code auditors found that LLM tools alone fail to supply the business logic and the adaptive, interactive strategies humans use when onboarding an unfamiliar system (arXiv). The fix in that study was a visual, hierarchical map that reduced reliance on reading LLM prose by 79 percent. Your mapping pass is the low-tech version of the same idea: extract structure, write it down, let the agent read the structure instead of the whole repository.



