Take over an existing codebase safely - survey where it hurts, pin its behaviour with characterization tests before changing it, register the debt as tickets, and ratchet the worst metrics so they only improve. Use on "reprise de code", "legacy", "dette technique", "on hérite de ce projet", "how bad is this codebase", before a large change in code nobody fully understands.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Legacy?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/sycatle-legacy-senior-mode)
---
name: legacy
description: Take over an existing codebase safely - survey where it hurts, pin its behaviour with characterization tests before changing it, register the debt as tickets, and ratchet the worst metrics so they only improve. Use on "reprise de code", "legacy", "dette technique", "on hérite de ce projet", "how bad is this codebase", before a large change in code nobody fully understands.
disable-model-invocation: true
---
# Legacy
Inherited code works, more or less, and people depend on what it does today, bugs included. The risk is
not that it is ugly; it is changing it without knowing what it does. So the order is: understand, pin,
then improve in small steps, never a rewrite on faith.
## Survey
1. **Run it and its checks.** Build it, run the tests, `senior-mode check`. Done when you know what runs,
what fails, and what is missing (no tests, no lint, no CI).
2. **Find where it hurts.** `senior-mode hotspots` lists the files that change most, with their size:
churn on a large file is where bugs and slow changes concentrate. Cross it with the bug history, the
modules nobody dares touch, and the dependencies years behind (`senior-mode audit` when senior-security
is installed).
3. **Map it** for the next reader: the modules, what each owns, the entry points, the data, the
integrations, the traps. Into `docs/architecture.md` and the instruction file (`docs`), short.
Done when you can say, with evidence, the three places where a change is riskiest and why.
## Characterize before changing
Before touching code with weak tests, pin what it does now: characterization tests through the public
seams (an endpoint, a command, a function), asserting the current output, even when it looks wrong. A
wrong-looking behaviour is a question for the user, not a fix to slip in. Then change the structure under
those tests (`tdd`, refactor case). Golden files or snapshots are fine for wide outputs; review them as code.
## Register the debt
Each problem worth fixing becomes a ticket (`to-tickets`, `senior-mode ticket add`): what hurts, the
evidence (hotspot, incidents, the time it costs), the smallest fix, its size. Not a wish list: what is not
worth fixing this year is left out, or written down once as a known limitation.
## Ratchet
Some debt is measurable and too big to fix at once: lint warnings, type errors, `any` or `unwrap` counts,
skipped tests, coverage. Freeze it so it only shrinks:
1. List the metrics in `.senior-mode/ratchet`, one per line: `<name><TAB><command printing a number>`, with
a third field `up` when higher is better (coverage).
2. `senior-mode ratchet update` records the baseline in `.senior-mode/ratchet-baseline`; commit both.
3. From then on `senior-mode check` fails when a metric gets worse. When one improves, `ratchet update`
locks the gain. It never records a worse value: lowering the bar is a hand edit a reviewer sees.
Pick metrics that are cheap to compute and hard to game; three good ones beat ten noisy ones.