Show HN: Treepeat – Code similarity detection using Tree-sitter
Treepeat is a command-line tool that detects code duplicates and structural similarities across multiple languages using Tree-sitter AST analysis and locality-sensitive hashing.
summary is enough The clear documentation and feature list make it easy to evaluate whether AST-based code duplication detection fits your workflow.
summary
Treepeat uses Tree-sitter and locality-sensitive hashing to find exact or structural code duplicates in large codebases across various programming languages. It offers configurable normalization rulesets, ranging from exact match to loose structural comparison, with output formats suitable for CI integration. Commenters note its utility for detecting redundant helper functions often generated by AI coding assistants.
key points
- Supports three normalization rulesets to detect everything from exact duplicates to structurally similar code.
- Uses Tree-sitter for language-aware parsing and locality-sensitive hashing for efficient similarity matching.
- Integrates into CI pipelines with SARIF output formatting and provides CLI options for minimum line counts and similarity thresholds.
who should read it
Backend developers and tech leads managing large codebases or dealing with code duplication from AI coding tools.
discussion warm
consensus
Commenters are enthusiastic about AST-level duplication detection, particularly noting its usefulness for cleaning up redundant code generated by AI coding assistants.
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.
[1]: https://github.com/ninjaxtools/slopdex
The commenter highlights a practical use case for agentic programming workflows and shares an alternative vector-search tool.
Generated by an LLM from the article and thread. Check the sources before relying on it.