/refactor
Spawns refactor-agent for code improvements.
Usage
code
/refactor # Analyze current code for smells /refactor Email # Create Email value object /refactor User.java # Refactor specific file
Workflow
- •Load
.claude/agents/refactor-agent.md - •Agent reads target file + tests
- •Identifies smell, loads template from
.claude/templates/refactoring/ - •Applies ONE refactoring, runs tests
- •Repeats until clean
Available Templates
Backend (.claude/templates/refactoring/)
- •
value-object.md- Replace primitive with value object - •
replace-string-with-enum.md- Replace string constants with domain enum - •
computed-field.md- Remove persisted field, replace with computed method - •
test-base-class.md- Extract shared test setup - •
factory-method.md- Replace constructor with factory - •
encapsulate-conditional.md- Move conditionals to data class - •
parameterize-helper.md- Add parameters to test helpers - •
inline-test-params.md- Simplify test→statement data flow
Frontend (.claude/templates/refactoring/)
- •
extract-component.md- Extract JSX block into field/section component - •
extract-shared-ui.md- Move reusable component toapp/components/ui/