# Behavior-Preserving Refactor

Restructures code and checks behavior before and after each structural edit.

- Repository: https://github.com/JuliusBrussee/caveman (116680 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add JuliusBrussee/caveman --skill safe-refactor -g -a claude-code -y`
Codex: `npx skills add JuliusBrussee/caveman --skill safe-refactor -g -a codex -y`
Cursor: `npx skills add JuliusBrussee/caveman --skill safe-refactor -g -a cursor -y`
Gemini CLI: `npx skills add JuliusBrussee/caveman --skill safe-refactor -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add JuliusBrussee/caveman`

## Description

Restructure code while preserving behavior. Use for extraction, consolidation, ownership moves, or cleanup where verification must bracket structural edits.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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.

