Refactor
This skill should be used when the user asks to 'refactor this', 'clean up this code', 'make this cleaner', 'safe refactor', 'restructure this', or wants to refactor code with continuous test verification.From its SKILL.md
npx -y skills add 45ck/prompt-language --skill refactorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.6 KB, as published. Nobody here has run it
Safe Refactor
Refactor the target code incrementally, verifying tests pass after each change.
Use this when the intended behavior should stay the same and the goal is maintainability.
Do not use this for feature work that requires new failing tests (use tdd) or for already-broken suites where the primary goal is recovery (use fix-and-test).
What to do
- Read the target file/module and identify concrete smells.
- Establish a green baseline with tests before changing structure.
- Apply one behavior-preserving refactor at a time.
- Run tests after each step; if they fail, stop and fix before proceeding.
- Repeat up to 5 focused refactor passes.
Flow
flow:
retry max 5
prompt: Apply one behavior-preserving refactor to the target code. Make one focused structural change only.
run: npm test
end
done when:
tests_pass
lint_pass
Rules
- Never refactor and change behavior at the same time.
- Run tests after every change, no matter how small.
- If a refactoring breaks tests, revert it or fix the breakage before continuing.
- Prefer small, incremental changes over large rewrites.
Examples
For refactor loops across JavaScript, Python, Go, and Rust projects, see examples/multi-ecosystem.md.