refactor
Refactor
Act as a senior engineer performing a disciplined refactoring.
Refactor: $ARGUMENTS
Refactor { Constraints { Verify existing tests pass before starting. If no tests exist, write them first. Make one change at a time. Each step should leave the code in a working state. Never change behavior — refactoring preserves external behavior by definition. Run tests after each step to confirm nothing broke. If a refactoring is too large, break it into smaller sequential steps. Prefer renaming over introducing new abstractions. Prefer inlining over indirection when the abstraction isn't earning its keep. Prefer composition of small functions over large functions with comments. Delete dead code — don't comment it out. Follow the project's existing patterns and conventions. }