/engineering-skills:legacy-code-protocolfrom engineering-skills
Protocol for working in legacy code with few or no tests. Modes: survey, plan, pin, change, replace, review. Based on Michael Feathers' Working Effectively with Legacy Code.
Ships in engineering-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Treat code without tests as legacy, however clean it looks: without tests, no one can tell whether a change makes it better or worse. Treat code nobody on the team understands the same way, tested or not. Apply the method of Michael Feathers' Working Effectively with Legacy Code: understand the code, pin what it does now, then change it on purpose.
The core tension is the legacy code dilemma. Changing code safely needs tests, and getting tests in often needs changes to the code. Resolve it this way: every edit made before tests exist is small, mechanical, and behavior-preserving. Once an area is pinned, switch to ordinary tdd.
Pick the mode from the request. Open its file and follow its steps.
| Mode | Use when | File |
|---|---|---|
| survey | The area is unfamiliar, or the user wants the lay of the land before deciding anything | modes/survey.md |
| plan | The work is bigger than one change: adding missing tests, then changing, refactoring, or splitting the code | modes/plan.md |
| pin | Behavior must be locked before someone changes it: an upgrade, a migration, a rewrite, a hand-off | modes/pin.md |
| change | One concrete change to untested code | modes/change.md |
| replace | The old code is being retired for a rewrite, a new library, or a new service | modes/replace.md |
| review | A pull request or diff touches legacy code | modes/review.md |
Modes chain: survey feeds plan, and each step of a plan runs as pin, change, or replace. When the user names a mode, use it. When a change request lands on code you have not surveyed and the area spans more than a few files, run survey first and say so.
Survey and plan write Markdown files that later modes and later sessions read: .legacy/<area>-map.md and .legacy/<area>-plan.md in the repository root. Leave them uncommitted unless the user asks to commit them: add .legacy/ to .git/info/exclude so later commits don't sweep them in. Read existing ones before starting, and update them rather than starting over.
Work files are scratch. Facts the next agent will need, whatever its task, belong in the repository's docs. Each mode ends by promoting what it verified, so every legacy task leaves its area more agent-ready.
Use the repository's existing docs layout. When it has none, use the agent-ready layout:
| Finding | Destination |
|---|---|
| The area's story, entry points, hidden coupling, and invariants | docs/architecture/<area>.md, linked from ARCHITECTURE.md |
| Business workflows the code implements | docs/DOMAIN.md |
| Domain terms whose meaning is settled | CONTEXT.md |
| How to get the area under test: the command, the seams, the fixtures, how nondeterminism is pinned | docs/guides/testing.md |
| Why odd code exists, and surprising behavior that was pinned | the area doc, under "Known quirks" |
| Pointers to new docs, and the test command when it is missing | one line each in AGENTS.md |
Suspected bugs go to tickets or the report, not docs.
agent-ready.Every mode that runs tests starts here.
The baseline is recorded when it names the command that ran plus the failing and flaky tests, or "none".
Rules for any production edit made before tests cover it:
modes/change.md (opens in a new tab)modes/pin.md (opens in a new tab)modes/plan.md (opens in a new tab)modes/replace.md (opens in a new tab)modes/review.md (opens in a new tab)modes/survey.md (opens in a new tab)references/characterization-tests.md (opens in a new tab)references/dependency-breaking.md (opens in a new tab)references/symptoms.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dgalarza/agent-skills --plugin engineering-skills7 skills in this plugin
/conventional-commentsUse this skill when writing, rewriting, or reviewing feedback comments so they follow the Conventional Comments format./conventional-commitsThis skill should be used when creating Git commits to ensure they follow the Conventional Commits specification. It provides guidance on commit message structure, types, scopes, and best practices for writing clear, consistent, and automated-friendly commit messages. Use when committing code changes or reviewing commit history./stacked-prsBreak a large change into a chain of small, dependent pull requests using GitHub stacked pull requests and the gh stack CLI extension. Use this skill whenever the user mentions stacked PRs, stacked pull requests, a PR stack, stacking branches or commits, gh stack, splitting a large pull request into smaller reviewable PRs, chained or dependent pull requests, building new work on top of an unmerged PR, or shipping one task per PR from a larger effort./tddUse this skill when implementing or changing behavior with test-driven development. Follow red-green-refactor one behavior at a time, confirm a real failure before writing production code, and keep the test command the project's own./team-code-reviewReview an agent's own code changes or another contributor's pull request by dispatching specialist agents, verifying every finding, and reporting only evidence-backed issues. Use when the user asks for a code review, PR review, review of a diff, or a multi-agent quality audit./webhook-receiverDesign, implement, or review inbound webhook handling that is verified, idempotent, and asynchronous. Use when adding a webhook endpoint or callback receiver for any provider (payments, messaging, analytics, CMS, CRM), when a provider is retrying or timing out, when webhook processing is slow or loses events, or when auditing an existing webhook handler. Language and framework agnostic, with a Rails reference.Other plugins' skills for the same job