PolyglotPiranha
PolyglotPiranha is a free structural search-and-replace engine for code cleanup.
What PolyglotPiranha is
PolyglotPiranha is a free structural search-and-replace engine for code cleanup. It can refactor code associated with stale feature flags when given a flag name, expected behavior, and rules for the relevant feature-flag API. Its rule engine connects cleanup steps into graphs and includes language-specific rules for simplifying boolean expressions and if-else statements, removing empty declarations and files, and inlining local variables. Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax, and custom rule chains can handle other structural refactoring tasks. The project provides a Python library and a command-line interface, with the Python API wrapping the CLI. The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages. A dry run prevents in-place rewriting; summaries include matches, rewrites, and file content after rewriting or analysis. The Python API is installed with pip, while the CLI can be built with Rust and Cargo or obtained from repository releases. It is Apache 2.0 licensed and provided as is, not as an official Uber product.
Good
- Provides Python and command-line interfaces.
- Dry runs prevent in-place rewriting.
- Supports seven listed CLI target languages.
- Rules can be composed into graphs.
- Apache 2.0 licensed.
Watch out
- Does not include prebuilt rules for every cleanup.
- The repository says it is unlikely to add languages.
- Provided as is; no security certifications are stated.
Who it suits
PolyglotPiranha suits developers who need repeatable structural code cleanup, especially for stale feature-flag code. Teams can also incorporate its Python API into pipelines.
Verdict
PolyglotPiranha offers configurable rule-based refactoring with a dry-run option and language-specific cleanup rules. Users should expect to write their own rules for tasks without a built-in cleanup and to consult GitHub issues for questions or bug reports.
The facts
Each one read from PolyglotPiranha's own pages, with the date it was checked.
What it does
- Cleanup
- Prebuilt language-specific rules can simplify boolean expressions and if-else statements, remove empty declarations, delete empty files, and inline local variables.checked 7 Oct 2026
- Configuration
- The API requires a code path, configuration path, target language, and substitutions; configuration can include rules.toml and edges.toml files.checked 7 Oct 2026
- Custom cleanup limit
- Piranha does not include prebuilt rules for every cleanup, such as adding a custom import, so users can write a cleanup rule for that task.checked 7 Oct 2026
- Dry run
- The dry-run option disables in-place rewriting, and the output summary includes matches, rewrites, and file content after rewriting or analysis.checked 7 Oct 2026
- Feature flag cleanup
- It can refactor code related to stale feature flags using a flag name, expected behavior, and configured feature flag API rules.checked 7 Oct 2026
- Installation
- The Python API is installed with pip, while the CLI can be built from source with Rust and Cargo or obtained from the repository’s releases.checked 7 Oct 2026
- Integrations
- The Python wrapper is described as suitable for incorporation into pipelines; the documentation does not name specific CI or feature flag vendor integrations.checked 7 Oct 2026
- Interfaces
- The project can be used as a Python library or as a command-line tool, and its Python API wraps the CLI.checked 7 Oct 2026
- Languages
- The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages.checked 7 Oct 2026
- Language support limit
- The repository says it supports languages used at Uber and likely will not add new languages there.checked 7 Oct 2026
- License
- Piranha is licensed under Apache 2.0.checked 7 Oct 2026
- License and status
- Piranha is licensed under Apache 2.0, and the repository states it is not an official Uber product and is provided as is.checked 7 Oct 2026
- Other refactoring
- Users can also use custom rule chains for structural search and replace beyond stale feature flags.checked 7 Oct 2026
- Purpose
- Polyglot Piranha is a multilingual structural search and replace engine that applies chains of interdependent rules for code cleanup.checked 7 Oct 2026
- Rule engine
- Rules can be composed into graphs, and the engine provides prebuilt language-specific cleanup rules such as simplifying boolean expressions and removing empty declarations.checked 7 Oct 2026
- Rule formats
- Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax.checked 7 Oct 2026
- Security
- The repository identifies the project as provided as-is and does not state security certifications or compliance claims.checked 7 Oct 2026
- Support
- Users with questions or bug reports are directed to open a GitHub issue.checked 7 Oct 2026
- Supported languages
- The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages.checked 7 Oct 2026
Alternatives to PolyglotPiranha
- 1

Sourcery
Free planWebAPIExtensionLinux7.9From $12 a month - 2

Moderne
WebAPILinuxmacOS7.3From $2,000 a month - 3

ast-grep
Free planWebAPIExtensionLinux7.0Free plan - 4

ReSharper
Free planExtensionLinuxmacOSWindows6.8From $389 a year - 5
jSparrow
LinuxmacOSWindows6.4From $1,325 a year - 6

CodeRush
Free planExtensionLinuxmacOSWindows6.3Free plan
