working-with-legacy-code

working-with-legacy-code is a skill for Claude Code, Codex from clubpay/ronykit. It costs 69 tokens per session (4,341 once invoked), scanned A, a copy of working-with-legacy-code, BSD-3-Clause.

A guide to changing legacy code, meaning existing code that lacks reliable tests or is difficult to modify safely.

In plain words
What is it for?
Adding characterization tests, introducing seams and dependency injection, wrapping or extending existing code, and verifying changes in application and repository tests.
Why use it?
It shows how to record current behavior and create safe points for change before refactoring or fixing bugs.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/clubpay/ronykit/working-with-legacy-code
Any agent
npx skills add clubpay/ronykit --skill working-with-legacy-code
Clone the repo
git clone --depth 1 https://github.com/clubpay/ronykit

Made for: Claude Code, Codex.

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 working-with-legacy-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/clubpay/ronykit/working-with-legacy-code.svg)](https://agentmods.dev/skills/clubpay/ronykit/working-with-legacy-code)
Your own site
<a href="https://agentmods.dev/skills/clubpay/ronykit/working-with-legacy-code"><img src="https://agentmods.dev/badge/skills/clubpay/ronykit/working-with-legacy-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,341 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 97% copy Near-identical to another mod 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 $0.00069 $0.04341
Opus 5 $0.00034 $0.02171
Sonnet 5 $0.00014 $0.00868
Haiku 4.5 $0.00007 $0.00434

Measured 5d ago against content hash 17b6a28a234d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

working-with-legacy-code 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 5d 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.

Origin

This is a copy

97% identical to working-with-legacy-code — 49 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

ronyup/internal/skeleton/skills/working-with-legacy-code/SKILL.md · 250 lines

How it starts

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

Working Effectively with Legacy Code

A field manual for changing code that has no tests, distilled from Michael C. Feathers' Working Effectively with Legacy Code. Use it to get untestable classes into a harness, pin down current behavior with characterization tests, and make changes one safe, verifiable step at a time — without resorting to a rewrite.

When to use

  • Touching a RonyKit feature module that lacks app unit or repo integration tests (even "new" code without tests is legacy).
  • Bug fixes in internal/app or internal/repo with no failing test to start from.
  • Before refactoring-patterns when the safety net is missing.

RonyKit testing order

After pinning behavior with characterization tests here, bring coverage up to workspace standard:

  1. Repo portsx/testkit integration tests in internal/repo/integration_test/ (happy path, not-found, conflict). MCP architecture/integration-tests.
  2. App methods — unit tests for every exported App method in internal/app/.
  3. Verifymake verify in the feature module before claiming done.

Use constructor injection (x/di) and repo ports as natural seams. Never silently "fix" wrong behavior you discover while characterizing — pin it, file it, fix deliberately in a separate commit.

Core Principle

Legacy code is simply code without tests. Not old code, not ugly code — untested code: without tests you cannot know whether a change preserves behavior, so every edit is a gamble. The craft is breaking dependencies just enough to get tests in place before changing anything — cover and modify, never edit and pray.

Scoring

Goal: 10/10. Rate changes to untested code 0-10 against the principles below. Report the current score and the specific steps needed to reach 10/10.

  • 9-10: Change points covered by characterization tests before any edit; behavior changes and refactoring shipped as separate verified steps; dependencies broken with the least invasive technique
  • 7-8: Tests at most change points, but occasional mixed refactor-plus-behavior commits or heavier dependency surgery than needed
  • 5-6: Some characterization tests, yet key paths still changed on faith; sprouted code accumulating with no payback plan
  • 3-4: Edit-and-pray with manual verification; tests written after the change, asserting whatever the new code happens to do
  • 0-2: Untested edits straight into tangled code, refactoring and behavior change mixed in one commit, rewrite proposed instead of tests

Read the full file on GitHub · 250 lines

Files

What ships with it

5 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. 5d ago First seen · 250 lines · 69 tokens per session scan A 17b6a28a234d

Subscribe to this mod's changes

working-with-legacy-code is a skill published in the GitHub repository clubpay/ronykit (38 stars, last pushed 4d ago), licensed BSD-3-Clause. It adds 69 tokens to every session and 4,341 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 97% identical to working-with-legacy-code, differing in 49 lines, and is treated as a copy.

Related

Other skills, from other repositories

ast-introspection

Use Go AST-aware analysis to enumerate symbols, extract signatures, and propose mechanically safe refactors (read-only by default).

pilinux/gorest · 28 tokens

dependency-auditor

Inspect Go module dependencies, detect outdated or vulnerable modules, and recommend safe updates or pinning strategies.

pilinux/gorest · 25 tokens

test-runner

Run and triage Go tests with correct environment handling; produce compact, actionable failure summaries.

pilinux/gorest · 22 tokens

rpc

Vovk.ts RPC client — how vovk generate turns controllers into type-safe client modules, composed vovk-client vs segmented clients, call shape (apiRoot, params, body, query, meta, init, disableClientValidation, validateOnClient, interpretAs, transform, fetcher), customizing generation via outputConfig.imports.fetcher +…

finom/vovk · 354 tokens

bundle

Vovk.ts vovk bundle CLI — packages composed TypeScript client as zero-dep publishable npm package. Covers bundle.build async fn, [email protected] recipe, outputConfig.origin / package / reExports / imports.validateOnClient: null, prebundleOutDir / outDir / keepPrebundleDir, --include/--exclude segments, --openapi- mixin…

finom/vovk · 250 tokens

decorators

Vovk.ts decorators — built-in (@prefix, @operation, @get/@post/@put/@patch/@del, .auto()) and custom via createDecorator. Covers authorization / auth decorators, middleware-style wrapping (pre-handler + post-handler logic), req.vovk.meta() for cross-decorator state, stacking order, the decorate() alternative for…

finom/vovk · 228 tokens