anti-duplication
БесплатноБез исполняемых скриптовНе проверенBefore implementing new code (endpoints, components, services, models), search the codebase for existing patterns to reuse. Prevent code duplication by…
Об этом скилле
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:
- Search phase: Find existing similar implementations (endpoints, components, services, models)
- Reuse or justify: Either reuse/extend existing code OR justify why new implementation is necessary
The result: Codebases stay DRY, maintainable, and consistent.
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 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)
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
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)
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
Установить anti-duplication в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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), без исполняемых скриптов.
Похожие скиллы
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