
Grit
Automate code migrations at scale using a pattern-matching DSL
Replaces Moderne, Sonarqube, Qodo

Who it's for
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.
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.
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
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.
GritQL can find patterns, add side conditions, and rewrite matches with `=>`. Teams can move from exploration to automated remediation without changing tools.
JavaScript, TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, and SQL support makes Grit useful across mixed codebases.
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_hooksRecommended 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
FAQ
GritQL is a declarative query language for searching, linting, and modifying source code.
Grit matches code structure with metavariables and side conditions, while regex matches text. That makes Grit safer for many syntax-aware migrations.
Grit supports JavaScript, TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, and SQL.