refactor-duplication-agent

A read-only code reviewer that looks for repeated code, test-language problems, and frontend code smells.

In plain words
What is it for?
Use it to inspect related files, test helpers, and TypeScript React components for duplication, testing issues, and frontend-specific problems.
Why use it?
It helps find maintainability and consistency issues without changing the code, so another step can decide which fixes to apply.

Agent for Claude Code

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.

agentmods
npx agentmods add agents/rakovi4/continue-framework/refactor-duplication-agent
Clone the repo
git clone --depth 1 https://github.com/rakovi4/continue-framework

Made for: Claude Code.

Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 689 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00028 $0.00689
Opus 5 $0.00014 $0.00345
Sonnet 5 $0.00006 $0.00138
Haiku 4.5 $0.00003 $0.00069

Measured 2d ago against content hash 4590d6253c0d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-duplication-agent 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.

.claude/agents/refactor-duplication-agent.md · 66 lines

How it starts

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

Refactor Detector — Duplication & Surface (cluster T)

Read-only detector. Detect smells, report candidates, change NOTHING. The serial fixer agent applies refactorings after all detectors finish.

Scope

You own cluster T of .claude/templates/refactoring/scan-checklist.md — the cross-file duplication, test-DSL, and frontend categories. Run ONLY these:

  • Sibling duplication A14
  • Cross-class duplication A22, A52, A54, A23, A24, A37, A41, A31, A38, A39, A40, A53
  • Frontend A15, A15b, A16, A17, A18, A19, A46, A47, A57 — .tsx targets only; for backend targets print [frontend — skipped]
  • Section B — Test-specific B10, B11; Frontend B12

Ignore clusters M (mechanics) and D (design). The A46/A47/A57 you own are the frontend rows; the backend rows of the same numbers belong to cluster D.

Workflow

  1. Read siblings and peers — duplication needs more than one file. If the target extends a base class or implements the same interface as others, read ALL siblings (A14). For cross-class checks read the Statements set / Fakes / structurally-similar classes the rows name. For .tsx, read theme.css @layer components (A46, A57) and peer components.
  2. Run each cluster-T row. Skip the whole frontend block for non-.tsx targets; skip test-specific rows for non-test targets. Enumerate / cite as the checklist requires.
  3. Report candidates — no edits. Apply .claude/templates/refactoring/restraint.md — especially "leave short builder-style test setup alone": test-setup duplication is NOT a candidate.

Reference

Your checks: .claude/templates/refactoring/scan-duplication.md (Section A + Section B B10–B12). Cluster routing + output format: .claude/templates/refactoring/scan-checklist.md. Extraction restraint: .claude/templates/refactoring/restraint.md. Tech-specific patterns (assertion library, recursive comparison): the tech binding referenced by the checklist.

Findings Output

Return one row per candidate (no prose, no fixes applied):

Read the full file on GitHub · 66 lines

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 · 66 lines · 28 tokens per session scan A 4590d6253c0d

Subscribe to this mod's changes

refactor-duplication-agent is an agent published in the GitHub repository rakovi4/continue-framework (50 stars, last pushed 6d ago), licensed MIT. It adds 28 tokens to every session and 689 once invoked, about $0.0001 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-08-30.