code-refactoring

Installation
Summary

Structured patterns and techniques for improving code quality through safe, behavior-preserving refactoring.

  • Covers common code smells including long methods, deeply nested conditionals, primitive obsession, and feature envy with before/after examples
  • Provides core refactoring techniques: extract method, replace conditional with polymorphism, introduce parameter objects, and replace magic numbers with constants
  • Emphasizes safe refactoring workflow: ensure test coverage first, make small focused changes, run tests after each step, and commit frequently
  • Includes decision framework for when to refactor (before features, after tests pass, during code review) and when to avoid it (without tests, under tight deadlines, on code being replaced)
SKILL.md

Code Refactoring

Refactoring Principles

When to Refactor

  • Before adding new features (make change easy, then make easy change)
  • After getting tests passing (red-green-refactor)
  • When you see code smells
  • During code review feedback

When NOT to Refactor

  • Without tests covering the code
  • Under tight deadlines with no safety net
  • Code that will be replaced soon
  • When you don't understand what the code does

Common Code Smells

Long Methods

Related skills
Installs
584
GitHub Stars
1.1K
First Seen
Jan 20, 2026