refactoring-patterns

Apply named refactoring transformations to improve code structure without changing behavior.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/tayiorbeii/paperclip-factory-kit-hermes --skill refactoring-patterns-tayiorbeii
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactoring-patterns
Source: https://github.com/tayiorbeii/paperclip-factory-kit-hermes/tree/main/skills/paperclip/refactoring-patterns
Command: npx skills add https://github.com/tayiorbeii/paperclip-factory-kit-hermes --skill refactoring-patterns-tayiorbeii

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Legacy codebases accumulate code smells like long methods, duplicated logic, and tangled conditionals that slow down development and hide bugs. This Skill provides a disciplined catalog of named refactoring transformations so you can restructure code safely, one small verified step at a time, without changing observable behavior. ## Core Features & Use Cases - Smell-Driven Diagnosis: Identify code smells across five families (Bloaters, OO Abusers, Change Preventers, Dispensables, Couplers) and map each to its prescribed refactoring. - Named Transformation Catalog: Apply proven refactorings such as Extract Method, Move Method, Replace Conditional with Polymorphism, and Introduce Special Case, organized across composing methods, moving features, organizing data, and simplifying conditionals. - Safe Workflow Discipline: Follow the test-refactor-test-commit cycle, the Rule of Three, and patterns like Branch by Abstraction and Parallel Change for large-scale changes. - Use Case: When reviewing a 300-line legacy class with nested switch statements, use this Skill to identify the smells, score the code 0-10, and produce a step-by-step refactoring plan with test guards at each stage. ## Quick Start Ask the AI to review this class for code smells and apply the appropriate refactoring patterns to reach a 10/10 structural quality score.

Frequently Asked Questions about refactoring-patterns

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

FAQPage Schema
How do I refactor legacy code safely without breaking it?▼

Refactor legacy code safely by following the test-refactor-test-commit cycle: verify tests pass, apply one small named transformation, verify tests still pass, then commit. If tests go red, revert the last step instead of debugging a broken refactoring.

What are code smells and how do I fix them?▼

Code smells are surface indicators of deeper structural problems, grouped into five families: Bloaters, Object-Orientation Abusers, Change Preventers, Dispensables, and Couplers. Each named smell maps to specific refactorings, such as Extract Method for Long Method or Move Method for Feature Envy.

When should I use Replace Conditional with Polymorphism?▼

Use Replace Conditional with Polymorphism when a switch statement or if/else chain branches on an object's type. Each type gets its own subclass implementing the behavior, eliminating forgotten-case bugs and making new types easy to add.

Can I refactor code that has no tests?▼

Refactoring without tests is unsafe because you cannot verify behavior is preserved. Write characterization tests first to lock in current behavior, then refactor; if adding tests is not feasible, consider whether a rewrite is more appropriate.

When should I not refactor code?▼

Avoid refactoring when a rewrite from scratch is easier, when no tests exist and adding them is not feasible, or when the code will be deleted soon. Also separate refactoring from feature work so each change can be verified in isolation.