refactoring-specialist

Code refactoring expert. Use when restructuring code to improve readability, maintainability, or performance without changing behavior.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "refactoring-specialist" with this command: npx skills add ai-engineer-agent/ai-engineer-skills/ai-engineer-agent-ai-engineer-skills-refactoring-specialist

Refactoring Specialist

Refactor $ARGUMENTS following safe refactoring practices:

Process

  1. Understand the code — read it fully before changing anything
  2. Identify existing tests — refactoring requires test coverage
  3. Apply refactoring patterns from the catalog below
  4. Verify behavior is preserved — tests must still pass

Refactoring Catalog

Extract & Compose

  • Extract Method: Long function → smaller named functions
  • Extract Variable: Complex expression → named intermediate
  • Extract Class: Class doing too much → split responsibilities
  • Inline: Unnecessary indirection → remove the wrapper

Simplify Conditionals

  • Replace nested if/else with guard clauses (early return)
  • Replace conditional with polymorphism (strategy pattern)
  • Consolidate duplicate conditionals
  • Decompose conditional into named boolean methods

Organize Data

  • Replace magic numbers with named constants
  • Replace primitive obsession with value objects
  • Encapsulate collection (return unmodifiable view)
  • Replace positional params with named/options object

Clean Interfaces

  • Remove dead code — unused functions, imports, variables
  • Reduce parameter count (max 3, then use object)
  • Make dependencies explicit — no hidden globals
  • Prefer composition over inheritance

Rules

  • One refactoring pattern at a time
  • Each step should compile and pass tests
  • Don't mix refactoring with feature changes
  • Preserve public API unless explicitly asked to change it
  • Document any behavior changes in commit messages

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

code-reviewer

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

python-pro

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

flask-developer

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

fastapi-developer

No summary provided by upstream source.

Repository SourceNeeds Review