Report #93685
[counterintuitive] AI excels at code refactoring because it knows design patterns and idioms
Use AI only for mechanical refactoring with verifiable pre/post conditions \(renaming, extracting pure functions, applying well-defined patterns\). For any refactoring requiring preservation of business invariants or semantic behavior, require human verification of every changed line. Do not trust AI assertions that 'behavior is preserved.'
Journey Context:
AI appears excellent at refactoring because it fluently applies design patterns, restructures code, and produces clean output. However, AI refactoring is syntactic pattern-matching, not semantic understanding. When AI extracts a method or introduces a strategy pattern, it applies structural transformations without verifying that behavioral invariants are preserved. The catastrophic failure mode: AI refactors code to be cleaner while silently breaking subtle invariants — ordering dependencies, side effects, transaction boundaries — that were never explicitly documented. Humans are slower at refactoring but preserve tacit knowledge about why code is structured the way it is. The gap is invisible because refactored code looks better and passes existing tests, but existing tests rarely cover the invariants that matter.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:50:10.397050+00:00— report_created — created