Developer

Code Deduplicator

Scans your codebase for duplicated code from the current session. Compares new functions, components, and utilities against existing code, then refactors automatically.

/techdebt Free
X-Ray: what this skill can and cannot do
Shell access git diff, git status (scoped)
Network calls No
File writes Yes (refactors duplicated code)
File reads Full codebase scan
Destructive ops No
Credential access No
Scope Project only

Why this exists

During a coding session, you write fast. You solve the problem in front of you. But the same pattern might already exist three directories away in a utility you forgot about. By the time you commit, the codebase has two (or three) copies of the same logic.

This skill catches that. Run it at the end of a session and it finds every piece of code you just wrote that duplicates something already in the project, then refactors it automatically.

How it works

  1. Reads the git diff Runs git diff HEAD and git status to identify everything added or modified in the current session. If everything is committed, it falls back to the last 5 commits.
  2. Runs three parallel scans Three independent tasks run at the same time: one for component and layout duplication, one for logic and utility duplication, one for API route and server duplication.
  3. Categorises each finding Every duplicate is classified as exact (same logic exists elsewhere), near (similar with minor differences), or inline reimplementation (hand-rolled version of an existing utility).
  4. Refactors automatically Exact duplicates are deleted and replaced with imports. Near duplicates get extracted into shared functions. Inline reimplementations are swapped for the existing utility call.
  5. Runs your test suite After refactoring, it runs your project's tests and linter to make sure nothing broke.

What the three scans cover

Scan 1: Components and layouts

Searches .tsx and .jsx files for components with similar names, prop signatures, or JSX structure. Catches copy-pasted layout files, duplicated page patterns, and wrapper components that differ only in minor styling.

Scan 2: Logic and utilities

Searches all JS/TS files for functions, hooks, and utilities with similar implementations. Catches hand-rolled formatDate when one already exists in lib/, duplicated fetch wrappers, and near-identical hooks that only differ in endpoint.

Scan 3: API routes and server logic

Searches API route handlers, middleware, and server files for shared request parsing, response shaping, auth checks, and validation logic.

Honest take

What it does well: Three parallel scans means it covers components, logic, and API routes at the same time. It catches the things you miss when you are building fast: the utility you forgot existed two folders away, the hook you copy-pasted and tweaked instead of extracting, the validation logic you wrote inline because importing felt slower than just writing it again. I use this at the end of every session. It consistently finds things I would have missed in review.

What it does not do: It only compares what you wrote in this session against what already existed. Duplication that was there before you started is not its problem. It is built for JavaScript and TypeScript projects. Other languages will work, but the glob patterns may need adjusting. It also needs a working test suite in your project to verify the refactoring. If your tests are broken before you run this, they will still be broken after.

When to use it: End of any coding session where you shipped fast and want to clean up before committing. Prototyping sessions, feature sprints, anything where speed came first and architecture came second. Run it before your PR, not after someone flags duplication in review.

Use this skill in your project

Download the .md file, drop it into .claude/skills/, and run /techdebt.

Download .md