Skip to content

refactor

Improve code structure, readability, or performance without changing behavior.

/refactor [file or function] [goal: clean | extract | simplify | optimize]

Refactor: $ARGUMENTS

  1. Read the code thoroughly
  2. Identify what it does
  3. Note existing tests
  1. Identify improvement opportunities
  2. Ensure tests exist
  3. Plan incremental changes
  1. Make small, focused changes
  2. Run tests after each change
  3. Commit incrementally
  • Extract: Pull out reusable functions
  • Simplify: Reduce complexity
  • Rename: Improve clarity
  • Clean: Remove dead code
## Refactoring Complete
### Changes Made
- Extracted `validateInput()` function
- Simplified conditional logic
- Renamed `x` to `userCount`
### Before/After
[Code comparison]
### Tests
All passing

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.