refactoring-to-patterns

Guides refactoring toward, to, or away from Gang of Four design patterns based on code smells.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/vnovakovits/claude-skills --skill refactoring-to-patterns-vnovakovits
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactoring-to-patterns
Source: https://github.com/vnovakovits/claude-skills/tree/main/plugins/engineering-practices/skills/refactoring-to-patterns
Command: npx skills add https://github.com/vnovakovits/claude-skills --skill refactoring-to-patterns-vnovakovits

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers often introduce design patterns prematurely, producing over-engineered code, or miss the moment when a real smell justifies a pattern. This Skill provides Joshua Kerievsky's discipline for deciding when a pattern earns its complexity cost and when it should be inlined. ## Core Features & Use Cases - Smell-to-Pattern Mapping: Match concrete code smells (duplicated logic, type-switching conditionals, scattered null checks) to the right pattern destination such as Strategy, State, Null Object, or Composite. - Named Refactoring Moves: Apply specific refactorings like Replace Conditional Logic with Strategy, Introduce Null Object, and Form Template Method, each with before/after code examples. - Refactoring Away from Patterns: Recognize speculative pattern over-engineering and safely inline Singletons, unused Strategy hierarchies, and single-implementation abstractions. - Use Case: When reviewing a method with a growing switch statement on loan types, use this Skill to decide whether Replace Conditional Logic with Strategy is economically justified, then execute it in small tested steps. ## Quick Start Ask Claude to review a class with conditional type logic and recommend whether to refactor it toward a design pattern.

Frequently Asked Questions about refactoring-to-patterns

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

FAQPage Schema
When should I refactor code to a design pattern?▼

Refactor to a design pattern only when a concrete code smell is currently costing you, such as duplication or growing conditional logic. The pattern's complexity cost must be lower than the ongoing cost of the smell it eliminates.

How do I replace conditional logic with the Strategy pattern?▼

Extract each branch of the type-coded conditional into its own Strategy class implementing a common interface, then let composition select the strategy at runtime. Ensure tests cover current behavior before making the move in small steps.

What is the difference between refactoring to, toward, and away from a pattern?▼

Refactoring to a pattern is a complete move from smell to pattern. Refactoring toward a pattern is a partial improvement when full commitment is not yet justified. Refactoring away from a pattern inlines one that no longer earns its complexity.

When should I remove a design pattern from my code?▼

Remove a pattern when its flexibility is unused, such as a Strategy hierarchy with one implementation or a Singleton with no genuine need for a single instance. Inline the abstraction and merge the types to reduce debt.

Does the Strategy pattern apply in functional programming languages?▼

In functional languages, Strategy is typically just passing a function, so a class-based hierarchy is overkill. Some GoF patterns assume object-oriented constraints that do not exist in functional paradigms.