
T
Treepeat
Open Sourceπ Alt to SonarQubeDetect deep structural code duplication using Tree-sitter ASTs
π³ Self-Hostableπ No Sign-upβ‘ Editorial Signal: 76/100β
52 Stars
cargo install treepeatTreepeat analyzes abstract syntax trees across codebases to uncover structural code duplication and similarity patterns. By leveraging Tree-sitter parsers, it successfully ignores superficial formatting differences to flag deeply nested copy-paste anomalies.
Utilizes robust Tree-sitter parsers for multi-language AST extraction and structural comparison.
Ignores variable renaming, whitespace changes, and formatting quirks to catch true logic duplication.
Detects structural similarity and copy-paste anomalies not just within a single repo, but across entire project portfolios.
Auditing large microservice architectures for copy-pasted boilerplate logic
Refactoring legacy codebases to extract shared internal libraries
Enforcing architectural guidelines and preventing duplicate domain implementations
Unlike enterprise tools like SonarQube, Treepeat provides a lightweight, focused AST-centric approach to structural similarity without heavyweight platform overhead.
Software architects and senior engineers responsible for codebase health and technical debt reduction across multiple repositories.
Treepeat is engineered to eliminate critical operational friction in devtools & cli. From an architectural standpoint, the system adopts a local-first, self-contained deployment posture, ensuring streamlined onboarding and minimal setup overhead.
Because the underlying code is fully open-source, engineering teams can audit security implementations, inspect telemetry vectors, and extend functionality via custom fork without risk of sudden vendor deprecation.
Treepeat is an ultra-high-performance static code analysis engine implemented in systems Rust (dsummersl/treepeat), engineered to detect structural code clones and logic duplication across multi-language repositories. Departing from traditional token-based linters or naive text diffing algorithms that fail when variables are renamed, Treepeat leverages Tree-sitter's incremental C/Rust parsing libraries to extract rich Concrete Syntax Trees (CSTs) and Abstract Syntax Trees (ASTs). The execution loop operates over parallel Rayon thread pools, traversing source trees concurrently across multi-core processors. During traversal, Treepeat applies deterministic structural normalization: identifiers, variable names, literal string constants, numerical values, and comment tokens are stripped or anonymized, isolating pure syntactic structure and operational control flow. The engine computes recursive Merkle-style subtree hashes using rapid cryptographic hash routines across normalized node sequences, pruning trivial macro expansions and empty expressions. Subtree hashes exceeding a configurable token depth are registered in lock-free concurrent hash maps. Colliding hashes represent exact or near-identical structural blocks. The memory architecture relies on compact arena allocators and continuous byte slices, ensuring minimal heap fragmentation and low cache misses even when ingesting multi-gigabyte monorepositories containing millions of lines of complex polyglot source code.
Developer ergonomics in Treepeat prioritize frictionless command-line invocation, predictable configuration, and seamless continuous integration integration. Installation is instantaneous via Cargo (cargo install treepeat), producing a single self-contained binary with zero dynamic runtime dependencies. Developers execute scans via intuitive CLI commands (treepeat scan --min-lines 15 --similarity 0.85 ./src), utilizing clean flags to fine-tune structural similarity thresholds, minimum statement counts, and multi-language parser targets (including Rust, Python, Go, TypeScript, Java, and C++). Scans can be customized using a declarative .treepeatignore file to exclude third-party vendor directories, generated protobuf buffers, and fixture mock data. Output ergonomics cater to both humans and machines: the CLI emits side-by-side ANSI colorized terminal diffs highlighting duplicate logic blocks with line numbers, while automated CI pipelines consume structured JSON or native SARIF (Static Analysis Results Interchange Format) reports. SARIF compliance allows Treepeat to upload code scanning results directly into GitHub Advanced Security and GitLab Code Quality dashboards without custom parsing scripts. Tree-sitter's error-tolerant parsing guarantees that syntax errors in uncompiled files do not abort analysis, maintaining smooth developer iteration cycles during active codebase refactoring across diverse software engineering departments.
Treepeat is published under permissive open-source licensing (MIT / Apache 2.0 dual license), granting commercial software organizations complete legal freedom to audit, compile, and embed its binaries into internal build clusters without royalty obligations or copyleft restrictions. From a Total Cost of Ownership perspective, Treepeat delivers massive operational cost savings compared to heavyweight commercial static analysis suites like SonarQube Enterprise, which charge tens of thousands of dollars annually per line-of-code tier. As a compiled Rust binary, Treepeat incurs minimal self-hosting compute overhead: full repository audits complete in seconds while operating within two vCPUs and under five hundred megabytes of RAM. Expensive GPU accelerators and dedicated database servers are completely unnecessary. Furthermore, Treepeat operates entirely offline within the local machine boundary, making zero external network calls and transmitting zero telemetry. This air-gapped architecture guarantees absolute source code confidentiality, permanently eliminating enterprise compliance hurdles, legal data transfer risks, and recurring third-party cloud infrastructure expenses. Organizations achieve continuous structural duplication auditing across hundreds of microservices with essentially zero ongoing licensing, disk caching, or infrastructure maintenance overhead. Memory footprint remains strictly bounded thanks to zero-cost Rust abstractions and leak-free resource cleanup across all compilation phases.
Treepeat is production-ready as a high-speed code quality gate, architectural debt auditor, and monorepo refactoring analyzer for engineering organizations seeking to eliminate copy-pasted business logic and extract shared internal libraries. It provides unmatched structural precision where superficial variable renaming routinely confuses traditional token linters. However, Treepeat is not designed as a semantic vulnerability scanner or tainted dataflow analyzer; teams requiring dynamic taint tracking or cryptographic vulnerability auditing must deploy it alongside dedicated static application security testing (SAST) tools like Semgrep or CodeQL. A notable edge-case failure mode involves repetitive domain boilerplateβsuch as serialization wrappers or extensive unit test tablesβwhich Treepeat will flag as duplication unless filtered through minimum node count thresholds. For enterprise production deployment, package Treepeat into a minimal multi-stage Alpine or Scratch Docker image and inject it into pull request validation pipelines within GitHub Actions or GitLab CI. Configure the SARIF export flag to automatically annotate pull request diffs, set a similarity threshold of eighty-five percent, establish baseline configuration files to grandfather existing legacy clones, and exclude auto-generated code to prevent developer alert fatigue while enforcing clean architectural boundaries across microservice repositories.
Treepeat is 100% free and open-source under an open software license. There are no mandatory monthly subscription fees to access the source code or run it locally.
Unlike enterprise tools like SonarQube, Treepeat provides a lightweight, focused AST-centric approach to structural similarity without heavyweight platform overhead.
Yes. Treepeat is designed for self-hosting via Docker or direct server deployment. Running on your own infrastructure allows you to maintain direct control over your local compute, database storage, and operational environment.
No account creation or credit card is required to evaluate Treepeat. You can immediately access core features or run it locally without onboarding friction.
You can launch or test Treepeat quickly using the following command: cargo install treepeat Visit the official portal at https://github.com/dsummersl/treepeat for documentation and guides.
ToolsRadar maintains strict editorial independence. This review of Treepeat was conducted using our standardized 5-pillar evaluation framework (Setup, Code Auditability, Maintenance Vitality, Cost Advantage, and Community Signal). We do not accept paid placements to inflate benchmark scores.
Maintainers of Treepeat and community advocates can display this real-time verification badge in your GitHub README, official documentation, or landing page.
[](https://lordorange.top/tool/treepeat-code-similarity-detection-using-tree-sitter)<a href="https://lordorange.top/tool/treepeat-code-similarity-detection-using-tree-sitter" target="_blank"><img src="https://lordorange.top/badge/treepeat-code-similarity-detection-using-tree-sitter.svg" alt="Featured on ToolsRadar" /></a>Compare other trending developer tools and open-source projects in this space.
Cross-referenced architectural playbooks and category rankings featuring Treepeat.
High-signal, production-tested utilities with transparent codebases and active communities.
Take back data ownership by replacing expensive monthly cloud subscriptions with self-hosted software.
The definitive guide to escaping SaaS subscription sprawl with Coolify, Traefik, Tailscale, and automated S3 backup pipelines.
Replace sluggish 1970s Unix utilities with blisteringly fast, memory-safe Rust and Go modern CLI powerhouses.