refactor

Coordinates phased, incremental code refactoring with Git-based governance.

10|5|Updated Jan 5, 2026
One-click install
npx skills add https://github.com/phuthuycoding/moicle --skill refactor-phuthuycoding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/phuthuycoding/moicle/tree/main/assets/skills/refactor
Command: npx skills add https://github.com/phuthuycoding/moicle --skill refactor-phuthuycoding

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactoring work often risks behavior changes and inconsistent code quality. This Skill provides a structured, incremental workflow to guide teams through safe refactoring without altering external behavior.

Core Features & Use Cases

  • Phase-driven workflow: Analyze, Plan, Refactor, Test, Review, and Complete with governance checks.
  • Architecture-aligned: Reads architecture references to align refactor with target patterns and avoid architectural drift.
  • Incremental changes & gating: Small, testable steps with version control checkpoints to minimize risk.
  • Use Case: You need to clean up a legacy module while preserving functionality and performance, and you want to demonstrate progress and maintainability improvements.

Quick Start

Start a refactor by creating a scoped feature branch, then follow the gate-driven steps:

  1. Create a new branch: git checkout -b refactor/<scope>-<description>
  2. Read the architecture doc and define an incremental plan
  3. Apply one refactoring pattern at a time, run tests after each step, and commit
  4. Review and finalize with documentation and PR

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I safely refactor legacy code without changing external behavior?

Refactoring legacy code safely requires an incremental, gate-driven workflow that applies one refactoring pattern at a time with Git checkpoints. This approach enforces testing after each step to preserve external behavior while reducing technical debt.

What is the best way to plan an architectural restructure for a software project?

Planning an architectural restructure involves reading architecture references to avoid architectural drift, then following a phased workflow: Analyze, Plan, Refactor, Test, Review, and Complete. This gate-driven process ensures structural changes remain incremental and testable.

Do I need a Git branch to start cleaning up technical debt incrementally?

Yes, a Git branch is required to isolate incremental changes during technical debt reduction. Creating a scoped feature branch establishes version control checkpoints that gate each refactoring step, ensuring changes remain safe and reversible.

How does a gate-driven refactoring workflow handle feature cleanup?

A gate-driven refactoring workflow handles feature cleanup by enforcing a phased process of Analyze, Plan, Refactor, Test, Review, and Complete. Governance checks at each gate require passing tests before advancing to the next incremental step.

Can I use this refactoring workflow without existing test coverage?

Using this refactoring workflow without existing test coverage risks breaking external behavior. The process relies on running tests after applying each refactoring pattern to verify preserved functionality, making test coverage a practical prerequisite for safe gating.