refactoring

Identify code smells and apply test-driven refactoring patterns to improve code structure.

Updated Jun 23, 2024
One-click install
npx skills add https://github.com/jo-pouradier/dotfiles --skill refactoring-jo-pouradier
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/jo-pouradier/dotfiles/tree/main/coding-agent/.claude/skills/refactoring
Command: npx skills add https://github.com/jo-pouradier/dotfiles --skill refactoring-jo-pouradier

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured knowledge base for safely improving code structure without changing observable behavior, helping teams reduce technical debt and improve maintainability.

Core Features & Use Cases

  • Code Smells Catalog: Identify common smells (Long Method, Large Class, Data Clumps, etc.) and map them to proven refactoring strategies.
  • Common Refactoring Patterns: Includes Extract Method, Replace Conditional with Polymorphism, Introduce Parameter Object, and other shared techniques with concrete examples.
  • Safe Refactoring Process: Step-by-step workflow emphasizing small, test-driven changes, verification, and clear commit history.

Quick Start

Review the catalog, select a pattern for your module, and follow the Safe Refactoring Process to implement the change.

Frequently Asked Questions about refactoring

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

FAQPage Schema
How do I identify code smells and map them to refactoring strategies?

Code smells like Long Method, Large Class, and Data Clumps are identified through structural analysis and mapped to proven refactoring strategies such as Extract Method or Introduce Parameter Object to improve maintainability.

What is the safe refactoring process for reducing technical debt?

The safe refactoring process uses a step-by-step workflow emphasizing small, test-driven changes, continuous verification, and clear commit history to improve code structure without changing observable behavior.

How do I replace complex conditional logic with polymorphism?

Replace Conditional with Polymorphism is a refactoring pattern that moves conditional logic into subclasses, using polymorphism to simplify complex conditionals and improve code structure.

When should I use Introduce Parameter Object to refactor a method?

Introduce Parameter Object is used when a method contains a data clump of multiple parameters, grouping them into a single object to simplify method signatures and improve code maintainability.

What is the best way to safely extract a method from a long method code smell?

To safely extract a method from a long method, follow a test-driven refactoring workflow by isolating a code fragment, creating a new method, and verifying behavior remains unchanged before committing.

Do I need solid principles to apply these refactoring patterns?

SOLID principles guide the structural improvements achieved through refactoring patterns, ensuring the codebase remains maintainable and technically sound while safely reducing technical debt.