Skills

Refactor

Safe multi-file refactoring with automatic rollback.

Install

npx skills add SethGammon/Citadel --skill refactor -g -a claude-code -y
Repository
SethGammon/Citadel927
Category
Testing
Updated
5d ago
License
MIT
Context cost
Mediumabout 1,927 tokens
Runs scripts
No, instructions only

What it does

Safe multi-file refactoring with automatic rollback. Establishes a type/test baseline, plans all changes, executes file-by-file, and verifies zero regressions. Reverts if verification fails after two fix attempts. Handles renames, extracts, moves, splits, merges, and inlines.

/refactor, Safe Multi-File Refactoring

Orientation

Use /refactor when you need to:

  • Rename a symbol, file, or module across the codebase
  • Extract a function, component, hook, class, or module from existing code
  • Inline a function or module back into its callers
  • Move a file or set of files to a new location
  • Split a large file into smaller pieces
  • Merge related files into one
  • Change a function signature and update all call sites

Don't use when: debugging a specific bug (use /systematic-debugging); adding new features (use /marshal or /scaffold); deleting dead code (use /marshal for a targeted cleanup).

Boundary with /organize: /refactor changes code structure within files (extract, inline, split, merge, rename) and moves files as part of those operations. Repository-wide file/directory placement, naming sweeps, and where-does-this-belong decisions are /organize.

Behavior does not change. Tests pass before and after, no new type errors, the refactoring is correct.

Commands

CommandBehavior
/refactor rename [old] to [new]Rename symbol, file, or module
/refactor extract [target] from [source]Extract function/component/module
/refactor inline [target]Inline a function/module into callers
/refactor move [source] to [dest]Move file(s) with import updates
/refactor split [file]Split a file into logical pieces
/refactor merge [files...]Merge related files into one
/refactor [freeform description]Auto-detect refactoring type from description
/refactor --dry-run [any above]Plan only, show what would change

Protocol

Phase 1: BASELINE

Run typecheck (via node scripts/run-with-timeout.js 300 npm run typecheck) and tests. Record error/failure counts, pre-existing issues are not your responsibility, but you must not add to them. Warn if there are uncommitted changes in files you plan to modify.

Read the whole SKILL.md on GitHub

More in Testing