A disciplined refactoring plugin based on principles from "Refactoring" (Fowler) and "Working Effectively with Legacy Code" (Feathers).
- Analysis-First Approach: Identifies code smells and prioritizes high-impact refactorings
- 80/20 Principle: Focus on the least refactorings that give the most impact
- Safe Transformations: Step-by-step refactoring with verification at each step
- Incremental Changes: One transformation at a time, with git commits
- Multi-Language Examples: Python, TypeScript, Go, Dart, and more
If you're in this directory:
claude plugins install .Or specify the scope:
claude plugins install . --scope user # Available in all your projects
claude plugins install . --scope project # Only in current projectInstall from GitHub:
claude plugins install https://github.com/elifiner/refactoringOr with SSH:
claude plugins install git@github.com:elifiner/refactoring.gitInvoke the refactoring skill with:
/refactor [file or code to analyze]The skill follows a two-phase approach:
- Analyzes code for common code smells
- Prioritizes issues by impact (HIGH/MEDIUM/LOW)
- Applies 80/20 thinking - finds the least refactorings for most impact
- Presents findings and gets your approval
- Identifies ONE safe transformation
- Applies the change
- Verifies (tests, compiler, or manual inspection)
- Commits the change
- Suggests next step
> /refactor src/services/orderProcessor.js
Code Smell Analysis:
🔴 HIGH IMPACT (start here):
- Line 45: processOrder() is 150 lines, does 5 different things
- Lines 67-89: Validation logic duplicated in 3 places
🟡 MEDIUM IMPACT:
- Line 120: Deep nesting (4 levels) in calculateTotal()
Recommendation: Start with extracting validation logic.
This unlocks easier testing and future changes.
Proceed with extracting validation? (y/n)This plugin follows a strict discipline:
- Analysis before refactoring - Don't refactor everything, prioritize impact
- 80/20 principle - Focus on high-leverage changes
- One transformation at a time - Never mix multiple changes
- Always verify - Run tests or verify mechanically after each step
- Small steps - If you can't verify it, make it smaller
- Observe and adapt - Don't plan all steps upfront
- Know when to stop - Perfect code is not the goal
- Long functions (> 50 lines)
- Duplicated code blocks
- Deep nesting (> 3 levels)
- Unclear names
- Complex conditionals
- God classes/modules (> 500 lines)
- Long parameter lists (> 4 parameters)
- Extract Method/Function
- Inline Method/Function
- Rename (Variable, Function, Class, File)
- Move Method/Function
- Extract Variable
- Inline Variable
- Split Loop
- Replace Nested Conditional with Guard Clauses
See the detailed guide for complete explanations and examples in multiple languages.
refactoring/
├── .claude-plugin/
│ └── plugin.json # Plugin metadata
├── skills/
│ └── refactor/
│ ├── SKILL.md # Main skill workflow
│ └── guide.md # Detailed refactoring guide
└── README.md # This file
The skill will help you identify when NOT to refactor:
- Code that rarely changes
- Low-impact cosmetic improvements
- Areas with unclear requirements
- When you have higher priorities
To modify this plugin:
- Edit files in
skills/refactor/ - Update version in
.claude-plugin/plugin.json - Test locally:
claude --plugin-dir . - Reinstall:
claude plugins install .
MIT
- "Refactoring: Improving the Design of Existing Code" by Martin Fowler
- "Working Effectively with Legacy Code" by Michael Feathers