Agentic Ai Refactoring Done Right Fixing Unhealthy Legacy Code