legacy-code-safety

Add characterization tests before refactoring untested legacy code.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill legacy-code-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: legacy-code-safety
Source: https://github.com/TheBushidoCollective/han/tree/main/core/skills/legacy-code-safety
Command: npx skills add https://github.com/TheBushidoCollective/han --skill legacy-code-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill emphasizes safety when modifying untested legacy code by adding characterization tests first and following the RGR workflow.

Core Features & Use Cases

  • Characterization Testing: Write tests that document existing behavior before making changes.
  • Red/Green/Refactor Flow: Use a safe loop to red, green, and refactor with confidence.
  • Risk Mitigation: Prevent hidden regressions by anchoring changes to real behavior.

Quick Start

Identify a legacy function, write baseline characterization tests, run tests to confirm baseline, then proceed with small changes.

Frequently Asked Questions about legacy-code-safety

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

FAQPage Schema
How do I safely modify legacy code that has no test coverage?

Characterization testing lets you document existing behavior before making changes. Write tests that capture how the code currently works, verify they pass, then refactor with confidence using the Red-Green-Refactor loop. This anchors your changes to real behavior and prevents hidden regressions.

What is characterization testing and when should I use it?

Characterization testing writes tests that describe existing behavior in untested code. Use it when you need to modify, delete, or refactor legacy functions without test coverage. It's essential in codebases with low test discipline where tests are your primary safety net.

How do I start refactoring untested legacy code safely?

Identify the legacy function you need to change, write baseline characterization tests that document its current behavior, run tests to confirm they pass, then proceed with small incremental changes. Follow Red-Green-Refactor to validate each step.

Can I use characterization testing with dynamically typed languages?

Yes. Characterization testing is particularly valuable in dynamically typed languages where tests serve as the primary safety net. The workflow enforces Red-Green-Refactor discipline to catch regressions that static type systems might otherwise catch.

What's the difference between characterization testing and other testing approaches?

Characterization testing differs from unit testing by documenting existing behavior first rather than ideal behavior. It's a risk-mitigation strategy for untested legacy code, preventing regressions when you lack understanding of how code actually works.