working-with-legacy-code

Guides safe modification and testing of untested codebases using Feathers' legacy code techniques.

Updated Jul 8, 2026
One-click install
npx skills add https://github.com/HafidJoss/Lummy --skill working-with-legacy-code-hafidjoss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: working-with-legacy-code
Source: https://github.com/HafidJoss/Lummy/tree/main/agent/skills/working-with-legacy-code
Command: npx skills add https://github.com/HafidJoss/Lummy --skill working-with-legacy-code-hafidjoss

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Changing code that has no tests is risky: every edit is a gamble because nothing tells you whether existing behavior survived. This Skill provides a disciplined, step-by-step method for getting untested code under a test harness, pinning current behavior, and making changes one verifiable step at a time instead of editing and praying. ## Core Features & Use Cases - Legacy Code Change Algorithm: A five-step procedure (identify change points, find test points, break dependencies, write tests, then change) with safety checklists and triage guidance for tight deadlines. - Characterization Tests & Golden Masters: Techniques for pinning what code actually does — including snapshot testing done right and handling bugs discovered mid-characterization. - Dependency-Breaking Catalog: Named, mechanical techniques (Parameterize Constructor, Extract Interface, Sprout Method/Class, Wrap Method/Class, Break Out Method Object) with before/after code in TypeScript, Python, and Java. - Use Case: You inherit an 800-line OrderService with zero tests and must add a loyalty points feature. The Skill walks you through parameterizing the constructor, writing nine pin tests, sprouting the new logic as a fully tested class, and shipping with zero regressions. ## Quick Start Ask the AI to help you safely add a feature or fix a bug in a specific untested class or module, and it will apply the change algorithm, seams, and characterization test techniques to your code.

Frequently Asked Questions about working-with-legacy-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely change code that has no tests?

Follow the five-step legacy code change algorithm: identify change points, find test points, break dependencies with minimal signature-preserving edits, write characterization tests that pin current behavior, then make your change. Never mix refactoring and behavior changes in one commit.

What is a characterization test and how do I write one?

A characterization test documents what code actually does, not what it should do. Write an assertion you know is wrong, run it, read the failure message to learn the real behavior, then change the assertion to pin that observed value. Repeat until every branch your change touches is covered.

How do I test a class whose constructor opens database connections?

Use Parameterize Constructor: add constructor parameters for the dependencies with production defaults, so existing callers compile untouched while tests inject fakes. Extract Interface on heavy collaborators and Introduce Instance Delegator for statics are complementary moves.

Should I use jest.mock or dependency injection for legacy code tests?

Module mocking like jest.mock or unittest.mock.patch is a link seam that works well for getting first tests in place quickly, but it couples tests to file layout. For code you will keep changing, parameterizing constructors leaves better design behind and survives renames.

What should I do when I find a bug while writing characterization tests?

Pin the buggy behavior with a loud comment and a ticket number, then fix it later as a separate deliberate change. Silently fixing bugs during characterization is an unreviewed behavior change, and downstream code may depend on the wrong behavior.

When is a rewrite better than incrementally testing legacy code?

The Skill argues big-bang rewrites ship late and miss years of edge cases while the old system keeps moving. Incremental cover-and-modify grows coverage along the paths you actually change, which is the only testing budget that reliably exists.