cleanup-dedupe
Installation
SKILL.md
Find duplicated code and consolidate where it reduces complexity. Auto-extract only token-identical, sizeable blocks. Smaller or divergent duplicates often shouldn't be DRY'd — premature abstraction is worse than 3 similar lines.
Preflight
- Language detect — jscpd handles 150+ languages, so we run it on whatever is present.
- Git state: refuse auto-apply on dirty tree.
- Report dir: ensure
.claude/cleanup-reports/exists. - Read existing util conventions: where does the project keep shared utilities? Look for
lib/,utils/,shared/,common/, package directories. Extracted code goes there.
Detect
# jscpd - the standard for cross-language clone detection
bunx jscpd --min-tokens 70 --min-lines 30 --threshold 0 --reporters json --output /tmp/jscpd-out . 2>/dev/null \
|| npx jscpd --min-tokens 70 --min-lines 30 --reporters json --output /tmp/jscpd-out .
Parse /tmp/jscpd-out/jscpd-report.json. Each duplication entry has firstFile, secondFile, lines, tokens, and the actual fragment.