dedup

A workflow for finding repeated or near-identical functions and consolidating them into one shared implementation. It also adds a test that helps prevent the duplication from returning.

In plain words
What is it for?
Use it to remove duplicate helpers, consolidate repeated code, review duplication reports, and protect the cleanup with a test.
Why use it?
It separates meaningful copy-and-paste code from harmless matches and keeps future changes from recreating the same problem.

Skill for Claude CodeCodex

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 skills/edimuj/tokenlean/dedup
Any agent
npx skills add edimuj/tokenlean --skill dedup
Clone the repo
git clone --depth 1 https://github.com/edimuj/tokenlean

Made for: Claude Code, Codex.

Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,642 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00069 $0.01642
Opus 5 $0.00034 $0.00821
Sonnet 5 $0.00014 $0.00328
Haiku 4.5 $0.00007 $0.00164

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

Security

Grade A, and why

dedup scanned grade A with 1 finding 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

import { execFileSync } from 'node:child_process';
skills/claude/dedup/SKILL.md · 164 lines

How it starts

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

Dedup

tl dupes finds duplicates; removing them well is the skill. Most of the output is noise, the wins hide in two tiers, and the mitigation that actually sticks is non-obvious: you remove the second home, not "fix both copies."

Workflow

Scan → Triage → Mitigate → Verify → Ratchet

1. Scan

tl dupes --near        # structural + near surfaced first; tests excluded by default

Via the MCP tool, near is a number (the similarity threshold), not a flag: mcp__callmux__tl_dupes { near: 0.85 }. Passing near: true fails schema validation — the CLI's bare --near defaults that threshold for you.

Files copied verbatim into another tool (e.g. a plugin shipped into a user's config dir) are external contracts — their duplicate helpers are by-design, not cleanup targets. tl dupes excludes them by default. Mark your own in .tokenleanrc.json:

{ "externalContractFiles": ["src/my-copied-plugin.js"] }

Use tl dupes --near --include-contracts only when you deliberately want to audit those copies too.

2. Triage by tier — signal vs. noise

tl dupes returns four tiers. Treat them differently:

  • Structural + near = signal. Renamed clones and copy-paste-with-edits — the drift-prone ones. Start here.
  • Exact = quick wins, but check intent first. Two trivial pass-throughs colliding (return [...this.x.values()]) aren't always worth a shared home.
  • Names = mostly noise. Idiomatic repeats (update, close, get, logger levels). Skim, don't mine — add --no-names once you've glanced.

3. The "real dupe?" test

The rule that separates worth-fixing from leave-it:

  • Same rule encoded twice → collapse it. Validation, response unwrapping, a path-containment check, a magic constant, a normalization step. These are the drift hazards: one copy gets a fix, the other doesn't, and a phantom bug surfaces weeks later.
  • Same shape by coincidence → leave it. Logger debug/info/warn/error, SSE emit* helpers, store thunks, thin HTTP wrappers. Merging hurts readability for zero safety gain.

Read the full file on GitHub · 164 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 · 164 lines · 69 tokens per session scan A 69d5d02eaec4

Subscribe to this mod's changes

dedup is a skill published in the GitHub repository edimuj/tokenlean (11 stars, last pushed 1mo ago), licensed MIT. It adds 69 tokens to every session and 1,642 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

zerodust

Sweep 100% of native gas tokens (ETH, BNB, MATIC, etc.) from EVM chains via ZeroDust, leaving exactly zero balance. Use when: user wants to exit a chain completely, consolidate dust balances, clean up wallets, or bridge remaining native tokens cross-chain. Supports 25 mainnet chains including Ethereum, Base, Arbitrum…

andresdefi/zerodust · 93 tokens

ctx2img

Cut context tokens by rendering it as images. ctx2img paint turns any text-shaped input (a repo, a directory, a file, markdown, stdin) into dense images that carry the full text at 60-75% fewer tokens, with stable handles and a verbatim factsheet; ctx2img read recovers guaranteed-exact text. Use before ingesting any…

Koukyosyumei/h5i-ctx2img · 103 tokens

r3f-animation

React Three Fiber animation - useFrame, useAnimations, spring physics, keyframes. Use when animating objects, playing GLTF animations, creating procedural motion, or implementing physics-based movement.

zebbern/claude-code-guide · 43 tokens

design-system-builder

Extract design systems from reference UI images and generate implementation-ready UI design prompts. Use when users provide UI screenshots/mockups and want to create consistent designs, generate design systems, or build MVP UIs matching reference aesthetics.

zebbern/claude-code-guide · 47 tokens

r3f-best-practices

React Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.

zebbern/claude-code-guide · 74 tokens

log-error-digest

Analyze log files to troubleshoot errors, identify peak error periods, and produce error clustering, frequency statistics, and time distribution reports. Supports JSON, syslog, and Nginx formats with automatic detection. Use when a user uploads a .log file and asks to analyze errors, find patterns, debug issues, or…

zebbern/claude-code-guide · 71 tokens