# treepeat

A Python command-line tool that finds duplicate and near-duplicate code across a codebase using tree-sitter parsing and locality-sensitive hashing, with adjustable rules for how strictly two blocks must match.

treepeat scans a codebase for similar or duplicate code blocks using tree-sitter AST analysis and locality-sensitive hashing. It supports three normalization rulesets: an exact mode that only ignores irrelevant syntax, a default mode that also ignores whitespace, strings and high-level node types such as function names, and a loose mode that anonymizes identifiers and constants to find structurally similar code.

It works across fifteen languages including Python, JavaScript, TypeScript, Go, Rust, Java and Kotlin, and its command-line flags control similarity percentage, minimum match length, diff display and output format, including a SARIF option for continuous-integration pipelines. A separate treesitter subcommand shows how source code is normalized into tokens, to help explain why two blocks were flagged as similar. It installs from PyPI and is an early-stage project that supports a limited set of languages so far.

Website: https://github.com/dsummersl/treepeat
