Gr

GritQL, a Rust CLI for rewriting source code

Hacker News

GritQL, a Rust CLI for rewriting source code

Hi everyone! I’m excited to open source GritQL, a Rust CLI for searching and transforming source code. GritQL comes from my experiences with conducting large scale refactors and migrations. Usually, I would start exploring a codebase with grep. This is easy to start with, but most migrations end up accumulating additional requirements like ensuring the right packages are imported and excluding cases which don’t have a viable migration path. Eventually, to build a complex migration, I usually ended up having to write a full codemod program with a tool like jscodeshift. This comes with its own problems: - Most of the exploratory work has to be abandoned as you figure out how to represent your original regex search as an AST. - Reading/writing a codemod requires mentally translating from AST names back to what source code actually looks like. - Performance is often an afterthought, so iterating on a large codemod can be painfully slow. - Codemod frameworks are language-specific, so if you’re hopping between multiple languages—or trying to migrate a shared API—you have to learn different tools. GritQL is an attempt to develop a powerful middle ground: - Exploratory analysis is easy: just put a code snippet in backticks and use $metavariables for placeholders. - Incrementally add complexity by introducing side conditions with where clauses. - Reuse named patterns to avoid rebuilding queries, and use shared patterns from our standard library for common tasks like ensuring modules are imported. - Iterate on large codebases quickly: we use Rust for maximum performance GritQL has already been used on thousands of repositories for complex migrations[1] but we're excited to collaborate more with the open source community. [1] Ex. https://github.com/openai/openai-python/discussions/742

Share card

Actual performance

280points
54comments
Made the leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: openai, tasks, code · Missing: mac, agents, macos
86%86% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Hacker NewsStrong engagement from HN community · Strong signals: excited, open source, ide · Missing: https docs, just released, exist
70%70% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
65%65% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
TrustMRRFits verified-revenue profile · Missing: mobile apps, ios, personal
57%57% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
34%34% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
11%11% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: collaborate · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

Hs
Hsctl, a CLI for HomeSeer in Rust43%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Hsctl, a CLI for HomeSeer in Rust

Hacker News1
A
A simple Rust CLI for debugging transient errors47%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A simple Rust CLI for debugging transient errors

Hacker News3
A
A faster fuck (thefuck CLI rewritten in Rust)58%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

A faster fuck (thefuck CLI rewritten in Rust)

Hacker News2
Di
Diem – a daily CLI todolist in rust39%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Diem – a daily CLI todolist in rust

Hacker News1
RS
RSBadges - A code badge generator in Rust50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

RSBadges - A code badge generator in Rust

Hacker News20
St
StatsD in Rust51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

StatsD in Rust

Hacker News1
TF
TF-IDF in Rust51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

TF-IDF in Rust

Hacker News1
Sc
Screencast: An Introduction to Rust57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Screencast: An Introduction to Rust

Hacker News3
Ha
Handlebars for Rust51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Handlebars for Rust

Hacker News2
Ox
Oxischeme – A Scheme implementation in Rust56%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Oxischeme – A Scheme implementation in Rust

Hacker News18