refactor-clean

Refactor complex or duplicated code with test-driven incremental steps.

42|9|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/drvoss/everything-copilot-cli --skill refactor-clean-drvoss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-clean
Source: https://github.com/drvoss/everything-copilot-cli/tree/main/skills/development/refactor-clean
Command: npx skills add https://github.com/drvoss/everything-copilot-cli --skill refactor-clean-drvoss

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers clean up complex, duplicated, or cluttered code while preserving observable behavior and reducing maintenance cost.

Core Features & Use Cases

  • Identify code smells such as long functions, duplicated logic, deep nesting, god objects, and primitive obsession.
  • Safety-first workflow with guidance to establish a test baseline, make incremental changes, run tests after each step, and commit only passing refactors.
  • Use Case: When a repository contains repeated validation logic across handlers and long functions, use this Skill to extract shared validators, flatten nesting, and split modules without introducing feature changes.

Quick Start

Ask the agent to perform a small, test-backed refactor on the target module, preserving behavior and committing after each passing test.

Frequently Asked Questions about refactor-clean

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

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

Safe refactoring requires an incremental, test-driven workflow: establish a test baseline, make small structural changes, run tests after each step, and commit only passing refactors to a clean git history. This preserves observable behavior while reducing maintenance cost.

What are common code smells I should look for before restructuring a module?

Common code smells include long functions, duplicated logic, deep nesting, god objects, and primitive obsession. Identifying these issues helps target complex or cluttered codebases where extracting shared validators or splitting modules can improve overall structure.

Do I need existing test coverage to clean up long functions and god objects?

Yes, existing test coverage is a prerequisite. A safety-first workflow requires a committed codebase for safe rollbacks and a test baseline to verify that incremental refactors preserve observable behavior before committing any passing changes.

Can I flatten deep nesting and extract shared validators while keeping the same features?

Yes, you can flatten nesting and extract shared validators without introducing feature changes. The process applies iterative, test-driven refactors to repeated validation logic across handlers, ensuring behavior remains identical while improving code structure.

What is the best way to remove dead code from a complex repository?

The best way to remove dead code is through incremental, test-driven refactors on a committed codebase. Run tests after each small change to ensure no behavior shifts, and commit only passing refactors to safely reduce clutter and maintenance cost.

Why should refactoring be done in iterative steps rather than a single large rewrite?

Iterative refactoring ensures safety by running tests after each small change and committing only passing states. This test-driven approach prevents introducing feature changes and allows safe rollbacks if a structural modification breaks existing behavior.