# Legacy Code

> Safely change untested code: seams and characterization tests — an AI agent skill based on *Working Effectively with Legacy Code* by Michael C. Feathers.

Published 2026-06-11 · Updated 2026-08-17 · Code Quality · Free and MIT-licensed
Canonical: https://skills.wondel.ai/skills/working-with-legacy-code/
Source: https://github.com/wondelai/skills/tree/main/working-with-legacy-code

**Install:** `npx skills add wondelai/skills/working-with-legacy-code --global`

## 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.

## Key concepts from Working Effectively with Legacy Code your agent applies

- **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.

## When to use Legacy Code — and when not to

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.

## About 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.
The book: https://openlibrary.org/books/OL26223631M/Working_Effectively_with_Legacy_Code

## Example prompts

- 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)_

## Frequently asked questions

### 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.

### 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.

### 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.

### 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.

### 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.

## Related

- All Code Quality skills: https://skills.wondel.ai/skills/code/
- Clean Code: https://skills.wondel.ai/skills/clean-code/
- Pragmatic Programmer: https://skills.wondel.ai/skills/pragmatic-programmer/
- Refactoring: https://skills.wondel.ai/skills/refactoring-patterns/
- Software Design: https://skills.wondel.ai/skills/software-design-philosophy/
- Technical Documentation: https://skills.wondel.ai/skills/technical-documentation/

