dry-refactoring

dry-refactoring is a skill for Claude Code, Codex from kucherenko/jscpd. It costs 35 tokens per session (692 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.

not rated 6.2krepo +53 today A scan Socket: passSnyk: passSkillSpector: warn 35 tokens original MIT

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,156 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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 692 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 15 May 2026
  • Snyk pass 15 May 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.00035 $0.00692
Opus 5 $0.00017 $0.00346
Sonnet 5 $0.00007 $0.00138
Haiku 4.5 $0.00003 $0.00069

Measured 8d ago against content hash 89e10562df19, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 8d 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 · 71 lines

How it starts

The opening of the file, as written. The whole thing — 71 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>

See the jscpd skill for full option reference, including cross-format group syntax 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)
  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:

// Before: same block in two places
// After: shared function called from both places

Extract module/utility — when the duplicate spans multiple files in different domains:

// Move shared logic to a shared utility file and import it

Extract constant or config — when the duplicate is repeated data or configuration.

Template/base class — when the duplicate is structural (e.g., repeated class shape).

Always ensure:

  • All call sites are updated, not just the two reported by jscpd
  • Tests still pass after refactoring
  • The extracted abstraction has a clear, descriptive name

Read the full file on GitHub · 71 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. 8d 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,156 stars, last pushed today), licensed MIT. It adds 35 tokens to every session and 692 once invoked, about $0.0002 per session on Opus 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

Other skills, from other repositories

brooks-sweep

Full-sweep mode: runs a unified analysis across all quality dimensions — code decay, architecture, tech debt, and test quality — then applies fixes directly to the codebase. Safe changes are auto-applied; risky changes are confirmed before execution. Drawing on twelve classic engineering books. Triggers when: user…

hyhmrright/brooks-lint · 178 tokens

llm-friendly-context

Clarifies inputs, outputs, success criteria, decisions, and unresolved conditions so downstream consumers can execute without guessing. Use when writing or revising LLM-facing prompts, handoffs, planning artifacts, reviews, reports, or generated instructions.

shinpr/claude-code-workflows · 52 tokens

ring:exploring-codebases

Exploring a codebase across phases: scopes the target, detects architecture, components, and layers, deep-dives each discovered perspective, then synthesizes findings into actionable guidance with file:line evidence. Use to understand how a feature or system works before planning changes, or to orient on an unfamiliar…

LerianStudio/ring · 91 tokens

ring:mapping-feature-relationships

Mapping how features relate and phasing the work: categorizing PRD features, grouping them into domains, charting cross-feature journeys, dependencies, and integration points, and defining the binding Phases that plan.md mirrors one-to-one at Gate 7. Gate 2 of ring:planning-large-features; runs after…

LerianStudio/ring · 104 tokens

megalinter-check

Collect MegaLinter lint errors for the current repository. Use when the user wants to know if the code passes linting, why the MegaLinter CI job fails, or before/after fixing lint errors. Two modes - watch a CI job (GitHub Actions, GitLab CI, Azure Pipelines, Bitbucket Pipelines) and parse its logs, or run MegaLinter…

oxsecurity/megalinter · 96 tokens

bestie-features

Add BestieTemplate features (AGENTS.md, changelog, dependabot, pre-commit, lint workflow, testitem runner) to a Julia package with the bestie CLI — no Julia needed. Use when asked to add one of these files/setups to a package, or to see what BestieTemplate can add.

JuliaBesties/BestieTemplate.jl · 71 tokens