GitHub Stars
22
Version
v0.1.0
Language
Rust
License
MIT
Released
2026-06-12

dupehound (Rust, MIT, v0.1.0, 22★) scans your codebase for structurally identical functions regardless of renamed identifiers — a CI gate for AI-generated code slop. cargo install dupehound

formatDate. Three tickets later, another model writes renderTimestamp. A month after that, stringifyDate appears in the billing service. Three functions, same logic, aging separately, each one drifting under future edits.scan [path] — runs the full analysis and reports duplicate clusters sorted by deletable lines. Each cluster lists the representative function (marked with ★) and every copy, along with line counts and similarity percentages. The summary box reports a slop score: the percentage of the codebase that could be deleted by keeping only one copy of each duplicate cluster. 1$ dupehound scan .
dupehound v0.1.0 — scanned 19 files · 370 lines · 27 functions in 21ms
╭─────────────────────────────────────────────────────────╮
│ SLOP SCORE 36.1% grade F │
│ 127 of 352 significant lines are deletable duplicates │
╰─────────────────────────────────────────────────────────╯
● Cluster 1 ─ 4 copies · 100% similar · 42 deletable lines ─────────────
★ src/utils/date.ts:1 formatDate 14 lines
src/api/timestamps.ts:1 renderTimestamp 14 lines 100% █████████
src/jobs/report_dates.ts:1 stringifyDate 14 lines 100% █████████
src/billing/dates.ts:1 humanizeDate 14 lines 100% █████████
★ = representative (kept) · dupehound scan --explain 1 shows the codehistory — charts duplication across git history using monthly snapshots. Useful for spotting the commit range where the slop score started climbing — often correlates with the start of an AI-assisted sprint. 1check — the CI gate. Fails when an incoming change introduces a new duplicate of an existing function. It points to the function already in the codebase that the new code replicates, so the author can reference or refactor instead of merge. 1history and check subcommands need git on PATH. scan runs anywhere.| Project | Slop score | Grade |
|---|---|---|
| express | 0.0% | A |
| gin | 0.2% | A |
| tokio | 1.1% | A |
| fastapi | 1.7% | A |
| vscode | 2.8% | A |
dupehound scan . from the repo root. The scan takes under two seconds. If the slop score comes back at 15%+, you have a real problem: thousands of lines that are logically redundant, each one a future maintenance surface. The cluster report shows exactly which functions to consolidate, ranked by the lines you'd save.dupehound check to your pre-commit hook or CI workflow. From that point, every PR that re-implements an existing function gets rejected with a pointer to the original — before it's merged, not three months later when two diverged copies both have bugs.
cargo install dupehoundbrew install rafaelpta/dupehound/dupehoundscan has no external dependencies. history and check need git in PATH.brew tap works on macOS and Linux. Windows users need the prebuilt binary from releases or a cargo install. 2check is a pre-merge gate, not a remediation tool. It stops new duplication from entering; it doesn't generate consolidation patches or suggest refactors. The scan output tells you what exists; cleaning it up is on you.cargo install dupehound && dupehound scan .
围绕这条内容继续补充观点或上下文。