before-after
A reference set of small, behavior-preserving refactorings with the reasoning for each. Tests stay green across every one.
$ npx -y skills add vanara-agents/skills --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
Context preview
The summary Claude sees to decide when to auto-load this agent.
A reference set of small, behavior-preserving refactorings with the reasoning for each. Tests stay green across every one.
Agent definition
before-after.mdBefore / After Transformations
A reference set of small, behavior-preserving refactorings with the reasoning for each. Tests stay green across every one.
1. Decompose a conditional
// BEFORE — the condition's meaning is unclear at the call site
if (date < plan.summerStart || date > plan.summerEnd) {
charge = quantity * plan.regularRate + plan.regularServiceCharge;
} else {
charge = quantity * plan.summerRate;
}// AFTER — intention-revealing functions; the if/else now reads like prose
const isSummer = (date) => !(date < plan.summerStart || date > plan.summerEnd);
const summerCharge = () => quantity * plan.summerRate;
const regularCharge = () => quantity * plan.regularRate + plan.regularServiceCharge;
charge = isSummer(date) ? summerCharge() : regularCharge();
**Why behavior is preserved:** the boolean and both arithmetic branches are identical; only their names and placement changed.
2. Replace a type-code switch with a lookup table
# BEFORE — repeated dispatch, easy to forget a case
def shipping_cost(kind, weight):
if kind == "ground":
return weight * 1.0
elif kind == "air":
return weight * 2.5
elif kind == "freight":
return weight * 0.6
raise ValueError(kind)# AFTER — data, not control flow
RATES = {"ground": 1.0, "air": 2.5, "freight": 0.6}
def shipping_cost(kind, weight):
if kind not in RATES:
raise ValueError(kind)
return weight * RATES[kind]**Why behavior is preserved:** same rate per kind, same `ValueError` for unknown kinds.
3. Introduce a parameter object
// BEFORE — four loosely-related params that always travel together
function drawRect(x: number, y: number, w: number, h: number) { /* ... */ }
drawRect(0, 0, 100, 40);// AFTER — one cohesive concept
interface Rect { x: number; y: number; w: number; h: number; }
function drawRect(r: Rect) { /* ...same body, reading r.x etc... */ }
drawRect({ x: 0, y: 0, w: 100, h: 40 });**Why behavior is preserved:** the same four values reach the same body; only the call shape changed.
4. Inline a needless variable, then rename for clarity
// BEFORE
tmp := basePrice * taxRate
return tmp
// AFTER
return basePrice * taxRate
**Why behavior is preserved:** `tmp` was a pure alias with no other use; removing it changes nothing.
Reading these
Each transformation is the kind of step the agent takes one at a time: small, obviously behavior-preserving, and trivially revertible if a test goes red. None of them changes output for any input — that is the defining property of a refactor.
Read more
Before / After Transformations
A reference set of small, behavior-preserving refactorings with the reasoning for each. Tests stay green across every one.
1. Decompose a conditional
// BEFORE — the condition's meaning is unclear at the call site
if (date < plan.summerStart || date > plan.summerEnd) {
charge = quantity * plan.regularRate + plan.regularServiceCharge;
} else {
charge = quantity * plan.summerRate;
}// AFTER — intention-revealing functions; the if/else now reads like prose const isSummer = (date) => !(date < plan.summerStart || date > plan.summerEnd); const summerCharge = () => quantity * plan.summerRate; const regularCharge = () => quantity * plan.regularRate + plan.regularServiceCharge; charge = isSummer(date) ? summerCharge() : regularCharge();
**Why behavior is preserved:** the boolean and both arithmetic branches are identical; only their names and placement changed.
2. Replace a type-code switch with a lookup table
# BEFORE — repeated dispatch, easy to forget a case
def shipping_cost(kind, weight):
if kind == "ground":
return weight * 1.0
elif kind == "air":
return weight * 2.5
elif kind == "freight":
return weight * 0.6
raise ValueError(kind)# AFTER — data, not control flow
RATES = {"ground": 1.0, "air": 2.5, "freight": 0.6}
def shipping_cost(kind, weight):
if kind not in RATES:
raise ValueError(kind)
return weight * RATES[kind]**Why behavior is preserved:** same rate per kind, same `ValueError` for unknown kinds.
3. Introduce a parameter object
// BEFORE — four loosely-related params that always travel together
function drawRect(x: number, y: number, w: number, h: number) { /* ... */ }
drawRect(0, 0, 100, 40);// AFTER — one cohesive concept
interface Rect { x: number; y: number; w: number; h: number; }
function drawRect(r: Rect) { /* ...same body, reading r.x etc... */ }
drawRect({ x: 0, y: 0, w: 100, h: 40 });**Why behavior is preserved:** the same four values reach the same body; only the call shape changed.
4. Inline a needless variable, then rename for clarity
// BEFORE tmp := basePrice * taxRate return tmp
// AFTER return basePrice * taxRate
**Why behavior is preserved:** `tmp` was a pure alias with no other use; removing it changes nothing.
Reading these
Each transformation is the kind of step the agent takes one at a time: small, obviously behavior-preserving, and trivially revertible if a test goes red. None of them changes output for any input — that is the defining property of a refactor.
🐒 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
Other agents on vanara-agents-skills.
- AGENT
Use when designing a new HTTP/GraphQL API or changing an existing one — modeling resources, defining endpoint contracts, choosing status codes, pagination, filtering, error envelopes, versioning, and idempotency. Produces a reviewable API contract plus an OpenAPI snippet, not
Open agent - review-notes
This shows how the api-designer agent reviews a flawed draft. Findings are severity-ranked so the implementer fixes the contract-breakers first. Severity legend: **CRITICAL** (breaks clients / data risk), **HIGH** (real bug or inconsistency), **MEDIUM** (maintainability),
Open agent - contract-and-openapi
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 structure that document and what `scripts/lint-openapi.mjs` enforces.
Open agent - design-checklist
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 place real APIs go wrong in production.
Open agent - versioning-and-evolution
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 explicitly when you must break.
Open agent - pr-comment-template
Copy-paste templates for leaving review comments. Keep each comment to one finding: an anchor, the problem, and the fix.
Open agent

