AGENT
Use when designing a new HTTP/GraphQL API or changing an existing one — modeling resources, defining endpoint contracts, choosing status codes, pagination,…
Refactoring is only safe when each step is small, behavior-preserving, and verified. This is the loop and the mechanics behind it.
$ npx -y skills add vanara-agents/skills --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Refactoring is only safe when each step is small, behavior-preserving, and verified. This is the loop and the mechanics behind it.
Refactoring is only safe when each step is small, behavior-preserving, and verified. This is the loop and the mechanics behind it.
confirm tests GREEN
└─ pick ONE smell
└─ apply ONE small transformation
└─ run tests
├─ GREEN → keep, optionally commit, loop
└─ RED → revert last step, take a smaller step (or add a test)The loop is non-negotiable. The two questions that gate every step:
1. **Were the tests green before I started?** If not, you are not refactoring — you are debugging. Get to green first. 2. **Are the tests still green after this step?** If not, you changed behavior. Revert.
If the code you must refactor has no tests, write tests that **describe what it does now**, not what it should do:
1. Call the code with representative inputs. 2. Observe the actual output (run it). 3. Assert that exact output — even if it looks wrong. The goal is to detect *change*, not to judge correctness. 4. Now refactor under that net. If a characterization test goes red, your refactor altered behavior.
Fixing genuinely-wrong behavior is a *separate* task done *after* the refactor, with its own test.
Each refactoring has a known recipe. A few of the most common:
1. Copy the fragment into a new function with an intention-revealing name. 2. Pass in the variables it reads as parameters; return the values it writes. 3. Replace the original fragment with a call. 4. Run tests.
1. Use editor/tooling rename so every reference updates atomically. 2. Run tests. (With good tooling this is among the safest moves.)
1. Identify the error/edge conditions. 2. Turn each into an early `return`/`throw` at the top. 3. De-indent the remaining happy path. 4. Run tests.
1. Create a type/struct grouping the parameters that travel together. 2. Add it as a new parameter; populate from the old ones at the call site. 3. Move logic to read from the object; remove the old parameters. 4. Run tests after each sub-step.
able to trust that a `refactor:` commit changed no behavior.
Stop refactoring when any of these is true:
🐒 Free agents, skills & packs for Claude Code One subscription. An army of Claude Code agents. 30 production-grade agents, skills, and packs for Claude Code — free, Apache-2.0, install with one command.
Repo: vanara-agents/skills
Use when designing a new HTTP/GraphQL API or changing an existing one — modeling resources, defining endpoint contracts, choosing status codes, pagination,…
This shows how the api-designer agent reviews a flawed draft. Findings are severity-ranked so the implementer fixes the contract-breakers first. Severity…
The contract is the deliverable. Express it as an **OpenAPI 3.1** document so it is human-readable *and* machine-checkable. This reference covers how to…
Run through this before declaring an API contract done. It is ordered the way you should *design*: resources first, cross-cutting rules last. Every box is a…
APIs are forever once published: a consumer you've never met may depend on any field you expose. Design so you can **add without breaking**, and version…
Copy-paste templates for leaving review comments. Keep each comment to one finding: an anchor, the problem, and the fix.