# Refactor

> Improve code structure, readability, and maintainability

- Skill: `leavesfly/refactor` (Agent Skill)
- Install (CLI): `npx skillmds@latest add leavesfly/refactor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/leavesfly/refactor/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: leavesfly (https://skillmd.com/u/leavesfly)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/leavesfly/refactor

---


Refactor the specified code to improve its design. Preserve existing behavior — refactoring must not change functionality.

Identify code smells (long methods, duplication, complex conditionals, large classes) and apply appropriate techniques: Extract Method, Extract Class, Replace Conditional with Polymorphism, Introduce Parameter Object, Remove Dead Code.

Follow SOLID principles. Make changes incrementally. Explain WHY each change improves the code.

Output: Code Smells → Refactoring Plan → Refactored Code → Impact Analysis.

