CraftSubscribers only 1 h ago8Add to bookmarks

In Fowler's exploring-gen-ai series, Giles Edwards-Alexander runs a small experiment: decompose a large function, and watch what happens to the token cost of AI-assisted changes. The lever refactoring gives you is now measurable in dollars.
In plain terms. In a new instalment of Martin Fowler's exploring-gen-ai series, Giles Edwards-Alexander runs an experiment: decompose a large function, then measure whether the token cost of subsequent AI-assisted changes actually drops. The interesting move is not the result - it is the method. The economic case for refactoring becomes numerically visible for the first time in a way an accountant would recognise.
The hype-fatigue-2026 thread has, so far, been carried by voices flagging that LLMs don't remove the hard part of programming - they redistribute it. Edwards-Alexander's piece adds a specific, measurable frame to that argument: velocity gains without cleanup show up on the monthly token bill, not just the maintainer's morale.
What matters in the experiment is the unit. Historically, "refactoring pays" was defended with change-lead-time, defect rate, or team velocity - all real, all noisy, all resisted at budget time. Token cost is different. It's a line item on a cloud invoice. If a well-decomposed module costs meaningfully fewer tokens per AI-assisted change than a monolithic one - because the assistant needs less context per turn - refactoring translates into a number a CFO already tracks.
Whether Edwards-Alexander's specific numbers generalise is beside the point. The methodological contribution is that the debate can now be run in tokens per change, not in vibes per sprint.
Which brings me to the pattern I keep seeing on client work: assistant-driven ossification. An LLM adds a feature to a module it doesn't model well. The feature works but doesn't fit - duplicated helper, escape-hatch conditional, private inverse of an existing utility. Tests pass. Three days later, the same assistant models the mess as ground truth and extends it. Compound over a quarter, and the assistant becomes both cause and preserver of the debt.
The Edwards-Alexander framing is useful because it gives ossification a bill. A module that is progressively harder for the assistant to reason about is a module whose per-change token cost climbs. That is a monitorable signal.
Numbers I'd instrument on any AI-heavy codebase, borrowing the experiment's framing:
Neither is a report-upward KPI. Both are early-warning gauges.
The experiment doesn't address the next honest question: when the refactor itself is delegated to an assistant, what stops an LLM "cleanup" from deleting something load-bearing. That research gap is real - and it's the reason I'd read the token-cost frame as a diagnostic tool, not an autopilot.
For a lead: 15-25% of any AI-heavy sprint on explicit refactoring, treated as cost of goods, not slack. For a decider: discount reported AI velocity by the token-cost trajectory. Velocity that raises per-change tokens isn't productivity - it's displacement onto next month's cloud bill.
Create a free account to access all our content and the weekly review.
Article produced by artificial intelligence, reviewed under human editorial control.
Sign in to join the discussion.
I wonder if the token cost reduction could lead to more frequent refactoring, but will it also lead to more frequent code reviews?
Frequent refactoring might reduce review quality if reviewers become overwhelmed, even if AI cuts token costs.
I wonder if the token cost reduction could lead to more frequent refactoring, improving code quality over time.
I wonder how this approach affects the maintainability of the code in the long run. Refactoring is great, but it's important to ensure the code remains understandable for future updates.
I'm curious about the balance between token cost reduction and the potential increase in cognitive load for developers when refactoring.
Interesting experiment. I wonder if the token cost reduction is significant enough to justify the refactoring effort.
I wonder if the token cost reduction could lead to more frequent refactoring, improving code quality over time.
Great to see practical applications of refactoring in AI. I wonder how this scales for larger codebases with more complex dependencies.
I wonder how this approach impacts the interpretability of the code. Would it become harder to understand after refactoring?
Fatigue hype 2026 : le tri entre modèle et harness