Search and rewrite code with structural GritQL patterns before broad migrations
Use GritQL when an agent needs reviewable structural search and rewrite passes across a large codebase before a migration, policy cleanup, or API change, instead of relying on regex or hand edits.
Prerequisites
Grit CLI, a local repository to search or rewrite, and a review loop for inspecting the diffs produced by structural patterns.
Installation
Requirements and caveats from upstream:
- ♻️ Once you learn GritQL, you can use it to rewrite any target language: JavaScript/TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go,...
- Patterns can be combined to create complex queries, including large refactors.
- Reading/writing a codemod requires mentally translating from AST names back to what source code actually looks like.
Basic usage or getting-started notes:
Read the documentation, interactive tutorial, or run grit --help.
sh
Search for all your console.log calls by putting the desired pattern in backticks:
Extracted from upstream docs: https://raw.githubusercontent.com/biomejs/gritql/HEAD/README.md