Skills juliusbrussee caveman Caveman

safe-refactor

Use it when:
You're restructuring code, by extracting, merging or moving it, and its behavior must stay exactly the same.
It does:
Sets up a check of current behavior before editing, keeps feature changes out, and moves one piece of responsibility at a time.
You get:
Restructured code that passes the same checks as before, with every intermediate step still building.
Unlike migration:
That one moves data, schemas or APIs with a rollback plan; this one changes only how the code is organized.
Runs:
On its own, whenever the agent sees a task that fits; it's a short list of rules, not a step-by-step guide.

Skill 14 of 16 in the Caveman bundle, after surgical-patch and before migration.

TL;DR

Before any structural edit, the agent defines which behavior must be preserved and how it will verify that. It keeps new features out of the refactor, moves responsibility from one part of the code to another one step at a time, and preserves public interfaces, error behavior, ordering and compatibility unless you've said otherwise. Every intermediate state must still build and pass tests, and it adds no dependency or configuration unless correctness needs it. At the end it runs the same verification again, and stops once behavior matches and the requested structure is in place.

Summarizes the skill at bad48a0.

npx skills add https://github.com/juliusbrussee/caveman --skill safe-refactor
Total Downloads
120,380 on skills.sh, Nov 9, 2026
Repo stars
118,416 juliusbrussee/caveman
First seen
Aug 11, 2026 on skills.sh
Weekly Downloads
6.9K
-48% over the 8 weeks to Nov 9
Weekly values
Week toInstalls
Sep 2113,123
Sep 2810,908
Oct 511,006
Oct 128,448
Oct 197,239
Oct 267,648
Nov 27,234
Nov 96,874
Category

Test-first work, implementation from specs, git hygiene and scope control.

Everything for building software: planning, coding, debugging, design, frameworks, cloud, agents and skills.

Type

A multi-step process the agent follows: interview, debug, run a TDD loop, review.

Effect

Its own steps create or change files, git state or local tools.

Needs

Instructions only. Works in any agent that supports skills.

Publisher

Everyone else. Unverified vendor claims default to community.

Topics

SKILL.md

From juliusbrussee/caveman at bad48a0. Checked daily, last changed Oct 20, 2026.

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