Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

anti-duplication

БесплатноБез исполняемых скриптовНе проверен

Before implementing new code (endpoints, components, services, models), search the codebase for existing patterns to reuse. Prevent code duplication by…

marcusgollот marcusgoll★ 97 звёзд на GitHub25 установок в других каталогах

Об этом скилле

The anti-duplication skill enforces the DRY (Don't Repeat Yourself) principle by proactively searching the codebase for existing patterns before writing new code. This prevents code duplication, reduces maintenance burden, and promotes code reuse.

Code duplication creates maintenance nightmares:

  • Bug fixes must be applied in multiple places
  • Features evolve inconsistently across duplicates
  • Refactoring becomes exponentially harder
  • Codebase grows unnecessarily large
  • Onboarding takes longer (more code to learn)

This skill transforms "implement X" requests into a two-phase workflow:

  1. Search phase: Find existing similar implementations (endpoints, components, services, models)
  2. Reuse or justify: Either reuse/extend existing code OR justify why new implementation is necessary

The result: Codebases stay DRY, maintainable, and consistent.

When user says "create", "implement", "add", or "build" new functionality, **IMMEDIATELY** search for existing similar code before writing anything new.

Trigger phrases:

  • "Create a new API endpoint for..."
  • "Implement a component that..."
  • "Add a service to handle..."
  • "Build a model for..."
  • "Write a function that..."
**Step 1**: Extract search keywords from request - User: "Create an API endpoint to fetch user profile" - Keywords: "API endpoint", "fetch", "user", "profile", "GET"

Step 2: Search codebase for similar patterns

PRIMARY: Semantic search (mgrep)

  • mgrep for: "API endpoints that fetch user data", "profile retrieval handlers"
  • Finds similar implementations by meaning, not exact text

SECONDARY: Literal search (Grep/Glob)

  • Grep for: "router.get", "app.get", "/api/user", "profile"
  • Glob for: "/user.ts", "/profile.ts", "/routes/"

Step 3: Analyze findings

  • Found 3 similar endpoints: GET /api/user/:id, GET /api/user/settings, GET /api/admin/users
  • All use same auth middleware, validation pattern, error handling

Step 4: Present reuse options

  • Option A: Extend existing GET /api/user/:id to include profile data
  • Option B: Create new endpoint using same patterns as existing user endpoints
  • Option C: Justify why completely new approach is needed

Step 5: Implement chosen option (with existing patterns as template)

**Before anti-duplication skill**: User: "Create an API endpoint to update user email" Claude: *Writes new endpoint from scratch with different auth, validation, error handling* Result: 5th variation of similar endpoint, inconsistent patterns

After anti-duplication skill: User: "Create an API endpoint to update user email" Claude: Searches codebase, finds 4 existing user endpoints with consistent patterns Claude: "Found 4 similar user endpoints. They all use: authMiddleware, validateUserInput, standardErrorHandler. I'll create the new endpoint following this established pattern." Result: Consistent implementation, reused middleware, maintainable code

**Parse the implementation request**

Extract key information:

  • Type: What are they building? (endpoint, component, service, model, function, utility)
  • Domain: What business domain? (user, product, order, payment, auth)
  • Operation: What action? (create, read, update, delete, fetch, validate, transform)
  • Technology: What stack? (React, Express, TypeScript, SQL, GraphQL)

Example parsing:

Request: "Create a React component to display product details"

Parsed:
- Type: React component
- Domain: Product
- Operation: Display/render
- Technology: React, TypeScript (likely)
**Generate search strategies**

Create multiple search approaches to maximize coverage:

PRIMARY: Semantic search (mgrep) Use mgrep FIRST for pattern discovery - finds similar code by meaning:

  • "components that display product information"
  • "services that handle email sending"
  • "validation logic for user input"
  • "error handling patterns in API routes"

mgrep finds UserCard, ProductCard, ProfileView when searching for "display user details" even if names don't match.

SECONDARY: Literal searches (when mgrep insufficient)

A. Keyword-based searches (Grep):

  • Core domain terms: "product", "Product", "PRODUCT"
  • Operation terms: "display", "render", "show", "view"
  • Technology patterns: "React.FC", "function Component", "const.=.=>"

B. File pattern searches (Glob):

  • Domain files: "/product.tsx", "/Product.tsx"
  • Location patterns: "/components//Detail.tsx", "/components//Product*"
  • Type-specific: "/models/Product", "/services/product"

C. Structural searches (Grep with regex):

  • Class definitions: "class.*Product"
  • Function exports: "export (function|const).*product"
  • API patterns: "router.(get|post|put|delete).*product"

See [references/search-strategies.md](referen

Полный SKILL.md на GitHub

Установить anti-duplication в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/api-endpoint-reuse.mdreferences/reuse-patterns.mdreferences/search-strategies.md

FAQ

Что делает скилл anti-duplication?

Before implementing new code (endpoints, components, services, models), search the codebase for existing patterns to reuse. Prevent code duplication by finding and suggesting similar implementations. Auto-trigger when user asks to create, implement, add, or build new functionality.

Как установить скилл anti-duplication?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл anti-duplication запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить anti-duplication с