Agent skill

Code Dedup

by Nimblesite in Nimblesite/SharpLsp

Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them.

MITAuto-check passedTesting & QA

Install Code Dedup

skills CLI
$ npx skills add Nimblesite/SharpLsp --skill code-dedup -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Nimblesite/SharpLsp code-dedup --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Nimblesite/SharpLsp.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/code-dedup .claude/skills/code-dedup && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
code-dedup
GitHub stars
137
Token cost
~1.6k tokens
SKILL.md length
854 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them.

  • Works in 6 steps: Inventory test coverage → Scan for dead code → Scan for duplicate code → …
  • The user says deduplicate
  • SKILL.md covers Prerequisites — hard gate, Steps and Rules
  • Calls make

What it does

Code Dedup is an agent skill from Nimblesite/SharpLsp. Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Test coverage and Code simplification. It works with TypeScript. The licence is MIT.

When your agent uses it

  • The user says deduplicate
  • Find duplicates
  • Remove dead code

Example prompts

  • “deduplicate”
  • “find duplicates”
  • “remove dead code”
  • “/code-dedup”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Inventory test coverage
  2. Scan for dead code
  3. Scan for duplicate code
  4. Scan for duplicate tests
  5. Apply changes (one at a time)
  6. Final verification

What it can do on your machine

Read from SKILL.md and the folder at commit 34f38bf. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Code Dedup loads about 1.6k tokens when it runs. Until then it costs about 73 tokens; SKILL.md has 854 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Nimblesite/SharpLsp at commit 34f38bf, republished under its MIT licence (© Nimblesite). 854 words, ~1,592 tokens.

Download SKILL.mdSave it as .claude/skills/code-dedup/SKILL.md (or your agent's skills folder).
name
code-dedup
description
Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code.
<!-- agent-pmo:2efd847 -->

Code Dedup

Carefully search for duplicate code, duplicate tests, and dead code across the repo. Merge duplicates and delete dead code — but only when test coverage proves the change is safe.

Prerequisites — hard gate

Before touching ANY code, verify these conditions. If any fail, stop and report why.

  1. Run make test — all tests must pass. If tests fail, stop. Do not dedup a broken codebase.
  2. Run make test — tests are fail-fast AND enforce the coverage threshold from coverage-thresholds.json. If anything fails, stop and fix it before deduping.
  3. Verify the project uses static typing. Check for:
    • Rust, C#, F#: typed by default — proceed
    • TypeScript: tsconfig.json must have "strict": true — proceed

Steps

Copy this checklist and track progress:

Dedup Progress:
- [ ] Step 1: Prerequisites passed (tests green, coverage met, typed)
- [ ] Step 2: Dead code scan complete
- [ ] Step 3: Duplicate code scan complete
- [ ] Step 4: Duplicate test scan complete
- [ ] Step 5a: Dead code removed
- [ ] Step 5b: Duplicate code merged
- [ ] Step 5c: Duplicate tests removed
- [ ] Step 6: Verification passed (tests green, coverage stable)
Step 1 — Inventory test coverage

Before deciding what to touch, understand what is tested.

  1. Run make test to confirm green baseline. make test is fail-fast AND enforces the coverage threshold from coverage-thresholds.json. It exits non-zero on any test failure OR coverage shortfall.
  2. Note the current coverage percentage per project — this is the floor. It must not drop.
  3. Identify which files/modules have coverage and which do not. Only files WITH coverage are candidates for dedup.
Step 2 — Scan for dead code

Search for code that is never called, never imported, never referenced.

  1. Look for unused exports, unused functions, unused classes, unused variables
  2. Use language-appropriate tools:
    • Rust: the compiler already warns on dead code — check make lint output for clippy warnings
    • TypeScript: check for noUnusedLocals/noUnusedParameters in tsconfig, look for unexported functions with zero references
    • C#: Roslyn analyzer warnings IDE0051 (unused private member), IDE0052 (unread private member), CS0169 (unused field)
    • F#: compiler warnings FS0040 (unused value), FS0060 (unused binding)
  3. For each candidate: grep the entire codebase for references (including tests, scripts, configs). Only mark as dead if truly zero references.
  4. List all dead code found with file paths and line numbers. Do NOT delete yet.
Step 3 — Scan for duplicate code

Search for code blocks that do the same thing in multiple places.

  1. Look for functions/methods with identical or near-identical logic
  2. Look for copy-pasted blocks (same structure, maybe different variable names)
  3. Look for multiple implementations of the same algorithm or pattern
  4. Check across module boundaries — duplicates often hide in different Rust crates, .NET sidecar projects, or TypeScript modules
  5. For each duplicate pair: note both locations, what they do, and how they differ (if at all)
  6. List all duplicates found. Do NOT merge yet.
Step 4 — Scan for duplicate tests

Search for tests that verify the same behavior.

  1. Look for test functions with identical assertions against the same code paths
  2. Look for test fixtures/helpers that are duplicated across test files
  3. Look for integration tests that fully cover what a unit test also covers (keep the integration test, mark the unit test as redundant per CLAUDE.md rules)
  4. List all duplicate tests found. Do NOT delete yet.
Step 5 — Apply changes (one at a time)

For each change, follow this cycle: change -> test -> verify coverage -> continue or revert.

Show full SKILL.md (346 more words)Show less
5a. Remove dead code
  • Delete dead code identified in Step 2
  • After each deletion: run make test (fail-fast + coverage + threshold all in one)
  • If make test exits non-zero (test failure OR coverage drop): revert immediately and investigate
  • Dead code removal should never break tests or drop coverage
5b. Merge duplicate code
  • For each duplicate pair: extract the shared logic into a single function/module
  • Update all call sites to use the shared version
  • After each merge: run make test
  • If tests fail: revert immediately. The duplicates may have subtle differences you missed.
  • If coverage drops: the shared code must have equivalent test coverage. Add tests if needed before proceeding.
5c. Remove duplicate tests
  • Delete the redundant test (keep the more thorough one)
  • After each deletion: run make test
  • If coverage drops below threshold, make test exits non-zero — revert immediately. The "duplicate" test was covering something the other wasn't.
Step 6 — Final verification
  1. Run make lint — all linters must pass
  2. Run make test — tests must pass AND coverage must remain >= the baseline from Step 1
  3. Report: what was removed, what was merged, final coverage vs baseline

Rules

  • No test coverage = do not touch. If a file has no tests covering it, leave it alone entirely. You cannot safely dedup what you cannot verify.
  • Coverage must not drop. If removing or merging code causes coverage to decrease, revert and investigate. The coverage floor from Step 1 is sacred.
  • One change at a time. Make one dedup change, run tests, verify coverage. Never batch multiple dedup changes before testing.
  • When in doubt, leave it. If two code blocks look similar but you're not 100% sure they're functionally identical, leave both. False dedup is worse than duplication.
  • Preserve public API surface. Do not change pub function signatures, public class members, or export declarations that external code depends on. Internal refactoring only.
  • Three similar lines is fine. Do not create abstractions for trivial duplication. The cure must not be worse than the disease. Only dedup when the shared logic is substantial (>10 lines) or when there are 3+ copies.

© Nimblesite, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/code-dedup of Nimblesite/SharpLsp.

Open the folder on GitHubat commit 34f38bf

Compare with similar skills

Code Dedup next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Code Dedup compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Code Dedup this skillNimblesite/SharpLsp137—~1.6kAutomated safety check: PassMIT
Test Writing WorkflowiOfficeAI/AionUi33k1 repos~1.2kAutomated safety check: PassApache-2.0
Apprunyysun/apprun1.2k—~1.3kAutomated safety check: PassMIT
Supercovsupercorp-ai/supercov1481 repos~415Automated safety check: PassMIT
Coverage Toolszkldi/Tachi237—~580Automated safety check: PassNone
Write Testsopenplayerjs/openplayerjs649—~1.8kAutomated safety check: PassMIT

Similar skills

  • Test Writing Workflow

    iOfficeAI/AionUi

    Sets the test-writing workflow for the repository: risk-first scenario lists, behavior-focused Vitest tests, a full run before each commit and a coverage target.

    33k GitHub starsUsed in 1 repo~1.2k tokens
    Testing & QAAuto-check passed
  • Apprun

    yysun/apprun

    AppRun architecture guidance for building, reviewing, or fixing AppRun applications and the AppRun library itself.

    1.2k GitHub stars~1.3k tokensUpdated 2 mo ago
    Testing & QAAuto-check passed
  • Supercov

    supercorp-ai/supercov

    Measures test coverage and code quality in a repository with the supercov CLI, and turns what it finds into small, focused tests or fixes.

    148 GitHub starsUsed in 1 repo~415 tokens
    Testing & QAAuto-check passed
  • Coverage Tools

    zkldi/Tachi

    Aggregates Vitest v8/Istanbul coverage across Tachi workspaces via tachi-coverage-tools (manifest, CLI, optional programmatic API).

    237 GitHub stars~580 tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Write Tests

    openplayerjs/openplayerjs

    Write or extend Jest tests for OpenPlayerJS to this repo's exact conventions — makeCore factories, typed internals handles instead of as any, media property mocking, fake timers, ads/vast mocks, and…

    649 GitHub stars~1.8k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Supercov Security

    supercorp-ai/supercov

    Scans a repository's source for security vulnerabilities with the supercov CLI, pointing to the line of each finding and mapping it to CWE classes.

    148 GitHub starsUsed in 1 repo~236 tokens
    Testing & QAAuto-check passed

More from Nimblesite/SharpLsp

  • CI Prep

    Nimblesite/SharpLsp

    Prepares the current branch for CI by running the exact same steps locally and fixing issues.

    137 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Upgrade Packages

    Nimblesite/SharpLsp

    Upgrades all project dependencies to latest compatible versions.

    137 GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Code Dedup

What does Code Dedup do?

Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them. Code Dedup is an agent skill from Nimblesite/SharpLsp. Searches for duplicate code, duplicate tests, and dead code across the SharpLsp repo, then safely merges or removes them.

When should I use Code Dedup?

Code Dedup fits situations like: the user says deduplicate; find duplicates; remove dead code.

How do I install Code Dedup in Claude Code?

Run `npx skills add Nimblesite/SharpLsp --skill code-dedup -a claude-code`. Or copy the skill folder (.agents/skills/code-dedup in Nimblesite/SharpLsp) into .claude/skills/code-dedup in your project. Claude Code loads it when a task matches its description.

How do I install Code Dedup in Codex?

Run `npx skills add Nimblesite/SharpLsp --skill code-dedup -a codex`. Or copy the skill folder (.agents/skills/code-dedup in Nimblesite/SharpLsp) into .agents/skills/code-dedup in your project. Codex loads it when a task matches its description.

Can I use Code Dedup in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Nimblesite/SharpLsp --skill code-dedup -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/code-dedup, .gemini/skills/code-dedup, .github/skills/code-dedup and .opencode/skills/code-dedup in your project.

What does Code Dedup need to run?

Going by SKILL.md and its folder, Code Dedup needs the command-line tools its instructions call (make).

Does Code Dedup access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Code Dedup safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Code Dedup use?

Code Dedup is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Code Dedup use?

About 1.6k tokens (SKILL.md is roughly 6.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Code Dedup?

Skills that share tags, products or a category with Code Dedup: Test Writing Workflow (iOfficeAI/AionUi, 33k stars), Apprun (yysun/apprun, 1.2k stars), Supercov (supercorp-ai/supercov, 148 stars) and Coverage Tools (zkldi/Tachi, 237 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Code Dedup?

Nimblesite (a GitHub organization) maintains it in Nimblesite/SharpLsp, which has 137 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 6, 2026.

Source: Nimblesite/SharpLsp on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.