Code duplication detection rules. Patterns and thresholds for identifying clone code, role duplication, and variable duplication. Guide for removing duplicates through refactoring.
How this skill is triggered — by the user, by Claude, or both
Slash command
/chkim-su-serena-refactor:duplicate-detection-rulesThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Duplication is the enemy of change.**
Duplication is the enemy of change. When you change one, you must change all copies. Miss one, and you have a bug.
| Type | Definition | Similarity | Severity |
|---|---|---|---|
| Type-1 | Exact clone (whitespace ignored) | 100% | CRITICAL |
| Type-2 | Same structure, different names/literals | >90% | HIGH |
| Type-3 | Similar with some modifications | >70% | MEDIUM |
Details:
Read("references/clone-patterns.md")
Detection Signals:
| Signal | Description | Probability |
|---|---|---|
| Similar names | *Manager, *Handler, *Service | High |
| Same interface | Implements same interface | Very High |
| Similar methods | 3+ same method names | High |
Synonym Groups to Watch:
get, fetch, retrieve, find, loadcreate, make, build, generate, newvalidate, check, verify, ensure| Type | Detection Criteria |
|---|---|
| Magic numbers | Same value used 2+ times |
| Duplicate strings | Same string (5+ chars) used 3+ times |
| Config values | Same config in multiple places |
| Type | Threshold | Report |
|---|---|---|
| Type-1 Clone | 5 lines | Always |
| Type-2 Clone | 90% similar | Always |
| Type-3 Clone | 70% similar | 10+ lines |
| Role duplication | 3 same methods | Always |
| Magic numbers | 2+ usages | Always |
| Situation | Reason |
|---|---|
| Test code | Maintain test independence |
| Generated code | Auto-generation tool responsibility |
| External interface | Contract compliance required |
| Performance code | Intentional inlining |
Not Considered Duplication:
if (err) return;)Detailed patterns:
Read("references/fix-patterns.md")
| Duplication Type | Strategy |
|---|---|
| Clone code | Extract common function |
| Role duplication | Consolidate classes |
| Constants | Centralize config |
npx claudepluginhub chkim-su/serena-refactorGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Provides Slack GIF creation utilities with dimension/FPS/color constraints and Python PIL-based frame generation. Use for animated Slack emoji or message GIFs.