skills/refactoring/SKILL.md
Use when improving code structure without changing behavior - extract methods, simplify conditionals, reduce duplication, improve naming
npx skillsauth add kienbui1995/magic-powers refactoringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Refactoring improves code structure without changing external behavior. Every refactoring must be backed by passing tests.
Core principle: Small, safe, verified steps. Never refactor and add features simultaneously.
1. Ensure tests pass (green baseline)
2. Identify ONE smell
3. Apply ONE refactoring
4. Run tests → must stay green
5. Commit
6. Repeat
| Smell | Refactoring | |-------|-------------| | Long method (>20 lines) | Extract Method | | Deep nesting (>3 levels) | Early return / Guard clauses | | Duplicated code | Extract shared function/module | | Primitive obsession | Introduce value object/type | | Long parameter list (>3) | Introduce parameter object | | Feature envy | Move method to owning class | | God class | Extract class by responsibility | | Magic numbers/strings | Extract named constants | | Complex conditional | Extract to named boolean / strategy pattern | | Shotgun surgery | Consolidate into single module |
| Signal | Action | |--------|--------| | Tests failing after refactoring | Revert immediately, smaller step | | Refactoring + feature in same commit | Split into two commits | | "While I'm here, let me also..." | Finish current refactoring first | | No tests exist | Write characterization tests before touching code |
content-media
Use when designing for XR (AR/VR/MR), choosing interaction modes, or adapting 2D UI patterns for spatial computing
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment
development
Use when you have a spec or requirements for a multi-step task, before touching code
development
Use when executing a structured workflow — select and run a feature, bugfix, refactor, research, or incident template with correct agent and model assignments per phase.