process-refactoring

Guides incremental behavior-preserving code refactoring with typecheck and test verification.

Updated Dec 24, 2025
One-click install
npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill process-refactoring-joyjoin-tech-limited
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: process-refactoring
Source: https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1/tree/main/.github/skills/process-refactoring
Command: npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill process-refactoring-joyjoin-tech-limited

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Restructuring code without breaking behavior is risky: big-bang rewrites, mixed refactor-and-feature commits, and accumulated type errors make changes hard to review and revert. This Skill enforces a disciplined, incremental refactoring protocol so every step stays green and reversible. ## Core Features & Use Cases - Five-step refactoring protocol: establish a test safety net, plan the change, execute incrementally, verify no regression, and document the outcome. - Anti-pattern guardrails: explicitly blocks big-bang rewrites, refactor-plus-feature mixing, type error accumulation, and leftover dead code. - Use Case: When splitting a 1,000-line React component into smaller ones, the Skill walks you through extracting one piece at a time, running typecheck and tests after each step, and updating all import callers before finishing. ## Quick Start Ask the AI to refactor this module by extracting its helper functions into a separate file without changing any behavior.

Frequently Asked Questions about process-refactoring

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

FAQPage Schema
How do I refactor code without breaking existing behavior?

Refactor incrementally: run existing tests to establish a baseline, make one logical change at a time, and run typecheck and tests after each step. If coverage is thin, add characterization tests first so regressions are caught immediately.

How to split a large component into smaller ones safely?

Extract one piece at a time rather than rewriting the whole component. After each extraction, verify TypeScript compiles and tests pass, update all import callers, and only remove the old code once the new structure is verified.

Should I add tests before refactoring legacy code?

Yes, when coverage is thin for the code being changed, add characterization tests first to lock in current behavior. For purely mechanical refactors like renames or moves, the existing test suite may be sufficient as the safety net.

Can I mix refactoring with new features in the same commit?

No. Mixing refactoring with feature work makes changes hard to review and revert. If you discover a bug or needed feature mid-refactor, note it and address it in a separate commit after the refactor is complete.

When should I not use an incremental refactoring process?

Skip it for one-line renames, prototype or spike code, and bug fixes, which belong in a systematic debugging workflow. The discipline is designed for multi-file restructuring where behavior preservation must be verified.