Refactoring Specialist
Systematic refactoring: code smell identification, refactoring patterns catalog, safe refactoring workflows with tests, IDE automation, and quality measurement.
A systematic refactoring expert who identifies code smells by name, applies catalog patterns (Extract Method, Replace Conditional with Polymorphism, Introduce Parameter Object), and makes changes safely using the red-green-refactor cycle. Uses IDE automation (VS Code, IntelliJ) for safe renames and extractions, and measures quality improvement with cyclomatic complexity and code coverage metrics.
Added Mar 20, 2026
$npx skills add johnefemer/skillfish --skill refactoring-specialist What This Skill Can Do
Concrete capabilities you get when you install this skill.
Identify code smells: long method, feature envy, data clumps, shotgun surgery
Apply Fowler's refactoring catalog patterns with before/after code examples
Design refactoring sequences that keep tests green throughout the transformation
Use IDE automated refactoring (rename, extract, inline) to minimize manual errors
Measure refactoring impact with cyclomatic complexity, coupling, and coverage metrics
Prioritize refactoring targets by change frequency and defect density
Real Conversations
See how the Refactoring Specialist skill responds to actual requests. These are representative examples of what your AI agent will produce.
I have a function with a 300-line switch statement on order.status. Each case has 10-20 lines of business logic. It's getting impossible to maintain. How should I refactor this?
Apply Replace Conditional with Polymorphism — move each case's logic into a class or handler, then dispatch to the right one:
// ❌ Before: 300-line switch
function processOrder(order: Order) {
switch (order.status) {
case 'PENDING': { /* 20 lines */ break; }
case 'CONFIRMED': { /* 15 lines */ break; }
case 'SHIPPED': { /* 25 lines */ break; }
// ... 12 more cases
}
}
// ✅ After: strategy/handler pattern
interface OrderHandler {
process(order: Order): Promise<void>;
}
class PendingOrderHandler implements OrderHandler {
async process(order: Order) { /* 20 lines, now testable in isolation */ }
}
class ConfirmedOrderHandler implements OrderHandler {
async process(order: Order) { /* 15 lines */ }
}
const handlers: Record<OrderStatus, OrderHandler> = {
PENDING: new PendingOrderHandler(),
CONFIRMED: new ConfirmedOrderHandler(),
SHIPPED: new ShippedOrderHandler(),
// ...
};
async function processOrder(order: Order) {
const handler = handlers[order.status];
if (!handler) throw new Error(`No handler for status: ${order.status}`);
await handler.process(order);
}
Safe refactoring sequence:
- Add one handler class at a time, extract one case's logic into it
- Route that one case through the new handler — run tests
- Delete the old case from the switch — run tests
- Repeat for each case
Never extract all cases at once. Each step is a separate commit with passing tests. Use VS Code's "Extract Method" (Cmd+Shift+R) to move the case body into a method first, then move that method to the handler class.
Get Started
How to install and use this skill in your preferred environment.
Skills are designed for AI coding agents (Claude Code, Cursor, Windsurf) and IDE-based workflows where the agent can read files, run scripts, and act on your codebase.
Models & Context
Which AI models and context windows work best with this skill.
Recommended Models
Claude Sonnet 4 or GPT-4o for multi-step refactoring planning. For large-scale automated refactors, combine with OpenRewrite (Java) or ts-morph (TypeScript) for AST-level transformations.
Context Window
SKILL.md ~4KB. Refactoring sessions with full files benefit from 64K+ to hold before/after code simultaneously.
Pro tips for best results
Be specific
Include numbers — users, budget, RPS — so the skill can size the architecture.
Share constraints
Compliance needs, team size, and existing stack all improve the output.
Iterate
Start with a high-level design, then ask follow-ups for IaC, cost analysis, or security review.
Combine skills
Pair with companion skills below for end-to-end coverage.
Works Great With
These skills complement Refactoring Specialist for end-to-end coverage. Install them together for better results.
Ready to try Refactoring Specialist?
Install the skill and start getting expert-level guidance in your workflow — any agent, any IDE.
$npx skills add johnefemer/skillfish --skill refactoring-specialist