refactoring

Plan safe code refactors to reduce complexity and eliminate dead code.

Updated Oct 17, 2017
One-click install
npx skills add https://github.com/NAKKA-K/dotfiles --skill refactoring-nakka-k
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/NAKKA-K/dotfiles/tree/main/claude/skills/refactoring
Command: npx skills add https://github.com/NAKKA-K/dotfiles --skill refactoring-nakka-k

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This section outlines a disciplined approach to refactoring that helps reduce code complexity, eliminate dead code, and address technical debt without altering behavior.

Core Features & Use Cases

  • Identify bloated methods (e.g., >30 lines) and overextended classes (e.g., >10 methods).
  • Detect and consolidate duplicated logic across modules to reduce maintenance cost.
  • Provide a structured, phase-driven workflow with pre-checks, planning, execution, and verification.

Quick Start

Apply the refactoring guidelines to a sample project to begin improving structure without changing behavior.

Frequently Asked Questions about refactoring

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

FAQPage Schema
What is code refactoring and when should I start reducing technical debt?

Code refactoring restructures existing code to reduce complexity and eliminate dead code without altering behavior. Start when methods exceed 30 lines, classes have over 10 methods, or cyclomatic complexity exceeds 10.

How do I safely refactor bloated methods and duplicated logic?

Safe refactoring follows a structured, phase-driven workflow with pre-checks, planning, execution, and verification. It identifies bloated methods, detects duplicated logic across modules, and executes quick wins to reduce maintenance cost.

Can I use this refactoring workflow for cleaning up dead code in large projects?

Yes, this refactoring workflow applies to projects with high cyclomatic complexity and code duplication in three or more places. It enforces pre-refactor safety checks to eliminate dead code without changing behavior.

What's the best way to plan code refactoring to ensure no behavior changes?

The best way to plan refactoring is using a phased workflow with pre-refactor safety checks and documentation guidelines. This approach manages risk by executing quick wins first and verifying behavior remains unchanged.

What are the limitations of refactoring complex code with high technical debt?

Refactoring complex code requires strict adherence to pre-refactor safety checks and documentation guidelines. Limitations arise when methods exceed 30 lines or cyclomatic complexity exceeds 10, demanding careful risk management to avoid altering behavior.