anti-duplication
Before implementing new code (endpoints, components, services, models), search the codebase for existing patterns to reuse. Prevent code duplication by…
от marcusgoll★ 97 звёзд на GitHub
Установить anti-duplication в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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.
<quick_start> <trigger_pattern> 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..."</trigger_pattern>
Step 2: Search codebase for similar patterns
- 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) </basic_workflow>
<immediate_value> **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 patternsAfter 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 </immediate_value> </quick_start>
**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:
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 for detailed patterns.
**Execute searches in parallel**Run multiple searches concurrently for speed:
Search batch:
- Grep: "product" in **/*.tsx (find all product-related components)
- Grep: "ProductDetail" (find similar detail components)
- Glob: "/components//Product*.tsx" (find product component files)
- Grep: "interface.*Product" (find product type definitions)
- Grep: "display.*product.*props" (find rendering logic)
All 5 searches run in parallel (see parallel-execution-optimizer skill).
Time: ~5-10 seconds for comprehensive search across large codebase.
**Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- examples/api-endpoint-reuse.md
- references/reuse-patterns.md
- references/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), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis 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…