code-dedup
БесплатноБез исполняемых скриптовНе проверенSearches for duplicate code, duplicate tests, and dead code, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates"…
от Nimblesite★ 68 звёзд на GitHubОб этом скилле
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.
- Run
make test— all tests must pass. If tests fail, stop. Do not dedup a broken codebase. - Run
make test— tests are fail-fast AND enforce the coverage threshold fromcoverage-thresholds.json. If anything fails, stop and fix it before deduping. - Verify the project uses static typing. Check for:
- Rust, C#, F#, Dart, Go: typed by default — proceed
- TypeScript:
tsconfig.jsonmust have"strict": true— proceed (Lql/LqlExtension already does) - Untyped JavaScript: STOP. Refuse to dedup. Print: "This codebase has no static type checking. Deduplication without types is reckless — too high a risk of silent breakage. Add type checking first."
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 5: Changes applied
- [ ] Step 6: Verification passed (tests green, coverage stable)
Step 1 — Inventory test coverage
Before deciding what to touch, understand what is tested.
- Run
make testto confirm green baseline.make testis fail-fast AND enforces the coverage threshold fromcoverage-thresholds.json(REPO-STANDARDS-SPEC [TEST-RULES], [COVERAGE-THRESHOLDS-JSON]). It exits non-zero on any test failure OR coverage shortfall. - Note the current coverage percentage — this is the floor. It must not drop.
- 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.
- Look for unused exports, unused functions, unused classes, unused variables.
- Use language-appropriate tools where available:
- C#/F#: analyzer warnings (CA1801 unused parameters, IDE0051 unused private members) via
make lint - Rust:
cargo clippyalready warns on dead code — checkmake lintoutput - TypeScript:
noUnusedLocals/noUnusedParametersintsconfig.json; look for unexported functions with zero references
- C#/F#: analyzer warnings (CA1801 unused parameters, IDE0051 unused private members) via
- For each candidate: grep the entire repo (including tests, scripts, samples). Skip generated code under
Lql/lql-lsp-rust/crates/lql-parser/src/generated/. Only mark as dead if truly zero references. - 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.
- Look for functions/methods with identical or near-identical logic.
- Look for copy-pasted blocks (same structure, maybe different variable names).
- Look for multiple implementations of the same algorithm — particularly likely across
DataProvider/,Migration/,Sync/,Reporting/C# projects, and acrossLql/Nimblesite.Lql.CoreSQL transpiler dialects (Postgres,SqlServer,SQLite). - Check across module boundaries — duplicates often hide in different
.csprojprojects or Rust crates (lql-parser,lql-analyzer,lql-lsp). - For each duplicate pair: note both locations, what they do, and how they differ (if at all).
- List all duplicates found. Do NOT merge yet.
Step 4 — Scan for duplicate tests
Search for tests that verify the same behavior.
- Look for test functions with identical assertions against the same code paths.
- Look for test fixtures/helpers that are duplicated across test projects (
Tests.Shared/is meant to hold these). - 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 "Prefer E2E/integration tests").
- 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.
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 testexits 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. Prefer placing shared code in
Tests.Shared/(for test helpers) or the closest.Coreproject (e.g.Sync/Nimblesite.Sync.Core,Lql/Nimblesite.Lql.Core). - 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 diff
Установить code-dedup в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл code-dedup?
Searches for duplicate code, duplicate tests, and dead code, 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.
Как установить скилл code-dedup?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл code-dedup запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic