Back to Skills

refactoring-patterns

Apply named refactoring transformations to improve code structure without changing behavior. Use when the user mentions "refactor this", "code smells", "extract method", "replace conditional", "technical debt", "move method", "inline variable", or "decompose conditional". Also trigger when cleaning up legacy code, preparing code for new features by restructuring, or identifying which transformation to apply to a specific code smell. Covers smell-driven refactoring, safe transformation sequences,

1,196stars129forksUpdated 6/4/2026

Security Assessment

Safe(100/100)
Security Score100/100

About refactoring-patterns

The refactoring-patterns skill provides a systematic approach to improving the internal structure of code without altering its behavior. It helps developers identify code smells and apply named refactoring transformations to enhance readability, maintainability, and overall design quality. By focusing on behavior-preserving transformations, this skill ensures that developers can restructure legacy code or ongoing projects safely, reducing technical debt and preparing codebases for new features without introducing bugs or unintended side effects.

The main features of this skill include smell-driven refactoring, safe transformation sequences, and testing safeguards to verify correctness at each step. It covers a wide range of common code smells, such as long methods, duplicate code, feature envy, shotgun surgery, and primitive obsession, providing actionable guidance on which named refactoring patterns to apply. Users are encouraged to follow the disciplined loop of verifying tests, applying small structural changes, and re-verifying tests to maintain code integrity. The skill also provides scoring guidance, enabling developers to rate structural quality on a scale of 0-10 and determine what specific refactorings are needed to reach optimal design.

This skill is particularly useful for software developers, code reviewers, and teams focused on maintaining high-quality codebases. It is ideal for scenarios such as cleaning up legacy code, preparing code for new feature integration, or systematically reducing technical debt. Target users include those working in object-oriented programming environments who need to enforce maintainable design principles, improve function cohesion, eliminate duplication, and ensure comprehensive test coverage while performing iterative code improvements.

FAQ

How do I use this skill to refactor my code?

Identify code smells in your codebase and apply the suggested named refactoring patterns. Always verify that your tests pass before and after each transformation to ensure behavior is preserved.

Which programming languages are supported?

The skill is language-agnostic but is most applicable in object-oriented languages where named refactoring patterns like Extract Method or Move Method can be applied effectively.

Can this skill introduce bugs during refactoring?

If the prescribed discipline is followed—small behavior-preserving steps with test verification—behavior should remain unchanged. Risks increase if transformations are applied without testing.

Is this skill suitable for legacy code?

Yes, it is especially designed for cleaning up legacy code, reducing technical debt, and preparing the code for new features by restructuring.

Do I need prior knowledge of code smells to use this skill?

While familiarity with common code smells helps, the skill provides guidance on identifying smells and mapping them to specific refactoring patterns.

All Files

7 files
references/composing-methods.md11.6 KB
View
references/moving-features.md12.0 KB
View
references/smell-catalog.md13.2 KB
View
references/organizing-data.md12.7 KB
View
SKILL.md20.7 KB
View
references/simplifying-conditionals.md12.8 KB
View
references/refactoring-workflow.md14.0 KB
View

Install refactoring-patterns

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

wondelai/skills