Use to restructure code while guaranteeing that all existing tests continue to pass.
Scanned 5/29/2026
Install to Claude Code
npx -y skills add yeaight7/agent-powerups --skill test-preserving-refactor --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Test Preserving Refactor?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/yeaight7-test-preserving-refactor)More formats (shields.io, HTML) on the badges page.
---
name: test-preserving-refactor
description: "Use to restructure code while guaranteeing that all existing tests continue to pass."
---
# Test-Preserving Refactor
Refactoring is only safe if it is backed by tests.
## The Protocol
1. **Run Tests First**: Before touching any code, run the tests covering the target area. They MUST be green. If they are red, stop and fix the tests (or the code) first.
2. **Small Steps**: Make one structural change at a time (e.g., extract a method).
3. **Run Tests Immediately**: Run the tests immediately after the single structural change.
4. **Revert on Red**: If the tests fail, you made a mistake. Revert the change (`git checkout` or `ctrl+z`) and try a different approach. Do not attempt to "fix" the refactor while tests are failing.
5. **Commit**: Once the small change is green, consider it a safe checkpoint.
This strict Red/Green/Refactor cycle prevents you from getting trapped in an uncompilable state.Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!
Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.