explaingit

rafaelpta/dupehound

Analysis updated 2026-05-18

19RustAudience · developerComplexity · 2/5Setup · easy

TLDR

A command-line tool that finds duplicate functions in a codebase by comparing their structure, built for projects where AI assistants re-implement existing code.

Mindmap

mindmap
  root((repo))
    What it does
      Finds duplicate functions
      Structural comparison
      Slop score
    Tech stack
      Rust
      tree-sitter
      Multiple language grammars
    Use cases
      Scan for duplication
      Track history over time
      Gate CI builds
    Audience
      Developers
      AI-assisted teams
    Design
      Fully local
      Deterministic output

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Scan a codebase for duplicate functions and get a slop score showing how much could be deleted.

USE CASE 2

Chart how duplication has grown over the project's git history without checking out old commits.

USE CASE 3

Block a CI build automatically when a new function duplicates an existing one.

What is it built with?

Rusttree-sitterTypeScriptPythonGo

How does it compare?

rafaelpta/dupehoundd10n/tui-globehase9awa/termtypist
Stars191919
LanguageRustRustRust
Setup difficultyeasyeasymoderate
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Prebuilt binaries for macOS, Linux, and Windows, also installable via Cargo or Homebrew.

In plain English

Dupehound is a command-line tool that finds duplicate functions in a codebase. It was built specifically for projects where AI coding assistants write most of the code, since those tools tend to re-implement things that already exist rather than reuse them. The tool compares functions by their structure rather than their text, so it catches copies even when variable names, string values, or numbers have been changed. The tool has three commands. "scan" goes through a directory, groups duplicate functions into clusters, and produces a "slop score": the percentage of code that could be deleted if each cluster were consolidated into one copy. "history" reads past git commits and draws a chart showing how duplication changed over time, without needing to check out each version. "check" is designed for automated build pipelines: it compares newly added or changed functions against the rest of the codebase and stops the build if a duplicate is found, naming the original function the developer should reuse instead. Under the hood, function bodies are parsed with a tool called tree-sitter, which understands the grammar of each supported language. After parsing, identifiers, strings, and numbers are replaced with placeholder tokens so that only the structural skeleton remains. That skeleton is broken into overlapping chunks and fingerprinted. Two functions match when enough fingerprints overlap. The approach is deterministic: given the same code, it always produces the same result, which matters when the output is a CI gate. Everything runs locally. There is no network connection, no API key, and no machine learning model involved. Prebuilt binaries are available for macOS, Linux, and Windows, and the tool can also be installed through Rust's package manager or Homebrew. Supported languages include TypeScript, JavaScript, Python, Rust, Go, Java, Ruby, and Swift. On a very large codebase like VS Code, with roughly 3 million lines and 53,000 functions, a full scan takes about 3.6 seconds on a laptop. Test files are excluded from duplicate checks by default, since table-driven tests are intentionally repetitive. Generated, minified, and vendored files are also skipped. Any match can be inspected with the "--explain" flag, which prints the actual code side by side as confirmation.

Copy-paste prompts

Prompt 1
Run dupehound scan on this repo and summarize the biggest duplicate clusters.
Prompt 2
Explain what the slop score means for my codebase and how to reduce it.
Prompt 3
Set up dupehound check as a CI gate that blocks duplicate functions in pull requests.
Prompt 4
Show me the history chart of duplication in this repo over the last year.

Frequently asked questions

What is dupehound?

A command-line tool that finds duplicate functions in a codebase by comparing their structure, built for projects where AI assistants re-implement existing code.

What language is dupehound written in?

Mainly Rust. The stack also includes Rust, tree-sitter, TypeScript.

How hard is dupehound to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is dupehound for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.