Agentic coding with legacy code
Thoughts on how to do agentic coding well in legacy systems.
Overview
While reflecting after finishing a pair programming session with an acquaintance, I realized that although I do agentic coding enthusiastically in personal projects, in projects I get paid for my attitude becomes conservative and the proportion of hand-written coding goes up. (As of October 2025)
I thought it would be good to think about ways to do agentic coding more aggressively in legacy systems.
Fragments of thought
(ToDo: finish organizing this)
What is needed is the result, not the process:
- The experience in Agentic coding experiment 1 where I tried hard to make the agent imitate a human and do TDD
- What did I actually need? A simple design that satisfies the requirements so far, and good test cases that cover the code so far. Whether the agent follows the TDD cycle exactly is not important.
On the other hand, if you think about how every result is also a process for something bigger, it becomes ambiguous what is a process and what is a result. In the end, what I need to find is not a vague, indiscriminate “result,” but rather a result at an appropriate level of abstraction.
What is the appropriate level of abstraction in the current context? Since human code review is the bottleneck, modifications in units that are easy to review.
What are the things needed when working in legacy code?
- Making only changes that perfectly guarantee that the system’s behavior does not change even if there are no tests (Hyperaware editing)
- Temporarily moving into a state that is not what is generally called “good code.” For example: deliberately creating duplication (Reconcile differences), creating tests that pass because there is a bug (Characterization test)
- Adding only tests without touching the AUT
- Strengthening type checks or linter settings only for specific parts of the code, then gradually expanding outward
- Modifications centered on tidying
It would be nice if I could easily switch the agent’s mode so that it produces commits made up only of the kinds of modifications above. AGENTS.md, custom slash commands, subagents, and so on would make that easy enough if used appropriately.