Getting Started
Agent Skill
Use jscpd with AI coding assistants to automatically detect and refactor code duplications.
Overview
jscpd includes an agent skill for skills.sh that teaches AI coding assistants (Claude, Copilot, Gemini, Cursor, and others) how to detect and eliminate code duplication automatically.
Installation
Terminal
npx skills add kucherenko/jscpd
Once installed, the skill is available to your AI assistant in any project.
What the Skill Does
When activated, the skill instructs the agent to:
- Run jscpd with the
aireporter on the target path - Parse the detected clone pairs (file paths + line ranges)
- Read both duplicated code fragments from the source files
- Design a refactoring — extracting a shared function, module, constant, or base class
- Apply the refactoring and update all call sites
- Re-run jscpd to confirm the duplication is eliminated
- Repeat for remaining clones, highest-impact first
How It Uses the AI Reporter
The skill uses the ai reporter, which produces compact, token-efficient output optimized for agent consumption:
Terminal
npx jscpd --reporters ai ./src
Example output:
Clones:
src/utils/ auth.ts:10-25 ~ helpers.ts:40-55
src/utils/auth.ts 30-45 ~ 80-95
---
2 clones · 3.1% duplication
This format uses ~79% fewer tokens than the default reporter, keeping context usage low while giving the agent everything it needs to locate and fix each duplication.
More Information
- Skill page: skills.sh/kucherenko/jscpd
- Source:
SKILL.mdin the jscpd repository - AI Reporter docs: Reporters