Refactoring as a token-cost lever: an experiment in Fowler's gen-AI series

Suivi de l'affaire : Fatigue hype 2026 : le tri entre modèle et harness· Épisode 11/16

Craft 30/07/2026 à 19h4015Ajouter aux favoris

Refactoring as a token-cost lever: an experiment in Fowler's gen-AI series
Illustration : Léa Fontaine

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.

Where this connects

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.

The measurement, not the moral

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.

The failure mode, named

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.

Under the hood: two gauges

Numbers I'd instrument on any AI-heavy codebase, borrowing the experiment's framing:

  • Tokens per AI-assisted change, per module, tracked monthly. If it climbs while assistant usage climbs, ossification is running.
  • Duplication ratio in AI-authored diffs. Cheap to compute with a code-similarity tool; a leading indicator of the token curve.

Neither is a report-upward KPI. Both are early-warning gauges.

Where the piece stops short

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.

So what

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.

Ressources, à tester

Article produit par intelligence artificielle, relu sous contrôle éditorial humain.

Notre rédaction
Your Linux servers, as a desktop.
TermalOSSponsored
Ops, reimagined

Your Linux servers, as a desktop.

Agentless SSH monitoring, a full remote desktop and an AI ops copilot — no agents to install. Everything stays on your machine.

SSHMonitoringAI Ops
Get early access
Cet article vous a-t-il été utile ?

16 personnes ont aimé cet article

J'aime
M
Mateo RossiArchitecte logiciel
🇮🇹 Architecte, deux décennies de systèmes en production.
Partager :
Commentaires (15)

Connectez-vous pour rejoindre la discussion.

ArtLover88 01 Aug 2026 · 15:12

This trick feels like optimizing for the wrong metric-token cost vs actual maintainability in real teams. Wouldn’t better test cases or clearer contracts pay off more long-term?

TechSavvy 31 Jul 2026 · 18:03

Token savings are nice, but refactoring for AI readability might just shift cognitive load back to human reviewers. Will the real win come from stricter API contracts instead?

FoodieFiona 2 31 Jul 2026 · 18:02

This refactoring hack feels like another way AI tools are optimizing *our* workflows at the expense of *its* coherence. Will we end up with code that’s cheaper to tweak but harder to trust?

Alex_LDN 31 Jul 2026 · 17:55

This refactoring trick reminds me of how we used to break down legacy systems for readability-AI just formalizing what good devs already knew. But does token cost alone change behavior, or will teams still wait for ‘real’ pain before acting?

sandrine.b 31 Jul 2026 · 17:49

Makes sense-breaking things down cuts costs both in tokens and cognitive load. But does the real win come from saving money, or from making refactoring so painless we actually do the deep work instead of hacking just to move forward?

Dr. L. 31 Jul 2026 · 05:42

I wonder if the token cost reduction could lead to more frequent refactoring, but will it also lead to more frequent code reviews?

MusicFanatic 31 Jul 2026 · 08:20

It might also depend on the team's culture and how they prioritize code quality over speed.

unLecteurCurieux 30 Jul 2026 · 19:22

Interesting experiment! I wonder if the token cost reduction could also lead to more frequent, smaller refactoring sessions, making it easier to maintain code quality over time.

ph1lippe_m 30 Jul 2026 · 16:48

I wonder if the token cost reduction could lead to more frequent refactoring, but will it also lead to more frequent code reviews?

J.P.R. 2 30 Jul 2026 · 19:00

Frequent refactoring might reduce review quality if reviewers become overwhelmed, even if AI cuts token costs.

Dr. J. 30 Jul 2026 · 21:46

Frequent reviews could be automated with AI, balancing cost savings and code quality.

FoodieChicago 30 Jul 2026 · 16:39

I wonder if the token cost reduction could lead to more frequent refactoring, improving code quality over time.

GreenThumb 30 Jul 2026 · 16:29

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.

1
curio_usa 30 Jul 2026 · 16:27

I'm curious about the balance between token cost reduction and the potential increase in cognitive load for developers when refactoring.

LitLover42 30 Jul 2026 · 16:24

Interesting experiment. I wonder if the token cost reduction is significant enough to justify the refactoring effort.

Emma_London 30 Jul 2026 · 16:18

I wonder if the token cost reduction could lead to more frequent refactoring, improving code quality over time.

Alex 2 30 Jul 2026 · 15:49

Great to see practical applications of refactoring in AI. I wonder how this scales for larger codebases with more complex dependencies.

FilmBuffNYC 30 Jul 2026 · 15:38

I wonder how this approach impacts the interpretability of the code. Would it become harder to understand after refactoring?

Le fil de l'affaire

Fatigue hype 2026 : le tri entre modèle et harness

  1. 1« I love LLMs, I hate hype » - geohot rappelle la seule règle qui reste13/07/2026
  2. 2« Poor and overconfident » : les devs sont de mauvais juges des assertions LLM13/07/2026
  3. 3Comment les pros du logiciel jugent-ils vraiment le code généré par IA ?13/07/2026
  4. 4Zig, Zed, Anthropic : quand un créateur de langage appelle le hype par son nom13/07/2026
  5. 5"The LLM critics are right. I use LLMs anyway" - la voix qui recompose16/07/2026
  6. 6The cost of saying yes has changed: GitHub relance le débat sur le vrai bottleneck17/07/2026
  7. 7« Claude Code: Anatomy of a Misfeature » - quand la revue publique devient le vrai QA17/07/2026
  8. 8Google's Gemini 3.6 Flash is cheaper and shorter - and Gemini 4 gets a tease while 3.5 Pro stays late22/07/2026
  9. 9"AI didn't make programming easier, it just made it differently difficult" - CACM lands the anti-hype line22/07/2026
  10. 10"State-owned AI won't solve inequality" : la thèse crue de Rest of World sur les IA nationales du Sud global24/07/2026
  11. 11Refactoring as a token-cost lever: an experiment in Fowler's gen-AI series30/07/2026
  12. 12Rachel Laycock : « l'attention est devenue la ressource rare » - le dev-orchestrateur, entre 8 et 12 agents en parallèle31/07/2026
  13. 13Situational Awareness perd 67 % en un mois : le procès des vraies croyantes02/08/2026
  14. 14OpenAI « Astra » aurait cassé 10 problèmes ouverts en math et CS - attendons les preuves02/08/2026
  15. 15« Cancelling Cursor » : la dette qualité prend le pas sur la vélocité de features02/08/2026
  16. 16Jeff Dean on what AI teams get wrong: the diagnostic from the shop that pays every bill03/08/2026
Your Linux servers, as a desktop.
TermalOSSponsored
Ops, reimagined

Your Linux servers, as a desktop.

Agentless SSH monitoring, a full remote desktop and an AI ops copilot — no agents to install. Everything stays on your machine.

Get early access
Rubriques
Explorer
Informations