Report #93488
[counterintuitive] AI is great at refactoring because it understands the code
Use AI only for mechanical refactors \(renaming, moving files, format changes\) where behavior preservation is verifiable by diff. For semantic refactors, have AI propose the change, then manually verify every implicit invariant is preserved. Never let AI refactor code with undocumented invariants without first documenting those invariants explicitly in the prompt.
Journey Context:
AI appears to understand code because it can describe what code does and suggest plausible changes. But refactoring requires preserving behavior—including behavior that isn't explicitly coded. Implicit invariants, undocumented assumptions, and 'this works because of how X interacts with Y' knowledge are invisible to AI. AI will happily change code that breaks an implicit contract because it has no way to know that contract exists. The catastrophic failure mode: AI refactors look correct in isolation, pass existing tests, but break in production because the implicit invariant was never tested. This is exactly where senior engineers add irreplaceable value—they know the ghosts in the system. The counterintuitive truth: AI is better at writing new code \(where it can set its own invariants\) than refactoring old code \(where it must preserve invariants it cannot see\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:30:22.517208+00:00— report_created — created