Skip to content
SPECIFICTION
Get listed

PolyglotPiranha

github.com

macOSLinuxiOSAPISelf-hosted
Visit github.com
Spec score 7.2 #19 of 22 in Code Refactoring Tools

What it is

PolyglotPiranha is a free, multilingual structural search-and-replace engine for code cleanup. It can refactor stale feature-flag code when given a flag name, expected behavior, and configured feature-flag API rules. Rules can form graphs, and built-in language-specific cleanups include simplifying boolean expressions and if-else statements, removing empty declarations and files, and inlining local variables. Queries and filters may use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax. The project is available as a Python library and command-line tool, with the Python API wrapping the CLI. The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages. Dry runs prevent in-place rewriting and produce summaries of matches, rewrites, and resulting file content. API configuration requires code path, configuration path, target language, and substitutions, with optional rules.toml and edges.toml files. Python installation uses pip; the CLI can be built with Rust and Cargo or obtained from releases. Piranha is Apache 2.0, provided as is, and not an official Uber product.

Spec sheet

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.Read 7 Oct 2026 · github.com
Integrations
The Python wrapper is described as suitable for incorporation into pipelines; the documentation does not name specific CI or feature flag vendor integrations.Read 7 Oct 2026 · github.com
Security
The repository identifies the project as provided as-is and does not state security certifications or compliance claims.Read 7 Oct 2026 · github.com
Support
Users with questions or bug reports are directed to open a GitHub issue.Read 7 Oct 2026 · github.com
License
Piranha is licensed under Apache 2.0.Read 7 Oct 2026 · github.com
Cleanup
Prebuilt language-specific rules can simplify boolean expressions and if-else statements, remove empty declarations, delete empty files, and inline local variables.Read 7 Oct 2026 · github.com
Configuration
The API requires a code path, configuration path, target language, and substitutions; configuration can include rules.toml and edges.toml files.Read 7 Oct 2026 · github.com
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.Read 7 Oct 2026 · github.com
Dry run
The dry-run option disables in-place rewriting, and the output summary includes matches, rewrites, and file content after rewriting or analysis.Read 7 Oct 2026 · github.com
Feature flag cleanup
It can refactor code related to stale feature flags using a flag name, expected behavior, and configured feature flag API rules.Read 7 Oct 2026 · github.com
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.Read 7 Oct 2026 · github.com
Interfaces
The project can be used as a Python library or as a command-line tool, and its Python API wraps the CLI.Read 7 Oct 2026 · github.com
Language support limit
The repository says it supports languages used at Uber and likely will not add new languages there.Read 7 Oct 2026 · github.com
Languages
The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages.Read 7 Oct 2026 · github.com
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.Read 7 Oct 2026 · github.com
Other refactoring
Users can also use custom rule chains for structural search and replace beyond stale feature flags.Read 7 Oct 2026 · github.com
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.Read 7 Oct 2026 · github.com
Rule formats
Queries and filters can use Tree-sitter queries, regular expressions, or Piranha’s concrete syntax.Read 7 Oct 2026 · github.com
Supported languages
The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages.Read 7 Oct 2026 · github.com

Strong points and limits

Strong points

  • Free Apache 2.0 project
  • Supports seven listed target languages
  • Dry-run rewriting summaries
  • Python library and CLI
  • Composable cleanup rule graphs

Limits

  • No prebuilt rule for every cleanup
  • Repository says new languages likely will not be added
  • Provided as is
  • Not an official Uber product

Who it suits

It suits developers maintaining feature-flag cleanup and other structural refactoring across supported languages. Teams can use the Python API in pipelines or run the command-line tool.

Verdict

PolyglotPiranha provides rule-driven, multilingual code cleanup with both API and CLI access. Its language scope and need for custom rules should be checked before adopting it for broader refactoring.

Where Specifiction places it

Alternatives to PolyglotPiranhaAll alternatives →