Skip to content
FossShelf
Home / Categories / For Engineers

Grit

Automate code migrations at scale using a pattern-matching DSL

Replaces Moderne, Sonarqube, Qodo

4.63K starsMITreviewed 20 Mar 2025last commit 16 Nov 2026
Screenshot of Grit

Who it's for

Platform engineers migrating APIs

Use Grit to rewrite repeated API patterns across many repositories while keeping the transformation rule reviewable.

The migration requires full runtime behavior analysis rather than source pattern changes.

Tech leads removing deprecated patterns

Use Grit to find and fix old imports, function calls, and framework idioms across a codebase.

The affected code appears in only a few files and a manual edit is faster.

Teams building reusable codemod libraries

Use Grit when migration patterns recur and should be stored, shared, and composed across future upgrades.

Your organization already has mature language-specific codemod tooling and no cross-language needs.

The problem

Large code migrations rarely fit simple search and replace. Regex misses syntax, AST codemods take time to write, and language-specific frameworks force teams to rebuild similar transformations for each stack. The result is slow migration work, hard-to-review scripts, and repeated manual fixes across many repositories.

How it works

Declarative GritQL patterns

Any code snippet can become a GritQL query with metavariables for the parts that change. This makes many migrations easier to read than imperative AST traversal code.

Search and rewrite in one language

GritQL can find patterns, add side conditions, and rewrite matches with `=>`. Teams can move from exploration to automated remediation without changing tools.

Multi-language target support

JavaScript, TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, and SQL support makes Grit useful across mixed codebases.

Standard pattern reuse

Grit links to a standard library with 200+ patterns, which helps teams reuse migration logic instead of writing every transformation from scratch.

Features

  • Declarative GritQL patterns
  • Search and rewrite in one language
  • Multi-language target support
  • Standard pattern reuse

How to install

Install the Grit CLI on a developer machine or CI runner, then initialize configuration in the repository you want to rewrite.

npm install --location=global @getgrit/cli
grit init
grit apply react_to_hooks

Recommended for this setup

Strengths

  • Better than regex for code shape: GritQL matches source structure rather than raw text, so it can handle code patterns that include imports, method calls, and side conditions.
  • Readable migration rules: Declarative patterns are easier for reviewers to audit than long traversal scripts, especially when non-specialists need to approve broad code changes.
  • MIT-licensed core: GritQL uses the MIT license, which keeps the core query language usable in commercial code migration workflows.

Trade-offs

  • Requires learning a new query language: GritQL is more approachable than many AST APIs, but teams still need to learn its pattern syntax before trusting it for broad rewrites.
  • Not a replacement for deep semantic analysis: Grit is strong for structural rewrites. Some migrations still need compiler-aware checks, test suites, or human review to catch behavioral changes.

Tech stack

Languages
Rust, Jupyter Notebook, TypeScript, JavaScript, Python, Shell, RenderScript, Vue, HCL, HTML, PLSQL, Kotlin
Frameworks
Next.js, React
Databases
—
Tooling
—

FAQ

What is GritQL?

GritQL is a declarative query language for searching, linting, and modifying source code.

How is Grit different from regex?

Grit matches code structure with metavariables and side conditions, while regex matches text. That makes Grit safer for many syntax-aware migrations.

Which languages does Grit support?

Grit supports JavaScript, TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, and SQL.

Similar tools

More in Engineers