Works with the AI tools you already use

    CClaude CodeCCursorCCodex CLIGGitHub CopilotGGemini CLI+17 more

    refactor surgeon persona

    by GarphenGate

    1

    Surgical refactoring specialist that improves code structure through provably behavior-preserving incremental steps.

    Secure checkout via Stripe

    0 installsSecurity scanned

    See it in action

    You say

    Refactor this legacy user-auth function. It is 300 lines long and hard to test. I need to make it modular but cannot break the existing login flow.

    Your agent does

    I will establish a safety net with characterization tests first.

    1. Extract Method: validate_credentials
    2. Extract Method: session_creation Reversal path: git checkout auth.py Behavior check: Pytest suite + checksum on return objects. Proposed diff follows.

    What you get

    Decompose monolithic functions into testable, modular units.Eliminate technical debt using precise, named refactoring patterns.Establish safety nets for legacy code via characterization tests.Separate structural cleanup from logic changes in version control.

    About this skill

    The problem

    Large refactors often break production because structural changes get mixed with logic updates. Manual cleanups frequently lack a reversal path or a safety net, leading to unverified code changes and "heroic rewrites" that fail.

    What it does

    • Establishes behavioral safety nets using characterization tests before any code is touched.
    • Decomposes complex structural changes into small, individually shippable steps that keep the build green.
    • Enforces a strict separation between refactoring commits and behavior-changing commits.
    • Justifies every change by quantifying the reduction in friction, bug rate, or onboarding time.
    • Identifies specific refactoring patterns like Strangler Fig or Extract Method with surgical precision.

    Why this beats prompting it yourself

    General LLMs often try to rewrite entire files, introducing subtle logic bugs. This skill enforces a disciplined, incremental methodology that prioritizes evidence over aesthetic taste, ensuring every step is provably behavior-preserving.

    Use cases

    • Untangling legacy payment systems or critical business logic where downtime is not an option.
    • Breaking down a monolithic function into testable modules without changing its output.
    • Preparing a codebase for a new feature by reducing existing change friction.
    • Implementing the Strangler Fig pattern to migrate logic away from a mess of technical debt.

    Known limitations

    Explicitly excludes feature development, performance tuning, and product-level decision making. Requires user confirmation for all file modifications and repository changes.

    How to install

    Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Frequently Asked Questions

    Popular in Testing & QA