dry-refactoring

dry-refactoring is a skill for Claude Code, Codex from kucherenko/jscpd. It costs 53 tokens per session (1,966 once invoked), scanned A, original, MIT.

A guided workflow for removing repeated code found by jscpd, a tool that detects copy-and-paste duplication. It helps decide whether to move shared code into a function, module, constant, or base class.

In plain words
What is it for?
Use it after running jscpd to inspect matching code sections, identify refactoring opportunities, and replace clones with shared code.
Why use it?
It reduces duplicated logic, so future fixes and changes do not have to be made in several places.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it after running jscpd to inspect matching code sections, identify refactoring opportunities, and replace clones with shared code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kucherenko/jscpd/dry-refactoring
About the project

jscpd is a source-code copy/paste detector that finds duplicated code blocks across files and reports the results in formats such as SARIF, HTML, and badges. Developers use it for code-quality checks, continuous integration, pre-commit hooks, and agent-assisted reviews across many programming-language formats. Its catalogue skills help coding agents run or interpret duplication checks.

kucherenko/jscpd · 6,637 stars · on GitHub · jscpd.dev

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add kucherenko/jscpd --skill dry-refactoring
Clone the repo
git clone --depth 1 https://github.com/kucherenko/jscpd

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dry-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/kucherenko/jscpd/dry-refactoring/github.svg)](https://agentmods.dev/skills/kucherenko/jscpd/dry-refactoring)
Your own site
<a href="https://agentmods.dev/skills/kucherenko/jscpd/dry-refactoring"><img src="https://agentmods.dev/badge/skills/kucherenko/jscpd/dry-refactoring/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dry-refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/kucherenko/jscpd/dry-refactoring"><img src="https://agentmods.dev/badge/skills/kucherenko/jscpd/dry-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,966 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 8 Oct 2026
  • Snyk pass 8 Oct 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 3 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 15
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 21
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium MCP Rug Pull · line 27
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00053 $0.01966
Opus 5.5 $0.00021 $0.00786
Sonnet 5.5 $0.00011 $0.00393
Haiku 4.5 $0.00005 $0.00197

Measured 1mo ago against content hash 246f191f6af2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dry-refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/dry-refactoring/SKILL.md · 116 lines

How it starts

The opening of the file, as written. The whole thing — 116 lines — stays where its author put it; the contents beside it link to each section on GitHub.

dry-refactoring

Guided workflow to eliminate copy-paste duplication in source code. Use after running jscpd to detect clones.

Prerequisites

First, run jscpd to identify duplications:

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:

npx jscpd --reporters ai --cross-formats "js-ts" <path>

On larger codebases, add --summary to get a refactoring-hotspot overview alongside the clone list — top files and folders with a dup% column showing how much of each file is duplicated:

npx jscpd --reporters ai --summary <path>

The default scan reports only exact copies, and those are the ones to refactor first: an exact clone is almost always a real copy-paste. Two more passes find copies that were edited after pasting. They are noisier: they ignore names, values or a few statements on purpose, so they also surface blocks that merely look alike (models and DTOs, config tables, test setup, generated code, shared idioms). Run them only after the exact clones are dealt with, one family at a time, with tight settings, and treat what they report as leads to read rather than defects to fix:

# Type-2: renamed copies (other variable names, other constants), reported as "(renamed)".
# Raise --min-tokens: with identifiers ignored, a short block is mostly placeholders.
npx jscpd --reporters ai --ignore-identifiers --min-tokens 70 <path>

# Type-3: near-miss copies (one or two edited lines, or JS/TS/Python functions with the same structure),
# reported as "[~0.91 gap]" and "[~0.85 ast]". Widen only if the tight run finds nothing.
npx jscpd --reporters ai --max-gap-lines 1 --similarity <path>

See the jscpd skill for full option reference, including cross-format group syntax, the clone-kind suffixes and how to read the summary.

Workflow

  1. Run jscpd with --reporters ai on the target path (add --summary on larger codebases to pick a starting point: files with high dup% and high token counts pay off most)
  2. Parse each clone line to identify the two duplicated locations (file + line range) and its kind: no suffix is an exact copy, (renamed) differs only in names or values, [~N gap] has a few edited lines in the middle, [~N ast] is a function pair with the same structure
  3. Read both code fragments from the source files
  4. Understand what the duplicated code does, and for renamed and similar clones list exactly what differs between the two sides
  5. Triage renamed and similar clones before touching them. Skip the pair, and say so, when any of these holds: the two sides do different things despite the same shape (a switch over different enums, two reducers with unrelated semantics); the sameness is intentional boilerplate (models, DTOs, config, route tables, test fixtures); the code is generated; a shared abstraction would need a vague name like processData; or the pair is under about 10 lines. Only a pair that would let you delete code and give the extraction a precise name goes on to the next step
  6. Design a refactoring: extract a shared function, class, module, or constant; the kind decides the strategy (below)
  7. Apply the refactoring — update both locations and all other usages
  8. Re-run jscpd with the same flags to confirm the clone is eliminated and the dup% of the touched files went down; a clone that was (renamed) will not show in a default run, so check with --ignore-identifiers again
  9. Repeat for remaining clones, highest-impact first: exact clones, then renamed, then similar. Report the skipped candidates separately from the refactored ones, with the reason, so nobody mistakes a normalized run's count for real duplication

Read the full file on GitHub · 116 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed 246f191f6af2
  2. 1mo ago Changed b97794e2a198
  3. 2mo ago Changed · +45 lines · +18 tokens per session acce05d78277
  4. 3mo ago First seen · 71 lines · 35 tokens per session scan A 89e10562df19

Subscribe to this mod's changes

dry-refactoring is a skill published in the GitHub repository kucherenko/jscpd (6,637 stars, last pushed yesterday), licensed MIT. It adds 53 tokens to every session and 1,966 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

dry-refactoring compared with skills from other repositories

dry-refactoring next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dry-refactoringkucherenko/jscpdSkill6.6kyesterdayMITA53Claude Code, Codex
brooks-sweephyhmrright/brooks-lintSkill1.6kyesterdayMITA178Claude Code
llm-friendly-contextshinpr/claude-code-workflowsSkill725yesterdayMITA52Claude Code
driftdadbodgeoff/driftSkill7949d agoApache-2.0A84Claude Code
laravel-owasp-securityAsyrafHussin/agent-skillsSkill111todayMITA87Claude Code
ring:mapping-feature-relationshipsLerianStudio/ringSkill21829d agoApache-2.0A104Cursor
laravel-audit-databaseMrPunyapal/laravel-auditorSkill854d agoMITA33Claude Code, Codex