/aif-skills:refactorfrom aif-skills
Use when refactoring existing code to improve readability or maintainability while preserving behavior.
Ships in aif-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.
None: SKILL.md is the whole skill.
Improve existing code structure without changing its observable behavior. Prefer the smallest change that addresses a clear maintenance problem.
Keep the work in a recoverable version-control state and follow the repository's workflow. A separate branch or commit is useful when the project expects one; it is not a requirement for every refactor.
| Smell | Possible refactoring |
|---|---|
| Long function with distinct steps | Extract focused functions while keeping the same order and behavior. |
| Repeated logic with the same meaning | Extract a shared helper. Keep different rules separate. |
| Module or class with unrelated responsibilities | Move a responsibility to an existing or appropriately scoped module. |
| Long parameter list | Group parameters only when they form a meaningful unit; update and inspect callers. |
| Nested conditionals | Use guard clauses when they preserve the same checks, order, and outcomes. |
| Logic that depends heavily on another object's data | Move the behavior toward the data owner when that improves cohesion and does not break boundaries. |
| Primitive values representing a domain concept | Introduce a type or value object only when it captures a real invariant or improves safety. |
| Unexplained literal values | Name values when the name adds meaning; ordinary obvious literals need no constant. |
| Unused code | Remove it only after confirming it has no callers or required side effects. |
These versions preserve the same checks and error results:
function process(order) {
if (order) {
if (order.user) {
if (order.user.isActive) {
if (order.total > 0) return processOrder(order);
return { error: 'Invalid total' };
}
return { error: 'User inactive' };
}
return { error: 'No user' };
}
return { error: 'No order' };
}
function process(order) {
if (!order) return { error: 'No order' };
if (!order.user) return { error: 'No user' };
if (!order.user.isActive) return { error: 'User inactive' };
if (!(order.total > 0)) return { error: 'Invalid total' };
return processOrder(order);
}
The total check uses !(order.total > 0) to preserve the original result for values such as NaN.
| Operation | Use |
|---|---|
| Extract or inline function | Give a focused operation a clear name, or remove an unnecessary wrapper. |
| Rename | Clarify intent; update and inspect all references. |
| Extract class or module | Separate a responsibility with a clear boundary. |
| Introduce parameter object | Group cohesive arguments; avoid wrapping unrelated values. |
| Replace conditional with polymorphism | Use when there are real, growing variants and the result is simpler than the conditional. |
| Replace type code with a type or enum | Make existing domain alternatives explicit without changing accepted values. |
| Replace inheritance with delegation | Reduce unwanted coupling when behavior can remain the same. |
Do not apply a pattern just because it appears in a catalog. A direct conditional or a small function is often clearer.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
41 skills in this plugin
/ask-mattAsk which skill or flow fits your situation. A router over the skills in this repo./cavemanUltra-compressed communication mode. Cuts output tokens 65% (measured) by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.
/cherry-pick-to-mainPrepare a feature branch created from `develop` for a selected target branch such as `main` or `uat`, creating a target-prefixed branch and cherry-picking only that feature's commits. Use when a feature needs a separate branch based on a chosen target./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./code-reviewReview the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X"./debug-mantraFour-mantra debugging discipline — reproduce, trace the fail path, falsify the hypothesis, cross-reference every breadcrumb. Recite the mantra block verbatim at the start of any debugging session, then apply the four steps in order before proposing any fix. Trigger on /debug-mantra and proactively whenever debugging starts — user reports a bug, says something is broken/throwing/failing, asks to debug/diagnose/investigate an issue, or pastes a stack trace or error log.npx claudepluginhub aifgrouplaos/ai-skills --plugin aif-skills