refactor-dedupe-and-cleanup
[Code Quality] Removes code duplication and cleans up dead code. Use to eliminate copy-paste code, consolidate similar logic, and remove unused code paths.
When & Why to Use This Skill
This Claude skill enhances code quality and maintainability by automatically identifying and eliminating redundant logic and 'dead' code. It streamlines software development by consolidating duplicated patterns into reusable methods and purging unused variables, functions, and imports, effectively reducing technical debt and improving codebase readability.
Use Cases
- Technical Debt Reduction: Automatically identifying and removing unreachable code, unused variables, and legacy functions to clean up long-term projects.
- Logic Consolidation: Merging duplicated code blocks into shared methods or applying the Template Method Pattern to ensure 'Don't Repeat Yourself' (DRY) principles.
- Codebase Auditing: Removing commented-out code and unused imports to reduce noise and improve the developer experience during code reviews.
- Refactoring Legacy Systems: Consolidating similar conditional expressions and logic paths to simplify complex, inherited code structures.
| name | refactor-dedupe-and-cleanup |
|---|---|
| description | "[Code Quality] Removes code duplication and cleans up dead code. Use to eliminate copy-paste code, consolidate similar logic, and remove unused code paths." |
Refactor: Dedupe and Cleanup
Eliminate redundancy and remove dead code.
Deduplication Patterns
1. Extract Common Method
Move duplicated logic to shared function.
2. Template Method Pattern
Abstract common structure, vary details.
3. Consolidate Conditional Expression
Combine conditions with same result.
Dead Code Removal
Types to Remove
- Unreachable code - after return/throw
- Unused variables - declared but never read
- Unused functions - never called
- Commented code - use git history instead
- Unused imports - clutters namespace
Safe Removal Process
- Search for all references
- Check for reflection/dynamic usage
- Remove in small commits
- Run full test suite