code-migration
Skill này làm gì
Skill đưa ra phương pháp chuyển một ứng dụng hoặc thư viện sang ngôn ngữ khác và kiểm tra từng hàm khi làm. Dành cho lập trình viên viết lại phần mềm, chẳng hạn ứng dụng Java chuyển sang Kotlin.
Khi nào nên dùng
- ✓Khi một đội muốn chuyển một thư viện từ ngôn ngữ lập trình này sang ngôn ngữ khác.
- ✓Khi lập trình viên cần xem hàm nào đã được chuyển và hàm nào còn lại.
- ✓Khi một đội muốn kiểm tra xem hai phiên bản của cùng một ứng dụng có còn hoạt động giống nhau không.
Liên kết skill
https://github.com/kucherenko/jscpd/blob/master/skills/code-migration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Giúp tôi chuyển thư viện Python này sang TypeScript, từng hàm một, và theo dõi những gì còn lại.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill dùng một công cụ so sánh để ghép mỗi hàm mã nguồn với hàm tương ứng. AI được yêu cầu chuyển các bài kiểm thử trước, rồi đến mã mà chúng kiểm tra, và dùng kết quả để theo dõi tiến độ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
code-migration
jscpd --compare SOURCE TARGET pairs every function of one folder with the function of the other folder that does the same job, in any pair of languages, and lists the functions that have no counterpart. This skill uses it to measure a port: what is ported, what is left, and whether the port you just wrote was recognized.
A port runs in two phases: the tests first, then the code they check. A coverage report of the source's tests tells which tests exercise which function, so each function is ported together with the tests that prove it works. See Plan: tests first, then code.
Two words are used throughout:
- source: the implementation you port from, such as the iOS app, the Python library, or the JavaScript package;
- target: the implementation you port to, such as the Android app, the Rust crate, or the TypeScript rewrite.
Neither has to be old or new. The source may stay in production and keep changing, and the target may already hold features the source lacks. For two implementations that both live on (ios/ and android/), the same report shows parity; see Parity.
jscpd finds functions in JavaScript, TypeScript, JSX, TSX, Vue, Svelte, Astro, Python, Rust, Go, Java, Kotlin, C#, C, C++, PHP, Ruby, Scala and Swift. The compare-codebases skill explains how the comparison pairs functions and how to check its result; the jscpd skill covers the rest of the tool.
Setup
--compare pairs functions with a code embedding model that runs inside jscpd. Download it once (548 MB, CodeRankEmbed). Ask the user before you start the download:
npx jscpd --semantic-download
jscpd caches the vectors, so a repeat run embeds only the functions whose code changed and takes seconds.
Pick the two paths and keep them fixed for the whole port: the source first, the target second. Two paths are required, and they must not overlap (app/ and app/android/ is refused). The target may be empty at the start.
One run measures both phases: the report has a Code block and a Tests block (a code and a tests section in JSON), and a test pairs only with a test. jscpd tells a test by the conventions of its language: test files such as *_test.go, test_*.py, *.test.ts or *Test.java, folders such as tests/, __tests__/ or src/test/, Rust tests in #[cfg(test)] modules, and JavaScript test cases such as it('rounds cents', () => …). Phase 1 reads the Tests block, phase 2 the Code block.
Keep vendored and generated code out
--compare counts and embeds every function in both paths. Vendored dependencies (vendor/ from cargo vendor or go mod vendor, third_party/), installed packages (node_modules/, .venv/), build output (target/, build/, dist/) and generated code are not part of the port, yet a vendored crate tree alone holds thousands of functions. With them in a path, the first run embeds all of them and takes tens of minutes instead of seconds, and the percentages describe the dependencies instead of the port.
jscpd skips what .gitignore excludes, but only inside a git repository. Before the first run:
Check both paths for such folders. A target you create for the port gets them as soon as you build it or vendor its dependencies, so check again after the first build.
Suggest a
.gitignoreto the user that lists the folders the target's language and tools produce, plus the report folder. For a Rust addon built with napi-rs:/target/ /vendor/ node_modules/ *.node .jscpd-compare/If the target is not in a git repository, tell the user that jscpd reads the
.gitignoreonly aftergit init.Until the
.gitignoreworks, pass the same folders with--ignore, and keep the globs the same for every run:npx jscpd --compare node-lib/ rust-lib/ --ignore "**/vendor/**,**/target/**,**/node_modules/**"
The totals line shows when something slipped through. Suspect vendored or generated code in a path when the target has far more functions than the source, or when a run embeds hundreds of functions after a small change.
Measure
Run the console report for yourself and for the user. Here a Python billing library is being ported to TypeScript:
npx jscpd --compare billing-py/ billing-ts/
71% 5 of 7 functions in billing-py/ have a counterpar
Câu hỏi thường gặp
Nó theo dõi tiến độ bằng cách nào?
Nó dùng một báo cáo so sánh cho biết hàm nào có bản khớp trong mã còn lại và hàm nào không.
Vì sao phải viết kiểm thử trước?
Mỗi hàm được chuyển cùng các kiểm thử chứng minh nó hoạt động, nên phiên bản mới có thể được kiểm tra khi phát triển.
Nó có so sánh được hai ứng dụng cùng đang được dùng không?
Có. Cùng báo cáo đó có thể cho thấy hai bản triển khai đang chạy khớp với nhau đến mức nào.
Chi tiết
Mô tả gốc của tác giả
Move code from one implementation to another function by function, tests first and code second, and check two implementations of one app for parity, with jscpd --compare as the progress measure and a coverage map binding each function to its tests. Use when porting a library or app to another language or framework (Java to Kotlin, JavaScript to Rust, a Python library to TypeScript, an iOS app to Android), when asked what is left to port, or when comparing the Android and iOS versions of an app.
repo: kucherenko/jscpd
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #14187
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
codebase-refactoring
6.5kGiúp agent của bạn cải thiện sức khỏe mã nguồn bằng cách sửa mã trùng lặp, xóa mã chết và đơn giản hóa các file phức tạp nhất, theo đúng thứ tự đó.
compare-codebases
6.5kGiúp agent của bạn so sánh hai thư mục mã từng hàm một, kể cả khác ngôn ngữ, để xem hàm nào khớp và hàm nào còn thiếu.
dry-refactoring
6.5kGiúp agent của bạn loại bỏ mã sao chép-dán khỏi dự án bằng cách gộp các khối lặp lại thành hàm dùng chung, bắt đầu từ những khối lặp lại nhiều nhất.
jscpd
6.5kGiúp agent của bạn tìm mã sao chép-dán trong dự án ở dạng chính xác, đổi tên hoặc gần giống, và đo mức độ trùng lặp của mã.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.