refactoring-surgeon

Identifies code smells and guides refactoring with validation scripts.

181|30|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/curiositech/some_claude_skills --skill refactoring-surgeon-curiositech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring-surgeon
Source: https://github.com/curiositech/some_claude_skills/tree/main/.claude/skills/refactoring-surgeon
Command: npx skills add https://github.com/curiositech/some_claude_skills --skill refactoring-surgeon-curiositech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires npm test:unit, npm run lint, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill tackles the challenge of improving existing code quality by identifying and rectifying code smells and technical debt, ensuring code remains maintainable and robust without altering its external behavior.

Core Features & Use Cases

  • Code Smell Detection: Identifies common anti-patterns like Long Methods, Large Classes, and Switch Statements.
  • Refactoring Techniques: Provides guidance and examples for techniques such as Extract Method, Replace Conditional with Polymorphism, and Introduce Parameter Object.
  • Safety & Validation: Emphasizes the importance of tests and provides a validation script to check refactoring readiness and safety.
  • Use Case: You have a method that has grown too long and complex. Use this Skill to guide you through the process of extracting parts of it into smaller, more manageable functions, improving readability and testability.

Quick Start

Use the refactoring-surgeon skill to help refactor a long method in the file 'utils.ts'.

Frequently Asked Questions about refactoring-surgeon

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

FAQPage Schema
How do I refactor a long method to improve code maintainability?

To refactor a long method for maintainability, use the Extract Method technique to break it into smaller, manageable functions. This improves readability and testability without altering external behavior.

What are common code smells that indicate technical debt?

Common code smells indicating technical debt include Long Methods, Large Classes, and complex Switch Statements. Identifying these anti-patterns helps target refactoring efforts to improve overall code quality.

How do I ensure code refactoring doesn't break existing behavior?

To ensure refactoring doesn't break behavior, adhere to testing best practices and run validation scripts. A validation script checks refactoring readiness and safety by verifying test coverage before changes.

Do I need unit tests before starting a code refactoring process?

Yes, unit tests are required before refactoring. The process depends on npm test:unit to validate that changes preserve external behavior and ensure the code remains robust throughout the transformation.

What's the best way to handle large classes during refactoring?

The best way to handle large classes is applying techniques like Introduce Parameter Object. This addresses bloat and conditional complexity through guided processes, ensuring code remains maintainable.