cd /news/developer-tools/show-hn-jscpd-start-support-type2-ty… Β· home β€Ί topics β€Ί developer-tools β€Ί article
[ARTICLE Β· art-126697] src=github.com β†— pub= topic=developer-tools verified=true sentiment=↑ positive

Show HN: Jscpd start support type2/type3 clones

Jscpd v5, a copy/paste detector for programming source code maintained by kucherenko, now detects Type-2 renamed clones and Type-3 near-miss clones across 224 supported formats. The Rust-based tool runs on a Rabin-Karp algorithm over language-aware token streams and ships as a self-contained binary installable via npm, PyPI, Cargo, Homebrew, Nix, and Docker, with an MCP server and token-efficient reporter for AI workflows. The release also provides a GitHub Action that uploads SARIF results to GitHub Code Scanning by default.

read9 min views1 publishedSep 11, 2026
Show HN: Jscpd start support type2/type3 clones
Image: Michielbdejong (auto-discovered)

Copy/paste detector for programming source code. 220+ formats, language-aware tokenization, exact, renamed and near-miss clones, Rust engine, self-contained binary, AI-ready with MCP server and token-efficient reporter.

Documentation: https://jscpd.dev

jscpd reads code the way its language defines it, not as plain text. Each of the 224 formats is tokenized with its own comment and string syntax, so # in Python, -- in SQL or ' in Visual Basic opens a comment only where the language says so. JavaScript, TypeScript, JSX and TSX go through the oxc parser, which handles template literals, regular expressions, JSX and decorators, and can erase TypeScript-only syntax so a .ts file matches its .js twin. Vue, Svelte, Astro, Markdown and Razor files are split into their embedded languages first, and each block is tokenized as the language it contains. Identifiers, keywords and literals are classified, which is what lets the renamed-clone pass replace names while keeping keywords in place.

On that token stream jscpd runs the Rabin-Karp algorithm to find duplicated blocks across files. Opt-in passes extend it to blocks that differ only in names or values (Type-2) and to copies with a few edited lines or the same function structure (Type-3), each reported with its kind and a similarity score. See How detection works.

curl -fsSL https://jscpd.dev/install.sh | bash

irm https://jscpd.dev/install.ps1 | iex

npx jscpd .

Then scan a project:

jscpd /path/to/code
Method Command Notes
npm npm install -g jscpd Installs the jscpd command; prebuilt binary, no Node.js at runtime
npm ( cpd command) npm install -g cpd Same binary, exposed as cpd
PyPI pip install jscpd Platform wheels with both commands; also pipx install jscpd ,uv tool install jscpd , oruvx jscpd . to run without installing
Cargo cargo install jscpd Builds from crates.io; installs both jscpd andcpd
Homebrew brew install jscpd macOS / Linux
Nix nix run github:kucherenko/jscpd -- /path/to/code Or nix profile install github:kucherenko/jscpd
Docker docker run --rm -v "$PWD:/src" ghcr.io/kucherenko/jscpd . Multi-arch image built from the release binaries
- uses: kucherenko/jscpd@v5
  with:
    threshold: 5

Uploads SARIF results to GitHub Code Scanning by default. See CI & Pre-Commit Hooks for all inputs and outputs.

Document Description
Rust engine Installation, CLI reference, reporters, baseline, summary, blame, config file
AI-Ready AI reporter, agent skills, MCP server
Programming API Rust API ( cpd-finder crate)
CI & Pre-Commit Hooks GitHub Action, Docker image, pre-commit hooks
Packages npm packages and crates that make up a release
Supported formats All 224 formats with their file extensions
Runnable demos One fixtures/<feature>-demo/ directory per feature, each README lists the commands with their expected output

jscpd v5 is a Rust engine that ships as a self-contained binary β€” no runtime required β€” under two npm names (jscpd installs the jscpd command, cpd installs cpd), on PyPI, crates.io, Homebrew, Nix, Docker, and as a GitHub Action.

  • Language-aware tokenization β€” per-format comment and string syntax for all 224 formats, the oxc parser for JavaScript/TypeScript/JSX/TSX, embedded-language extraction for Vue, Svelte, Astro, Markdown and Razor, and keyword/identifier/literal classification, so a clone is a repeated sequence oflanguage tokens , never a repeated run of text (seeHow detection works )
  • 224 language formats with cross-format detection (Vue SFC, Svelte, Astro, Markdown) and--cross-formats groups to match clones across JavaScript and TypeScript
  • Prebuilt for 8 platforms β€” macOS arm64/x64, Linux arm64/x64 (glibc and musl), Windows arm64/x64
  • Type-2 clones β€”--ignore-identifiers ,--ignore-literals and--ignore-annotations find blocks that differ only in names, literal values or annotations, reported asrenamed (seedocs )
  • Type-3 near-miss clones β€”--max-gap-lines N merges a copy with a few inserted or changed lines into onesimilar clone with a similarity score;--similarity 0.85 compares whole JavaScript/TypeScript functions by syntax-tree structure, so renames and scattered edits are still caught (seedocs )
  • Clone kinds in every reporter β€”exact ,renamed orsimilar in the console, JSON (kind ,similarity ,method ), XML, HTML, Xcode, SARIF (jscpd/duplicate-code ,jscpd/renamed-code ,jscpd/similar-code ) and Code Climate output; default runs report onlyexact clones and are unchanged
  • 15 reporters :console ,console-full ,json ,xml ,csv ,html ,markdown ,badge ,sarif ,codeclimate ,openmetrics ,ai ,xcode ,threshold ,silent
  • Clone baseline β€” gate CI onnew duplication only.--baseline .jscpd-baseline.json with--fail-on-new-clones[=N] tolerates legacy clones and fails the build on regressions;--baseline-from-ref origin/main does the same without a committed file (seedocs )
  • Exit codes you can gate on β€” an unknown--format , a missing scan path and a reporter that cannot write its file exit 1 instead of passing with an empty report;--fail-on-empty fails a scan that analyzed no files (seeExit codes )
  • GitLab-ready reporters β€”codeclimate (gl-code-quality-report.json ) andopenmetrics (jscpd-metrics.txt ) plug intoartifacts:reports
  • Git blame with side-by-side author comparison (--blame --reporters console-full )
  • --summary β€” codebase summary: top files and folders by tokens, lines, size, and a complexity estimate β€” refactoring hotspots straight from the scan (seedocs )
  • --mcp β€” built-in MCP server over stdio with fully described tools: point your AI assistant at the binary and it can check snippets for duplication against your codebase, or find structurally similar functions with asimilarity argument (seedocs )
  • AI reporter β€” token-efficient output for LLM pipelines (~79% fewer tokens than console)
  • --skip-local β€” report only clones that cross the scan roots: with jscpd packages/api packages/web --skip-local , pairs inside one of the two trees are dropped and only api-to-web duplication remains
  • --skip-isolated β€” ignore duplication between monorepo folders owned by different teams (--skip-isolated "packages/team-a|packages/team-b" )
  • --workers β€” control parallelism for file tokenization and detection (default: all CPU cores)
  • Config discovery β€”.jscpd.json ,.config/jscpd.json , or thejscpd key inpackage.json
  • Quiet in pipelines β€” tips and sponsor lines print only on an interactive terminal;--no-tips ,CI orJSCPD_NO_TIPS switch them off everywhere

See the Rust docs for the full CLI reference and rust/CHANGELOG.md for release notes.

jscpd v4 (TypeScript engine, Node.js API, LevelDB/Redis stores) is maintained on the master-v4 branch and published as jscpd@4 / the latest-4 dist-tag. README-v4.md describes it in one page (install, CLI, API, packages, maintenance policy); the same content is at https://jscpd.dev/getting-started/v4.

Package Registry Description
jscpd npm Installs the jscpd command (prebuilt binary via platform packages)
cpd npm Installs the cpd command (same binary)
jscpd-<platform> npm Platform binary packages pulled in as optional dependencies: jscpd-darwin-arm64 ,jscpd-darwin-x64 ,jscpd-linux-x64-gnu ,jscpd-linux-arm64-gnu ,jscpd-linux-x64-musl ,jscpd-linux-arm64-musl ,jscpd-windows-x64-msvc ,jscpd-windows-arm64-msvc
jscpd PyPI Platform wheels repacked from the release binaries; installs both jscpd andcpd commands
jscpd crates.io CLI crate; installs both jscpd andcpd binaries
cpd-core crates.io Detection algorithm (Rabin-Karp rolling hash), data models
cpd-tokenizer crates.io Source code tokenization (224 formats)
cpd-finder crates.io File walking, orchestration, git blame β€” the library entry point
cpd-reporter crates.io Output formatting (15 reporters)

The jscpd npm package is downloaded 10M+ times per month, and ~5,000 repositories declare it on GitHub's dependents graph.

Bundled by analysis platforms:

  • GitHub Super Linter β€” official GitHub linter aggregator, bundles jscpd as its copy/paste detector and runs it by default; 15,500+ workflow files on GitHub reference Super Linter (as of Sep 2026)
  • MegaLinter β€” open-source linter aggregator for CI, ships jscpd in every flavor includingci_light
  • Codacy β€” automated code analysis platform, jscpd powers the duplication engine

Explicitly enabled in Super Linter (VALIDATE_JSCPD: true) by dozens of public repositories, including:

  • A2A β€” Google's Agent2Agent protocol (25k+ stars)
  • RimSort β€” mod manager for RimWorld (1.2k+ stars); also runs jscpd directly with its own.jscpd.json
  • Contact Center AI samples β€” official Google Cloud samples, with a dedicated jscpd config
  • Drifty β€” open-source download manager

Used in notable projects:

Compared against other copy/paste detectors on the fixtures/ corpus (547 files, 150+ formats), default thresholds, wall-clock time on Apple Silicon:

Tool Time Files Clones Dup Lines
jscpd 84ms 347 212 9,133
jscpd-rs 111ms 360 222 10,317
Duplo 162ms 319 518 13,049
Fallow dupes 164ms 34 10 3,137
Simian 964ms 547 424 15,351
PMD CPD 35.980s 71 56 2,267

Methodology, cross-format detection and AI-token-efficiency comparisons: benchmark/BENCHMARK.md. Re-run with benchmark/benchmark.sh.

jscpd integrates into AI-powered workflows through three mechanisms:

Token-efficient output for LLM pipelines (~79% fewer tokens than the default console reporter):

jscpd --reporters ai /path/to/source              # compact clone list
jscpd --reporters ai --summary /path/to/source    # + compact codebase summary

Two installable skills that teach AI coding assistants how to use jscpd and refactor detected duplications:

Skill Purpose Install
jscpd Tool reference β€” CLI options, AI reporter format, config syntax npx skills add kucherenko/jscpd --skill jscpd
dry-refactoring Guided refactoring workflow β€” read clones, choose strategy, apply, verify npx skills add kucherenko/jscpd --skill dry-refactoring

After installation, ask your agent to "find and fix code duplication" and it will invoke jscpd with the right options and act on the results.

jscpd --mcp /path/to/project scans once and serves the Model Context Protocol over stdio, so an assistant can check any snippet for duplication against the codebase on demand, list a file's clones, re-scan the working directory, and look for structurally similar functions by passing similarity.

See AI-Ready docs for full details.

See CONTRIBUTING.md for the development setup, test policy, and pull request requirements. In short:

cd rust
cargo nextest run --workspace
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --all --check

Security issues go through the security policy, not public issues.

Thank you to all our backers! πŸ™ [Become a backer]

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

MIT Β© Andrey Kucherenko

── more in #developer-tools 4 stories Β· sorted by recency
── more on @jscpd 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/show-hn-jscpd-start-…] indexed:0 read:9min 2026-09-11 Β· β€”