---
name: Safe Refactor
slug: safe-refactor
category: Quality
description: Safe Refactor restructures code while preserving behavior. Use it for extraction, consolidation, ownership moves, or cleanup where verification must bracket structural edits.
github: "https://github.com/JuliusBrussee/caveman/tree/main/skills/safe-refactor"
language: Go
stars: 97841
forks: 5640
install: "npx degit https://github.com/JuliusBrussee/caveman/tree/main/skills/safe-refactor ~/.claude/skills/safe-refactor"
installs_to: ~/.claude/skills/safe-refactor
source_path: skills/safe-refactor/SKILL.md
collection_size: 20
category_size: 1354
collection_url: "https://dirskills.com/collections/JuliusBrussee/caveman"
added: 2026-08-13T07:35:52.975Z
last_synced: 2026-08-13T07:35:52.975Z
canonical_url: "https://dirskills.com/skills/safe-refactor"
---

# Safe Refactor

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

**Install:**

```bash
npx degit https://github.com/JuliusBrussee/caveman/tree/main/skills/safe-refactor ~/.claude/skills/safe-refactor
```

## README

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