I constantly have to push Claude to refactor code and extract pieces, not because the nesting is too deep or there is too many lines in a single function, but just to name things and give them meaning. LLMs tend to produce obscure code that doesn't aid understanding.
I view refactoring as steering the code in a particular direction. You have to know where you want to end up, or you'll wander aimlessly or end up somewhere else, making it harder to get things right. And each refactor is documentation of that journey.