Skip to content

Skill

Planning Behavior-Preserving Refactors

Plans a small, staged refactor that improves code structure, readability, or maintainability while preserving externally visible behavior.

Back to Skills

When to use

Plans a small, staged refactor that improves code structure, readability, or maintainability while preserving externally visible behavior - identifying the behavior to preserve, current structure issues, required versus optional changes, behavior-change risks, and the tests or checks to run.

  • Use when

    Use before extracting functions, reducing duplication, simplifying control flow, renaming internals, or separating responsibilities.

  • Limits

    Produces a plan only; does not edit code or claim the refactor was run or tested.

Skill package

SKILL.md

This Skill is a single file. The download is its SKILL.md, with the complete frontmatter and instructions.

  • planning-behavior-preserving-refactors/SKILL.md

Inputs required

Current code
The function, file, module, or component to refactor.
Refactor goal
What should improve: readability, duplication, function size, naming, control flow, responsibility boundaries, or maintainability.

Access needed

Needs read access to the code to refactor (repository or pasted excerpts); searching callers and existing tests improves the plan. Running existing tests for a baseline is optional and requires command-execution permission. Does not modify files.