Accelerating Code Migrations with AI: From 18 Months to 6 Weeks
Airbnb faced a massive problem: 3,400 enzyme test files blocking their React 19 upgrade. Manual migration would take 18 months. Using AI-powered automation, they completed the migration in 6 weeks.
The Migration Challenge
Airbnb’s web platform team inherited the hardest enzyme test files—the ones that survived years of manual migration attempts. Each file required deep contextual understanding of surrounding projects, making this work both time-intensive and painful.
Traditional approaches offered two options: commit 18 months of developer time or delay the React upgrade indefinitely. Neither option worked for a fast-moving engineering organization.
Four Foundational AI Migration Techniques
1. Write Migration-Specific Validation Scripts
Create validation scripts that run outside AI control. Never trust AI to evaluate its own work.
The process works like this:
- AI coding agent attempts migration with prompts
- Validation script checks results using migration-specific criteria
- Script runs in addition to normal SDLC tests
This validation forms the foundation for all other techniques.
2. Run Validation in a Loop with AI
Combine validation with AI transforms in a continuous feedback loop:
- Run validation first (always fails initially)
- Pass error information to AI coding agent
- AI attempts to fix failures
- Run validation again
- Repeat until success or max attempts reached
This loop enables two critical accelerators:
- Pause and resume capability: Idempotent validation lets you stop, fix scripts, and retry without losing progress
- Brute force retries: Multiple attempts dramatically improve LLM success rates
| |
3. Process Independent Groups Concurrently
Break migration targets into independent groups that can run simultaneously. Focus entirely on speed.
Targets can be:
- Individual files
- Project folders
- Modules or classes
- Lint violations
Run the validate-transform loop concurrently across target groups using a connection pool approach.
| |
4. Use Sample-Tune-Sweep Methodology
AI’s non-deterministic nature requires a different approach than traditional migrations:
Sample: Run migration script against a few targets first. Expect poor initial pass rates.
Tune: Analyze failures and update prompts. Repeat until you achieve reasonable pass rates on the sample.
Sweep: Run script against all targets in a single batch. Save successful results, analyze remaining failures, tune again, and repeat.
Your migration script evolves throughout the process. The final version won’t work well if you restart from the beginning.
Real Results
Airbnb’s enzyme migration results demonstrate the methodology’s power:
- Initial sweep: 75% pass rate in 4 hours (2,550 of 3,400 files)
- Concurrency: 100 processes on a local laptop
- Completion: 6 weeks total, including script development and code review
Since then, Airbnb completed 12 additional migrations using these techniques, moving over one million lines of code.
Implementation Framework
Airbnb built an internal framework codifying these techniques, but you can apply them without custom tooling:
| |
The framework includes:
- Target finding (like IDE file search)
- Composable validate-transform steps
- CLI encouraging sample-tune-sweep approach
Key Principles
Use idempotent, migration-specific validation for confidence in AI transforms. Write transforms and validation into feedback loops, then run loops concurrently against independent targets for speed.
Execute migrations breadth-first, tuning as you progress. Embrace imperfect initial scripts and aggressively push toward the long tail of remaining work.
Getting Started
Start with a small migration to test these techniques. Write your validation script first, then build the AI transform loop. Focus on breaking work into independent, concurrent targets.
The combination of AI capability and systematic methodology transforms impossible migrations into manageable engineering projects.