ast-grep vs Scalafix
ast-grep
ast-grep.github.ioScalafix
scalacenter.github.ioSide by side
| Figure | ast-grep | Scalafix |
|---|---|---|
| Price from | Free | — |
| Free plan | Yes | — |
| Free trial | — | — |
| Open source | — | — |
| Web | Yes | — |
| Windows | Yes | Yes |
| macOS | Yes | Yes |
| Linux | Yes | Yes |
| API | Yes | — |
| Plans published | 1 | 0 |
| Spec score · Code Refactoring Tools | 9.1 (#1) | 7.0 (#20) |
| Custom rules | Rules are written in YAML and can combine pattern, kind, regex, relational, and composite matching conditions. | Users can create custom linter and rewrite rules using the Scalafix public API. |
| Linting | The scan command runs configurable AST pattern rules and supports severity levels including error, warning, info, and hint. | It reports errors for code patterns that can cause production bugs or violate coding style. |
| Purpose | ast-grep is a fast, polyglot tool for structural code search, linting, and rewriting at scale. | Scalafix is a refactoring and linting tool for Scala. |
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.
Scalafix
Scalafix is a refactoring and linting tool for Scala that automates routine code-health work and one-time migrations. It reports patterns that may lead to production bugs or conflict with coding style, and teams can run rules during code review. Its check option fails when linting or fixes are needed. Syntactic rules run directly on source code; semantic rules need compiled sources with the SemanticDB compiler plugin enabled. Built-in rules include OrganizeImports, RemoveUnused, DisableSyntax, ProcedureSyntax, and RedundantSyntax. Developers can also create custom lint and rewrite rules through its public API. The official build integration is for sbt. Documentation also lists externally maintained integrations for scala-cli, Mill, Gradle, Maven, and Mega-Linter, whose integration supports only built-in syntactic rules. Scalafix is tested on macOS, Linux, and Windows. Listed tested Scala versions are 2.12.21, 2.13.18, and 3.9.0 LTS. It is no longer published for Scala 2.11 or sbt 0.13.x. Community help is available through Discord and Scala Users. The tool is free.