Extract Function Refactoring
Description
Identifies code blocks that can be extracted into reusable functions. Reduces duplication, improves readability, and makes code more maintainable.
Code
Skill Code
Look "keyword">for: 1. Repeated code blocks (3+ lines appearing twice) 2. Long functions (50+ lines) 3. Deeply nested code 4. Code with clear single responsibility 5. Comments explaining "what" (candidate "keyword">for "keyword">function name)
Usage Examples
Examples
User: refactor this long "keyword">function
Claude: I identified 3 extraction opportunities:
1. Lines 15-28: Extract to `validateUserInput()`
2. Lines 45-60: Extract to `formatResponse()`
3. Lines 72-85: Already appears twice, extract to `calculateDiscount()`
Shall I perform these extractions?
Installation
Add the following to your CLAUDE.md file (project root or ~/.claude/CLAUDE.md for global):
CLAUDE.md
# Extract Function Refactoring Look for: 1. Repeated code blocks (3+ lines appearing twice) 2. Long functions (50+ lines) 3. Deeply nested code 4. Code with clear single responsibility 5. Comments explaining "what" (candidate for function name)
Comments (0)
No comments yet. Be the first to share your thoughts!
Leave a Comment