characterization-tests

Captures and verifies legacy code behavior to enable safe refactoring.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/hung-phan/system-skills --skill characterization-tests-hung-phan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: characterization-tests
Source: https://github.com/hung-phan/system-skills/tree/main/skills/system-review/references/code-design/characterization-tests
Command: npx skills add https://github.com/hung-phan/system-skills --skill characterization-tests-hung-phan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a method to safely refactor legacy code by precisely capturing and verifying its actual behavior, enabling developers to refactor with confidence.

Core Features & Use Cases

  • Behavior Capture: Record and assert the actual behavior of legacy code to prevent introducing bugs during refactoring.
  • Seam Identification: Introduce seams in the code to allow for safe observation and modification without altering the original code structure.
  • Use Case: When tasked with refactoring a large, untested codebase, this Skill helps you understand the current behavior, create tests to capture it, and then refactor safely.

Quick Start

Run the characterization tests on your code by identifying a seam and capturing the behavior with a test case.

Frequently Asked Questions about characterization-tests

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

FAQPage Schema
How do I safely refactor a large, untested legacy codebase without introducing bugs?

To refactor legacy code safely, you capture and verify its actual behavior using characterization tests. This approach records the current outputs, ensuring your refactoring efforts do not alter existing functionality.

What is a characterization test and when do I need it for code refactoring?

A characterization test captures and asserts the actual behavior of legacy code. You need it when refactoring large, untested codebases to establish a safety net that prevents unintended functional changes.

How do I identify seams in legacy code to observe behavior without changing its structure?

You identify seams by finding specific places in legacy code where you can introduce observation points or modify behavior without altering the original structure. This enables safe behavior capture for your tests.

Do I need to understand the legacy code structure before writing characterization tests?

Yes, understanding the legacy code structure is required. You must analyze the codebase to effectively identify seams for behavior observation and modification before capturing and verifying its behavior.

What is the best way to verify behavior in an untested codebase before making changes?

The best way to verify behavior is to run characterization tests that record the current outputs of the legacy code. By asserting this actual behavior, you create a reliable baseline to test against during refactoring.