explaingit

biomejs/gritql

4,498RustAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A query language for searching and automatically rewriting code across your entire codebase using patterns that look like real code, eliminating the need for complex codemod scripts.

Mindmap

mindmap
  root((gritql))
    What It Does
      Code search
      Auto rewrite
      Custom lint rules
    Languages
      JS and TS
      Python Go Rust
      JSON YAML SQL
    How It Works
      Pattern matching
      Where clauses
      tree-sitter parse
    Use Cases
      Library migration
      API upgrades
      CI enforcement
    Setup
      Single curl install
      200 built-in patterns
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Find every call to a specific function across a large multi-language codebase in seconds

USE CASE 2

Automatically rename or restructure API calls when upgrading a library version

USE CASE 3

Create custom lint rules your team runs in CI to enforce consistent code style

USE CASE 4

Migrate a codebase from one logging library to another without manual find-and-replace

Tech stack

Rusttree-sitter

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial projects, as long as you keep the copyright notice.

In plain English

GritQL is a query language for finding and rewriting code across an entire codebase. The central idea is that you describe what you are looking for by writing something that looks like the actual code, with placeholder variables for the parts you want to match against anything. For example, putting console.log($msg) in backticks gives you a search that finds every console.log call regardless of what argument is passed. Adding => winston.log($msg) turns that search into an automatic replacement. The language is designed to replace the point where large coding projects typically outgrow simple text search and have to be replaced with complex codemod scripts. Writing a codemod normally requires learning how the language's abstract syntax tree (a technical internal representation of code structure) works, which is time-consuming and hard to read back later. GritQL lets you stay closer to the original source code syntax while still handling complex conditional rules through where clauses that narrow down which matches actually qualify. GritQL supports more than a dozen programming languages from a single tool: JavaScript and TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, and SQL. Patterns can be saved to a configuration file and run as custom lint rules in a continuous integration pipeline using grit check. A standard library of over 200 reusable patterns is available, covering common refactoring tasks like updating API calls when a library changes its interface. The tool is written in Rust and is built for performance at scale, with the README citing repositories of over ten million lines as a target use case. It uses tree-sitter under the hood for parsing. Installation is a single curl command. The license is MIT.

Copy-paste prompts

Prompt 1
Write a GritQL pattern to find all console.log calls in my TypeScript project and replace them with logger.info, preserving the arguments
Prompt 2
How do I write a GritQL where clause to only match import statements from a specific package path and rename them?
Prompt 3
Create a GritQL pattern to find all deprecated API usages in my Python code and suggest the replacement call
Prompt 4
Write a grit.yaml config with a custom lint rule that flags any use of var declarations in JavaScript files and fails CI
Open on GitHub → Explain another repo

← biomejs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.