refactor

Refactor legacy code by extracting functions and renaming identifiers without changing behavior.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/lucasgaldinos/my-skills --skill refactor-lucasgaldinos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/lucasgaldinos/my-skills/tree/main/skills/refactor
Command: npx skills add https://github.com/lucasgaldinos/my-skills --skill refactor-lucasgaldinos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactor code to improve maintainability without changing external behavior.

Core Features & Use Cases

  • Provides a structured approach to extract methods, rename identifiers, reduce god functions, and address code smells while preserving behavior.
  • Encourages incremental changes with tests and version control as guardrails.
  • Suitable for medium to large codebases and multi-language projects.

Quick Start

Start by identifying a large function and extract a focused helper function, then add or run tests to verify behavior remains unchanged.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor large functions without changing external behavior?

To refactor large functions without altering behavior, extract focused helper methods incrementally and run tests after each change to verify the external output remains identical.

What are code smells and how do I address them in a legacy codebase?

Code smells are structural weaknesses in legacy code, such as god functions, which you address by decomposing large constructs and renaming identifiers to improve maintainability.

Do I need tests in place before refactoring complex modules?

Yes, tests are required before refactoring complex modules to enforce behavior-preserving changes, serving as guardrails alongside version control for safe incremental improvements.

Can I use incremental refactoring on medium to large multi-language codebases?

Incremental refactoring applies to medium to large codebases and multi-language projects, guiding method extraction and decomposition of large constructs to improve overall structure.

What's the best way to start improving code maintainability on legacy modules?

The best way to start improving maintainability is identifying a large function, extracting a focused helper function, and running tests to verify behavior remains unchanged.

When should I avoid refactoring code?

You should avoid refactoring code when you lack sufficient test coverage to verify external behavior, as tests and version control are required as guardrails for incremental changes.