Refactor Skill
Trigger Phrases
This skill is automatically triggered when the user:
- •Asks to "refactor", "restructure", or "reorganize" code
- •Requests code improvements or cleanup
- •Wants to "extract function" or "simplify code"
- •Mentions "code smell", "duplication", or "complexity"
- •Asks to improve code structure or maintainability
Delegation Instructions
When this skill is triggered:
- •Delegate immediately to the
refactoreragent - •Specify what code needs refactoring
- •Include refactoring goals or focus areas
- •Provide context about current issues
- •Include any constraints or requirements
Context to Pass
- •Code to Refactor: Files or components
- •Refactoring Goals: What to improve (readability, maintainability, etc.)
- •Issues: Known code smells or problems
- •Constraints: Must preserve behavior, no breaking changes, etc.
- •Scope: Full refactor vs. specific improvements
- •Standards: Project coding standards
Agent Responsibilities
The refactorer agent will:
- •Analyze code for improvement opportunities
- •Identify code smells and duplication
- •Refactor while preserving behavior
- •Improve code structure and organization
- •Ensure code follows standards
- •Verify refactoring doesn't break functionality
Usage Examples
Example 1: Extract Function
User: "This function is duplicated in three places, refactor it"
Delegation: Delegate to refactorer with:
- •Issue: Code duplication
- •Goal: Extract shared function
- •Files: Files with duplication
Example 2: Simplify Code
User: "This file is too complex, can you refactor it?"
Delegation: Delegate to refactorer with:
- •File: Complex file
- •Goal: Reduce complexity
- •Constraints: Preserve functionality
Example 3: Improve Structure
User: "Refactor this module to be more maintainable"
Delegation: Delegate to refactorer with:
- •Module: Module to refactor
- •Goal: Improve maintainability
- •Standards: Project standards
Best Practices
- •Delegate refactoring to refactorer
- •Specify refactoring goals
- •Include constraints clearly
- •Provide code context
- •Request behavior preservation verification