返回 Skill 列表
extension
分类: 开发与工程无需 API Key

jscpd

查找重复的代码块并分析文件间的重复度指标。在识别复制粘贴的代码、衡量技术债务或准备重构时使用。

person作者: jakexiaohubgithub

jscpd

Copy-paste detector for JavaScript, TypeScript, and many other languages.

Quick Start

# With ignore patterns
bunx jscpd --ignore "**/node_modules/**,**/dist/**" <path>

Common Options

| Option | Description | | ------------------ | ---------------------------------------- | | --min-tokens N | Minimum tokens for duplicate detection | | --min-lines N | Minimum lines for duplicate detection | | --threshold N | Fail if duplication % exceeds threshold | | --ignore "glob" | Ignore patterns (comma-separated) | | --reporters type | Output format: console, json, html | | --output path | Output directory for reports | | --silent | Suppress console output |

Workflow

  1. Run jscpd to find duplicates
  2. Review the reported duplicates
  3. Refactor to eliminate duplication
  4. Re-run to verify cleanup

Related Skills

  • maintenance: Refactoring and technical debt management
  • design: DRY principle violations
  • ast-grep: Structural refactoring of duplicated patterns