refactoring-patterns

Apply behavior-preserving refactorings to code smells with test verification.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/tayiorbeii/paperclip-factory-kit --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/tree/main/skills/refactoring-patterns
Command: npx skills add https://github.com/tayiorbeii/paperclip-factory-kit --skill refactoring-patterns-tayiorbeii

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you improve existing code structure without changing its behavior by applying well-known, named refactoring transformations—guided by code smells and protected by a test-first workflow.

Core Features & Use Cases

  • Smell-driven refactoring: Map common code smells (like Long Method, Feature Envy, Duplicate Code, and complex conditionals) to specific mechanical refactorings.
  • Composable method improvements: Break large or confusing logic into smaller, intention-revealing methods while keeping behavior identical.
  • Data and conditional simplification: Improve design by replacing primitive data representations and deconstructing complex conditionals into clearer structures.
  • Safe workflow discipline: Use the refactoring loop (test → small change → test) to ensure changes remain behavior-preserving.

Quick Start

Use the refactoring-patterns skill to identify the main code smell in the snippet you provide, propose the smallest behavior-preserving refactoring step to apply first, and explain how to verify it with tests.

Frequently Asked Questions about refactoring-patterns

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

FAQPage Schema
How do I refactor long methods without changing existing behavior?

To refactor long methods safely, you apply behavior-preserving transformations like Extract Method, breaking large logic into smaller intention-revealing methods while relying on a test-first workflow to verify identical output.

Which refactoring should I use to simplify complex conditional logic?

Simplifying complex conditional logic involves applying named transformations like conditional simplification to deconstruct intricate structures into clearer designs, guided by mapping specific code smells to their corresponding mechanical refactorings.

What is the best way to map code smells to specific refactoring patterns?

The best way to map code smells to refactorings is to identify the primary issue—such as Feature Envy or Duplicate Code—and select the smallest mechanical transformation that addresses it, followed by test verification.

Do I need unit tests before starting a code refactoring sequence?

Yes, a test-backed workflow is required. You must run tests before and after each small incremental refactoring step to ensure the changes remain behavior-preserving and avoid introducing technical debt.

How do I improve object responsibilities when organizing domain data?

Improving object responsibilities involves restructuring code to replace primitive data representations and organizing domain data using named transformations, ensuring each object handles its own logic safely.