safe-refactor — Claude Code skill: what it does, how to install
Restructures code while preserving existing behavior, enforcing verification boundaries before structural edits.
npx skills add JuliusBrussee/caveman --skill safe-refactor -a claude-codeWhat safe-refactor does
The skill instructs coding assistants to bracket refactoring within strict verification steps. Before touching the code, the model defines the boundary of behavior to preserve and sets up checks. Feature changes stay strictly outside the refactoring scope.
During execution, the assistant moves one ownership boundary at a time. It keeps public interfaces, failure modes, ordering, and compatibility intact. Each intermediate state must build and pass tests. The rules also block new dependencies or config changes unless strictly required for correctness.
Install this when restructuring messy components or moving modules. It prevents the model from quietly changing logic while tidying up.
What it helps with
- extract or consolidate code without altering runtime behavior
- move ownership boundaries incrementally step by step
- keep public interfaces and failure handling intact during cleanup
- ensure every intermediate edit remains buildable and testable
Example prompts for the agent
- Use safe-refactor to split this controller into separate services
- Clean up this module without changing its public API or failure behavior
How to install safe-refactor
1Skills CLI (Vercel)
npx skills add JuliusBrussee/caveman --skill safe-refactor -a claude-code2Manually: put the files in place
~/.claude/skills/safe-refactor/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/safe-refactor/
1Skills CLI (Vercel)
npx skills add JuliusBrussee/caveman --skill safe-refactor -a codex2Manually: put the files in place
.agents/skills/safe-refactor/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add JuliusBrussee/caveman --skill safe-refactor -a cursor2Manually: put the files in place
.cursor/skills/safe-refactor/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install JuliusBrussee/caveman safe-refactor2Manually: put the files in place
.github/skills/safe-refactor/SKILL.md1Skills CLI (Vercel)
npx skills add JuliusBrussee/caveman --skill safe-refactor -a gemini-cli2Platform CLI
gemini skills install https://github.com/JuliusBrussee/caveman --path skills/safe-refactorManually: put the files in place
.devin/skills/safe-refactor/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add JuliusBrussee/caveman --skill safe-refactor -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set22
The whole set →Similar
Questions about safe-refactor
How to install safe-refactor in Claude Code?
Run npx skills add JuliusBrussee/caveman --skill safe-refactor -a claude-code in your terminal. You can also place the skill file in ~/.claude/skills/safe-refactor/SKILL.md.
What does safe-refactor do?
It enforces behavior verification before and after structural edits. The assistant preserves public interfaces, keeps intermediate builds passing, and leaves feature additions out.
Does safe-refactor allow adding new dependencies?
It avoids adding dependencies or configuration growth unless strictly required for correctness.
Source text
SKILL.md · Apache-2.0
--- name: safe-refactor description: Restructure code while preserving behavior. Use for extraction, consolidation, ownership moves, or cleanup where verification must bracket structural edits. --- # Safe refactor Define behavior-preservation boundary and establish verification before structural edits. - Keep feature changes outside refactor. - Move one ownership boundary at a time. - Preserve public interfaces, failure behavior, ordering, and compatibility unless explicitly scoped. - Keep intermediate states buildable and testable. - Avoid dependency or configuration growth without correctness need. Run same proof after change. Stop when behavior matches and requested structure is achieved.
© JuliusBrussee · Apache-2.0 · JuliusBrussee/caveman