Refactoring tips

I occasionally use the Agent to do refactoring. First times I tried it, it hallucinated and introduced new bugs (on features that used to work). It took some time to recover and in some cases I had to bring back a complete older version of the code base. Lately I tried a different approach, I told the Agent to copy the files it planned to refactor to a subdirectory (which it has access to) and then do the refactoring (only one refactor at the time). Now, if there is a regression, the Agent can look the working code and figure. I am not really sure but it at least “feels” like it worked better.