ast-grep vs PolyglotPiranha
ast-grep
ast-grep.github.ioPolyglotPiranha
github.comSide by side
| Figure | ast-grep | PolyglotPiranha |
|---|---|---|
| Price from | Free | — |
| Free plan | Yes | — |
| Free trial | — | — |
| Open source | — | — |
| Web | Yes | — |
| Windows | Yes | — |
| macOS | Yes | Yes |
| Linux | Yes | Yes |
| iOS | — | Yes |
| API | Yes | Yes |
| Self-hosted | — | Yes |
| Plans published | 1 | 0 |
| Spec score · Code Refactoring Tools | 9.1 (#1) | 7.2 (#19) |
| Integrations | The documentation describes editor integrations, including a VS Code extension and language server support for editors such as Vim and Neovim. | The Python wrapper is described as suitable for incorporation into pipelines; the documentation does not name specific CI or feature flag vendor integrations. |
| Languages | The project says it supports 20+ languages and allows custom languages to be loaded. | The CLI lists Java, Swift, Python, Kotlin, Go, TSX, and TypeScript as target languages. |
| Purpose | ast-grep is a fast, polyglot tool for structural code search, linting, and rewriting at scale. | 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. |
| Support | The project directs users with questions or issues to GitHub or Discord and also points to Stack Overflow and Reddit. | Users with questions or bug reports are directed to open a GitHub issue. |
Plans
In their own words
ast-grep
ast-grep is a free, open-source tool for structural code search, linting, and rewriting. It matches patterns against syntax-tree nodes, helping developers locate and change code across a codebase rather than searching plain text. Its CLI can preview and apply rewrites interactively, and scan configurable YAML rules with error, warning, info, or hint severity. Rules can combine pattern, kind, regex, relational, and composite conditions, and CLI commands help create and snapshot-test them. The project says it supports more than 20 languages and can load custom languages. JavaScript and WebAssembly APIs allow programmatic syntax-tree work; a browser playground offers a way to try patterns without local installation. Editor options include a VS Code extension and language-server setups, including for Vim and Neovim. The tool is free, has a web interface, and is distributed through package managers or built from source. Its FAQ notes that some advanced static-analysis information is unsupported, and one rule cannot target multiple languages at once.
PolyglotPiranha
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.