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.

Updated Free & MIT-licensed

npx skills add wondelai/skills/working-with-legacy-code --global
Working Effectively with Legacy Code
Michael C. Feathers
Working Effectively with Legacy Code by Michael C. Feathers

Working Effectively with Legacy Code Michael C. Feathers View on Amazon

02 What it is

What is the Legacy Code skill?

Code without tests is the case Michael Feathers wrote a book about, and this free skill is your agent's procedure for it: find the change points, find the seams, break the dependencies, pin current behaviour with characterization tests — and only then change anything.

03 Key concepts

Five principles your agent applies.

Drawn from Working Effectively with Legacy Code — not advice it repeats back to you, but decisions it makes while it works.

01 The Change Algorithm Identify change points, find test points, break dependencies, write tests, then change — cover and modify, never edit and pray.
02 Seams Places where you can alter behavior without editing the code — object seams, link seams, and their enabling points are how tests take control.
03 Characterization Tests Document what the code actually does: assert something absurd, read the failure, pin the observed behavior in place.
04 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.
05 Dependency Breaking A catalog of mechanical moves — Parameterize Constructor, Extract Interface, Subclass and Override — that unblock testing with minimal risk.

04 Fit

When to use it, and
when not to.

four symptoms it fixes, and four it doesn't.

Reach for it when

You need to change a file that has no tests and nobody left on the team wrote it.

You want to add tests to existing code but every class drags in a database, a network call, or a singleton.

A bug fix keeps being deferred because the blast radius of touching that module is unknown.

You are inheriting a codebase and want a safe first change rather than a rewrite proposal.

Reach for something else when

The code already has good test coverage. go straight to Refactoring, which assumes a safety net.

You are writing new code and want it to read well. Clean Code applies from the first line.

The decision is whether to rewrite or keep the system at all; that is a strategy question, not a technique one.

You need to reduce interface complexity in well-tested code. Software Design is the better fit.

05 Prompts

Say it like this.

Name the skill at the end of a prompt and the agent applies the framework rather than a vibe. Or say nothing — it loads on its own when a task matches.

example prompts
# 01 · Dependency breaking

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

# 02 · Safety net

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

# 03 · Safe change

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

# 04 · Test strategy

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

06 About the author

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.

08 Questions

Before you install.

01

How do I install the Legacy Code skill?

Run npx skills add wondelai/skills/working-with-legacy-code --global. It takes about 30 seconds and needs no account. The Legacy Code skill then works in Claude, Claude Code, Claude Cowork, Codex, Cursor, OpenClaw and Hermes Agent — anything that reads the open agentskills.io format — and your agent loads it on its own when a task calls for it. It is free and MIT-licensed, and the source is at https://github.com/wondelai/skills.

02

Which book is the Legacy Code skill based on?

It packages Working Effectively with Legacy Code by Michael C. Feathers — software design consultant, defined "legacy code" for the industry. The skill distils the book's method into instructions your agent follows while it works, covering the change algorithm, seams and characterization tests. It sits in the Code Quality part of the library.

03

What counts as "legacy code" here?

Feathers's definition, which the skill uses: code without tests. Not old code, not inherited code, not code in an unfashionable language — code you cannot change confidently because nothing will tell you if you broke it. By that definition something written last week can already be legacy, and a twenty-year-old system with thorough tests is not.

04

What is a characterization test, and why not just write a normal one?

A characterization test documents what the code currently does, including behaviour that looks wrong. You write an assertion, run it, and paste in whatever the code actually produced. It isn't a specification — it's a tripwire, so that when you change the structure you find out immediately if you also changed behaviour. Fixing the wrong-looking behaviour is a separate, later, deliberate change.

05

What is a seam?

A place where you can change the program's behaviour without editing the code at that spot — an injectable parameter, an overridable method, a link-time substitution. Seams are how you get untestable code under test without first performing the risky refactor you were trying to make safe. The skill's main job is finding the cheapest seam for the change you actually want to make.

One skill, one command.

Install Legacy Code, or the whole stack.

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

MIT licensed · Claude, Claude Code, Codex, Cursor, OpenClaw, Hermes · No account

  We build the skills you already use. Now we’ll build yours. See what we build  ·  Book a 15-min call