refactor

Analyze code to identify refactoring opportunities and generate actionable recommendations.

3|Updated Jul 4, 2020
One-click install
npx skills add https://github.com/mei28/dotfiles --skill refactor-mei28
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/mei28/dotfiles/tree/main/.claude/skills/refactor
Command: npx skills add https://github.com/mei28/dotfiles --skill refactor-mei28

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Analyzes code to identify refactoring opportunities and generate actionable recommendations to reduce complexity, remove code smells, and improve maintainability.

Core Features & Use Cases

  • Detects complexity hotspots and proposes targeted extractions and simplifications.
  • Removes code duplication by extracting reusable validation and utilities.
  • Offers pattern-based refactors like Extract Method, Introduce Parameter Object, and Replace Conditional with Polymorphism.
  • Use Case: When adding features to a large module, run the analyzer to obtain a prioritized refactor plan.

Quick Start

Provide a code sample and request an automated refactor plan.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I identify refactoring opportunities to reduce code complexity?

To identify refactoring opportunities, you analyze code to detect complexity hotspots and code smells. This process generates targeted simplification recommendations, helping you reduce complexity and improve maintainability through actionable extractions.

What is the best way to remove code duplication and extract reusable utilities?

The best way to remove code duplication is by extracting reusable validation logic and utilities. This refactoring approach isolates redundant code blocks into shared methods, reducing duplication and enhancing overall code maintainability across modules.

When do I need to introduce a parameter object or extract method in my code?

You need to introduce a parameter object or extract method when addressing specific design patterns to reduce complexity. These refactors are applied when analyzing code reveals long methods or cumbersome parameter lists, generating actionable improvement recommendations.

How do I generate a safe, incremental refactor plan for a large module?

You generate a safe, incremental refactor plan by analyzing a large module to prioritize refactoring opportunities. This provides a structured scope with before/after examples, ensuring safe, automated application of select refactors without breaking functionality.

Can I replace conditional logic with polymorphism to improve code maintainability?

Yes, you can replace conditional logic with polymorphism as a pattern-based refactor. By analyzing code to identify complex conditionals, this approach generates actionable recommendations to improve maintainability through polymorphic design patterns.