code-refactoring

Detects code smells and applies behavior-preserving structural refactoring patterns.

138|5|Updated Sep 19, 2024
One-click install
npx skills add https://github.com/macalbert/envilder --skill code-refactoring-macalbert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-refactoring
Source: https://github.com/macalbert/envilder/tree/main/.github/skills/code-refactoring
Command: npx skills add https://github.com/macalbert/envilder --skill code-refactoring-macalbert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate technical debt through long methods, duplicated logic, tight coupling, and architecture violations, but refactoring without discipline risks breaking observable behavior. This Skill provides a structured method for identifying concrete code smells and executing safe, incremental refactoring while keeping all behavioral verification intact. ## Core Features & Use Cases - Smell Detection Catalog: Identify ten concrete smells including long methods, large classes, duplicated logic, tight coupling, primitive obsession, and architecture violations, each with clear indicators. - Behavior-Preserving Implementation: Apply one coherent transformation at a time while keeping protected verification artifacts frozen, running targeted tests and stack formatters after each step. - SOLID Review Method: Evaluate candidates against Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles, with a deletion test for shallow modules. - Use Case: When implementing an approved PURE_REFACTOR contract in a TypeScript, .NET, or Python codebase, use this Skill to review structural findings, execute incremental changes, and route any behavioral test conflicts back to the orchestrator instead of silently reclassifying them. ## Quick Start Ask the AI to review the target module for code smells and propose a safe incremental refactoring plan that preserves all existing test behavior.

Frequently Asked Questions about code-refactoring

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

FAQPage Schema
How do I refactor code without breaking existing behavior?

Establish a test baseline first, then apply one coherent transformation at a time while keeping verification artifacts unchanged. Run targeted tests and formatters after each step, and run the broader suite before completion.

What code smells should I look for during a code review?

Look for long methods, large classes, duplicated logic, tight coupling, mixed abstraction levels, architecture violations, feature envy, shallow modules, primitive obsession, and speculative generality. Each smell has concrete indicators tied to maintenance or correctness risk.

How do SOLID principles apply to refactoring decisions?

Each principle maps to a concrete check: one reason to change per unit, variation without unstable branching, safe subtype substitution, minimal client-facing interfaces, and policy depending on abstractions rather than details.

What should I do when a refactoring requires changing a behavioral test?

Stop immediately. A required test change means the task may be a behavior change, the test may be coupled to private structure, or the contract may be defective. Route that decision to the orchestrator rather than silently reclassifying it.

When is it acceptable to conclude no refactoring is needed?

No changes required is a valid outcome when the candidate code is already clear and cohesive. The review method explicitly accepts this result and prohibits forcing modifications after review.