duplicates
Find similar code symbols repo-wide by comparing embeddings to plan refactoring and deduplicate. Supports diff scoping and filtering.
Instructions
Repo-wide near-duplicate scan: pairs of symbols whose embeddings exceed threshold. Use for refactor planning (where else does this logic live?) and dedup. Prefer over manual similar-walks — duplicates evaluates all pairs once with min_body_lines filtering out trivial bodies. Requires vex index --semantic. Supports diff scoping: since (rev), since_branched, changed_only (mutually exclusive) and no_stale_check.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| why | No | Surface a JSON trace under `_meta.why`: applied threshold + min_body_lines, pairs before/after path filter, filter snapshot. | |
| limit | No | Max pairs to return | |
| since | No | Restrict pairs to files changed between `<rev>..HEAD`. Mutually exclusive with `since_branched` and `changed_only`. | |
| exclude | No | Blacklist pairs by path glob — a pair is dropped when either side matches (repeatable) | |
| explain | No | Include reasoning per pair: identifier-set Jaccard overlap + truncated unified diff between the two bodies | |
| include | No | Whitelist pairs by path glob — a pair is kept when at least one side matches (repeatable) | |
| threshold | No | Minimum cosine similarity (0.0..1.0); 0.9 keeps only very close pairs | |
| auto_update | No | Auto-update the index if stale, or bootstrap it if missing, before running (default: true) | |
| filter_path | No | Substring path filter — keep pairs where at least one symbol's path contains this substring. Legacy alias: `filter`. | |
| async_update | No | With auto_update, refresh a stale index in the background instead of waiting for it: results come from the index already on disk and _meta.vex.dev/stale says so (default: false) | |
| changed_only | No | Restrict pairs to working-tree changes (staged + unstaged + untracked). Mutually exclusive with `since` and `since_branched`. | |
| project_root | No | Absolute path to the project root (defaults to the MCP working directory) | |
| exclude_tests | No | Drop test files from the results (tests/ dirs, *_test.*, test_*.py, *.spec.ts, __tests__/, tests.rs, ...; same set as tests_for). Composes with include/exclude. Path-based only: Rust unit tests inside a `#[cfg(test)] mod tests` block of a non-test file are not excluded. | |
| min_body_lines | No | Skip symbols with body shorter than this many lines (filters trivial wrappers) | |
| no_stale_check | No | Skip the staleness check that runs before each call; assumes the index is fresh. Redundant when `auto_update` is true. | |
| since_branched | No | Restrict pairs to files changed since this branch diverged from `origin/main` (or `main`/`master`). Mutually exclusive with `since` and `changed_only`. |