legacy-modernizationlisted
Install: claude install-skill alexander-danilenko/cortex-ai-skills
# Legacy Modernization
Incremental migration of running systems. The constraint that shapes every decision here: the system is in production and must keep working while it changes.
## The sequence
Order matters more than the individual techniques — each step exists to make the next one safe.
1. **Characterize before changing.** Write tests that pin current behaviour, bugs included. You are not testing what the code _should_ do; you are recording what it _does_, so a behaviour diff becomes visible. When an assertion looks wrong, that is the point — write it down and say so:
```python
def test_domestic_lightweight():
order = {"weight": 5, "destination": "domestic", "priority": False}
# Current behaviour: nothing charged under 10kg. Looks like a bug —
# pin it here, fix it as its own change after the migration lands.
assert calculate_shipping_cost(order) == 0.0
```
Golden-master or approval tests (approvaltests, syrupy) get coverage over gnarly code fastest, because they capture output wholesale instead of requiring you to understand it first.
Then check the net actually holds: run a mutation tester over the code you are about to change. Characterization suites routinely look thorough and still miss the exact branch you're about to touch — surviving mutants tell you where, before an incident does.
2. **Insert a seam.** Branch by abstraction: introduce an interface over the thing you're replacing, and route all callers through it