CClaude Code Catalog
All Skills

Refactoring Guide

CodingAdvanced

Analyzes specified code to detect code smells such as duplicated code, long functions, and complex conditionals. Provides step-by-step refactoring methods and expected improvements for each issue.

Trigger/refactor [file]
FrequencyAs needed

Inheriting legacy code with no idea where to start? Run /refactor to get priorities + a step-by-step plan

RefactoringCode QualityDesign

How It Works

Run /refactor [file]
Phase 1: 4 measurements in parallel
length-check
Measure function length
complexity
Analyze cyclomatic complexity
dup-detect
Detect code duplication
nesting-check
Check nesting depth
Calculate health score -> create improvement plan
Health score X/10 + step-by-step refactoring plan

Skill Code

# Refactor Guide Skill ## Trigger: /refactor [file] When invoked: 1. Analyze code quality: - Function length (flag > 30 lines) - Cyclomatic complexity - Duplicate code blocks - Deep nesting (> 3 levels) - Parameter count (flag > 4) 2. Identify patterns: - Extract Method opportunities - Replace Conditional with Polymorphism - Introduce Parameter Object - Move Method / Extract Class 3. Output format: --- ## ♻️ Refactoring Report ### Code Health Score: [X/10] ### Issues Found 1. **[Issue Type]** at line [N] - Problem: [description] - Suggestion: [refactoring technique] - Impact: [readability / performance / maintainability] ### Refactoring Plan Step 1: [action] — [why] Step 2: [action] — [why] ### Before / After Preview [code comparison] ---

Copy and paste into your CLAUDE.md to start using immediately.

How Refactoring Guide Works

Refactor Guide scans the target file for code smells — long functions, deep nesting, duplicated logic, god objects — then creates a step-by-step refactoring plan with before/after examples and risk assessment for each change.

When to Use Refactoring Guide

Best deployed on legacy codebases where you need to improve structure without breaking existing behavior, especially when the code lacks tests and each refactoring step needs to be safe and reversible.

Key Strengths

  • Detects multiple code smell categories automatically
  • Generates safe, incremental refactoring steps
  • Includes risk assessment for each proposed change
  • Provides before/after examples for clarity

Same Category

Coding View All

Popular in Other Categories