refactor
/refactor - Refactoring Command
Section titled “/refactor - Refactoring Command”Purpose
Section titled “Purpose”Improve code structure, readability, or performance without changing behavior.
/refactor [file or function] [goal: clean | extract | simplify | optimize]Refactor: $ARGUMENTS
Workflow
Section titled “Workflow”Step 1: Understand Current Code
Section titled “Step 1: Understand Current Code”- Read the code thoroughly
- Identify what it does
- Note existing tests
Step 2: Plan Refactoring
Section titled “Step 2: Plan Refactoring”- Identify improvement opportunities
- Ensure tests exist
- Plan incremental changes
Step 3: Execute
Section titled “Step 3: Execute”- Make small, focused changes
- Run tests after each change
- Commit incrementally
Refactoring Types
Section titled “Refactoring Types”- Extract: Pull out reusable functions
- Simplify: Reduce complexity
- Rename: Improve clarity
- Clean: Remove dead code
Output
Section titled “Output”## Refactoring Complete
### Changes Made- Extracted `validateInput()` function- Simplified conditional logic- Renamed `x` to `userCount`
### Before/After[Code comparison]
### TestsAll passingGap Analysis Rule
Section titled “Gap Analysis Rule”Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.