Refactoring Patterns Skill
Installation
SKILL.md
Refactoring Patterns Skill
Safe transformations — same behavior, better structure.
Golden Rule
Tests pass before AND after.
When to Refactor
| Trigger | Action |
|---|---|
| Feature is hard to add | Refactor first |
| Same bug twice | Refactor to prevent |
| "I don't understand" | Refactor for clarity |
When NOT to Refactor
- No tests + time pressure
- Code won't change
- Right before release
- Should rewrite instead
Core Moves
| Move | When |
|---|---|
| Extract Function | Does too many things |
| Inline Function | Body clear as name |
| Extract Variable | Complex expression |
| Rename | Name doesn't reveal intent |
| Move Function | Uses other class's data |
Code Smells → Fix
| Smell | Refactoring |
|---|---|
| Long function | Extract Function |
| Long param list | Parameter Object |
| Duplicate code | Extract Function |
| Feature envy | Move Function |
| Large class | Extract Class |
Refactor vs Rewrite
| Refactor | Rewrite |
|---|---|
| Core logic sound | Design is wrong |
| Tests exist | Untestable |
| <30% changes | >70% changes |
Safe Workflow
Commit → Test → Small change → Test → Commit → Repeat
Synapses
See synapses.json for connections.
Related skills
More from fabioc-aloha/lithium
bicep avm mastery
Azure Verified Modules (AVM), Bicep best practices, and MCP-powered infrastructure as code for Azure
9brain qa
Semantic, logic, code, and architectural validation of Alex's cognitive architecture — not just file counts, but meaning coherence
1infrastructure as code skill
**Domain**: DevOps & Cloud Engineering
1skill-activation
Internal metacognitive skill for automatic capability discovery — self-triggers when uncertain about available skills
1dream-state
Neural maintenance, synapse validation, automated health diagnostics, and unconscious processing
1ui/ux design
User interface design, user experience optimization, accessibility compliance, design systems
1