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 is designed to enhance code quality and maintainability by automating the refactoring process. It focuses on eliminating technical debt by identifying and removing code duplication (DRY principle) and purging dead code, such as unused variables, unreachable paths, and legacy comments. By consolidating logic and streamlining the codebase, it helps developers maintain a clean, efficient, and professional repository.
Use Cases
- Legacy Codebase Cleanup: Identify and merge redundant logic across multiple files to reduce maintenance overhead and improve readability.
- Pre-deployment Optimization: Automatically detect and remove unused imports, variables, and unreachable code blocks to ensure a lean production environment.
- Logic Consolidation: Refactor repetitive conditional expressions and similar functions into reusable utility methods or design patterns like the Template Method.
- Technical Debt Reduction: Systematically clear out commented-out code and deprecated functions that clutter the namespace and confuse team members.
| 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