cleanup-dedupe

Solid

Detect duplicated code blocks and refactor to DRY where it reduces complexity. Runs jscpd (multi-language), filters by signal-to-noise, and auto-extracts only token-identical blocks ≥30 LOC. Use when the user asks to deduplicate, DRY up, find copy-paste, or consolidate repeated logic. Example queries — "DRY this up", "find copy-paste in the codebase", "consolidate repeated logic", "where are the duplicated blocks".

AI & Automation 78 stars 9 forks Updated today MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
63
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

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 1. **Language detect** — jscpd handles 150+ languages, so we run it on whatever is present. 2. **Git state**: refuse auto-apply on dirty tree. 3. **Report dir**: ensure `.claude/cleanup-reports/` exists. 4. **Read existing util conventions**: where does the project keep shared utilities? Look for `lib/`, `utils/`, `shared/`, `common/`, package directories. Extracted code goes there. ## Detect ```bash # 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. **Filter the noise** before further analysis: - Drop matches in `node_modules/`, `dist/`, `build/`, `.next/`, `__generated__/`, `*.generated.*`. - Drop matches inside test files mirroring each other (test setup duplication is often intentional). - Drop matches that are just type/interface definitions — those go to `cleanup-types`. - Drop matches in migration files. ## Assess Write `.claude/cleanup-reports/cleanup-dedupe-{YYYY-MM-DD}.md`:...

Details

Author
raintree-technology
Repository
raintree-technology/agent-starter
Created
7 months ago
Last Updated
today
Language
JavaScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category