refactor-rename-for-clarity
[Code Quality] Performs systematic renaming to improve code clarity: variables, functions, classes, files. Use when names are unclear, misleading, or inconsistent with their purpose.
When & Why to Use This Skill
This Claude skill automates systematic renaming to improve code readability and maintainability. It refactors variables, functions, classes, and files to ensure they reveal intent, remain searchable, and match the appropriate abstraction level, effectively reducing technical debt and improving long-term code quality.
Use Cases
- Legacy Code Refactoring: Replacing cryptic or single-letter variable names (e.g., 'd', 'temp') with descriptive identifiers that reflect their actual purpose.
- Standardizing Naming Conventions: Aligning function and class names across a large codebase to ensure consistency and adherence to clean code principles.
- Improving Boolean Logic: Converting vague flags into descriptive boolean names like 'isUserAuthenticated' or 'hasPermission' to make conditional statements self-documenting.
- API and Abstraction Alignment: Renaming methods to better match their level of abstraction, such as changing 'fetchDataAndParse' to 'getUserProfile'.
| name | refactor-rename-for-clarity |
|---|---|
| description | "[Code Quality] Performs systematic renaming to improve code clarity: variables, functions, classes, files. Use when names are unclear, misleading, or inconsistent with their purpose." |
Refactor: Rename for Clarity
Improve code readability through better naming.
Naming Principles
1. Names Should Reveal Intent
// BAD: let d: Int
// GOOD: let elapsedDays: Int
2. Names Should Be Searchable
// BAD: if status == 1 { }
// GOOD: if status == .active { }
3. Names Should Match Abstraction Level
// BAD: func getFromNetworkAndParseJSON()
// GOOD: func fetchUserProfile()
Common Patterns
| Bad Name | Better Name | Why |
|---|---|---|
| data | userResponse | Specific type |
| temp | previousValue | Purpose clear |
| flag | isEnabled | Boolean pattern |
| doIt() | submitForm() | Action + target |