Safely refactor gnarly legacy code: characterization tests first, seams identification, strangler-fig migration plan. Based on real enterprise migration experience.