Blog
How AI Agentic Coding Helps You Understand and Migrate Legacy Systems to Microservices
Every legacy migration I've worked on ran into the same wall early on — not writing the new code, but understanding the old code well enough to trust the rewrite. The original developers are long gone, the documentation describes a version of the system that stopped existing years ago, and the business logic that actually matters is buried in a service class nobody has opened since 2014. This is exactly where AI agentic coding is starting to change the economics of legacy modernization — not by writing the microservices for you, but by collapsing the time it takes to build a reliable mental model of the system you're migrating away from.
The bottleneck was never the rewrite — it's the understanding
Martin Fowler's Strangler Fig pattern has been the standard playbook for legacy modernization for years, for good reason: instead of a risky big-bang rewrite, you grow a new system around the old one, incrementally taking over functionality until the legacy application can be switched off. Fowler is explicit that the first step isn't coding at all — it's decomposing the system into "seams," the natural boundaries along which you can peel off one piece at a time. Finding those seams is a discovery problem, and discovery is exactly what takes the longest in a real legacy Java system: tracing which batch job actually still runs in production, which of three near-identical service classes is the live one, and which database tables are read by code that was supposedly decommissioned two reorganizations ago.
Where AI agentic coding genuinely helps
This is the part coding agents are good at today. Given access to a codebase, an agent can crawl thousands of files, trace call graphs and entity relationships, reconstruct end-to-end user flows across modules, and generate documentation for parts of the system nobody has described in years — work that would take a human engineer weeks of archaeology. Industry reporting backs this up: McKinsey has estimated that generative AI in application modernization can cut technology-debt-related costs by around 40% and accelerate timelines by 40–50%, largely by compressing this discovery phase rather than the coding itself.
The more advanced approaches go a step further than plain prompting. AltexSoft's experience report on agent-driven modernization describes feeding agents a graph-grounded view of the codebase — mapped structure, dependency graphs, reconstructed user flows — rather than relying on the agent to hold everything in its own context. That single change reduced hallucination rates on modernization tasks by roughly 40–50% compared to letting an agent reason over raw source files alone. For a Java monolith with a decade of accumulated Spring, Hibernate and EJB layers, that structural grounding is the difference between an agent surfacing a real dependency and confidently inventing one.
Where it still falls short — and why that matters
I'd be doing you a disservice if I stopped there. The same AltexSoft report is candid about the limits: context window constraints still prevent any single agent session from holding a genuinely large codebase in view at once, and most tools have no persistence between sessions — insight gained analyzing one module doesn't automatically carry over to the next. In one modernization project cited in that report, 17 REST endpoints went missing from the migrated system and were only discovered a month after deployment, because no single pass — human or AI — had mapped every caller of the legacy API surface.
The honest conclusion from teams who've actually run these projects is blunt: "the moment you hand over decision-making to AI, you're no longer functioning as an engineer." Service boundary decisions, sequencing, risk tolerance and production validation stay firmly in the hands of the architect. What changes is how much of the tedious groundwork — mapping, tracing, drafting documentation — an agent can take off your plate before that judgment is applied.
Combining agentic AI with the Strangler Fig approach
In practice, the two fit together well, mapped onto Fowler's four activities:
- Establish outcomes — still a human and business conversation; no agent can tell you what "done" should mean for your organization.
- Decompose the system — this is where an agent earns its keep: mapping modules, tracing dependencies, and proposing candidate seams for you to review and correct, instead of you tracing every call chain by hand.
- Deliver incrementally — agents can draft the transitional adapters and routing code the Strangler Fig pattern requires between old and new, while you validate each slice against production behavior before it ships.
- Transform the organization — entirely a people and process question that no tooling shortcuts.
The pattern doesn't change. What changes is that the most time-consuming activity — decomposition — now starts from an AI-generated map of the system instead of a blank whiteboard, provided someone with real Java and architecture experience checks that map before a single service boundary is cut.
How I use this in practice
For mid-market clients, I start any modernization engagement with the same question I'd ask with or without AI in the loop: what does this system actually do today? I use agentic coding tools during that discovery phase — the Java Modernization Assessment I offer — to accelerate mapping architecture, dependencies and technical debt across the codebase, then apply 25 years of Java and Spring experience to validate what the tooling surfaces, decide where the real seams are, and sequence the migration so production never has to stop. The agent shortens the archaeology. It doesn't replace the architect who has to sign off on where the cuts go.
Conclusion
AI agentic coding isn't going to migrate your legacy Java system to microservices on its own, and any pitch that claims otherwise skips the part where 17 endpoints quietly go missing. What it does well is exactly what used to be the most expensive part of every legacy project: building a fast, structurally grounded understanding of a system nobody fully understands anymore. Combine that with a disciplined Strangler Fig rollout and experienced human judgment on the boundaries, and modernization timelines that used to run in years genuinely start to shrink.
Further reading:
- Martin Fowler — StranglerFigApplication
- AltexSoft — Legacy Modernization Using AI Agents: Hands-On Experience
- awesome-agentic-software-modernization (GitHub)
Modernizing a legacy Java system?
I help you understand what you actually have before we decide how to migrate it.
Discuss your project