Code Quality

Legacy Code

Safely change untested code: seams and characterization tests

Safely change untested codebases using Michael C. Feathers' Working Effectively with Legacy Code. This skill equips your AI agent with the legacy code change algorithm — finding seams, breaking dependencies, pinning behavior with characterization tests, and making changes one safe, verifiable step at a time.

Working Effectively with Legacy Code by Michael C. Feathers

Working Effectively with Legacy Code

by Michael C. Feathers

npx skills add wondelai/skills/working-with-legacy-code

What your agent learns

The Change Algorithm

Identify change points, find test points, break dependencies, write tests, then change — cover and modify, never edit and pray.

Seams

Places where you can alter behavior without editing the code — object seams, link seams, and their enabling points are how tests take control.

Characterization Tests

Document what the code actually does: assert something absurd, read the failure, pin the observed behavior in place.

Sprout & Wrap

When you can't test the host today, write new logic as fresh, tested code called from a single line — or wrap the old method decorator-style.

Dependency Breaking

A catalog of mechanical moves — Parameterize Constructor, Extract Interface, Subclass and Override — that unblock testing with minimal risk.

Michael C. Feathers

Software design consultant, defined "legacy code" for the industry

Michael C. Feathers is the founder of R7K Research & Conveyance, a consultancy focused on software design and the rehabilitation of aging systems. A long-time consultant and conference speaker, he gave the field its working definition: legacy code is simply code without tests.

View Book →

Try these with the skill installed

Get this class with a hard-wired database connection under test using working-with-legacy-code skill

Dependency breaking

Write characterization tests for this function before I refactor it using working-with-legacy-code skill

Safety net

Add this feature to an untested module using sprout method using working-with-legacy-code skill

Safe change

Plan incremental test coverage for our legacy codebase using working-with-legacy-code skill

Test strategy

Install Legacy Code

Free, open-source, and ready in 30 seconds.

npx skills add wondelai/skills/working-with-legacy-code

MIT Licensed · Works with Claude Code, Cursor, Claude Cowork & OpenClaw · No account needed