The Economic Benefit of Refactoring
Giles Edwards-Alexander gives refactoring an unusually concrete AI-era price tag. In a roughly 150,000-line, agent-written Rust application, a representative change initially pulled 159,564 input tokens into context. After breaking a 17,155-line Firestore module into coherent responsibilities, the same task used 27,360 tokens, an 83 percent reduction. The useful mechanism is not small files for their own sake. Better boundaries let an agent find and load less irrelevant code.
The number is evidence, not a universal exchange rate. This was one greenfield codebase, the token counts were estimated from characters, and the agent needed sustained human direction to recognize and execute the refactoring. Correctness, review time, testability, and human comprehension still matter more than a cheap prompt. The durable lesson is that technical debt now charges two readers: people and machines. Good structure can lower both bills, but deciding what belongs together remains design work.