Treepeat - Code similarity detection using Tree-sitter
Show HN: Treepeat – Code similarity detection using Tree-sitter
Treepeat is a proof-of-concept tool that finds duplicate and near-duplicate code blocks in your codebase using Tree-sitter AST analysis and locality-sensitive hashing. It supports multiple languages including Python, JavaScript, Go, and Rust. With configurable rulesets (none, default, loose) and similarity thresholds, you can detect exact duplicates, ignore whitespace and strings, or find structurally similar code. Treepeat integrates into CI via SARIF output and offers side-by-side diffs for easy review.
Find duplicate code blocks meaningful to the language (classes/functions), not just lines.
- ryuuseijin
This is what I wanted to help with duplicate code detection, which is now a real problem with agentic programming since the agent tends to duplicate helper functions a lot in bigger codebases.
I ended up writing my own tool [1] that uses vector search, which works but can be unusably slow in large codebases.
I will give this a shot.
- adityamishra241
Nice approach. AST-level similarity seems much more useful than simple text matching.
- Game_Ender
Thank you for a README that is readable. It might have a bit of AI help but it’s concise and makes it clear how to use the tool.