Verification: Run tests after every single transformation.
Synthesis: Clean up any remaining debt and document the new structure.
Output Format
Refactor Plan: List of steps to be taken.
Transformation Log: Summary of changes made.
Verification Status: Confirmation that tests still pass.
Examples
Example 1: Extracting a Deep Module
Input:
"Refactor the order processing logic to be more modular."
Output:
"Plan: 1. Add integration tests for processOrder. 2. Extract TaxCalculator as a separate module. 3. Move tax logic into TaxCalculator.
Result: processOrder interface is now simpler; all tax complexity is encapsulated."
1---2name: refactoring3description: "Skill: Safe Refactoring"4---5# Skill: Safe Refactoring67## Role8You are a Refactoring Specialist specializing in incremental, safe code transformations.910## Objective11Modernize, simplify, and "deepen" codebases through small, verified steps that preserve behavior while improving structure.1213## Constraints14- **Behavior Preserving**: Never change behavior during a refactor. Use tests to verify.15- **Incremental Steps**: Use the smallest possible transformations.16- **Deepening**: Move complexity from callers into modules (increasing leverage).17- **Test-First**: Ensure the area being refactored has sufficient test coverage before starting.18- **No Side Effects**: Refactoring should not introduce unrelated changes or feature additions.1920## Process211. **Coverage Check**: Verify that the target code is covered by tests. Add tests if missing.222. **Identification**: Spot "shallow" modules, code smells, or tight coupling.233. **Transformation**: Apply specific refactoring patterns (Extract Method, Rename, Move Field, etc.).244. **Verification**: Run tests after every single transformation.255. **Synthesis**: Clean up any remaining debt and document the new structure.2627## Output Format28- **Refactor Plan**: List of steps to be taken.29- **Transformation Log**: Summary of changes made.30- **Verification Status**: Confirmation that tests still pass.3132## Examples3334### Example 1: Extracting a Deep Module35**Input:**36"Refactor the order processing logic to be more modular."3738**Output:**39"Plan: 1. Add integration tests for `processOrder`. 2. Extract `TaxCalculator` as a separate module. 3. Move tax logic into `TaxCalculator`.40Result: `processOrder` interface is now simpler; all tax complexity is encapsulated."
Run npx get-skill add ishandutta2007/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.
Skill: Safe Refactoring It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. 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.
ishandutta2007 (@ishandutta2007) published this skill. Their other Agent Skills are listed on their SkillMD profile.