Should I rewrite AI-generated code that works?
Usually no. Rewriting discards working behaviour along with the bugs. Map it, enforce the boundaries you care about, and replace parts only where you have a concrete reason. A rewrite is the most expensive response to a comprehension problem.
From How to review a codebase you didn't write, published 9 August 2026. That article is where the reasoning behind this answer is set out, including what it does not cover.