The archive · Product Ideas · Product decision · 2024–2026
GritQL lets any code snippet be a query for rewriting huge multi-language codebases
GritQL turns source code into the query language: paste the snippet you want to find, add metavariables, and rewrite millions of lines across languages.
Grit
What it had to solve
Large refactors usually begin as grep and end as full codemod programs in tools like jscodeshift: the exploratory search is abandoned while the regex is translated into AST concepts, frameworks are language-specific and hard to compose, and iteration on huge codebases is slow. GritQL set out to be the middle ground between grep and a codemod framework.
How it works
GritQL grew out of Grit's own large-scale refactors, where migrations follow a familiar arc: exploratory grep searches to scope the problem, then accumulated requirements — imports to ensure, edge cases to exclude — that push the work into a full codemod program. That jump is where most of the pain sat: the exploratory work gets abandoned, regex must be mentally translated into AST nodes, and every framework is language-specific and poorly composable.
GritQL's move was to let the query read like the code itself. Any code snippet in backticks is a valid query — `console.log($_)` finds every console.log call — with $metavariables as holes, `=>` turning a match into a rewrite, and where clauses adding side conditions such as 'not inside a try-catch'. The same grammar works for search, custom lints and migrations, so a first grep can harden into a permanent rule without switching tools or languages.
Written in Rust on tree-sitter, the engine scaled to 10M+ line repositories and a dozen target languages, and a module system plus a 200+ pattern standard library made complex migrations composable from small, reviewable rules. The Show HN of March 2024 brought 280 points and 54 comments, and commenters reported using it for real moves within days; by 2026 the project page lived under biomejs with 4.6k stars.
Why it lands
- The tool's grammar matched the developer's grammar: people already know how to write the code they want to find, so the first query needs no AST vocabulary or new framework.
- Exploration could harden into automation: a pattern starts as a search, gains where clauses for edge cases, and ends up as a lint or migration rule in the same file.
- Composition replaced copy-paste: named patterns and a shared standard library let a team assemble complex migrations from small, reviewable pieces.
- The engine was built for the hard case: Rust plus tree-sitter kept queries fast on 10M+ line repositories across many languages, where slower codemods had failed.
What it did
The Show HN drew 280 points and 54 comments on 20 March 2024, with developers reporting real migrations done in the first days — the OpenAI SDK 1.0 upgrade and a mobx-to-react-hooks move. The project page later moved to the biomejs organization, where the 2026 snapshot shows 4.6k stars, 125 forks and 379 commits.
What you can take
Design the control language from the work itself: when a query uses the same grammar as the code it edits, the learning curve vanishes and a pattern can grow from search into a permanent rewrite rule.
Since then
GritQL stayed open source under MIT and remained the query layer of Grit's migration work, with the standard library of reusable patterns still referenced from the project. The repository's 2026 home is the biomejs organization, showing 4.6k stars, 125 forks and 379 commits, and the language continued to be positioned for searching, linting and auto-fix remediation as well as whole-codebase rewrites.
Sources
spotted an error? The archive wants to know.
Your turn
You just read one. Describe the brief you are staring at, and see who has been given the same problem.
Free account · 3 free questions · no card