Skip to content

Treepeat

Dennis Lee edited this page Sep 29, 2026 · 1 revision

title: treepeat radar_quadrant: Tools radar_ring: Assess radar_position:

treepeat

treepeat is a command-line tool that finds duplicate and near-duplicate code across a codebase. Copy-pasted or slightly modified code tends to accumulate quietly over a project's life, and each copy becomes a separate place a future bug fix or change has to be repeated. Simple text- or line-based duplicate finders miss most of this, because they are thrown off by renamed variables, reformatted whitespace, or minor edits.

treepeat instead parses source files into abstract syntax trees using tree-sitter, the same parsing library used by many editors for syntax highlighting. It normalizes those trees against a configurable ruleset and then hashes the normalized structure to compare code by shape rather than by text, so it can catch duplicates that differ in naming, formatting, or literal values. Matching sensitivity is adjustable across three levels, from exact structural duplicates to loosely similar code, along with configurable minimum line counts and similarity thresholds. Results can be viewed as a side-by-side diff in the terminal or exported in SARIF format for integration into CI pipelines. It supports more than fifteen languages, including Python, JavaScript, TypeScript, Java, Rust, Go, and several markup and config formats.

Radar Assessment

treepeat is placed in the Tools quadrant. The wiki author has not used it in a production workflow, so it does not meet the Trial or Adopt gate, which requires confirmed first-person use rather than a plausible use case. It sits in Assess: the maintainer describes the project as "very much a proof of concept," and at roughly 80 stars with ongoing open pull requests it is early and still finding its shape. The AST-based, multi-language approach to duplicate detection is worth exploring for codebases where duplication has become a maintenance cost, but production adoption should wait for the tool to mature past its stated proof-of-concept stage.

References

Clone this wiki locally