Refactor code safely while preserving observable behavior. Extracts functions, simplifies conditionals, renames for clarity, deduplicates logic, and modernizes syntax. Use when the user says "refactor", "clean up", "simplify", "extract", "rename", "deduplicate", or asks to improve code structure without changing behavior. Always run the existing test suite before and after; if no tests exist, propose characterization tests first.