Legacy systems that no one dares touch become a drag on business. Specifications have been lost, and the original authors are gone. Organizations lack both the budget to rewrite everything and the courage to shut systems down. Core business systems and internal tools at many small and medium-sized enterprises remain frozen in this state for years. With every change in personnel, the mantra of "don't touch it or it will break" gets passed down; modification estimates run into years and tens or hundreds of millions of yen; and initiatives are deferred once again in an endless loop.
However, with the practical emergence of AI coding agents, this assumption has begun to crumble. The InfoQ presentation "Moving Mountains: Migrating Legacy Code in Weeks instead of Years" provides a practical case study demonstrating how large-scale migrations that once took years can be compressed to weeks or months with AI assistance. Yet this does not mean blindly handing everything over to an AI for an instant fix. From our perspective supporting legacy modernization in custom development, the true secret of this speed lies in drawing a clear distinction between tasks that can be automated and the human judgment required to guarantee quality. This article details that fast yet incident-free approach.
Why legacy migrations have failed in the past
The reasons frozen legacy systems remain untouched extend beyond technical difficulty.
- Specifications exist only within the code. Documentation has decayed, leaving the 20-year-old running code itself as the sole source of truth. Simply deciphering it takes months.
- Safety nets (tests) are nonexistent. Because automated tests do not exist, changing even a single line creates unknown failure risks. Consequently, no one touches it.
- Impact blast radius is invisible. Functions are so intricately entangled that manually tracing call graphs to see where things are called is entirely impractical.
- The terror of big-bang rewrites. Halting everything to rebuild from scratch carries risks too high to survive executive decision-making.
In short, the bottleneck was never the speed of hands writing code, but rather the time needed to decipher existing behavior and the absence of guarantees against breakage. This dynamic is precisely what AI is beginning to transform.
What AI changes and what remains unchanged
AI coding agents excel at large-scale analysis that was previously unfeasible with manual labor alone. Conversely, what remains unchanged—and in fact grows even more vital—is human judgment over quality.
| Process | Traditional (manual) | AI-assisted | Source of acceleration |
|---|---|---|---|
| Specification audit and analysis | Several weeks to months | Several hours to several days | Automated code comprehension and call graph extraction |
| Test generation (safety nets) | Frequently postponed | Automatically drafted | Exhaustive input/output capture |
| New code implementation | Written manually | Drafted by agents | Mass generation of pattern transformations |
| Go/No-go and migration decisions | Human | Human (unchanged) | Not automated |
| Responsibility for production cutover | Human | Human (unchanged) | Not automated |
One report notes that for a 12-year-old, approximately 200,000-line .NET Framework monolith, manual analysis that previously required 6 to 8 weeks was reduced to 6 hours of agent execution plus 4 hours of human review (Augment Code). The crucial detail is that the 4 hours of human review did not disappear. What accelerated was the analysis; decision-making remains firmly in human hands. The fundamental criteria for determining when, where, and how to execute an approved migration directly parallel the philosophy outlined in Refactoring Decisions and Technical Debt in the AI Era.
The 4-step framework for fast, incident-free migration
Step 1: Auditing and visualizing impact blast radius
First, visualize the entirety of the running system with AI assistance. Tracing call graphs outward from entry points (screens, APIs, batch jobs) identifies areas of concentrated change, heavily depended-on modules, and dead code. Here, migration scope and sequencing are defined. Rather than attempting everything at once, begin with low-risk, high-impact vertical slices.
Step 2: Reverse-extracting specifications from code
Have AI reverse-extract lost specifications directly from code. However, never accept extracted specifications as absolute truth at face value; treat them strictly as drafting baselines for human review. The key is articulating current behavior, bugs included, thereby cleanly distinguishing intentional business logic from incidental behavior that just happened to work.
Step 3: Test harness construction (most critical)
This step represents the single non-negotiable requirement of any migration. Migrating without tests is the equivalent of defusing a bomb while blindfolded. Because legacy systems typically lack test suites, first establish characterization tests (golden master testing). Popularized by Michael Feathers (Wikipedia: Characterization test), this technique captures current behavior as-is rather than defining idealized specs. By passing diverse inputs through the legacy system and recording the outputs as a baseline golden master, you can verify whether new code produces identical outputs given the same inputs.
# 概念フロー:旧コードの挙動を「正解」として固定し、新コードと突き合わせる
# 1. レガシーに現実的な入力セットを流し、出力をGolden Masterとして保存
legacy-cli run --inputs ./samples/*.json --record ./golden/
# 2. AIエージェントに、旧コードの仕様抽出とテスト下書きを依頼
agent extract-spec ./legacy/billing/ --out ./spec/billing.md
agent gen-tests ./spec/billing.md --golden ./golden/ --out ./tests/
# 3. 同一入力を旧・新の両方に流し、出力を比較(parallel run)
diff-runner --old legacy-cli --new new-service \
--inputs ./samples/*.json --assert-equal
# 4. 広い入力で出力が一致したら、ルーティングを新コードへ切り替え
Running parallel executions—feeding the same inputs to both legacy and new code and comparing outputs—serves as the core safety valve of AI-assisted migration. Our approach to assuring test quality itself reflects principles discussed in Mutation Testing for Delivery Quality Assurance in Custom Development and Test Automation Implementation Support. We verify not just whether safety nets exist, but whether they actually catch defects.
Step 4: Phased migration (Strangler Fig)
Shielded by the verified test suite, replace the system incrementally. Rather than a risky big-bang rewrite, employ Martin Fowler's Strangler Fig pattern (Thoughtworks). Place a facade (proxy) in front of the legacy system and progressively route traffic to new implementations as each capability is migrated. The legacy system remains operational throughout, gradually superseded by modern code. This enables seamless rollback capabilities, eliminates production downtime, and ensures reliable, modular modernization.
Our custom development delivery structure
When undertaking modernization engagements, we define deliverables not by volume of AI-generated code, but by the functional scope successfully migrated without breakage. As an illustrative example, in an order management system for a manufacturing client (name withheld, running for 15 years and facing imminent end-of-life for its primary language), we spent the first two weeks establishing an audit baseline and characterization test harness, kicking off phased migration with low-risk report generation modules. In initial weeks, we dedicate more time to rollback architecture than raw migration speed, because solidifying these foundations ensures later phases proceed much faster and more safely.
Our staffing structure comprises three tiers: engineers driving AI agents, senior leads reviewing outputs and validating test rigor, and project managers aligning business specifications with stakeholders. While AI supplies abundant coding hands, determining whether behavior is truly identical and whether specific quirks represent business requirements or historical bugs remains a human responsibility. Our overall workflow configuration using AI tools is further described in Development Workflows with Claude Code.
Ideal vs. unsuited scenarios
AI-assisted rapid migration is not a silver bullet. We candidly outline where it excels and where caution is required.
| Well-suited | Unsuited / proceed with caution |
|---|---|
| Most specifications are locked inside the codebase | Highly regulated domains requiring strict formal certification of behavior |
| Inputs and outputs are observable and easily reproducible | Workflows with extensive external side effects that are hard to reproduce |
| Clean modular boundaries exist for phased migration | Tightly coupled monoliths with no extractable boundaries |
| Desire to migrate while preserving existing behavior | Desire to fundamentally redesign business logic from scratch |
Projects aiming to modernize underlying platforms while preserving existing functionality offer the best fit. Conversely, attempting an overhaul of business logic at the same time invalidates golden master baselines and dramatically compounds complexity. Keeping modernization and functional additions in separate phases is an ironclad rule. If you also wish to revamp usability during modernization, that should be paired as a separate initiative using Legacy System UX Improvement.
Pitfalls: Where projects run aground
Finally, here are the most frequent failure modes encountered in AI-assisted migrations.
- The fantasy of total delegation. Assuming that feeding code into an agent will automatically complete a migration leads inevitably to failure. AI output is merely a draft; the moment human review and critical evaluation are bypassed, invisible defects will be shipped straight into production.
- Migrating without tests. If you switch to new code without building a safety net, you will not even know what broke. Skipping tests in the name of speed is the most expensive shortcut you can take.
- The big-bang temptation. The mindset of "if we're rebuilding it anyway, let's do it all at once" makes risk grow exponentially. Never abandon phased migration and rollback planning.
- Confusing specifications with bugs. Freezing current behavior as-is means you will also port existing bugs. When building a Golden Master, a human process is required to sort out whether something is intended behavior or an accident.
Speed naturally follows as a result of automating tasks that can be automated. What you can eliminate first is manual labor, not judgment and testing.
The longer a shelved system is left untouched, the more migration costs and business risks quietly mount. At the same time, there is no need to rush into an immediate full-scale rebuild. A pragmatic approach is to start with the first step: visualizing what the current system actually does, and safely moving forward from the low-risk areas.
If you are hesitating to take the plunge into legacy migration, or if progress has stalled because the estimate is too large, please consult us first with a small assessment. If you share the current state of your target system via Contact Us, we will propose an approach to the migration and the scale of the initial phase.
Sources
- InfoQ: Moving Mountains: Migrating Legacy Code in Weeks instead of Years
- Augment Code: 15 AI-Driven Tactics to Speed Monolith-to-Microservices Migration
- Wikipedia: Characterization test(Golden Master)
- Thoughtworks: Embracing the Strangler Fig pattern for legacy modernization
- Microsoft Learn: Strangler Fig pattern
- Related article: Refactoring Decisions and Technical Debt in the AI Era
- Related article: Custom Development Ensuring Deliverable Test Quality with Mutation Testing
- Related article: Implementation Support for Test Automation
- Related article: UX Improvement for Legacy Systems
- Related article: Development Workflows Using Claude Code









