refactor

Plan and execute multi-file refactorings with automatic rollback on failure.

820|78|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/SethGammon/Citadel --skill refactor-sethgammon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/SethGammon/Citadel/tree/main/skills/refactor
Command: npx skills add https://github.com/SethGammon/Citadel --skill refactor-sethgammon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

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.

Core Features & Use Cases

  • Deterministic planning with a defined baseline.
  • Phase-driven execution: baseline, plan, execute, verify.
  • Safety-first: typecheck, tests, and automatic rollback on failures.

Quick Start

Specify the target and desired change to generate a deterministic, rollback-ready plan.

Frequently Asked Questions about refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely execute a multi-file refactor across a large codebase?

Safe multi-file refactoring requires a baseline typecheck and test pass, followed by a phased workflow of planning, executing, and verifying changes. The system automatically reverts all modifications if verification fails after two fix attempts.

What types of codebase refactoring operations are supported?

Supported refactoring operations include renames, extracts, moves, inlines, splits, and merges across multiple files. The process preserves behavior by establishing a deterministic baseline and verifying zero regressions after execution.

Do I need passing tests before starting a codebase refactor?

Yes, a valid baseline with passing typechecks and tests is required before refactoring. If the baseline is invalid, the process halts and makes no changes to ensure safety and prevent regressions.

What happens if verification fails during a multi-file refactor?

If verification fails during a multi-file refactor, the system attempts two fixes before automatically rolling back all changes. This safety mechanism ensures the codebase returns to its stable baseline state.

What is the best way to plan and execute codebase splits and merges?

The best way to execute splits and merges is through a phase-driven workflow: establish a baseline, generate a deterministic plan, execute file-by-file, and verify. This guarantees automatic rollback if any phase fails.

Can I revert a multi-file rename if it breaks my typecheck?

Yes, if a multi-file rename breaks the typecheck during verification, the system automatically reverts the changes. It attempts two fixes first, then rolls back to the baseline if failures persist.