Legacy code with AI
For engineers
Mapping an unfamiliar codebase, pinning behaviour with characterization tests and refactoring in safe steps
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
You ask an agent to map a legacy repo. Which request gives you the most checkable result?
Check yourself · 2 of 5
A function has an odd special case for one country. What should you do before an agent removes it?
Check yourself · 3 of 5
What does a characterization test assert?
Check yourself · 4 of 5
Why commit a legacy refactor in small steps with a test run after each?
Check yourself · 5 of 5
An agent deletes a function because a search finds no callers in the repo. What should you check before accepting?
Topics
- Mapping an unfamiliar codebase with an agent4 min read · Asking an agent for entry points, data flow, a module map and dependencies, then checking the map against the code
- Recovering intent from history and tickets4 min read · Using git blame, commit messages, tickets and old docs to learn why odd code exists before an agent changes it
- Characterization tests before changing legacy code5 min read · Pinning what the code does today, odd behaviour included, so an agent's change cannot alter it silently
- Small safe refactors with green tests5 min read · Refactoring in small mechanical steps, one commit each, with the tests run after every step
- Rewrites that lose legacy behaviour5 min read · Big-bang rewrites, dropped edge cases, deleted 'dead' code that was still used and changed error handling
Start here
- Legacy Modernization meets GenAI (martinfowler.com) (opens in a new tab)ArticleFree
Thoughtworks field notes on using generative AI to understand and modernise old systems.
- Characterization test (Wikipedia) (opens in a new tab)ArticleFree
Defines the technique of pinning current behaviour with tests before you change code.
- Strangler Fig Application (Martin Fowler) (opens in a new tab)ArticleFree
The standard pattern for replacing a legacy system piece by piece instead of all at once.
Helps to know first
110 questions · last verified 2026-12