Modernize Legacy Code
Incremental workflow for updating old code to modern patterns
CLAUDE.md
When modernizing legacy code:
- Add tests for the current behavior first. You need a safety net before changing anything.
- Make one type of modernization at a time: don’t mix syntax updates with logic changes.
- Start with low-risk changes: var to const/let, callbacks to async/await, require to import.
- Progress to structural improvements: extract classes, add types, improve error handling.
- Run the full test suite after each change.
- Don’t modernize code that’s scheduled for removal or rewrite. Focus effort on code that will live.
- Ship modernization changes separately from feature work — never in the same PR.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.