One of the biggest benefits of using AI agents for development is that the concept of legacy code is gone.
There are no more silos in development teams now. Anyone can work on any part of the application. Ask your agent how that part of the system works and you'll have a detailed explanation in 5 minutes.
Too hard to understand? Tell the agent to use visuals and artifacts.
Make it a conversation
Ask the agent how some part of the code works. Then ask why it gave you that explanation. Point it at another part of the code and ask it to contrast them.
The conversation helps the agent validate its findings, and it helps you understand how things work, technically and from the business side.
Thanks to that conversation, when you ask the agent to change a part of the code that nobody has reviewed in a few years, you can evaluate the change and decide if the approach is right.
The same idea applies to refactors
You can refactor anything. Just be sure there is a good test suite. If there isn't one, create it. I wrote about how agents do that part in Testing in the Age of AI.
Then have the conversation, and ask the agent for the refactor.
Summary
Legacy code meant code nobody felt confident changing. Talk through it with an agent until you understand it, keep a test suite under it, and you can change it or refactor it with your eyes open.