Skip to content
SkillModel-led117 tokens in use

Working Effectively with Legacy Code

Change hard-to-test code safely with rules inspired by Michael Feathers: characterization tests, seams, sprout and wrap methods, dependency breaking.

3,324 stars on the repository MIT Licenseciembor/agent-rules-books · working-effectively-with-legacy-code
npx skills add ciembor/agent-rules-books --skill working-effectively-with-legacy-code
View source

Install command as written in the repository's README

Skill label

measured from its files

What installing Working Effectively with Legacy Code costs

37tokens idle
117tokens in use
3,891tokens, up to

Idle is what sits in context while the skill is installed. In use is its instructions, loaded when it runs. Up to adds the files its instructions link. Counts are approximate, made offline with cl100k_base.

Model dependence Model-led

Script-ledMixedModel-led

Mostly instructions, so how well it works depends on the model that follows them.

This describes the skill's structure, how much of it is scripts. It does not say how well it works.

Touches

Nothing detected: no shell, network, file writes, git or credentials in its files.

Declared tags come from the skill's frontmatter; detected ones from its scripts, its code blocks and the commands it names in inline code. This is detected, not audited.

How it scores

Quality

How well the skill is written, counted from its own files: its frontmatter, its steps, examples, stated output and constraints, its size and whether every file it ships is one it names.How we score it →
Needs attention
  • Frontmatter11/15
  • Structure0/25
  • Examples0/15
  • Output2/15
  • Size15/15
  • Resources10/15

Security

Starts at 100 and loses points for each thing in the skill's files that a reader should look at first.How we score it →
Excellent

No findings.

Repository health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
Fair
  • Development activity44
  • Maintenance72
  • Community52
  • Maturity28
  • Momentum40

This skill gives a coding agent a set of rules inspired by Michael Feathers’s Working Effectively with Legacy Code. It applies when a change touches code without trustworthy tests, where behavior is unclear or dependencies block local feedback.

The agent first states the behavior to change and the behavior to keep, then adds characterization tests, finds or creates the smallest seam, breaks the dependency that blocks testing, makes the change and refactors locally. A longer reference version of the rules covers the dependency-breaking techniques in detail.

What You Get

  • A compact rule set with a legacy-change loop, trigger rules and a final checklist that the agent loads when the skill applies
  • A longer reference version listing dependency-breaking techniques and how to pick one for the actual barrier
  • Guidance on sprout method, sprout class, wrap method and wrap class for adding behavior beside fragile code
  • Review rules that flag mixed structural and behavioral edits, hard-coded collaborators and constructor side effects

Common Use Cases

  • Adding a feature to a large untested method without editing its many branches
  • Making a class instantiable in a test when its constructor opens connections or reads global state
  • Wrapping time, randomness, files or network calls so tests become repeatable
  • Reviewing a pull request that renames and reformats while leaving the real dependency knots in place

What Makes It Unique

Where general refactoring skills assume tests exist, this one starts from their absence. Its loop puts characterization and seam creation before any design change, separates seams for sensing from seams for separation, and attaches a cleanup duty to temporary tricks such as subclass-only or public-for-test seams. It also names the techniques to use for each kind of barrier.

Under The Hood

The skill is a short SKILL.md that tells the agent to read the compact rules file before making design or code decisions, and to open the full file only when the compact one does not settle a tradeoff. There are no scripts. It does not fetch web pages, call APIs, run commands or write files. The rules shape how the agent plans tests and edits in the code you point it at.

Join founders building with open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on SubstackJoin 750+ subscribers