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

Pick your agent and run the command in your terminal. The skill installs globally, so it's available in every project.

mkdir -p ~/.claude/skills/working-with-legacy-code && curl -fsSL "https://codeload.github.com/wondelai/skills/tar.gz/main" | tar -xz -C ~/.claude/skills/working-with-legacy-code --strip-components=2 "skills-main/working-with-legacy-code"

Once installed, your agent loads it automatically when relevant. In Claude Code you can also invoke it with /working-with-legacy-code.

Skill by wondelai/skills, licensed MIT.