The Problem
You inherited a codebase. It works, mostly. But when you ask an AI agent to make changes, it produces garbage — it doesn't understand the implicit architecture, the historical decisions, or the "don't touch that" zones humans absorb through months of tribal knowledge.
Legacy code is harder for AI than it is for humans. The fix isn't rewriting it, it's surfacing the invisible context — turning the tribal knowledge into something an agent can read straight off the page. This guide walks you through the refactoring pipeline that makes that switch, plus the seam markers, strangler-fig moves, and characterization tests that keep you safe while you do it.
The Core Insight
Refactoring for AI is about making implicit knowledge explicit.
What humans learn through months of working with code, AI needs to see in the code itself. The goal isn't to make code "perfect" - it's to make code self-explaining.