Engineering RefactoringCode SmellsClean Code

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.

You

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?

Agent

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:

  1. Add one handler class at a time, extract one case's logic into it
  2. Route that one case through the new handler — run tests
  3. Delete the old case from the switch — run tests
  4. 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

1

Be specific

Include numbers — users, budget, RPS — so the skill can size the architecture.

2

Share constraints

Compliance needs, team size, and existing stack all improve the output.

3

Iterate

Start with a high-level design, then ask follow-ups for IaC, cost analysis, or security review.

4

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.

$ skillfish add johnefemer/skillfish --all # install all skills at once

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
← Browse all skills