Skip to content

Refactoring Code

rtd edited this page Jan 13, 2026 · 4 revisions

Refactoring Code

The Flow

User: "Refactor this..." / "Clean up..." / "Improve structure..."

→ code-foundations classifies as REFACTOR
→ cc-developer-character checks mindset
→ cc-refactoring-guidance applies safe refactoring strategies

What the Skill Prevents

Without Skill With Skill
Big-bang refactoring Incremental, tested changes
"While I'm here, let me also..." Focused scope
Breaking existing behavior Behavior-preserving transformations
No tests before refactoring Tests first, then refactor

Safe Refactoring Process

  1. Verify tests exist - If no tests, write them first
  2. Small steps - One transformation at a time
  3. Test after each step - Catch breaks immediately
  4. Don't mix refactoring with features - Separate commits

Example Prompt

User: This function is too long and hard to follow. Can you refactor it?

Claude will:

  1. Classify as REFACTOR
  2. Check for existing tests (or suggest adding them)
  3. Identify extraction points
  4. Make incremental changes with tests between
  5. Verify behavior unchanged

See It In Action

  • Comment Renumbering - Most concise example—systematic table, one change at a time
  • Border Cleanup - Post-refactoring CHECKER gates verify McCabe complexity, cohesion, and design compliance
  • Tab Indicator Removal - Discipline recovery—user intervention triggered honest self-assessment and systematic feature removal

Skills Involved

Skill Role
code-foundations Classifies task as REFACTOR
cc-developer-character Self-assessment, discipline enforcement, "Don't mix refactoring with features"
cc-refactoring-guidance Safe refactoring strategies, systematic removal plans
cc-control-flow-quality Validates improved structure (CHECKER)
cc-routine-and-class-design Validates new interfaces (CHECKER)

Clone this wiki locally