jscpd
Skill này làm gì
Skill giải thích cách chạy công cụ phát hiện trùng lặp jscpd và đọc kết quả. Dành cho lập trình viên muốn đo hoặc giảm mã lặp lại trên nhiều ngôn ngữ.
Khi nào nên dùng
- ✓Khi lập trình viên muốn biết bao nhiêu phần của dự án là mã sao chép-dán.
- ✓Khi một đội muốn có danh sách ngắn các file trùng lặp nhiều nhất.
- ✓Khi lập trình viên muốn tìm các bản gần giống đã được sửa sau khi dán.
Liên kết skill
https://github.com/kucherenko/jscpd/blob/master/skills/jscpd/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
“Có bao nhiêu phần của dự án này là mã sao chép-dán, và tôi nên xem file nào trước?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill chạy công cụ với định dạng báo cáo gọn, rồi liệt kê các khối khớp và tóm tắt các file trùng lặp nhiều nhất.
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.
jscpd
Copy-paste detector for programming source code, supports 220+ languages. Use this skill to run jscpd and understand its output.
Quick Start
# Run with ai reporter (compact output optimized for agents)
npx jscpd --reporters ai <path>
# With ignore patterns
npx jscpd --reporters ai --ignore "**/node_modules/**,**/dist/**" <path>
# Scope to specific formats
npx jscpd --reporters ai --format "javascript,typescript" <path>
# Second pass, noisier: copies that only differ in names and values (Type-2, "renamed").
# Review each hit before acting on it.
npx jscpd --reporters ai --ignore-identifiers --min-tokens 70 <path>
# Third pass, noisier still: copies with a few edited lines or the same function
# structure (Type-3, "similar"). Keep the settings tight.
npx jscpd --reporters ai --max-gap-lines 1 --similarity <path>
# Where to refactor first: clone list plus a hotspot summary
npx jscpd --reporters ai --summary <path>
# Most complex files only, without clone detection
npx jscpd --complexity --reporters ai <path>
AI Reporter Output Format
The ai reporter produces compact, token-efficient output designed for agent consumption:
Clones:
src/ foo.ts:10-25 ~ bar.ts:42-57
src/utils/helpers.ts:100-120 ~ src/utils/other.ts:5-25
src/cart/ basket.js:1-9 ~ cart.js:1-9 (renamed)
src/api/ save-account.js:1-12 ~ save-user.js:1-11 [~0.91 gap]
src/billing/ orders.ts:1-14 ~ refunds.ts:1-15 [~0.85 ast]
---
5 clones · 4.2% duplication
Each line represents one clone pair:
- Same file:
path/file.ts 10-25 ~ 45-60(shared path shown once) - Same directory:
shared/prefix/ file-a.ts:10-25 ~ file-b.ts:42-57(common prefix factored out) - Different paths:
path/a.ts:10-25 ~ path/b.ts:42-57
A suffix tells the kind of clone; no suffix means an exact copy:
(renamed): the two blocks differ only in identifier names, literal values or annotations (Type-2). Only appears with--ignore-identifiers,--ignore-literalsor--ignore-annotations.[~0.91 gap]: two exact clones merged across up to--max-gap-linesunmatched lines (Type-3). The number is matched tokens over the merged span.[~0.85 ast]: two functions whose normalized syntax trees share at least--similarityof their subtrees (Type-3). The number is that share. The names of called functions and methods and the operators count, local names and literal values do not, so a renamed copy with other constants scores 1 and a copy that calls other methods scores lower. A name still has to stand for one name on the other side: a copy that swaps the roles of two names scores lower.
Options
| Option | Description |
|---|---|
--reporters ai |
Use the AI-optimized reporter (compact clone list for agents) |
--reporters html |
Generate HTML report |
--reporters json |
Output JSON report |
--min-tokens N |
Minimum tokens to consider a duplication (default: 50) |
--min-lines N |
Minimum lines to consider a duplication (default: 5) |
--threshold N |
Exit with error if duplication % exceeds N |
--ignore "glob" |
Ignore patterns (comma-separated) |
--format "list" |
Limit to specific languages (e.g. typescript,javascript) |
--cross-formats "groups" |
Detect clones across related formats (e.g. javascript,typescript or the js-ts preset) |
--ignore-identifiers |
Treat all identifiers as equal, so blocks that differ only in variable, function or type names match (Type-2, reported as renamed); a name must stand for one name on the other side, so look-alikes with another data flow stay out, while a field and a local of one text are two names, so this.url = url still matches this.url = link (--ignore-identifiers=blind matches any names) |
--ignore-literals |
Treat all string literals as equal and all numeric literals as equal (Type-2) |
--ignore-annotations |
Drop @Name / @Name(...) annotations and decorators before matching, in languages where @ means one (Type-2) |
--max-gap-lines N |
Merge clones of one file pair separated by at most N unmatched lines into one similar clone (Type-3, default: 0 = off) |
--similarity [RATIO] |
Report pairs of functions whose normalized syntax trees share at least RATIO of their subtrees, in (0, 1], as similar clones (Type-3, 0.8 without a value). JavaScript, TypeScript, Python, Java, Kotlin, Scala, C#, Go, Rust, C, C++, PHP, Ruby, Swift and Clojure; test files are left out |
--min-nodes N |
The fewest |
Câu hỏi thường gặp
Nó hỗ trợ bao nhiêu ngôn ngữ?
Skill nói rằng nó hỗ trợ hơn 200 ngôn ngữ.
Bản sao đổi tên là gì?
Đó là bản sao chỉ thay đổi tên biến hoặc giá trị.
Kết quả có luôn là lỗi không?
Không. Skill nói các lượt quét nhiễu hơn có thể đánh dấu mã trông giống nhau, nên cần đọc từng kết quả trước khi hành động.
Chi tiết
Mô tả gốc của tác giả
Copy-paste detector for 220+ languages. Detect exact, renamed and near-miss duplicated code, measure duplication percentages, and find refactoring hotspots with the codebase summary.
repo: kucherenko/jscpd
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #14191
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
code-migration
6.5kGiúp agent của bạn chuyển mã từ ngôn ngữ hoặc framework này sang cái khác, từng hàm một, có kiểm thử trước và đo tiến độ so với bản gốc.
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.
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á.