/codebase-maintenance:test-preserving-refactorfrom codebase-maintenance
Restructures code in small, test-backed steps, keeping tests green at every change. Reverts on red to avoid broken states.
Ships in codebase-maintenance. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Refactoring is only safe if it is backed by tests. Work in a strict loop — green baseline, one structural change, immediate re-run, revert on red — so you are never trapped in an uncompilable state.
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:
npx jest path/to/target # or: pytest tests/test_target.py -q
Small steps. Make one structural change at a time (e.g., extract a method).
Run tests immediately after the single structural change. The per-change loop:
# repeat per structural change: edit -> test -> commit (green) | revert (red)
npx jest path/to/target && git commit -am "refactor: extract X" || git checkout -- .
Revert on red. If the tests fail, you made a mistake. Revert the change (git checkout -- . or git restore .) and try a different approach. Do not attempt to "fix" the refactor while tests are failing.
Commit on green. Once the small change is green, consider it a safe checkpoint.
This strict loop prevents you from getting trapped in an uncompilable state.
What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/ai-slop-cleanerUse when a working code path feels bloated, noisy, or over-abstracted, when asked to clean up or deslop AI-generated code, or when a reviewer-only anti-slop pass is requested./architecture-simplificationUse when a codebase carries over-engineered abstractions, unnecessary layers, or redundant logic that should be collapsed without changing behavior./context-retrieval-loopUse when about to refactor, rename, or remove code, assessing dead code before deletion, or unsure of the blast radius of a change.npx claudepluginhub yeaight7/agent-powerups --plugin codebase-maintenanceOther plugins' skills for the same job