About refactor-safe
refactor-safe is a code-review skill for identifying and ranking maintainability-focused refactoring suggestions. It excludes generated and vendor files, gives each suggestion a location, rationale, safety level, and effort estimate, and limits the list to ten items.
Key features
- 01Checks for a valid project
- 02Finds common refactoring opportunities
- 03Groups suggestions by safety level
- 04Provides locations and rationale
- 05Estimates effort and flags testing needs
Use cases
- 01Reviewing a codebase for safe cleanup
- 02Prioritizing refactoring work by risk
- 03Finding unused code or repeated patterns
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dzhuneyt/ skills --skill refactor-safeAfter installing, type/refactor-safein Claude Code to confirm it loaded.
Details
From the project READMEExecute the following steps:
-
Check if current directory is a valid project (package.json, requirements.txt, etc.)
-
Analyze code patterns and identify safe refactoring opportunities:
- Duplicate code blocks that can be extracted into functions
- Long functions that can be broken down
- Magic numbers/strings that should be constants
- Unused imports or variables
- Simple type improvements (TypeScript/Python)
- Dead code that can be removed safely
-
Prioritize suggestions by safety level:
- Safe: No behavior change (extract constants, remove unused code)
- Low Risk: Mechanical refactoring (extract functions, rename variables)
- Medium Risk: Structural changes that need testing
-
For each suggestion provide:
- Location (file:line)
- What to refactor
- Why it's safe
- Estimated effort (small/medium/large)
Safety criteria:
- Only suggest refactoring for code patterns, not business logic changes
- Prioritize mechanical transformations over subjective improvements
- Flag any suggestions that require tests to verify safety
- Exclude files that look like generated code or vendor libraries
- Focus on maintainability improvements with clear benefits
Output format:
- Group suggestions by safety level
- Show file locations with line numbers
- Provide brief rationale for each suggestion
- Include rough effort estimates
- Limit to top 10 most impactful suggestions
Comments
Markdown supported