From refactor-tools
Apply safe, behavior-preserving cleanup edits to existing code by selecting a scope, reviewing for duplication, readability, and meaningful efficiency issues, then summarizing what was changed versus left manual. Use this skill whenever the user asks to simplify, clean up, refactor, streamline, de-duplicate, polish, or make existing code more maintainable, readable, or efficient, especially for staged changes, the latest commit, or explicitly named files after a feature or bug fix, even if they do not explicitly say "simplify." Also use it when the user wants safe cleanup with edits plus a structured report of risky follow-ups. Do not use it for review-only requests, debugging, new feature work, or broad architectural redesign.
How this skill is triggered — by the user, by Claude, or both
Slash command
/refactor-tools:simplifyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill to clean up existing code without changing intended behavior.
Use this skill to clean up existing code without changing intended behavior.
The job is not just to review. The job is to identify safe simplifications, apply the ones that are clearly behavior-preserving, and leave the risky or ambiguous items for the user.
Do not use this skill when the user primarily wants:
Before doing any cleanup, determine:
If the user includes extra text after invoking the workflow, treat that text as focus guidance and prioritize matching concerns first.
Use this fallback order:
git diff --cached --name-only.git show --name-only --pretty='' HEAD.If git-based scope detection fails because the directory is not a git repo, the repo has no commits, or the result is otherwise unusable, ask the user to specify files manually and stop.
Apply these filtering rules:
.min.js, sourcemaps, and build artifacts.node_modules/ and vendor/.If no eligible files remain, respond with exactly:
No eligible files found in the selected scope.
If more than 15 files remain, list them and ask the user to confirm before proceeding. Offer to narrow the scope to a directory or smaller file set.
Look for project rules in this order:
AGENTS.md.github/copilot-instructions.mdCLAUDE.md.cursorrulesUse the first file found and extract enforceable conventions such as naming, structure, preferred patterns, and forbidden practices.
If no rules file exists, continue with language-idiomatic conventions and normal linter sensibilities. In the final report, state:
No project rules file found - using general best practices.
Read the full content of every target file unless a file is so large that using a diff is materially more practical.
Then run exactly three review passes in parallel using the same input package for each pass.
Shared input for every pass:
none found - use general best practices.Required finding format:
- **file**: `path/to/file`
**line**: L or L-L range
**issue**: one-sentence description of the problem
**suggestion**: concrete code change or refactor to apply
**confidence**: high | medium | low
**risk**: safe | caution | risky
Interpret the risk labels this way:
safe: behavior-preserving.caution: could change behavior.risky: changes public API or semantics.Run these three passes:
Look for:
Do not flag repetition that is clearer left explicit, such as test fixtures or tiny, readable one-off code paths.
Look for:
Look for:
Do not micro-optimize code that is unlikely to matter.
After the three passes complete:
Apply this filter before editing:
high confidence plus safe risk fixes.medium confidence plus safe risk fixes, but call them out in the report.low confidence findings.caution or risky findings.When editing:
LEFT UNCHANGED instead.Use this exact section structure:
**SCOPE**
- Source: staged changes | last commit | user-specified scope
- Files processed: N
- Files skipped: N (with reasons if any were filtered)
- Project rules: `filename` | none found
- Focus: `<user focus text>` | none
**AGENT FINDINGS**
- Code Reuse: N findings (N high, N medium, N low)
- Code Quality: N findings (N high, N medium, N low)
- Efficiency: N findings (N high, N medium, N low)
**APPLIED FIXES**
- [ ] `file:line` - what changed - why - confidence
**LEFT UNCHANGED**
- [ ] `file:line` - reason not auto-fixed (low confidence | risk | conflict | test code)
**SUMMARY**
- Total fixes applied: N
- Remaining manual items: N
- Confidence: High | Medium | Low
- Rollback: `git checkout -- <files>` to undo all changes
If no meaningful improvements are found, respond with exactly:
No material simplifications found in the selected changes.
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub dhohner/clankers --plugin refactor-tools