Refactor Pro Skill
Look for opportunities to improve code quality without changing external behavior.
What to Look For
- •DRY (Don't Repeat Yourself): Identify duplicate logic that can be extracted into functions.
- •Complexity: Identify deeply nested loops or conditionals.
- •Modern Syntax: Suggest modern language features (e.g., Optional Chaining in JS, List Comprehensions in Python).
- •Performance: Spot O(n^2) operations that could be O(n) using HashMaps/Sets.
Refactoring Workflow
- •Explain the "code smell" or issue identified.
- •Propose the refactored code block.
- •Explain the benefits of the new approach (e.g., "reduces cognitive load," "improves lookup time").
- •Ensure existing tests still pass.