Safe Refactor

by juliusbrussee2e08b9177c07No licenseListed Oct 8, 2026Updated Oct 8, 2026

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

Instructions onlySoftware Development
AI-generated overview

Guides behavior-preserving code restructuring with verification before and after structural edits.

What it does
Provides a workflow for refactoring code while keeping behavior unchanged. It has the agent define a behavior-preservation boundary, establish verification before making structural edits, move one ownership boundary at a time, and keep intermediate states buildable and testable. It also directs keeping feature changes out of the refactor and preserving public interfaces, failure behavior, ordering, and compatibility unless explicitly scoped.
When to use it
Use when restructuring code through extraction, consolidation, ownership moves, or cleanup, and when verification must bracket the structural edits. Also use when behavior preservation is the priority and feature changes should stay separate. Not intended for adding new functionality.
Requirements
No scripts or tools required; instructions only. The agent needs access to the codebase being refactored and the ability to run its existing build and test commands.

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.

Source and attribution

Source:juliusbrussee/cavemaninskills/safe-refactorat commit2e08b91

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal