Grit is an open source code transformation tool that uses GritQL, a structural pattern-matching query language, to automate large-scale code migrations, dependency upgrades, and framework refactors across entire codebases.
The Problem
Framework upgrades and large refactors require making the same code change in hundreds or thousands of places. Manual find-and-replace fails on structural patterns; regex is fragile for code transformations; codemods require writing custom AST traversal scripts for each migration. Engineering teams spend days on mechanical transformation work that should be automated.
How Grit Solves It
GritQL is a query language for matching and rewriting code patterns structurally, not as text. Write a pattern that matches the old code shape and a replacement pattern for the new shape, and Grit applies the transformation across the entire codebase. A library of pre-built migration patterns covers common framework upgrades and API changes. Results are output as diffs or pull requests. MIT license applies to the core GritQL engine.
Key Features
- GritQL pattern language for structural code matching: handles syntax-aware rewrites that regex cannot
- Pre-built migration patterns for React, TypeScript, and other common framework upgrades
- Codebase-wide transformation: apply patterns across every file in a repository in one command
- Outputs diffs or creates pull requests for review before applying changes
- AI-assisted pattern generation: describe a transformation and Grit generates a GritQL pattern
Who It's For
Grit is best for platform engineering teams and tech leads managing large codebases who need to execute framework migrations, API deprecation cleanups, or large-scale refactors without assigning developers to mechanical transformation work.
Compared to Manual Codemods
Unlike writing one-off codemod scripts using jscodeshift or ts-morph, GritQL provides a reusable, declarative pattern language. Patterns are readable, testable, and composable across multiple migrations, rather than imperative scripts that are difficult to audit or generalize.

