Saturday, October 24, 2026 4,350 lists 78,096 records on file
List your app or device

  1. Home
  2. Code Refactoring Tools
  3. PolyglotPiranha

PolyglotPiranha

What it is

PolyglotPiranha is a multilingual structural search-and-replace engine for code cleanup. It can remove code connected to stale feature flags when given a flag name, expected behavior, and rules for the relevant feature flag API. Cleanup rules can be linked into graphs, and built-in language-specific rules cover tasks such as simplifying boolean expressions, removing empty declarations and files, and inlining local variables. Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax. Custom rule chains can handle structural search and replacement beyond feature flag cleanup.

The project is available as a Python library and a command-line tool; the Python API wraps the CLI. The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages. Dry-run mode prevents in-place changes, and its summary reports matches, rewrites, and file content after rewriting or analysis. API configuration requires a code path, configuration path, target language, and substitutions, and can include rules.toml and edges.toml files. The Python API installs with pip; the CLI can be built with Rust and Cargo or obtained from repository releases. Piranha is free under Apache 2.0 and is provided as is.

For and against

For

  • Supports seven CLI target languages.
  • Dry-run mode prevents in-place rewriting.
  • Rules can be composed into graphs.
  • Python library and command-line interfaces are available.

Against

  • Does not include prebuilt rules for every cleanup.
  • The project says it is unlikely to add new languages.
  • Provided as is, without stated security certifications.

The verdict

PolyglotPiranha combines built-in cleanup rules with custom structural search and replacement. Its language coverage and configuration requirements make it important to check whether a project fits the listed targets and rule model.

Who it suits

It suits developers who need configurable, rule-based cleanup across supported programming languages. The Python API can be incorporated into pipelines.

On the record

Cleanup
Prebuilt language-specific rules can simplify boolean expressions and if-else statements, remove empty declarations, delete empty files, and inline local variables.github.com · read 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.github.com · read 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.github.com · read 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.github.com · read 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.github.com · read 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.github.com · read 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.github.com · read 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.github.com · read 7 Oct 2026
Languages
The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages.github.com · read 7 Oct 2026
Language support limit
The repository says it supports languages used at Uber and likely will not add new languages there.github.com · read 7 Oct 2026
License
Piranha is licensed under Apache 2.0.github.com · read 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.github.com · read 7 Oct 2026
Other refactoring
Users can also use custom rule chains for structural search and replace beyond stale feature flags.github.com · read 7 Oct 2026
Purpose
Polyglot Piranha is a lightweight code transformation toolset for automating large scale changes and is used at Uber mostly to clean up stale feature flags.github.com · read 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.github.com · read 7 Oct 2026
Rule formats
Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax.github.com · read 7 Oct 2026
Security
The repository identifies the project as provided as-is and does not state security certifications or compliance claims.github.com · read 7 Oct 2026
Support
Users with questions or bug reports are directed to open a GitHub issue.github.com · read 7 Oct 2026

The review

PolyglotPiranha is a structural search-and-replace engine for chained code cleanup rules. It suits teams that need repeatable refactoring across supported languages; its strongest case is feature-flag cleanup, while custom work requires configuration and rule writing.

Overview

Piranha applies interdependent rules to code, including rules that remove stale feature-flag logic when given a flag name, expected behavior, and configured API rules. It can also run custom structural refactors beyond feature flags. That makes it useful for project-wide cleanup where edits depend on code structure, rather than simple text matching.

The project is Apache 2.0 licensed and provided as is; it is not an official Uber product. Questions and bug reports go through GitHub issues. The repository makes no security certification or compliance claims, so organizations that require those assurances will need another basis for approval.

Key features

Rules can be arranged into graphs so one cleanup can lead into another. Prebuilt rules cover tasks such as simplifying boolean expressions and if-else statements, removing empty declarations and files, and inlining local variables. This gives teams a useful starting set, but it does not eliminate the need to understand and configure the rule model.

Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax. That range lets users choose how to describe a match, though it also means rule authors must be comfortable with structural queries or the project’s syntax. There are no prebuilt rules for every task: adding a custom import, for example, calls for a rule of your own.

Piranha is available as a Python library and a command-line tool; the Python API wraps the CLI and can be incorporated into pipelines. A dry run disables in-place rewriting, and the summary reports matches, rewrites, and file content after rewriting or analysis. This supports review before changes are applied, but no specific CI or feature-flag vendor integrations are named.

Pricing

Piranha is free, with no free trial. There are no paid plans or seat and usage caps stated for the project. The cost is setup and maintenance: API use requires a code path, configuration path, target language, and substitutions, and configuration can involve rules.toml and edges.toml. Install the Python API with pip; the CLI can be built with Rust and Cargo or obtained from repository releases.

Platforms

The project targets API, iOS, Linux, macOS, and self-hosted use. The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages. The repository says its language support focuses on languages used at Uber and is unlikely to expand to new languages, which makes language fit a central selection criterion for teams outside that set.

Who it's for

Piranha is a good fit for engineering teams removing stale feature flags or building repeatable, project-wide refactors in its supported languages. Python users can bring it into pipelines, and command-line users can run it directly. It is a weaker fit for teams seeking broad language coverage, ready-made rules for every cleanup, or a managed commercial support and compliance package.

Pros and cons

  • Pros: Rule graphs handle dependent cleanup steps, which suits refactors where one edit enables another.
  • Pros: Dry-run output includes matches, rewrites, and file content, giving reviewers a way to inspect proposed changes before in-place rewriting.
  • Pros: Free and Apache 2.0 licensed, with both Python and CLI interfaces for pipeline or direct use.
  • Cons: Setup requires paths, language, substitutions, and configuration, so teams must invest in rule setup before relying on it.
  • Cons: Language support is limited to the repository’s target list and is unlikely to grow, ruling it out for projects in other languages.
  • Cons: Custom cleanup needs custom rules, and the project is provided as is without stated security certifications or compliance claims.

Alternatives

Choose ast-grep if its broader platform range, including extensions, web, and Windows, better matches how your team works. CodeRush is worth considering for extension-based use across Linux, macOS, and Windows; its free and paid subscriptions have the same features and updates, with technical support requiring a paid subscription.

OpenRewrite suits teams seeking an Apache-licensed recipe framework on Linux or self-hosted infrastructure; its core runs one repository at a time. Sourcery fits teams that want AI reviews and one-click fixes for public repositories in its free Open Source plan.

Spoon is another free option for API, Linux, and self-hosted use. Coccinelle is a free alternative for Linux and macOS. ReSharper offers a free non-commercial plan with C# support in VS Code and compatible editors, plus paid plans. Roslynator is a free choice for teams looking for tools and extensions across Linux, macOS, and Windows.

Verdict

Choose PolyglotPiranha if your team needs free, configurable project-wide cleanup—especially stale feature-flag removal—and works in one of its supported languages. Its chained rules and dry-run summary are the main reasons to pick it. Look elsewhere if your language is outside its target set or your cleanup depends on ready-made rules and support the project does not provide.

Alternatives to PolyglotPiranha

Every alternative, ranked