Back to Skills

working-with-legacy-code

Safely change and test untested codebases using Feathers' "Working Effectively with Legacy Code". Use when the user mentions "legacy code", "no tests", "untested codebase", "how do I test this", "seams", "characterization tests", "golden master", "sprout method", "afraid to change this code", "monster method", "dependency breaking", or "inherited a messy codebase". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it,

1,944stars195forksUpdated 8/17/2026

Security Assessment

Safe(96/100)
Security Score96/100

About working-with-legacy-code

Working with Legacy Code is a software-craft reference skill that teaches how to safely change and test untested codebases, distilled from Michael C. Feathers' book 'Working Effectively with Legacy Code'. It reframes legacy code as simply code without tests and addresses the core dilemma that you need tests to change code safely but must often change code to get tests in place. The remedy it teaches is the cover-and-modify discipline: get code into a test harness, pin current behavior with characterization tests, then change one verifiable step at a time instead of a rewrite.

The skill provides a change algorithm (identify change points, find test points, break dependencies, write tests, then change and refactor), a scoring rubric from 0 to 10 for rating how safely changes are made, and a framework covering seams, characterization/golden-master tests, sprout and wrap methods, and dependency-breaking techniques for constructors, statics, and singletons. Reference files add detailed case studies (for example getting an 800-line untested service class or a singleton-ridden Python pricing module under test), plus focused guides on characterization tests, the change algorithm, dependency breaking, and seams. It explicitly separates behavior changes from refactoring so failures stay diagnosable.

Target users are developers who have inherited messy or untested code, are afraid to modify a tangled module, or need to add features or fix bugs while building incremental test coverage. It points to companion skills for refactoring already-tested code and for day-to-day code quality.

FAQ

What problem does this skill solve?

How to change untested 'legacy' code safely: getting hard-to-instantiate classes into a test harness, pinning existing behavior with characterization tests, and making small verifiable changes instead of a risky rewrite.

What is the core method?

A fixed change algorithm: identify change points, find test points, break dependencies with the least invasive technique, write characterization tests, then make behavior changes and refactor as separate verified steps.

Is it tied to a specific language?

No. The principles are language-agnostic, and the case studies span TypeScript and Python examples for dependency breaking and getting singletons and monster methods under test.

How does the scoring work?

Changes to untested code are rated 0-10 against the principles, with a goal of 10/10; the skill reports the current score and the specific steps needed to reach it.

When should I use a different skill instead?

For refactoring code that already has tests, use refactoring-patterns; for day-to-day code quality, use clean-code. This skill is specifically for untested/legacy code.

All Files

6 files
references/case-studies.md13.4 KB
View
references/characterization-tests.md11.8 KB
View
references/change-algorithm.md11.9 KB
View
references/dependency-breaking.md13.9 KB
View
references/seams.md10.5 KB
View
SKILL.md19.0 KB
View

Install working-with-legacy-code

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

wondelai/skills