code-clone-assistant

code-clone-assistant is a skill for Claude Code from terrylica/cc-skills. It costs 33 tokens per session (1,691 once invoked), scanned A, original, MIT.

A code-analysis workflow that finds copied or closely similar code using PMD CPD and Semgrep. It also guides refactoring those repeated sections.

In plain words
What is it for?
Use it to scan files for exact duplicates or similar code patterns, identify DRY violations, and plan refactoring.
Why use it?
It helps reveal copy-and-paste code and repeated patterns that can make a codebase harder to change consistently.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md; mentions Claude Code.

Part of the quality-tools plugin — 11 skills shipped together , and of cc-skills

Good fit Use it to scan files for exact duplicates or similar code patterns, identify DRY violations, and plan refactoring.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/terrylica/cc-skills/code-clone-assistant
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add terrylica/cc-skills --skill code-clone-assistant
Clone the repo
git clone --depth 1 https://github.com/terrylica/cc-skills

Made for: Claude Code.

Or install quality-tools, the plugin that ships this one along with the rest of its 11 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-clone-assistant

README.md
[![agentmods](https://agentmods.dev/badge/skills/terrylica/cc-skills/code-clone-assistant.svg)](https://agentmods.dev/skills/terrylica/cc-skills/code-clone-assistant)
Your own site
<a href="https://agentmods.dev/skills/terrylica/cc-skills/code-clone-assistant"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/code-clone-assistant.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,691 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00033 $0.01691
Opus 5 $0.00016 $0.00846
Sonnet 5 $0.00007 $0.00338
Haiku 4.5 $0.00003 $0.00169

Measured 2d ago against content hash 56b18a24393a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

code-clone-assistant scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/quality-tools/skills/code-clone-assistant/SKILL.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Code Clone Assistant

Detect code clones and guide refactoring using PMD CPD (exact duplicates) + Semgrep (patterns).

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

Tools

  • PMD CPD v7.17.0+: Exact duplicate detection
  • Semgrep v1.140.0+: Pattern-based detection

Tested: October 2025 - 30 violations detected across 3 sample files Coverage: ~3x more violations than using either tool alone


When to Use This Skill

Use this skill when:

  • Finding duplicate code in a codebase
  • Detecting DRY violations
  • Refactoring similar code patterns
  • Identifying copy-paste code

Why Two Tools?

PMD CPD and Semgrep detect different clone types:

Aspect PMD CPD Semgrep
Detects Exact copy-paste duplicates Similar patterns with variations
Scope Across files ✅ Within/across files (Pro only)
Matching Token-based (ignores formatting) Pattern-based (AST matching)
Rules ❌ No custom rules ✅ Custom rules

Result: Using both finds ~3x more DRY violations.

Clone Types

Type Description PMD CPD Semgrep
Type-1 Exact copies ✅ Default
Type-2 Renamed identifiers --ignore-*
Type-3 Near-miss with variations ⚠️ Partial ✅ Patterns
Type-4 Semantic clones (same behavior)

Quick Start Workflow

# Step 1: Detect exact duplicates (PMD CPD)
pmd cpd -d . -l python --minimum-tokens 20 -f markdown > pmd-results.md

# Step 2: Detect pattern violations (Semgrep)
semgrep --config=clone-rules.yaml --sarif --quiet > semgrep-results.sarif

# Step 3: Analyze combined results (Claude Code)
# Parse both outputs, prioritize by severity

# Step 4: Refactor (Claude Code with user approval)
# Extract shared functions, consolidate patterns, verify tests

Read the full file on GitHub · 169 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 169 lines · 33 tokens per session scan A 56b18a24393a

Subscribe to this mod's changes

code-clone-assistant is a skill published in the GitHub repository terrylica/cc-skills (62 stars, last pushed yesterday), licensed MIT. It adds 33 tokens to every session and 1,691 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

generic-react-code-reviewer

Review React/TypeScript code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md workflow compliance. Enforces TypeScript strict mode, GPU-accelerated animations, WCAG AA accessibility, bundle size limits, and surgical simplicity. Use when completing features, before commits, or…

travisjneuman/.claude · 71 tokens

generic-fullstack-code-reviewer

Review full-stack code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md compliance. Enforces TypeScript strict mode, input validation, GPU-accelerated animations, and design system consistency. Use when completing features, before commits, or reviewing pull requests.

travisjneuman/.claude · 64 tokens

generic-static-code-reviewer

Review static site code for bugs, security issues, performance problems, accessibility gaps, and CLAUDE.md compliance. Enforces pure HTML/CSS/JS standards, minimal page weight, mobile-first design. Use when completing features, before commits, or reviewing changes.

travisjneuman/.claude · 59 tokens

generic-code-reviewer

Review code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md workflow compliance. Supports any tech stack - HTML/CSS/JS, React, TypeScript, Node.js, Python, NestJS, Next.js, and more. Use when completing features, before commits, or reviewing pull requests.

travisjneuman/.claude · 70 tokens

plan-review-architecture

Architecture-dimension reviewer for written plans. Use when running plan-review or directly when an architectural review is wanted. Activate for keywords like "architecture review", "data flow", "failure modes", "rollback", "edge cases", "test matrix". Scores 5 sub-dimensions 0-10, produces ranked fixes. Always cite…

duthaho/claudekit · 87 tokens

reviewing

Claude-on-Claude code review protocol — reviews implementation against spec requirements and code quality standards.

LucasDuys/forge · 19 tokens