You have to remain the driver and solution architect
I used Claude Code to refactor a series of tests from Minitest::Mock to the Mocha library this early morning.
The main reason is that I had certain parts of the tests using Mocha and others utilizing Minitest::Mock. Since other projects I work on use RSpec, I find Mocha to be closer toons in RSpec, which minimizes the context change for me overall.
I started with a simple example and provided this prompt:
Go in the test/services/bluesky/save_thread_test.rb and redo the test 'empty result when client returns empty array' to use mocha instead of simple Minitest mock
Here is what Claude Code proposed as a change. It added the line with instance_variable_set (it is not marked here as a diff because I chose 'No' when it asked me to apply, and I'm not sure why it isn't marked).
What is true is that the SaveThread object is not handling dependency injection properly: it instantiates a Bluesky::Client, but it does not accept it during initialization.

So I followed up with:
Instead of doing instance_variable_set wouldnt it be better to do depedency injection in the SaveThread object?
And I got the following answer:

It’s an interesting solution, but I don't like it for obvious reasons: the object I want to test is also the object that is altered by the test (which goes against the fundamental principles of testing).
Thus, I asked:
I prefer to change the SaveThread object itself
Notice that it included the client in the initializer, added an attr_reader for it, and also kept the previous memoized method.

In my opinion, this type of behavior reinforces the notion that you need to know how you want your code to be structured (which I refer to as code design).
It also seems more important than ever to be able to read a diff and understand the proposed changes. LLMs may improve over time, but at least for now, it appears to me that to ensure good code quality, one must first have enough experience to recognize what good quality is and be able to determine which changes to accept or reject.