Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Dedup Merge

ASecurity

Find copy-pasted code (functions, classes, components, modules, queries), merge each duplicate group into one shared function or component with the differences passed as a variant, and report the before/after line counts. Use when the user runs /dedup-merge or asks to check for duplicated code, merge duplicates, or make copy-pasted code share one implementation.

2 stars
0 votes
0 copies
0 views
Added 9/28/2026
ai-agentsbashgitapi

Works with

api

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add TonyLikeDev/TrustMeBro --skill dedup-merge --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dedup Merge?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Dedup Merge
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tonylikedev-dedup-merge/badge)](https://www.skillsdirectory.com/skills/tonylikedev-dedup-merge)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: dedup-merge
description: Find copy-pasted code (functions, classes, components, modules, queries), merge each duplicate group into one shared function or component with the differences passed as a variant, and report the before/after line counts. Use when the user runs /dedup-merge or asks to check for duplicated code, merge duplicates, or make copy-pasted code share one implementation.
---

# Dedup merge

Purpose: copy-pasted code becomes one implementation, so there is less to read and change. "Merge" here means code merging, not git merging. Success is a smaller and simpler codebase, so measure it (step 5).

## 1. Find the duplicates

- Read `LAYOUT.md` if it exists. Look for files or folders with parallel names (`admin/` vs `user/`, `create_order` vs `create_invoice`, `ProductCard` vs `ServiceCard`) and for functions with the same shape under different names.
- If the project already has a duplicate detector (`jscpd`, PMD CPD, pylint's `duplicate-code` check), run it instead of comparing by hand.
- Diff each candidate pair (`diff a b | wc -l`, or compare line counts) and note how much of it is identical.
- List each group with its files, its size and its overlap, sorted by lines saved. Show the list to the user before merging anything, unless they already said "merge them".

## 2. Decide per group: merge, extract or leave

| Overlap | Action |
|---|---|
| About 70% identical or more | Merge into one implementation. The differences become a variant. |
| About 40 to 70% | Extract only the identical blocks as helpers. Leave the callers in place. |
| Under about 40% | Leave as is. |

Also leave as is:
- Groups that have a comment explaining why they are separate.
- Groups whose shared part is only a few lines (under about 20): a helper that small costs more to follow than it saves.
- Groups where one side has a feature the other lacks (undo, an extra step), unless it becomes a clean variant.
- Code that is deliberately separate: generated files, vendored code, test fixtures, and copies kept apart on purpose (different release cycles, different owners).

A merge that needs more adapter and type lines than it saves is the wrong call. Undo it and say so.

## 3. Merge with variants

- One shared file holds the common code. The differences come in as a `kind` parameter (`kind: "admin" | "user"`) or a small option (`read_only=True`), not as copied branches.
- Put everything that differs in one place, a config object or one loader function, so a reader sees the whole difference at once.
- Follow a pattern already in the repo (an existing variant parameter, config object or base class) before inventing a new one.
- Delete the old files and any helper that only they used. Keep old entry points (routes, pages, public functions, exported names) as thin wrappers when something outside the group depends on them.
- Merge the most identical groups first (usually UI components and pure helpers). Merge data-access code (queries, API handlers, server actions) last: it is usually the least identical, so it saves the least.

## 4. Verify

- Run the project's checks (tests, type checker, linter), whichever exist. Fix failures before reporting.
- If a UI change was not checked in a browser or app, say so.
- Write down every visible behaviour change (URLs or parameters, wording, control style, error messages). A merge should not change behaviour, and when it must, tell the user.
- Update `LAYOUT.md` in the same change: the folder tree (delete old entries, add the new files) and the Logic list (point each merged piece of logic at the shared function). Do not commit unless asked.

## 5. Report with numbers

Compare committed `HEAD` with the working tree per merged group:

```bash
# before: sum of the old files at HEAD; after: the new files
for f in old1 old2; do git show HEAD:"$f" | wc -l; done
wc -l new1 new2
git diff --shortstat HEAD -- <files of the merged groups>
```

Show one table (group, before, after, net, %) and one total. Then explain any gap between the expected saving (about half for exact copies) and the real one:

- **Similarity**: the fewer lines were really identical, the less the merge saves.
- **Adapter objects**: the per-caller config that restates what the old code did inline.
- **Types**: the definitions the shared code needs to describe what each caller supplies.
- **Comments**: added explanations of why the variants differ.

Count "lines added" in the diff separately from net size. New shared files show up as all-new lines even when the total shrinks, which is why a merge can look like growth in a diff.

Attribution

TonyLikeDevTonyLikeDev
View sourceMore from TonyLikeDev →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1074701 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

695601 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

691 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →