code-refactoring

Applies refactoring patterns to improve code structure without changing behavior.

Updated Dec 23, 2025
One-click install
npx skills add https://github.com/macintorsten/aurapod --skill code-refactoring-macintorsten
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-refactoring
Source: https://github.com/macintorsten/aurapod/tree/main/.github/skills/code-refactoring
Command: npx skills add https://github.com/macintorsten/aurapod --skill code-refactoring-macintorsten

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy codebases accumulate code smells like long methods, deeply nested conditionals, and magic numbers that slow down development and increase bug risk. This Skill provides concrete refactoring patterns and a safe process for cleaning up code without altering its behavior. ## Core Features & Use Cases - Code Smell Detection: Identifies common problems such as long methods, arrow code, primitive obsession, and feature envy with before-and-after TypeScript examples. - Refactoring Techniques: Covers extract method, replace conditional with polymorphism, introduce parameter object, and replace magic numbers with constants. - Safe Refactoring Process: Enforces a test-first workflow with small incremental changes, frequent commits, and a completion checklist. - Use Case: When preparing to add a feature to a tangled legacy module, use this Skill to restructure the code first so the new change becomes straightforward and regression-safe. ## Quick Start Refactor the getDiscount function in my order module to remove deeply nested conditionals using guard clauses.

Frequently Asked Questions about code-refactoring

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

FAQPage Schema
How do I refactor deeply nested conditionals in code?▼

Replace nested if statements with guard clauses that return early when conditions are not met. This flattens arrow code into a linear sequence of checks, making the happy path clear at the bottom of the function.

What are common code smells to look for during refactoring?▼

Common code smells include long methods doing too much, deeply nested conditionals, primitive obsession where raw strings replace value objects, and feature envy where a method heavily uses another object's data. Each has a standard refactoring pattern.

When should I not refactor code?▼

Avoid refactoring when there are no tests covering the code, when under tight deadlines without a safety net, when the code will be replaced soon, or when you do not understand what the code does. Refactoring without tests risks silent behavior changes.

How do I safely refactor legacy code without breaking it?▼

First ensure tests exist and pass, then make one small refactoring at a time, running tests after each change. Commit frequently so you can revert easily, and review the diff to confirm only structure changed, not behavior.

How to replace a switch statement with polymorphism?▼

Define a common interface with the varying method, then create a class per type implementing that interface. Each class holds its own logic, eliminating the switch and making new types easy to add without modifying existing code.