refactor

Refactor code structure while preserving behavior by default.

Updated Jul 5, 2025
One-click install
npx skills add https://github.com/sqfzy/my_configs --skill refactor-sqfzy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/sqfzy/my_configs/tree/main/claude/skills/refactor
Command: npx skills add https://github.com/sqfzy/my_configs --skill refactor-sqfzy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Targeted refactoring that restructures code while preserving external behavior by default, with an optional breaking mode for design-level changes that require migration planning.

Core Features & Use Cases

  • Preserves behavior in default mode; changes in code structure only.
  • Breaking mode enables explicit migration plans, checkpoint commits, and automatic branch creation.
  • Phase-driven workflow with safety checks, baselining, and test guidance to minimize risk.

Quick Start

Describe the intended refactor and run the /refactor command with the appropriate flags to begin a guided, plan-driven rewrite.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I safely restructure code without altering external behavior?

Safe code refactoring uses a default mode that restructures internal code while preserving external behavior, utilizing phase-driven workflows, baselining, and safety checks to minimize risk.

How do I plan a breaking API change that requires a migration plan?

Breaking API changes are managed using a breaking mode refactoring that generates explicit migration plans, creates checkpoint commits, and automates branch creation to handle architecture updates safely.

What is the best way to automate branches and commits during a code rewrite?

Automating branches and commits during a code rewrite is handled by phase-driven refactoring workflows that automatically generate branches, commits, and test guidance based on the chosen refactoring mode.

When do I need an explicit migration plan for software design changes?

Explicit migration plans are required for software design changes when executing breaking mode refactoring to alter APIs or architecture, utilizing checkpoint commits to ensure safe transitions.

Does targeted code refactoring work with existing quality assurance tests?

Targeted code refactoring integrates with quality assurance by providing test guidance and baselining during the phase-driven workflow, ensuring existing tests validate behavior preservation throughout the rewrite.

What are the limitations of default code refactoring mode?

The limitation of default code refactoring mode is that it strictly preserves external behavior, meaning you cannot execute breaking API or architecture changes without switching to breaking mode and generating a migration plan.