compare-codebases
Skill6.3k starsChanged 3 months agoMITView on GitHub
Compare two folders function by function with jscpd --compare, in the same language or across languages, and explain the result. Use when asked how two codebases relate, which functions one implementation has and the other lacks, how far a port has come, whether the iOS and Android versions of an app match, or which function in one folder corresponds to a function in the other.
Trending
More talk lately.about the whole repository
Who's talking about kucherenko/jscpd
- A Hacker News story“Jscpd Public Copy/paste detector for programming source code”Hacker News · Jun 29, 2025 · 5 points
- sivagao/blog“2016/03/31 针针见血:怎么消除JavaScript中的代码坏味道”GitHub · Mar 31, 2016 · 5 reactions
- @marmelab.bsky.social“Just came across jscpd: A Copy/paste detector for programming source code. It lets you see if your code can …”Bluesky · Mar 7, 2025 · 4 likes
- A Hacker News story“Show HN: Jscpd start support type2/type3 clones”Hacker News · Sep 11, 2026 · 2 points
- AFI-Protocol/afi-config“chore(deps-dev)(deps-dev): bump jscpd from 4.2.5 to 5.0.12”GitHub · Jul 20, 2026 · 2 reactions
The biggest 5 of 49 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 49
Talked about on GitHub, Hacker News and Bluesky (49 times).
On GitHub · 44
- Mar 31, 20162016/03/31 针针见血:怎么消除JavaScript中的代码坏味道 — sivagao/blog5 reactions · 9 comments
- Jul 20, 2026chore(deps-dev)(deps-dev): bump jscpd from 4.2.5 to 5.0.12 — AFI-Protocol/afi-config2 reactions · 3 comments
- Jun 8, 2026Bump jscpd from 4.2.4 to 5.0.4 — hbmartin/raffy-research2 reactions · 3 comments
- May 31, 2026Bump jscpd from 4.0.9 to 4.2.4 — hbmartin/react-mentions-ts2 reactions · 3 comments
- Aug 8, 2026chore(deps): bump the dev-minor-patch group across 1 directory with 13 updates — juliopolycarpo/mangostudio1 reaction · 7 comments
39 more on GitHub
- Jul 20, 2026build(deps): bump the routine-minor-patch group with 20 updates — zaks-io/splitch1 reaction · 3 comments
- Jul 20, 2026build(deps-dev): bump the dev-dependencies group across 1 directory with 15 updates — zaks-io/splitch1 reaction · 2 comments
- Jul 20, 2026build(deps-dev): bump the dev-dependencies group with 14 updates — zaks-io/splitch1 reaction · 5 comments
- Jul 13, 2026build(deps-dev): bump the dev-dependencies group with 12 updates — zaks-io/splitch1 reaction · 2 comments
- Jul 13, 2026build(deps): Bump jscpd from 4.2.4 to 5.0.12 — zaks-io/insecur1 reaction · 1 comment
- Jul 6, 2026build(deps-dev): bump the dev-dependencies group with 8 updates — zaks-io/splitch1 reaction · 5 comments
- Jun 30, 2026chore(deps): bump jscpd from 4.2.4 to 5.0.11 — zaks-io/insecur1 reaction · 1 comment
- Jun 18, 2026README benchmarks may be outdated after jscpd Rust rewrite — fallow-rs/fallowsays it tested it1 reaction · 5 comments
- Apr 14, 2026chore(deps): bump the npm-deps group across 1 directory with 14 updates — dctmfoo/openai-agents1 reaction · 1 comment
- Jan 24, 2023New linters/formatters — db-ux-design-system/core-web1 reaction · 3 comments
- Oct 5, 2026chore(deps): bump jscpd from 5.0.14 to 5.4.0 — actions-marketplace-validations/Raed2180416_holt0 reactions
- Oct 5, 2026build(deps-dev): bump jscpd from 5.3.1 to 5.4.0 — aurelienbobenrieth/harness0 reactions
- Oct 5, 2026chore(deps): bump jscpd from 5.0.14 to 5.3.3 in /benchmarks — CircuitBoardGames/Fallow-Forgejosays it tested it0 reactions
- Oct 5, 2026chore(deps-dev): bump jscpd from 4.2.5 to 5.4.0 — Axl47/Theoria-Codex0 reactions
- Oct 5, 2026ci(deps): bump kucherenko/jscpd from 5.3.2 to 5.4.0 in the github-actions group — xsyetopz/easel.js0 reactions · 1 comment
- Oct 4, 2026chore(deps-dev): bump jscpd from 4.3.0 to 5.4.0 — GabrielV-Engineer/AILIENANT0 reactions
- Oct 3, 2026chore(deps-dev): bump jscpd from 5.2.1 to 5.4.0 — ZinTrust/zintrust0 reactions · 1 comment
- Oct 3, 2026Bump jscpd from 5.0.12 to 5.1.2 — xiejianjun000/eco-agent0 reactions · 1 comment
- Oct 3, 2026build(deps-dev): bump jscpd from 5.0.12 to 5.1.2 — murilloleonel939-art/deepseek0 reactions · 1 comment
- Oct 1, 2026build(deps-dev): bump the npm-dependencies group with 2 updates — chapmandu/rust-in-peace0 reactions
- Oct 1, 2026chore(deps): bump jscpd from 5.0.16 to 5.3.2 in /benchmarks — actions-marketplace-validations/fallow-rs_fallowsays it tested it0 reactions
- Oct 1, 2026build(deps): bump jscpd from 4.3.0 to 5.3.2 — astubbs/duplicate-code-cross-check0 reactions · 1 comment
- Oct 1, 2026Bump jscpd from 5.0.16 to 5.3.2 — vinceyvincey/agent-readiness0 reactions
- Sep 30, 2026chore(deps): bump jscpd from 5.0.12 to 5.3.2 — fderuiter/equipose-randomization0 reactions · 1 comment
- Sep 29, 2026chore(deps): bump jscpd from 5.0.14 to 5.3.2 — Raed2180416/holt0 reactions
- Sep 29, 2026chore(deps-dev): bump jscpd from 5.0.16 to 5.3.2 — xplorer1/starter-test0 reactions
- Sep 28, 2026Bump jscpd from 3.4.2 to 5.3.2 in /dependencies — asia215/super-linter0 reactions
- Sep 28, 2026chore(deps): bump jscpd from 5.0.14 to 5.3.2 — Dorsey-Creative/secrets-sync-cli0 reactions
- Sep 26, 2026chore(deps-dev): bump jscpd from 5.2.0 to 5.3.0 — mnahkies/shoe-string-server0 reactions
- Sep 23, 2026chore(deps-dev): bump jscpd from 4.3.0 to 5.3.2 — Glock-Boonyarith/school-check0 reactions · 1 comment
- Sep 23, 2026build(deps-dev): bump jscpd from 5.0.15 to 5.3.1 — authenticmemory/gami-cli-verifier0 reactions
- Sep 21, 2026Bump jscpd from 3.3.26 to 5.2.1 in /dependencies — SM-125F/super-linter0 reactions
- Sep 15, 2026build(deps-dev): bump jscpd from 5.0.12 to 5.0.15 — Suife-yuanxing/deepseek-harness-personal0 reactions · 1 comment
- Sep 14, 2026build(deps-dev): bump jscpd from 5.0.12 to 5.0.15 — AStarqx/DeepSeek-Harness-Desktop0 reactions · 1 comment
- Sep 12, 2026chore(deps-dev): bump jscpd from 5.0.14 to 5.2.0 — ninasokolov8/browser-coder0 reactions
- Sep 11, 2026build(deps): Bump jscpd from 5.0.14 to 5.1.2 — codacy/codacy-duplication-jscpd0 reactions · 1 comment
- Sep 10, 2026Bump jscpd from 4.3.0 to 5.1.2 — VISVANTHA/Digital-Sippoy-new0 reactions
- Sep 7, 2026Bump jscpd from 3.5.3 to 5.1.2 in /dependencies — NocturnalGlory/super-linter0 reactions
- Aug 14, 2026jscpdで重複コードを防ぐ仕組みを作る — taka1156/webspaces0 reactions
On Hacker News · 4
- Jun 29, 2025Jscpd Public Copy/paste detector for programming source code5 points
- Sep 11, 2026Show HN: Jscpd start support type2/type3 clones2 points
- Oct 22, 2025jscpd: Copy/paste detector for programming source code2 points
- Jan 30, 2024Copy/paste detector for programming source code, supports 150 formats1 point
On Bluesky · 1
- Mar 7, 2025Just came across jscpd: A Copy/paste detector for programming source code. It lets you see if your code can be “simplified” in certain… — @marmelab.bsky.social4 likes and reposts
In this repository4 other files it gives its agents.
- codebase-refactoringSkill
- code-migrationSkill
- dry-refactoringSkill
- jscpdSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
When neither side has a test that counts (see below), the report has one block and no headings.
- Very specific: line 44
Keep parallel structures when you can (ios/<module> and android/<module>).
- Very specific: line 93
When both folders hold tests, the report has a Code block and a Tests block, each with everything below.
- Very specific: line 98
If one folder has no functions, the report is one line of totals and <folder> has no functions yet.
- Very specific: line 109
every low pair, since related code pairs there too (a client call and the endpoint it calls, a function counting UTF-8 bytes and one …
- Distinctive: line 112
When a sample pair is wrong, say which one and why.
- Distinctive: line 141
Keep the folders, their order, the options and the model the same when you compare runs over time, or the numbers stop being comparable.
- Distinctive: line 147
Only functions are compared.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
compare-codebases
jscpd --compare A B pairs every function of folder A with the function of folder B that does the same job, and lists the functions of each folder that have no counterpart. The two folders may be in one language or in two (Python and TypeScript, Kotlin and Swift, Java and Rust). This skill explains how the comparison works and how to run one well. For porting code with the comparison as the progress measure, use the code-migration skill; for the rest of jscpd, the jscpd skill.
How the comparison works
jscpd finds the functions of JavaScript, TypeScript, JSX, TSX, Vue, Svelte, Astro, Python, Rust, Go, Java, Kotlin, C#, C, C++, PHP, Ruby, Scala and Swift files in both folders. It turns the code of each function into a vector with a code embedding model that runs inside jscpd (CodeRankEmbed by default), so two functions that do the same job point the same way even when their languages, names and structure differ. Functions of one folder are never compared with each other.
Functions pair in two steps:
- By code. Two functions pair when each is the other's closest match in the other folder, their cosine similarity reaches the model's threshold (0.4125 across languages and 0.6375 within one language, with CodeRankEmbed), and the similarity stands out from the function's other matches. A function close to the best one also pairs when it reaches a higher bar, so a feature written twice on one side gets two pairs. Functions shorter than
--min-tokens(30 with--compare) or--min-lines(5) stay out of this step, because a short function resembles too many others. - By name. A function left over pairs with a function of the other folder under the same name, once case, underscores, spaces and punctuation are ignored (
encodeBinary,encode_binary,_encode_binary; the test titlerounds centsandrounds_cents), when their similarity reaches themediumlevel (0.5625 across languages with CodeRankEmbed). A name pair skips the closest-match and stand-out checks of the first step, so it needs more than that step's threshold; otherwise everyloadandinitof two codebases would pair. Size does not matter here, so a short port is found. A name pair has to stay within modules the first step linked. A module is the folder right under the deepest folder all files of a side share (notificationinandroid/notification/…), and a file that sits higher than the rest, such as a build script, does not move that folder up. Two modules link when one holds the most of the other's pairs, counted for code and for tests separately. SocheckPermissionsof one plugin does not pair with its namesake in another.
Each pair gets a level on the scale of the model, because a cosine that is high for one model is low for another:
| Level | With CodeRankEmbed, across languages | Meaning |
high | 0.7125 and up | almost always the same function |
medium | 0.5625 to 0.7125 | usually the same function, restructured |
low | 0.4125 to 0.5625 | read both: related code pairs here too |
jscpd measures tests and code apart, in two blocks of the report, and pairs a test only with a test. It tells a test by the conventions of its language:
- a test file such as
*_test.go,test_*.py,*.test.ts,*.spec.js,*Tests.swiftor*_spec.rb; - a test folder such as
tests/,__tests__/,spec/,src/test/(where Java, Kotlin and Scala keep their tests) orMyAppTests/, the compared folder's own name included; - a Rust function in a
#[cfg(test)]module or under#[test]; - a JavaScript or TypeScript test case such as
it('rounds cents', () => …).
When neither side has a test that counts (see below), the report has one block and no headings.
Totals count the functions of at least --min-tokens tokens and --min-lines lines; smaller ones appear only as partners. Declarations without a body (TypeScript overloads, the functions of a .d.ts file, interface and abstract methods) take no part. Anonymous functions (callbacks, closures) take no part either, except JavaScript and TypeScript test cases. A test case such as it('rounds cents', () => …) goes by its title, and so do those written with test, specify, fit, xit, xtest or bench, with .only, .skip or .each(table) after them. Suites and hooks stay anonymous. jscpd does not compare types, constants, SQL or UI markup.
A way to compare two folders
1. Pick the folders
- Point at the code, not the repositories:
app/src/main/javaandios/Sources, not the two repository roots. Build output, vendored code, installed packages and generated files dilute the result, and a vendored dependency tree can turn a run of seconds into one of tens of minutes, since every function in it is embedded. Inside a git repository jscpd skips what.gitignoreexcludes; outside one, or for folders the.gitignoremisses, pass them with--ignore(--ignore "**/vendor/**,**/target/**,**/node_modules/**"). When a side has no.gitignoreentries for such folders, suggest them to the user. - Two folders are required, and they must not overlap:
app/andapp/android/is refused. - Keep parallel structures when you can (
ios/<module>andandroid/<module>). Modules steer the name step, so matching folder names help. - For a port, put the source first and the target second, so the first line of the report is the port's progress. For two implementations that both live on, the order does not matter.
- One run covers tests and code, since the report measures the tests in a block of their own. When the user asks about the code alone, leave the tests out with
--ignore "**/__tests__/**,**/*.test.*,**/test/**". When they ask about the tests alone, pass the two test folders as the paths, or pick the test files with--pattern.
2. Get the model
The first run needs the model (548 MB). Ask the user before downloading it:
npx jscpd --semantic-downloadjscpd caches the vectors per pair of folders, so later runs embed only the functions whose code changed.
3. Read the overview
npx jscpd --compare billing-py/ billing-ts/ 71% 5 of 7 functions in billing-py/ have a counterpart in billing-ts/
80% 4 of 5 functions in billing-ts/ have a counterpart in billing-py/
billing-py/
file paired similarity counterpart
billing.py 4 / 5 0.89 billing.ts
shipping.py 1 / 2 0.91 shipping.ts
billing-ts/
file paired similarity counterpart
billing.ts 3 / 4 0.89 billing.py
shipping.ts 1 / 1 0.91 shipping.py
Paired under other names (1):
billing-py/ billing-ts/ similarity
billing.py:28 tax_for_region billing.ts:27 salesTax 0.87 high
Only in billing-py/ (2):
billing.py (1)
46 due_date 6 lines
shipping.py (1)
18 estimate_delivery_days 8 lines
Only in billing-ts/ (1):
billing.ts (1)
39 toCurrency 8 lines- When both folders hold tests, the report has a
Codeblock and aTestsblock, each with everything below. The two top lines of a block give the share of each folder's functions (or tests) that have a counterpart in the other. - The file tables give each file's paired functions, the mean similarity of its pairs (with the number of
lowpairs, as in0.62, 1 low), and the file on the other side that holds most of its counterparts. - "Paired under other names" lists the pairs whose names differ even once case and underscores are ignored. A search by name never finds these.
- "Only in" lists the functions with no counterpart, per folder, grouped by file with the number of each file's functions, then each function's first line, name and length.
- In colour, levels are green (
high), yellow (medium) and red (low), and the shares are green when complete, yellow when partial and red when nothing is paired. Pass--no-colorswhen you parse the console output, or read the JSON report instead. - If one folder has no functions, the report is one line of totals and
<folder> has no functions yet. Check the path and the languages before concluding anything else.
4. Check the pairs
npx jscpd --compare billing-py/ billing-ts/ -r console-fullconsole-full adds every pair with its similarity and level, and marks the pairs found by name. Before reporting the comparison as reliable, read a sample:
- two or three
highpairs, to confirm the pairing works on this code; - every
lowpair, since related code pairs there too (a client call and the endpoint it calls, a function counting UTF-8 bytes and one converting a string to them); - the pairs marked
by name, since a same-named function can do something else.
When a sample pair is wrong, say which one and why.
5. Check the functions with no counterpart
A function in an "Only in" list is either missing on the other side, or its counterpart was not recognized. Before calling it missing, search the other folder: in its counterpart file, under other names, as part of a larger function, or replaced by a library or platform call. The known gaps in pairing:
- constructors across languages (a Java constructor and Rust's
new, Kotlin'sconstructor, Swift'sinit) pair only when their code is similar enough; - a short function renamed on the other side (
add_historyfor_finder_penalty_add_history); - one function split into several, or several merged into one: only the closest part may pair.
Functions that exist on one side only by design are expected: platform glue (an iOS delegate callback, an Android notification channel), helpers a language needs and another does not, features one side dropped.
6. Report
For the user, summarize in a few lines: the two percentages, the notable renamed pairs, the low pairs you checked and what you found, and the real gaps on each side, grouped by file or module. For a person who wants to explore the result, write the migration map, -r html: one offline page that draws both sides as dependency graphs with the pairs bridging them, and lists the same pairs as a table on a second tab. For a document or an issue, write the Markdown report and attach or paste it:
npx jscpd --compare billing-py/ billing-ts/ -r markdown -o .jscpd-compareFor your own processing, read the JSON report (-r json, written to jscpd-compare.json). It has a code and a tests section of the same shape. Each has sides[0] and sides[1], each with path, functions, matched, percentage, files (file, functions, matched, counterpart, similarity, lowPairs) unmatched (file, name, start, end) and readyToPort (the unmatched functions whose callees all have a counterpart, each with its number of callers), and pairs, each with a, b, similarity, level, renamed and matchedBy. Paths are relative to each folder. Write reports outside the repository or add the folder to .gitignore.
Options that change the result
--min-tokensand--min-linesset which functions count. Raise them to focus on substantial functions.--ignoreand--formatnarrow the files, for example to leave out tests or build scripts.--semantic-modelpicks another model, and--semantic-urlan OpenAI-compatible embeddings API;npx jscpd --semantic-modelslists the models with calibrated thresholds.--semantic-thresholdand--semantic-same-thresholdmove the thresholds; change them only after reading pairs on both sides of the new value.--semantic-rebuild-cacheembeds everything again, which is needed only when the cache is suspect.
Keep the folders, their order, the options and the model the same when you compare runs over time, or the numbers stop being comparable. The exit code is 0 whatever the result.
Limits
- Similarity does not see small differences in behavior: two versions that drifted apart still pair, often at
high. Only tests and reading the code catch drift. - The more one side is restructured, the fewer of its functions pair by code.
- Only functions are compared.
- The model runs on the CPU. The first run embedded about 25 functions a second on an Apple M1 (261 functions in 11 seconds) and can be several times slower on a small CI machine; later runs reuse the cache.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

