legacy-code-testing

legacy-code-testing is a skill for Claude Code from timwukp/agent-skills-best-practice. It costs 106 tokens per session (1,133 once invoked), scanned A, original, MIT.

A testing guide for legacy code, meaning existing code that lacks reliable tests or is difficult to change. It uses characterization tests that record current behavior before refactoring.

In plain words
What is it for?
Use it to add tests to untested code, identify safe points for substituting dependencies, plan risk-ranked coverage, and refactor gradually.
Why use it?
It provides a safety net for changing inherited code, including behavior that may be buggy but must be preserved until separately fixed.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the engineering-skills plugin — 18 skills shipped together

Good fit Use it to add tests to untested code, identify safe points for substituting dependencies, plan risk-ranked coverage, and refactor gradually.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/timwukp/agent-skills-best-practice/legacy-code-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add timwukp/agent-skills-best-practice --skill legacy-code-testing
Clone the repo
git clone --depth 1 https://github.com/timwukp/agent-skills-best-practice

Made for: Claude Code.

Or install engineering-skills, the plugin that ships this one along with the rest of its 18 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for legacy-code-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/timwukp/agent-skills-best-practice/legacy-code-testing/github.svg)](https://agentmods.dev/skills/timwukp/agent-skills-best-practice/legacy-code-testing)
Your own site
<a href="https://agentmods.dev/skills/timwukp/agent-skills-best-practice/legacy-code-testing"><img src="https://agentmods.dev/badge/skills/timwukp/agent-skills-best-practice/legacy-code-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for legacy-code-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/timwukp/agent-skills-best-practice/legacy-code-testing"><img src="https://agentmods.dev/badge/skills/timwukp/agent-skills-best-practice/legacy-code-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 106 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,133 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00106 $0.01133
Opus 5.5 $0.00042 $0.00453
Sonnet 5.5 $0.00021 $0.00227
Haiku 4.5 $0.00011 $0.00113

Measured 3mo ago against content hash 4dbab26417de, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

legacy-code-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/skills/legacy-code-testing/SKILL.md · 60 lines

How it starts

The opening of the file, as written. The whole thing — 60 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Legacy Code Testing

Untested code you must change is a trap: you can't refactor safely without tests, and you can't test cleanly without refactoring. The way out is characterization testing — pin down what the code currently does (not what it should do), then refactor under that safety net.

The golden rule: before refactoring, tests assert current behavior — even buggy behavior. A characterization test that "fails" because the code has a bug is wrong; the test must pass against today's code. Log suspected bugs separately for the team to triage.

Process

  1. Scope and rank. Identify what actually needs a safety net: code you're about to change, plus its blast radius (callers and shared state). Rank by change-likelihood × consequence-of-breaking. Do not attempt whole-codebase coverage — legacy coverage is bought module by module, just-in-time.
  2. Find the seams. For each target, identify where behavior can be observed and where dependencies can be substituted without editing the logic under test (see Seams table). If there is no seam, apply the minimal enabling refactor (extract method, parameterize constructor, wrap static call) — mechanical, behavior-preserving, small enough to eyeball.
  3. Write characterization tests.
    • Start with the happy path for the most common input; then boundaries (empty, null, max, malformed); then the weird branches the code visibly handles.
    • When you don't know the expected output, run the code and capture it: write the assertion against the observed result. If you can't execute it, write the assertion as your best reading of the code and mark it // CHARACTERIZATION: verify against production behavior before trusting.
    • For outputs too large/complex to assert piecewise, use snapshot/golden-master testing: capture the full output once, assert future runs match byte-for-byte (or with explicit normalization for timestamps/ids).
  4. Log suspected bugs, don't fix them. Maintain a SUSPECTED-BUGS.md (or ticket list): behavior pinned by a test that looks wrong, with the test name, why it looks wrong, and the blast radius of fixing it. Fixing comes after the net exists, as separate, deliberate changes.
  5. Refactor under the net. Only after the characterization suite is green and running in CI: refactor in small steps, keeping the suite green at each step. As real intent becomes clear, graduate characterization tests into proper specification tests (rename, assert intent, delete redundant pins).
  6. Report. Deliver: tests written, observed coverage of the target module, seams introduced (with the enabling refactors listed), suspected bugs logged, and what remains unprotected.

Read the full file on GitHub · 60 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 60 lines · 106 tokens per session scan A 4dbab26417de

Subscribe to this mod's changes

legacy-code-testing is a skill published in the GitHub repository timwukp/agent-skills-best-practice (14 stars, last pushed 2mo ago), licensed MIT. It adds 106 tokens to every session and 1,133 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

legacy-code-testing compared with skills from other repositories

legacy-code-testing next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
legacy-code-testingtimwukp/agent-skills-best-practiceSkill142mo agoMITA106Claude Code
bedrockitsmostafa/aws-agent-skillsSkill1.2k4d agoMITA36Claude Code
ecsitsmostafa/aws-agent-skillsSkill1.2k4d agoMITA35Claude Code
cloudwatchitsmostafa/aws-agent-skillsSkill1.2k4d agoMITA43Claude Code
ec2itsmostafa/aws-agent-skillsSkill1.2k4d agoMITA320Claude Code
cloudformationitsmostafa/aws-agent-skillsSkill1.2k4d agoMITA34Claude Code
cognitoitsmostafa/aws-agent-skillsSkill1.2k4d agoMITA38Claude Code