Skip to content
Back to skills

Legacy Code Characterization

ASecurity

Records what untested legacy code actually does by writing characterization tests first, so you can change or refactor it without guessing at behavior.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsdatabase

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill legacy-code-characterization --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Legacy Code Characterization?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Legacy Code Characterization
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-legacy-code-characterization/badge)](https://www.skillsdirectory.com/skills/workspace-templates-legacy-code-characterization)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: legacy-code-characterization
description: Records what untested legacy code actually does by writing characterization tests first, so you can change or refactor it without guessing at behavior.
---

# Legacy code characterization

Describe what the code does, not what it should do. Do not fix anything in this step.

## Steps

1. Choose the seam: one function, class or endpoint. Read it and list its inputs, outputs, side effects (database, files, network, clock, randomness) and callers.
2. Make it testable without changing behavior. Replace time, randomness and network with test doubles at the edge, and use a temporary database or fixtures. If the code cannot be called without a rewrite, use the smallest wrapper or an extracted-but-identical function, and say so.
3. Collect realistic inputs: from existing fixtures, logs, call sites and sample data. Add boundaries: empty, zero, null, maximum length, unusual encodings and error cases.
4. Write a test per input that asserts the current output. If you do not know the output, run the code, read the result and paste it in as the expected value. Snapshot tests are fine for large outputs.
5. Run the suite three times to catch flaky tests. A test that fails randomly is not a safety net; find the hidden dependency.
6. Check coverage for the target (`--coverage`) and add inputs until each branch runs at least once.
7. Mark suspicious results. When the output looks wrong, keep the test, add a comment `// current behavior, looks like a bug` and list it.

## Rules

- Change no production logic in this step, except the minimal seam from step 2.
- Name tests after the input, not the expected value.
- Never delete a failing characterization test; ask first.

## Report

Tests added, branch coverage reached, the seams introduced, and a list of suspected bugs with their inputs.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.