Copy/Paste Detector for Source Code
npx jscpd .Built for codebases where agents write code
jscpd . --threshold 3Runs in pre-commit and CI. "An agent will argue a comment, but a failing build just stops it." — @nark3d
Set up the gate →jscpd --mcpMCP server built into the binary. Claude, Cursor, or any MCP client checks for clones before writing more.
MCP server docs →npx skills add kucherenko/jscpdOne skill: detect duplicates, propose the extraction, verify the count went down.
Install the agent skill →jscpd . --reporters aiAbout 79% fewer tokens than the default reporter. Pipe it straight into your agent loop.
See the token benchmark →jscpd . --summaryFiles ranked by tokens, lines, or complexity, each with its duplication share. Refactor the worst first.
Summary options →How teams wire it
- Pre-commit
- CI gate
- Agent loop
Block the commit before the clone lands.
npx jscpd --threshold 3 .Fail the pull request when duplication crosses the line.
# .github/workflows/jscpd.yml
- uses: kucherenko/jscpd@v5
with:
threshold: 3
Give the agent the same detector, over MCP.
// MCP client config
{ "mcpServers": { "jscpd": {
"command": "jscpd", "args": ["--mcp", "."] } } }
Core
A decade of refining the art of duplicate detection. Now rewritten in Rust for native performance — no Node.js runtime required.
How detection works →JavaScript, Python, Java, Go, Rust, C++, TypeScript, Ruby... If you can write it, we can scan it. Vue, Svelte, Astro, and Markdown cross-format detection too.
View supported formats →A Rust engine with parallel detection across format groups. 159 MB codebase? 3.4 seconds. No Node.js runtime — just a single native binary.
See benchmarks →One command to rule them all. Works everywhere — your laptop, CI/CD, that ancient Jenkins server nobody wants to touch.
Get started →HTML, JSON, XML, badges for your README. Make technical debt visible (and slightly embarrassing).
Explore reporters →Set a threshold and fail the build. Or commit a baseline and fail only on clones that are new since the last run.
Configure thresholds →Vue SFC, Svelte, Astro, and Markdown files are tokenized per-block — a <script> in .vue can match a .ts file. And --cross-formats "js-ts" compares related formats in one pool, catching clones between .js and .ts files.
--blame annotates every clone with the authors from git history, so you know who to ask before you refactor.
One of the most trusted tools in the ecosystem. Join developers who rely on jscpd every day.
View on npm →Integrations
uses: kucherenko/jscpd@v5 — scans the repository, fails on threshold, and uploads SARIF to Code Scanning. No install step.
Works with the pre-commit framework, Husky, or a plain shell hook in .git/hooks. Blocks the commit when duplication exceeds the threshold.
--reporters sarif writes a SARIF file that GitHub Code Scanning renders as inline alerts on the pull request.
The codeclimate reporter feeds GitLab Code Quality and openmetrics feeds its metrics reports, so duplication shows up on the merge request.
Embed detection in your own tools with the Rust crates (cpd-finder, cpd-core), or drive the CLI and parse its JSON output from any language.
How much copy/paste ships in GitHub's trending repos? A daily pipeline runs jscpd v5 on each and publishes clone counts and duplication stats.
See today's results →See It In Action
# Scan your source code
$ jscpd ./src
Clone found (typescript):
- src/utils.ts [10:1 - 25:3] (15 lines, 129 tokens)
src/helpers.ts [5:1 - 20:3]
Clone found (typescript):
- src/utils.ts [45:5 - 62:2] (17 lines, 178 tokens)
src/components/Button.tsx [12:1 - 29:2]
Clone found (typescript):
- src/hooks/useAuth.ts [1:1 - 34:2] (33 lines, 245 tokens)
src/hooks/useSession.ts [1:1 - 34:2]
# ... more clones
Found 90 clones.
Detection time: 13ms
Fresh from GitHub Trending
Who Uses jscpd
10M+ npm downloads / month · ~5,000 repositories declare jscpd on GitHub's dependents graph · 15,500+ workflow files reference Super Linter, which runs jscpd by default
Developers Are Talking
One of the most important tools you can add to CI when building with AI: github.com/kucherenko/jscpd
へぇ 「jscpd v5 は Rust 製で速い。 26.7 万行 / 127ms。CI コストは実質ゼロ」
I highly recommend jscpd: github.com/kucherenko/jscpd Can’t live without this in my projects now
TIL: jscpd
npmjs.com/package/jscpd がDartコードのコピペ検出も対応してることを dart-lang/sdk の issue で知って試したら普通に動いた( ´・‿・`) 利用例: `jscpd . --pattern "**.dart" --min-lines 20`
One of my favorite tools during a code audit is jscpd. It detects copy/pasted code. In a codebase I’m currently reviewing, nearly half of the JS is duplicated! jscpd lists the specific duplicated spots so we can consider a cleanup.
Get AI to reduce duplicated code, reduce the jscpd number
I du regular sweeps with jscpd, ran a Socrates analysis yesterday and it was in the single digits. Could purge more, but writing overly generic code has its own problems.
Same here, jscpd and the linter both sit in our CI gate. The thing that surprised me is it holds up better with agents than a review comment does. An agent will argue a comment, but a failing build just stops it, so the duplication never gets in.
jscpd というコピペコードを検出する静的解析ツールいいかもしれない 結局コード品質を担保するにはAIに逐一指示するというアプローチよりは静的解析ツールとかでガチガチに縛ってしまった方が気持ち的に大胆にリファクタリングしやすい
just added a jscpd pre-commit hook and why did i not do this ages ago
Problem: You want to find copy/pasted code. Solution: jscpd. It finds copy/pasted code in over 150 languages. I just ran this command on a JS project: npx jscpd --ignore "**/node_modules/**" It found over 6,000+ lines of duplicated code.
I break my specs into directed acyclic graphs in order to identify what work depends on other work and which tasks can be worked in parallel. I also run jscpd in pre-commit which helps cleanup duplicate code and interfaces. See my GitHub DAG project as an example of this
a good way to minimize slop in a typescript codebase is a forced validation command of knip, jscpd and linter of your choice. the more static validation you have the better.
重複コードを消すツール! これも良さそう!!
Been experimenting with jscpd to spot similar code that I might be able to refactor, with the goal of simplifying and optimising and hopefully shave some bytes off my apps. Works with 150+ formats.
I’ve got jscpd in the pre-commit hook for the same reason. It catches the duplicate before commit instead of in review, and review misses copy-paste because each diff reads fine alone. Gets more useful the more an agent repeats the same helper.
知らせる層は knip(デッドコード)と jscpd(重複)。 こっちは止めずに、気づかせるだけの設定 あとは"入れて終わり"にしたくなかったので、既存のコードで溜まってた借金を返すEpicも立てて、子Issue10件で完走
jscpd is genuinely one of those quietly-everywhere dev tools, congrats on the milestone. a small OSS project really can outlast flashier ones…
Problem: Your code base probably contains a lot of copy/pasted code, but it’s hard to find. Solution: jscpd jscpd is a command line tool that finds copy/pasted code and reports specific duplicated lines. Works for over 150 languages.