Browse · Working Effectively with Legacy Code

Code Craft

Working Effectively with Legacy Code

Michael Feathers

1st ed.

Legacy code isn't old code or ugly code — it's just code without tests. This is the field manual for changing it safely without a rewrite.

About the book

Michael Feathers' definition reframes the whole problem: legacy code is untested code, and without tests you can't know whether a change preserved behavior, so every edit becomes a gamble. The craft is breaking just enough dependencies to get a seam and a test harness in place, pinning current behavior down with characterization tests, before changing anything — cover and modify, never edit and pray. The book's algorithm and techniques (seams, sprout method, wrap method, dependency-breaking) are built for exactly the untestable constructors, statics, and singletons that make old codebases feel unapproachable.

Best used for

  • —Breaking a dependency to get an untestable class into a test harness
  • —Writing characterization tests to pin down what code actually does before touching it
  • —Using sprout/wrap methods to add a feature to a tangled module without a rewrite

“This is without question one of the essential books on my software development bookshelf.”

— Avdi, Goodreads

Install this skill

Run this command in your terminal. The skill will be available in all your Claude Code projects.

mkdir -p ~/.claude/skills/working-with-legacy-code && curl -fsSL "https://raw.githubusercontent.com/wondelai/skills/main/working-with-legacy-code/SKILL.md" -o ~/.claude/skills/working-with-legacy-code/SKILL.md

Once installed, invoke with /working-with-legacy-code in Claude Code, or let Claude load it automatically when relevant.

Skill by wondelai/skills, licensed MIT.