duplicate-code-detector
Use when the user mentions duplicated code, copy-paste, code clones, repeated code, similar code across files, overlapping implementations, code quality audit, code smells, technical debt involving duplication, or refactoring preparation. Also for cross-language duplication checks, CI duplication warnings, and codebase redundancy scans. DO NOT TRIGGER for implementing refactoring (use incremental-refactoring), fixing bugs, writing tests, adding features, or code review. --- # Duplicate Code Detector jscpd performs token-level comparison across every file pair, catching duplicates invisible to manual review. This skill runs that analysis and turns output into a classified, prioritized refactoring plan. **REQUIRED FOLLOW-UP SKILL:** Use `incremental-refactoring` to implement the refactoring after detection. If the user says "refactor technical debt" or "clean up this codebase", start here to find targets first. ```dot digraph detection_flow { "Check project config" -> "jscpd available?" [shape=diamond]; "jscpd available?" -> "Run jscpd" [label="yes"]; "jscpd available?" -> "Grep fallback" [label="no"]; "Run jscpd" -> "Extract & cap results (jq)"; "Grep fallback" -> "Extract & cap results (jq)"; "Extract & cap results (jq)" -> "Classify (exact/near/structural)"; "Classify (exact/near/structural)" -> "Rank by impact score"; "Rank by impact score" -> "Present findings → incremental-refactoring"; } ``` --- ## Quick Reference | Clone Type | Description | Refactoring Pattern | |---|---|---| | **Exact** | Byte-for-byte identical | Extract Function (no params) | | **Near** | Differs in names/literals/minor expressions | Parameterize (extract with args for varying parts) | | **Structural** | Same algorithm pattern, different implementations | Template Method / Strategy | **Ranking:** `impact_score = duplicated_lines x instances`. Tiebreaker: exact > near > structural. --- ## Workflow ### Step 1: Check environment and config ```bash ls .jscpd.json .jscpdrc .jscpdrc.json 2>/dev/
Changelog: Source: GitHub https://github.com/pvillega/claude-templates
No comments yet. Be the first one!