refactoring-code

star 33

Batch behavior-preserving refactors for multi-file, repeated-pattern, large-file, rename, move, extract, split, or restructure work. Use for "refactor across files", "batch rename", "update pattern everywhere", large files (500+ lines), or 5+ coordinated edits in one file. NOT for single targeted edits, behavior changes or bug fixes (use fixing-code), test-only refactors (use improving-tests), code review (use reviewing-code), or architecture redesign (use architecture-design/review).

alexei-led By alexei-led schedule Updated 6/3/2026

description: Batch behavior-preserving refactors for multi-file, repeated-pattern, large-file, rename, move, extract, split, or restructure work. Use for "refactor across files", "batch rename", "update pattern everywhere", large files (500+ lines), or 5+ coordinated edits in one file. NOT for single targeted edits, behavior changes or bug fixes (use fixing-code), test-only refactors (use improving-tests), code review (use reviewing-code), or architecture redesign (use architecture-design/review). name: refactoring-code

Refactoring Code

Refactor in small, verified batches. If behavior changes, it is not a refactor; it is a feature wearing a fake mustache.

Preconditions

  • Understand the current behavior and test coverage.
  • Identify the smallest safe batch.
  • Run or add tests before broad edits when risk is non-trivial.
  • Confirm before large mechanical changes across many files.

Workflow

  1. Define the refactor goal and non-goals.
  2. Map all affected sites before editing with available file/text search tools.
  3. Read representative files and tests.
  4. Add characterization tests when behavior is under-specified.
  5. Apply one coherent batch with edit or write.
  6. Run narrow tests.
  7. Run broader lint/type/test checks before the next batch.
  8. Delete dead code introduced or exposed by the refactor.

Safe Batches

Good batches:

  • rename one public symbol and all callers
  • move one function/module with tests unchanged
  • remove one duplicate implementation after tests prove equivalence
  • update one repeated pattern across files

Bad batches:

  • rename everything while changing logic
  • reorganize modules and change APIs in one pass
  • add abstractions for imagined future callers
  • edit generated files by hand

Output Contract

## Refactor Result

### Changed

- `path` — what changed

### Behavior

- preserved by <tests/checks>

### Verification

- `<command>` — pass/fail

### Follow-up

- remaining safe batches, if any
Install via CLI
npx skills add https://github.com/alexei-led/cc-thingz --skill refactoring-code
Repository Details
star Stars 33
call_split Forks 5
navigation Branch main
article Path SKILL.md
More from Creator