用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/kucherenko/jscpd --skill jscpd命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | jscpd |
| description | Copy-paste detector for 220+ languages. Detect duplicated code and measure duplication percentages. |
Copy-paste detector for programming source code, supports 150+ languages. Use this skill to run jscpd and understand its output.
# 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>
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
---
3 clones · 4.2% duplication
Each line represents one clone pair:
path/file.ts 10-25 ~ 45-60 (shared path shown once)shared/prefix/ file-a.ts:10-25 ~ file-b.ts:42-57 (common prefix factored out)path/a.ts:10-25 ~ path/b.ts:42-57| 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) |
--min-similarity N | Minimum similarity percentage (default: 100, range: 1-100) |
--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) |
--pattern "glob" | Glob pattern to select files |
--gitignore | Respect .gitignore |
--output "path" | Directory to write reports to |
--silent | Suppress output (useful with --output only) |
--list-output | Print clone list to stdout (alternative to ai reporter) |
--store-path "path" | Directory for LevelDB cache |
--no-tips | Disable tips in output (enabled by default in CI) |
--config "path" | Path to .jscpd.json config file |
By default each format is compared only against itself. --cross-formats defines groups of related formats that share one comparison pool, so a block duplicated between a .js and a .ts file is reported as a clone:
# One group: compare JavaScript and TypeScript files together
npx jscpd --reporters ai --cross-formats "javascript,typescript" <path>
# Preset covering javascript, jsx, typescript, tsx
npx jscpd --reporters ai --cross-formats "js-ts" <path>
# Multiple groups are separated by ";"
npx jscpd --reporters ai --cross-formats "javascript,typescript;css,scss" <path>
Notes:
function f(a: number): void matches function f(a). Reported positions still reference the original source.crossFormats (or cross-formats) and accepts a string ("javascript,typescript;css,scss"), an array of strings (["javascript,typescript", "css,scss"]), or an array of arrays ([["javascript","typescript"],["css","scss"]]).Create a .jscpd.json in your project root:
{
"threshold": 0,
"reporters": ["ai"],
"ignore": ["**/node_modules/**", "**/dist/**", "**/*.min.*"],
"format": ["typescript", "javascript"],
"minLines": 5,
"minTokens": 50,
"output": "./reports/jscpd"
}
Once you've detected clones, use the dry-refactoring skill for a guided workflow to eliminate them:
→ dry-refactoring — step-by-step refactoring strategies and workflow for removing duplication. Install with:
npx skills add https://github.com/kucherenko/jscpd --skill dry-refactoring