1---2name: refactoring3description: Safe refactoring steps4---56# Safe Refactoring78Improve structure without changing behavior.910## Preconditions1112- [ ] Tests exist and pass13- [ ] Coverage >= 80%14- [ ] Understand current behavior1516## Step 1: Identify1718- Find code smell19- Document why change needed20- Estimate impact2122## Step 2: Test Coverage2324- Add tests for behavior to preserve25- Run tests - must pass before refactor2627## Step 3: Refactor2829- Make smallest possible change30- Run tests after each change31- Commit when tests pass3233## Step 4: Verify3435- Full test suite passes36- No new lint errors37- Performance not degraded3839## Common Refactors4041- Extract function42- Rename for clarity43- Remove duplication44- Simplify conditionals45- Introduce abstraction4647## Anti-Patterns4849- Never refactor without tests50- Never mix refactor with feature51- Never skip running tests
Run npx skillmds@latest add hongmaple0820/refactoring in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Safe refactoring steps It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
hongmaple0820 (@hongmaple0820) published this skill. Their other Agent Skills are listed on their SkillMD profile.