Repolode
Rafaelpta

Rafaelpta/dupehound

A local, deterministic duplicate-code detector that finds functions copied by AI agents even after identifiers are renamed.

Stars
102
Forks
10
Open issues
3
Last commit
2 months ago

What is it?

dupehound is a command-line duplicate-code detector aimed at codebases where AI agents write much of the code. It parses each function with tree-sitter, normalizes identifiers and literals, and fingerprints the structure of the code, so a renamed copy is still matched to its original.

It offers three commands: scan reports duplicate clusters and a repo-level slop score, history charts duplication across git history to show when it increased, and check fails CI or pre-commit when a change duplicates existing code and names the function to reuse. The tool runs fully offline with no API keys or AI models, and produces the same result on every run.

The project also ships an MCP server mode so a coding agent can call the check and scan tools while editing. Languages include TypeScript, Python, Rust, Go, Java, C#, Kotlin and many others.

Key features

  • 01Detects renamed copies by fingerprinting code structure rather than text
  • 02Scan reports duplicate clusters and a repo-level slop score
  • 03History command charts duplication across git commits
  • 04Check command gates CI and pre-commit on new duplicates
  • 05Runs offline and deterministically with no AI or network required
  • 06Exposes check and scan as MCP tools for coding agents

Use cases

  • Stopping an AI coding agent from reimplementing functions that already exist in the repo
  • Gating pull requests in CI so new duplicate code is flagged before merge
  • Tracking how duplication grows over the history of a large codebase

Quick start

  1. 1

    Install with cargo

    cargo install dupehound
  2. 2

    Run a duplicate scan on a directory

    dupehound scan [path]

Things to know

  • The history and check commands require git on PATH.
  • The --include-classes and --containment flags are experimental and opt-in.

In collections

Topics

FAQ

What is dupehound?
A local, deterministic duplicate-code detector that finds functions copied by AI agents even after identifiers are renamed. dupehound is a command-line duplicate-code detector aimed at codebases where AI agents write much of the code. It parses each function with tree-sitter, normalizes identifiers and literals, and fingerprints the structure of the code, so a renamed copy is still matched to its original.
Is dupehound free to use? What license does it have?
dupehound is open source under the MIT license. Check the license terms before using it in commercial products.
Is dupehound still maintained?
Updated within 6 months. The last commit to dupehound was on Sep 21, 2026.
What can I use dupehound for?
Stopping an AI coding agent from reimplementing functions that already exist in the repo Gating pull requests in CI so new duplicate code is flagged before merge Tracking how duplication grows over the history of a large codebase
How do I install dupehound?
Install with cargo: cargo install dupehound Run a duplicate scan on a directory: dupehound scan [path]
Where can I get dupehound?
The source code and installation instructions are on GitHub: https://github.com/Rafaelpta/dupehound

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects