Agent skill
jscpd
Finds duplicate code blocks and analyzes duplication metrics across files. Use when identifying copy-pasted code, measuring technical debt, or preparing for refactoring.
Install this agent skill to your Project
npx add-skill https://github.com/knoopx/pi/tree/main/agent/skills/jscpd
SKILL.md
jscpd
Copy-paste detector for JavaScript, TypeScript, and many other languages.
Quick Start
# Scan a directory, ignoring build artifacts
bunx jscpd --ignore "**/node_modules/**,**/dist/**" src/
# Scan with threshold — exit code 1 if duplication exceeds 5%
bunx jscpd --threshold 5 --ignore "**/node_modules/**,**/dist/**" src/
Common Options
| Option | Description |
|---|---|
--min-tokens N |
Minimum tokens for duplicate detection (default: 50) |
--min-lines N |
Minimum lines for duplicate detection (default: 5) |
--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
- Scan: Run jscpd to detect duplicates
bash
bunx jscpd --reporters console --ignore "**/node_modules/**,**/dist/**" src/ - Review: Examine each reported duplicate pair — decide whether to extract a shared function, merge files, or accept the duplication
- Refactor: Extract shared logic into a helper, utility, or base class. Common patterns:
- Identical functions in multiple files → extract to shared module
- Similar functions with small differences → parameterize or use generics
- Repeated config blocks → extract to a shared config file
- Verify: Re-run with a threshold to confirm duplication is within target
bashIf the command exits with code 0, duplication is below the threshold.
bunx jscpd --threshold 5 --ignore "**/node_modules/**,**/dist/**" src/
Example: JSON Report for CI
bunx jscpd --reporters json --output ./reports src/
# Produces reports/jscpd-report.json with structured duplicate data
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
conventional-commits
Writes and reviews Conventional Commits commit messages (v1.0.0) to support semantic versioning and automated changelogs. Use when drafting git commit messages, PR titles, release notes, or when enforcing a conventional commit format (type(scope): subject, BREAKING CHANGE, footers, revert).
nix-flakes
Creates reproducible builds, manages flake inputs, defines devShells, and builds packages with flake.nix. Use when initializing Nix projects, locking dependencies, or running nix build/develop commands.
skill-authoring
Writes effective pi skills with proper structure, concise content, and progressive disclosure. Use when creating new skills, improving existing skills, or reviewing skill quality.
gtkx
Build GTK4 desktop applications with GTKX React framework. Use when creating React components that render as native GTK widgets, working with GTK4/Libadwaita UI, handling signals, virtual lists, menus, or building Linux desktop UIs.
nu-shell
Processes structured data through pipelines, filters tables, transforms JSON/CSV/YAML, and defines custom commands. Use when scripting with typed parameters or working with tabular data.
nix
Runs packages temporarily, creates isolated shell environments, and evaluates Nix expressions. Use when executing tools without installing, debugging derivations, or working with nixpkgs.
Didn't find tool you were looking for?