refactor-dedupe-and-cleanup
[代码质量]消除代码重复并清理死代码。用于消除复制粘贴代码、合并相似逻辑和删除未使用的代码路径。
📖 中文导读:[代码质量]消除代码重复并清理死代码。用于消除复制粘贴代码、合并相似逻辑和删除未使用的代码路径。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
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