codedupes finds duplicate code in Python, C, Rust, JavaScript/JSX, and TypeScript/TSX. It combines structural/token matching with semantic embeddings to find both similar syntax and similar intent. It also reports potentially unused Python definitions, ones nothing in the tree references, for review.
Use check to review duplicate candidates with file and line locations, or search to find functions and methods using a natural-language query. It analyzes source files without building or running your project.
pip install "codedupes @ git+https://github.com/pszemraj/codedupes.git"
codedupes infoSee installation for prerequisites, parser/runtime requirements, and editable development setup.
Run these from the repository you want to analyze. Replace ./src with your source directory, . for the current directory, or a single supported source file.
# Find duplicates using both structural/token and semantic matching.
codedupes check ./src
# Find code by describing what it does.
codedupes search ./src "normalize request payload" --top-k 5See the CLI reference for file-level ranking and model profiles before the first semantic run.
For a first scan without loading or downloading an embedding model:
codedupes check ./src --traditional-only --no-unusedThis checks structural/token duplicates and disables unused-code guesses. It still uses the same installed package and parser dependencies.
See output and exit codes for findings and CI behavior. Analysis scope and filters and language support define what is scanned.
| Goal | Documentation |
|---|---|
| Adjust scan scope, thresholds, or search | CLI reference (codedupes check --help / codedupes search --help) |
| Call the analyzer from Python | Python API |
| Interpret findings or integrate with CI | Output and exit codes |
| Understand defaults and unused-code heuristics | Analysis defaults |
| Check language support and extraction boundaries | Polyglot language support |
| Change models or work offline | Model profiles |
| Diagnose CPU, CUDA, or Apple Silicon execution | Accelerators |
| Inspect or clear cached embeddings | Embedding cache |
| Develop and test this project | Development setup |
| Reproduce calibration experiments | Hybrid gate tuning |
| Review upcoming behavior changes | Next release changes |
| Check whether a missing capability was considered | Deferred work |