Back to Skills

refactoring-advisor

verified

Provides refactoring recommendations and step-by-step improvement plans. Use when planning refactoring, improving code structure, or reducing technical debt.

View on GitHub

Marketplace

fastagent-marketplace

armanzeroeight/fastagent-plugins

Plugin

code-quality-toolkit

Code Quality

Repository

armanzeroeight/fastagent-plugins
20stars

plugins/code-quality-toolkit/skills/refactoring-advisor/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/armanzeroeight/fastagent-plugins/blob/main/plugins/code-quality-toolkit/skills/refactoring-advisor/SKILL.md -a claude-code --skill refactoring-advisor

Installation paths:

Claude
.claude/skills/refactoring-advisor/
Powered by add-skill CLI

Instructions

# Refactoring Advisor

## Quick Start

Plan refactoring based on identified issues:

1. Identify the problem (code smell, complexity)
2. Select appropriate refactoring pattern
3. Create step-by-step plan
4. Ensure tests exist
5. Refactor incrementally

## Instructions

### Step 1: Assess Current State

Analyze the code:
- What is the problem? (long method, god class, etc.)
- What is the impact? (maintainability, testability)
- What is the risk? (how much code depends on it)

### Step 2: Select Refactoring Strategy

| Problem | Strategy | Risk |
|---------|----------|------|
| Long Method | Extract Method | Low |
| God Class | Extract Class | Medium |
| Duplicated Code | Extract Method | Low |
| Switch Statement | Replace with Polymorphism | High |
| Long Parameter List | Introduce Parameter Object | Medium |

### Step 3: Create Refactoring Plan

**Template:**
```markdown
## Refactoring: [Name]

**Problem:** [Description]
**Goal:** [Desired outcome]
**Risk Level:** [Low/Medium/High]

### Prerequisites
- [ ] Tests exist and pass
- [ ] Code is committed
- [ ] Dependencies identified

### Steps
1. [First small change]
2. [Run tests]
3. [Next small change]
4. [Run tests]
...

### Validation
- [ ] All tests pass
- [ ] No functionality changed
- [ ] Code is cleaner
```

### Step 4: Execute Incrementally

**Golden Rule:** Make the change easy, then make the easy change

1. Make one small change
2. Run tests
3. Commit
4. Repeat

## Refactoring Examples

### Extract Method

**Before:**
```javascript
function printOwing(invoice) {
  let outstanding = 0;
  
  console.log("***********************");
  console.log("**** Customer Owes ****");
  console.log("***********************");
  
  for (const o of invoice.orders) {
    outstanding += o.amount;
  }
  
  console.log(`name: ${invoice.customer}`);
  console.log(`amount: ${outstanding}`);
}
```

**Plan:**
1. Extract banner printing
2. Run tests
3. Extract outstanding calculation
4. Run tests
5. Extract details printing
6. Run te

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3593 chars