본문으로 건너뛰기
Skillpedia
일반 코딩6.5k · #14189

compare-codebases

하는 일

두 코드베이스의 함수를 짝짓고, 각각 다른 쪽에 없는 것을 보고하는 방법을 설명합니다. 두 프로젝트가 어떻게 관련되어 있는지, 또는 포팅이 얼마나 진행됐는지 확인하려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓팀이 앱의 한 버전에는 있고 다른 버전에는 없는 함수를 알고 싶을 때.
  • ✓개발자가 앱의 iOS 버전과 Android 버전이 일치하는지 확인하려 할 때.
  • ✓개발자가 한 폴더의 함수가 다른 폴더의 어떤 함수에 해당하는지 찾아야 할 때.

스킬 링크

https://github.com/kucherenko/jscpd/blob/master/skills/compare-codebases/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/kucherenko/jscpd/blob/master/skills/compare-codebases/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 iOS 코드 폴더와 Android 코드 폴더를 비교해서, Android 앱에 빠진 함수가 무엇인지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 함수 이름이 아니라 기능을 기준으로 함수를 짝짓는 비교를 실행합니다. 그다음 일치한 함수와 일치하지 않은 함수를 쉬운 말로 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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:

  1. 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.
  2. 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 title rounds cents and rounds_cents), when their similarity reaches the medium level (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 every load and init of 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 (notification in android/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. So checkPermissions of 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.swift or *_spec.rb;
  • a test folder such as tests/, __tests__/, spec/, src/test/ (where Java, Kotlin and Scala keep their tests), MyAppTests/ or MyApp.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,

자주 묻는 질문

같은 언어여야 하나요?

아니요. 두 폴더는 Python과 TypeScript처럼 다른 언어여도 됩니다.

함수 이름으로 짝을 짓나요?

아니요. 코드 임베딩 모델을 사용해 함수가 하는 일을 기준으로 짝을 짓습니다.

한 폴더 안의 함수끼리도 비교하나요?

아니요. 두 폴더 사이의 함수만 비교합니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
6.5k
순위
#14189
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬