refactor

Refactors existing code through phased extraction, splitting, and deduplication while preserving behavior.

6|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/greglas75/zuvo --skill refactor-greglas75
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/greglas75/zuvo/tree/main/skills/refactor
Command: npx skills add https://github.com/greglas75/zuvo --skill refactor-greglas75

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Restructuring code by hand risks silently changing behavior, breaking callers, or duplicating existing utilities. This Skill runs a gated, multi-phase refactoring workflow that characterizes current behavior with tests before any edit, verifies each change, and blocks completion until safety gates pass. ## Core Features & Use Cases - Phased refactoring pipeline: Discovery, planning, test characterization, transformation, adversarial review, remediation, and completion phases with a resumable JSON contract per target file. - Behavior-preservation gates: Characterization tests must run green on pre-refactor code before any move, mutation probes verify the tests actually detect changes, and an independent CQ auditor plus adversarial review validate the final diff. - Refactor type routing: Classifies work as RENAME, EXTRACT, SPLIT, INLINE, or RESTRUCTURE, with dedicated protocols for GOD_CLASS decomposition, dead-code deletion, and pure structural moves. - Use Case: Splitting a 900-line service file into focused modules — the Skill maps all importers, writes pin-down tests for uncovered units, extracts responsibilities one at a time, and proves the public API is unchanged before committing. ## Quick Start Ask the assistant to refactor a specific file, for example: refactor src/services/order.service.ts to extract its pricing logic into a separate module.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor a large file without breaking existing behavior?

Invoke the refactor skill on the target file. It writes characterization tests that pin down current behavior, confirms they pass on the pre-change code, then performs the extraction or split and re-verifies tests, callers, and code quality before committing.

How to split a god class into smaller modules safely?

The skill auto-detects god classes over 600 lines with 5+ responsibilities and escalates to an iterative decomposition protocol. It extracts one responsibility at a time, runs tests after each extraction, and checks size gates until the original file has a single responsibility.

Can I resume an interrupted refactoring run?

Yes. Each run writes a versioned contract file under zuvo/contracts recording its phase and evidence. Passing the continue argument resumes the contract at its recorded stage instead of restarting analysis.

Does the refactor skill work without CodeSift MCP tools?

Yes, in degraded mode. When CodeSift is unavailable, agents fall back to Read, Grep, and Glob for dependency mapping and duplicate detection, and the run records the degradation explicitly rather than claiming full verification.

What happens if tests do not cover the code being moved?

The skill routes to CHARACTERIZE_GAP mode and blocks production edits until pin-down tests exercise every uncovered unit and pass on the old code. Mutation probes then confirm the tests actually fail when behavior changes.

When should I use refactor instead of a build or feature skill?

Use refactor only for structural changes that preserve behavior, such as renames, extractions, splits, and deduplication. New features or behavior changes belong to a build-oriented skill, since refactor's gates are designed to prove nothing observable changed.