dry-refactoring
Guided workflow to eliminate copy-paste duplication detected by jscpd. Refactor clones using extract function, module, constant, or base class strategies.
npx skills add kucherenko/jscpd --skill dry-refactoring --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# dry-refactoring Guided workflow to eliminate copy-paste duplication in source code. Use after running [jscpd](../jscpd/SKILL.md) to detect clones. ## Prerequisites First, run jscpd to identify duplications: ```bash npx jscpd --reporters ai <path> ``` In codebases that mix related formats (e.g. JavaScript and TypeScript), add `--cross-formats` so clones spanning both are detected too: ```bash npx jscpd --reporters ai --cross-formats "js-ts" <path> ``` See the **[jscpd](../jscpd/SKILL.md)** skill for full option reference, including cross-format group syntax. ## Workflow 1. Run jscpd with `--reporters ai` on the target path 2. Parse each clone line to identify the two duplicated locations (file + line range) 3. Read both code fragments from the source files 4. Understand what the duplicated code does 5. Design a refactoring: extract a shared function, class, module, or constant 6. Apply the refactoring — update both locations and all other usages 7. Re-run jscpd to confirm the clone is eliminated 8. Repeat for remaining clones, highest-impact first ## Refactoring Strategies **Extract function** — when the duplicate is a block of logic: ```ts // Before: same block in two places // A
- Prerequisites
- Workflow
- Refactoring Strategies
- Tips
npx jscpd --reporters ai <path> npx jscpd --reporters ai --cross-formats "js-ts" <path>
What does the dry-refactoring skill do?
Guided workflow to eliminate copy-paste duplication detected by jscpd. Refactor clones using extract function, module, constant, or base class strategies.
How do I install it?
Run `npx skills add kucherenko/jscpd --skill dry-refactoring --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From kucherenko/jscpd, a repository with 5,966 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
