Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

safe-refactor — Claude Code skill: what it does, how to install

Restructures code while preserving existing behavior, enforcing verification boundaries before structural edits.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add JuliusBrussee/caveman --skill safe-refactor -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/safe-refactor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/safe-refactor/

From the same set22

The whole set →
caveman JuliusBrussee Cuts filler and polite greetings from agent responses while keeping technical facts and code exact. Stays active until turned off. Claude Code CX Codex Cursor +1 591,500installs caveman-commit JuliusBrussee Generates terse Conventional Commits messages focused strictly on intent. Ideal for keeping git history clean without boilerplate or AI signatures. Claude Code CX Codex Cursor +1 414,700installs caveman-review JuliusBrussee Generates terse, single-line code review comments with exact line numbers, problems, and fixes. Eliminates conversational filler in pull request reviews. Claude Code CX Codex Cursor +1 410,700installs caveman-compress JuliusBrussee Rewrites CLAUDE.md and todo files into terse caveman-speak so the model reads fewer input tokens. The source gets overwritten; a readable backup stays out of tree. Claude Code CX Codex Cursor +1 410,300installs caveman-help JuliusBrussee A quick reference for Caveman modes and commands in Claude Code and other supported hosts. Use it when you need to control response style or find related skills. Claude Code CX Codex Cursor +1 401,800installs cavecrew JuliusBrussee cavecrew delegates code searches, small edits, and diff reviews to three subagents. Use it when keeping the main agent's context lean matters. Claude Code CX Codex Cursor +1 357,900installs caveman-stats JuliusBrussee Displays recorded output and cache-read tokens for Claude Code sessions or points to host native usage stats. Useful for tracking raw token consumption. Claude Code CX Codex Cursor +1 356,700installs caveman-explore JuliusBrussee A read-only skill locates relevant files and line ranges in a repository. Use it for cold-start orientation or broad searches. Claude Code CX Codex Cursor +1 106,500installs

Similar

find-animation-opportunities emilkowalski Scans a codebase or UI for motion that would clarify states and interactions, while rejecting decoration that gets in the way. It is read-only. Claude Code CX Codex Cursor +1 206,800installs ponytail-audit DietrichGebert It audits a repository and ranks bugs, risks, and redundant code in a one-shot report. Use it when you need a review without code changes. Claude Code CX Codex Cursor +1 44,800installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs triage Matt Pocock This skill moves issues and external PRs through triage states, verification, and agent briefs. It fits maintainers managing an issue queue. Claude Code 990,453installs codebase-design Matt Pocock This skill helps design modules with small interfaces and hidden complexity. Use it when refactoring code, choosing a seam, or making tests easier to write. Claude Code 850,344installs code-review Matt Pocock Reviews changes from a chosen reference point against repository standards and the originating spec. Use it for a branch, PR, or work in progress. Claude Code 789,521installs implement Matt Pocock Implements work from a specification or tickets, following a test-driven flow and ending with review and a commit. Use it when a coding task needs a defined delivery routine. Claude Code 774,700installs

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

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor