refactoring-advisor
БесплатноБез исполняемых скриптовНе проверенProvides refactoring recommendations and step-by-step improvement plans. Use when planning refactoring, improving code structure, or reducing technical debt.
от armanzeroeight★ 30 звёзд на GitHubОб этом скилле
Refactoring Advisor
Quick Start
Plan refactoring based on identified issues:
- Identify the problem (code smell, complexity)
- Select appropriate refactoring pattern
- Create step-by-step plan
- Ensure tests exist
- 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:
## 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
- Make one small change
- Run tests
- Commit
- Repeat
Refactoring Examples
Extract Method
Before:
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:
- Extract banner printing
- Run tests
- Extract outstanding calculation
- Run tests
- Extract details printing
- Run tests
After:
function printOwing(invoice) {
printBanner();
const outstanding = calculateOutstanding(invoice);
printDetails(invoice, outstanding);
}
function printBanner() {
console.log("***********************");
console.log("**** Customer Owes ****");
console.log("***********************");
}
function calculateOutstanding(invoice) {
return invoice.orders.reduce((sum, o) => sum + o.amount, 0);
}
function printDetails(invoice, outstanding) {
console.log(`name: ${invoice.customer}`);
console.log(`amount: ${outstanding}`);
}
Extract Class
Before:
class Person {
name;
officeAreaCode;
officeNumber;
getTelephoneNumber() {
return `(${this.officeAreaCode}) ${this.officeNumber}`;
}
}
Plan:
- Create TelephoneNumber class
- Move areaCode field
- Run tests
- Move number field
- Run tests
- Move getTelephoneNumber method
- Run tests
- Update Person to use TelephoneNumber
- Run tests
After:
class TelephoneNumber {
areaCode;
number;
toString() {
return `(${this.areaCode}) ${this.number}`;
}
}
class Person {
name;
telephoneNumber;
getTelephoneNumber() {
return this.telephoneNumber.toString();
}
}
Safety Checklist
Before refactoring:
- Tests exist and pass
- Code is in version control
- You understand what the code does
- You have time to complete the refactoring
During refactoring:
- Make small changes
- Run tests after each change
- Commit working states
- Don't add features while refactoring
After refactoring:
- All tests pass
- Code review completed
- Documentation updated
- No functionality changed
Установить refactoring-advisor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл refactoring-advisor?
Provides refactoring recommendations and step-by-step improvement plans. Use when planning refactoring, improving code structure, or reducing technical debt.
Как установить скилл refactoring-advisor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл refactoring-advisor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic