Characterization Tests

Generate Jest characterization tests documenting legacy code behavior before refactoring.

6|1|Updated Dec 29, 2025
One-click install
npx skills add https://github.com/benaor/claude-config --skill characterization-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Characterization Tests
Source: https://github.com/benaor/claude-config/tree/main/.claude/skills/characterization-test
Command: npx skills add https://github.com/benaor/claude-config --skill characterization-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers safely refactor legacy code by capturing its current behavior before changes are made, creating a safety net against unintended consequences.

Core Features & Use Cases

  • Behavior Documentation: Automatically documents how code functions with real-ish inputs.
  • Refactoring Safety Net: Provides confidence when modifying complex or untested code.
  • Use Case: Before updating a critical, but poorly understood, payment processing module, use this Skill to write tests that document its exact current behavior, ensuring the refactored version behaves identically or predictably.

Quick Start

Use the characterization-test skill to generate tests for the PublishArticleUseCase by running the provided Jest command.

Frequently Asked Questions about Characterization Tests

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

FAQPage Schema
How do I write characterization tests for legacy code before refactoring?

Characterization tests capture and document the exact current behavior of legacy code using real-ish inputs and Jest spies, creating a safety net that ensures refactoring does not introduce unintended consequences.

What is the best way to document existing behavior in untested code?

Generating characterization tests documents existing behavior by recording use case outputs, tracking side effects via spies, and verifying API responses, providing a reliable baseline for future modifications.

How do I configure Jest to exclude characterization tests from coverage reports?

Configure Jest exclusion rules for characterization tests to prevent safety net tests from skewing project coverage metrics, ensuring accurate reporting for newly developed features.

Can I use characterization tests to capture side effects and API responses in Jest?

Yes, characterization tests utilize Jest spies to capture side effects and verify API responses, accurately documenting external interactions and current legacy code behavior.

When do I need characterization tests instead of behavior driven development tests?

You need characterization tests when refactoring poorly understood legacy code, as they document existing behavior rather than defining desired new behavior like behavior driven development tests do.