Deduplicate

From swissarmyhammer/swissarmyhammer · View interactive version

Deduplicate is an AI agent skill from the GitHub repository swissarmyhammer/swissarmyhammer. Find and refactor duplicate code. Use this skill when the user wants to find near-duplicate code, check for copy-paste redundancy, or DRY up a codebase — optionally scoped to changed files.

How to use this skill

Skill file

Deduplicate

Find near-duplicates with tree-sitter semantic similarity, then refactor to remove redundancy.

Process

  1. Scope:
  1. Check tree-sitter index: {"op": "get status"} — must be ready before detection.
  1. Detect: treesitter op: "find duplicates" on scoped files. For each cluster note: what's duplicated, severity, refactor opportunity (extract function, module, trait).
  1. Refactor (if requested, not just analysis):
  1. Track on kanban for clusters needing human decision:

```json

{"op": "init board"}

{"op": "add tag", "id": "duplicate", "name": "Duplicate Code", "color": "ff8800", "description": "Near-duplicate code needing refactoring"}

{"op": "add task", "title": "<concise description>", "description": "<files and lines>\n\n<what's duplicated>\n\n<suggested refactoring>", "tags": ["duplicate"]}

```

  1. Summarize: clusters by severity, refactors done, kanban tasks created, next-step recommendation.

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.