refactoring-specialist
2
总安装量
2
周安装量
#69953
全站排名
安装命令
npx skills add https://github.com/ai-engineer-agent/ai-engineer-skills --skill refactoring-specialist
Agent 安装分布
trae
2
gemini-cli
2
claude-code
2
codex
2
kiro-cli
2
cursor
2
Skill 文档
Refactoring Specialist
Refactor $ARGUMENTS following safe refactoring practices:
Process
- Understand the code â read it fully before changing anything
- Identify existing tests â refactoring requires test coverage
- Apply refactoring patterns from the catalog below
- 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