Refactoring Surgeon

🌐Community
by erichowens · vlatest · Repository

Safely restructures complex backend code into cleaner, more maintainable modules while preserving functionality.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add refactoring-surgeon npx -- -y @trustedskills/refactoring-surgeon
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "refactoring-surgeon": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/refactoring-surgeon"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

The Refactoring Surgeon skill assists AI agents in safely restructuring complex backend code to improve its quality and maintainability without altering its behavior. It focuses on applying established refactoring techniques to address specific code smells and patterns, ensuring functionality remains consistent throughout the process. This skill is particularly useful for improving existing codebases rather than creating new ones.

When to use it

  • When dealing with "bloaters" like long methods or large classes that hinder understanding and modification.
  • To simplify complex conditional logic (e.g., switch statements) into more manageable polymorphic structures.
  • For gradually migrating legacy codebases using patterns like the Strangler Fig approach.
  • When a codebase needs organization, such as replacing magic numbers with named constants or introducing parameter objects to reduce long parameter lists.
  • To address "change preventers" where changes in one area require modifications across multiple classes.

Key capabilities

  • Extraction: Extract Method, Extract Class, Extract Interface
  • Movement: Move Method, Move Field, Inline Method
  • Simplification: Replace Conditional with Polymorphism, Decompose Conditional
  • Organization: Introduce Parameter Object, Replace Magic Numbers
  • Legacy Migration: Strangler Fig, Branch by Abstraction, Parallel Change
  • Provides a reference guide to common code smells and associated refactoring techniques.

Example prompts

  • "Refactor this method using the Extract Method technique."
  • "Apply the Strangler Fig pattern to migrate this legacy module."
  • "Replace this switch statement with polymorphism."
  • "Introduce a parameter object for this function that has five parameters."

Tips & gotchas

  • Tests are essential: Refactoring should always be accompanied by existing tests to ensure behavior is preserved. Write characterization tests first if coverage is lacking.
  • Small, incremental changes: Avoid "Big Bang Refactoring" - make small, frequent commits and test after each change.
  • Focus on refactoring, not feature addition: The goal is to improve the structure of existing code, not add new functionality.

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
erichowens
Installs
66

🌐 Community

Passed automated security scans.