software-engineering-eng-refactor

Identify code smells and propose behavior-preserving refactoring moves for legacy code.

Updated May 6, 2025
One-click install
npx skills add https://github.com/rodrigo-altissimo/qiartificial --skill software-engineering-eng-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: software-engineering-eng-refactor
Source: https://github.com/rodrigo-altissimo/qiartificial/tree/main/.claude/skills/software-engineering/eng-refactor
Command: npx skills add https://github.com/rodrigo-altissimo/qiartificial --skill software-engineering-eng-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you improve the structure of existing code without changing behavior by identifying code smells and applying safe, test-protected refactoring moves—especially in legacy systems with little or no test coverage.

Core Features & Use Cases

  • Code smell identification and mapping: Detects common smells (e.g., Long Method, God Class, Duplicate Code, Shotgun Surgery) and links each to named refactoring actions.
  • Behavior-preserving refactoring workflow: Enforces small-step refactoring, running tests after every move, and clearly separating refactoring from feature work.
  • Legacy code transformation strategy: Guides characterization tests and legacy migration patterns (e.g., Strangler Fig) to reduce risk when modifying untested systems.
  • Refactoring command support: Provides standardized operational commands such as generating a refactoring plan, assessing technical debt, and ensuring safe refactoring.

Usage examples

  • Refactor a monolithic service by extracting methods/classes in small, test-backed steps.
  • Reduce technical debt by turning identified smells into an ordered execution plan.
  • Work on legacy modules by first establishing characterization tests and then applying safe moves around seams.

Quick Start

Ask for a refactoring plan by providing the relevant code snippet or file area and the symptoms (e.g., “long method” or “shotgun surgery”), and request the exact smell(s) found plus the ordered safe refactoring moves with before/after guidance.

Frequently Asked Questions about software-engineering-eng-refactor

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

FAQPage Schema
How do I refactor legacy code safely when there are no existing tests?

To refactor legacy code safely without tests, you first establish characterization tests to capture current behavior, then apply small, test-protected refactoring moves around seams to ensure no functionality breaks during the transformation.

What is the best way to reduce technical debt in a monolithic codebase?

The best way to reduce technical debt is by identifying specific code smells like God Class or Shotgun Surgery, then mapping each smell to an ordered, behavior-preserving refactoring plan that executes in small, verified steps.

How do I identify and fix code smells without changing program behavior?

You identify and fix code smells by detecting structural issues like Long Method or Duplicate Code, then applying explicit smell-to-refactoring mappings such as extracting methods or classes in small, test-backed steps.

When should I use the Strangler Fig pattern for code refactoring?

Use the Strangler Fig pattern for legacy migration when you need to incrementally transform a large, untested system by gradually replacing old modules with new implementations while reducing the risk of widespread behavior changes.

Can I plan a refactoring sequence for a complex module with high coupling?

Yes, you can plan a refactoring sequence by assessing the module's technical debt, identifying specific structural smells, and generating a step-by-step execution plan that separates refactoring from feature work to maintain safety.

What are characterization tests and how do they protect legacy code during refactoring?

Characterization tests are safety nets created to document the exact current behavior of untested legacy code, ensuring that subsequent behavior-preserving refactoring moves do not accidentally alter existing functionality.