Sources
Refactoring Cut an Agent's Input Tokens 83% on a 17,155-Line Rust File — Thoughtworks Publishes the First Controlled Measurement
Giles Edwards-Alexander (Thoughtworks CTO for EMEA and India) published a controlled experiment on martinfowler.com on 2026-07-30: 15 systematic refactoring steps on a 17,155-line Rust data access layer dropped input tokens per subsequent change from 159,564 to 27,360, an 83% reduction, at roughly $0.40 saved per change at Sonnet 5 pricing. Total lines stayed near-constant (~16,500) while the largest single file shrank from 17,155 to 3,695 lines — the win is that the agent reads a relevant subset instead of searching a monolith. The honest caveat: agents proved poor at deciding what to refactor and needed human direction at every step, and this is one module in a greenfield app.
↳ Follow the thread