Code Clone Assistant
This tool helps you quickly find and understand similar code snippets (clones) to accelerate development and improve code quality.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add code-clone-assistant npx -- -y @trustedskills/code-clone-assistant
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"code-clone-assistant": {
"command": "npx",
"args": [
"-y",
"@trustedskills/code-clone-assistant"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
The Code Clone Assistant helps you identify and understand similar code snippets (clones) within a codebase to improve code quality and accelerate development. It leverages two tools, PMD CPD for detecting exact duplicates and Semgrep for finding patterns with variations. Combining these tools allows the skill to detect approximately 3x more potential DRY (Don't Repeat Yourself) violations than using either tool alone.
When to use it
- Finding duplicate code in a codebase
- Detecting DRY violations
- Refactoring similar code patterns
- Identifying copy-paste code
Key capabilities
- Exact Duplicate Detection: Uses PMD CPD (v7.17.0+) to find exact copies of code.
- Pattern-Based Detection: Employs Semgrep (v1.140.0+) to identify similar code patterns with variations, using custom rules.
- Combined Analysis: Provides a combined analysis of results from both PMD CPD and Semgrep for more comprehensive clone detection.
- Clone Type Identification: Differentiates between various clone types including exact copies (Type-1), near misses (Type-3) and those with renamed identifiers (Type-2).
Example prompts
- "Find duplicate code in this Python file."
- "Detect potential DRY violations in my project's codebase."
- "Identify similar code patterns that I can refactor."
Tips & gotchas
- Not all duplication is bad: The skill highlights the importance of checking for accepted exceptions before recommending refactoring, as some intentional copy-and-adapt patterns should be preserved (e.g., in generation-per-directory experiments or SQL templates).
- Semgrep requires configuration: Semgrep uses a
clone-rules.yamlfile to define pattern matching rules. - Pro Semgrep needed for cross-file analysis: The Semgrep tool has limited scope, only allowing within/across files with the Pro version.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.