compare-codebases
Ce qu’il fait
Ce guide explique comment associer les fonctions de deux bases de code et signaler ce que l'une possède et que l'autre n'a pas. Il s'adresse aux développeurs qui vérifient le lien entre deux projets ou l'avancement d'un portage.
Quand l’utiliser
- ✓Quand une équipe veut savoir quelles fonctions une version d'application possède et que l'autre n'a pas.
- ✓Quand un développeur veut vérifier que les versions iOS et Android d'une application concordent.
- ✓Quand un développeur doit trouver quelle fonction d'un dossier correspond à une fonction d'un autre dossier.
Lien du skill
https://github.com/kucherenko/jscpd/blob/master/skills/compare-codebases/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Comparez nos dossiers de code iOS et Android, et dites-moi quelles fonctions manquent à l'application Android.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Le skill lance une comparaison qui associe les fonctions selon ce qu'elles font plutôt que selon leur nom. Il explique ensuite les fonctions associées et non associées en termes simples.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
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. A pair stays only when it is the best match of at least one of its two functions, so a lookalike from another class does not join a function and its counterpart; a tie goes to the file of the same name. 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),MyAppTests/orMyApp.Tests.Integration/, 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,
Questions fréquentes
Faut-il le même langage ?
Non. Les deux dossiers peuvent être dans des langages différents, comme Python et TypeScript.
Associe-t-il les fonctions par leur nom ?
Non. Il associe les fonctions selon leur rôle, à l'aide d'un modèle d'embeddings de code.
Compare-t-il des fonctions d'un même dossier ?
Non. Il compare uniquement les fonctions entre les deux dossiers.
Détails
Description originale de l’auteur
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.
repo: kucherenko/jscpd
Popularité
- Étoiles GitHub
- 6.5k
- Position au classement
- #14189
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
code-migration
6.5kAide votre agent à porter du code d'un langage ou d'un framework vers un autre, une fonction à la fois, avec des tests d'abord et une progression mesurée par rapport à l'original.
codebase-refactoring
6.5kAide votre agent à améliorer la santé d'une base de code en corrigeant le code dupliqué, en supprimant le code mort et en simplifiant les fichiers les plus complexes, dans cet ordre.
dry-refactoring
6.5kAide votre agent à supprimer le code copié-collé d'un projet en regroupant les blocs répétés dans des fonctions communes, en commençant par les répétitions les plus importantes.
jscpd
6.5kAide votre agent à trouver le code copié-collé d'un projet, sous forme exacte, renommée ou approximative, et à mesurer la part de code dupliquée.
Skills similaires
diffs
394kPermet à votre agent de produire un diff réel et partageable de vos modifications, sous forme de lien ou d'image, plutôt qu'un résumé écrit à la main.
coding-agent
394kAide votre agent à confier une tâche de programmation plus importante à Codex, Claude Code ou OpenCode comme travailleur en arrière-plan, puis à suivre sa progression.
gh-issues
394kAide votre agent à trouver des tickets GitHub, choisir ceux à traiter et ouvrir des pull requests avec des correctifs, y compris le suivi des commentaires de relecture.