AgentSkillsCN

refactor

运行Spring Boot后端应用。在用户想要启动后端服务器,或提及“/run-backend”命令时使用此功能。

SKILL.md
--- frontmatter
name: refactor
description: Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions.

/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

  1. Load .claude/agents/refactor-agent.md
  2. Agent reads target file + tests
  3. Identifies smell, loads template from .claude/templates/refactoring/
  4. Applies ONE refactoring, runs tests
  5. 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 to app/components/ui/