About

What this is

Refactoring In The Loop is a reference site that places three classic works on code quality side-by-side and adds a second column for AI coding agents.

  • Refactoring (Fowler, Beck) — refactorings and code smells.
  • Refactoring to Patterns (Kerievsky) — composite refactorings.
  • Design Patterns (Gang of Four) — the 23 reusable object-oriented patterns.

The signature surface is the compare view. Each entry sits in a two-column layout: the human column on the left, the agent column on the right. Both columns carry the same six force fields — Symptom, Goal, Pressure, Tradeoff, Relief, Trap — so any row reads as a direct contrast. The names match Fowler, Kerievsky, or the Gang of Four; the agent row names a token-cost or context-window mechanism for the same name.

Entries cross-link by role. A smell links to the refactorings that relieve it; a refactoring links back to the smells it targets and to any composite refactoring or design pattern it composes into. The catalog forms a bidirectional graph — symptom to remedy in one direction, target shape back to smells in the other.

Terms from LLM research — context window, lost-in-the-middle, token cost — carry inline definitions throughout the catalog. Hover or tap any underlined term to read the definition and its citation without leaving the entry.

The catalog spans roughly 140 entries across the three books. Six force fields per entry, two actors per entry.


Who this is for

  • You are a developer pair-coding with LLM agents. You know the classic catalogs and want a second axis: how each smell, refactoring, and pattern plays out when the editor is an LLM rather than a person.

  • You are a tech lead writing AI coding standards. You need citable, per-smell reasoning grounded in agent mechanics rather than opinion.

  • You are a self-taught developer shipping with an agent. You need a vocabulary for the thing your agent just did and a lookup table to the canonical name.


The problem

No catalog mapped the classic vocabulary onto agent mechanics in a per-entry, mechanism-grounded way. The canon was written for human readers — Fowler, Kerievsky, the Gang of Four — and LLM-paired developers reach for the same names without a second axis that says why each smell costs an agent something different from what it costs a person.

Generic “AI is bad at long files” advice is slop. It names no mechanism, picks no entry, gives no remedy.

When an LLM is the editor, the binding constraints shift to (what fits, what falls outside, ) and (tokens per read, tokens per branch walk, tokens for unrelated payload).

A Long Function is hard to read for a human. For an agent, every reasoning pass loads the whole body, and each extracted helper inflates context cost by one more definition. Same name, different force, different remedy.

A reader who knows Fowler can look up Mysterious Nameand see, in the same vocabulary, why it costs an agent more than a human, and which refactoring’s agent-side relief cancels which agent-side pressure. The classic vocabulary keeps its authority; the agent column carries the second axis.


Three example uses

Diagnosing a degrading agent session. Mid-refactor, the agent starts duplicating a helper across three modules and proposing inconsistent signatures. Open the Duplicated Code entry, read the agent-side pressure, follow the cross-link to Extract Function, and reshape the prompt to point the agent at the canonical helper before asking for the next change.

Writing a team AI coding standard. Pull up Mysterious Name on the compare view. The human column supplies the Fowler framing the team already knows. The agent column supplies the missing sentence: every reasoning pass re-derives meaning from surrounding context; chained edits compound the cost. Paste both columns into the standards doc with a link back to the entry. Repeat for Long Function and Primitive Obsession. The doc now reads as two-actor reasoning, not opinion.

Recognizing a smell the agent just produced. A fourth switch (kind)block lands in the codebase and quietly breaks one of the older three. Search for “switch”, land on Repeated Switches, and read the human-side symptom. The agent-side trap lands the stake: adding a new case requires the agent to find and modify every site, and missing one ships a silent bug. The entry links to Replace Conditional with Polymorphism; the agent-side relief supplies the structural target.


Attributions

Source works

Every entry name, the category structures, and the conceptual frame are drawn from these books.

  • Martin Fowler (with contributions by Kent Beck). Refactoring: Improving the Design of Existing Code, 2nd ed. Addison-Wesley, 2018. ISBN 978-0134757599.
  • Joshua Kerievsky. Refactoring to Patterns. Addison-Wesley, 2004. ISBN 978-0321213358.
  • Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. ISBN 978-0201633610.

This site does not reproduce the books’ prose, diagrams, or code listings. The agent-side force fields, the compare-view commentary, and any synthesized examples are original to Refactoring In The Loop. This is a reference and study aid; it is not a substitute for reading the originals. Where an example is derived from a source book, the entry carries a per-entry citation in its exampleSource field.

AI in production

Portions of this site’s prose, including the agent-side force fields, were drafted by AI coding agents (Anthropic Claude) working from the source books and reviewed and edited by the author. The architecture, voice rubric, and editorial decisions are the author’s.

Contact

Feedback to [email protected].