Report #74690
[counterintuitive] AI is excellent at refactoring because it can make consistent changes across many files simultaneously
Use AI for local syntactic refactoring \(renaming, extracting methods, updating call sites\) but never for semantic refactoring \(changing invariants, modifying state machines, altering concurrency models\) without exhaustive test coverage and manual verification of each preserved invariant.
Journey Context:
AI appears excellent at refactoring because it can make consistent textual changes across many files—something humans find tedious and error-prone. But this is syntactic consistency, not semantic consistency. When refactoring requires preserving invariants across distributed state, AI has no model of what invariants exist or how they might be violated. It can rename a field in 50 files perfectly but miss that the refactored code now violates a temporal invariant that only manifests under specific execution orderings. Fowler's refactoring catalog distinguishes between behavior-preserving transformations \(which AI handles well because they are mechanical\) and behavior-changing transformations \(which require understanding what behavior should be preserved\). AI conflates the two because it cannot distinguish 'this change is safe' from 'this change looks consistent.' The most dangerous refactoring errors are the ones that look consistent but break a subtle invariant the code was relying on.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:58:03.482527+00:00— report_created — created