HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
ast-grep
ast-grep
Rust2023–2026
ast-grep / ast-grep

ast-grep

⚡A CLI tool for code structural search, lint and rewriting. Written in Rust

14Distinct people
19Mentions
0Explicit recommenders
16.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

⚡A CLI tool for code structural search, lint and rewriting. Written in Rust

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year19 dated mentions

Observed mentions: 2023-05-10 17:14:02 UTC to 2026-07-29 05:08:00 UTC.

02462023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 5 mentions; 2 submissions, 3 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 7 mentions; 0 submissions, 7 comments20242025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC523
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC707
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC303
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC413

What Hacker News says

19 sources
The relevant points have already been made: (1) LSP is a JSON-RPC protocol, not a CLI app, and (2) Language Servers that implement LSP often utilize AST manipulation, even the resultant manipulations are exposed to the client via character ranges. Still, these links may be of interest: TypeScript’s language-service implementation of the “Move to file” refactor: https://github.com/microsoft/TypeScript/blob/main/src/servic... Documentation for how `typescript-language-server` exposes that refactor as an opt-in code action: https://github.com/typescript-language-server/typescript-lan... `ast-grep`, an AST-based search and transformation tool that may be closer in spirit to the cli functionality you describe, albeit more general-purpose: https://github.com/ast-grep/ast-grep
In Interview with Boris Cherny [video]
Text surely is a hill, but I believe it's a local one, we got stuck on due to our short-sighted inability to go into a valley for a few miles until we find the (projectional) mountain. All of your examples work better for code with structural knowledge: - grep: symbol search (I use it about 100x as often as a text grep) or https://github.com/ast-grep/ast-grep - diff: https://semanticdiff.com (and others), i.e.: hide noisy syntax only changes, attempt to capture moved code. I say attempt, because with projectional programming we could have a more expressive notion of code being moved - sed: https://npmjs.com/package/@codemod/cli - version control: I'd look towards languages like Unison to see what funky things we could do here, especially for libraries. A general example: no conflicts due to non-semantic changes (re-orderings, irrelevant w
Read the rest
hitespaces, etc.)
In Formatting code should be unnecessary
Congrats from ast-grep team! Nice job Morgante! GritQL shares a lot of common ground with ast-grep, which is also a code rewriter based on tree-sitter. Interested folks may wonder about their difference. The key difference is that their surface APIs are quite different. GritQL is more like a DSL (or SQL). while ast-grep is more like pattern language + embedded configuration in YAML. Check it out here if you are interested https://github.com/ast-grep/ast-grep
In Show HN: GritQL, a Rust CLI for rewriting source code
Something I find really interesting about this is the way the tool is packaged. You can install the CLI utility in four different ways: https://ast-grep.github.io/guide/quick-start.html#installati... # via Homebrew brew install ast-grep # via Cargo cargo install ast-grep # via npm npm i @ast-grep/cli -g # via pip pip install ast-grep-cli # I tested and pipx works too: pipx install ast-grep-cli I really like this - it means the tool is available to people with familiarity of any of those four distribution mechanisms. You can also download pre-built binaries from their releases page: https://github.com/ast-grep/ast-grep/releases/tag/0.14.2 On top of that, they offer API bindings for it in three different languages: - Rust (not yet stable): https://docs.rs/ast-grep-core/latest/ast_grep_core/ - JavaScr
Read the rest
ipt/TypeScript: https://ast-grep.github.io/guide/api-usage/js-api.html - Python: https://ast-grep.github.io/guide/api-usage/py-api.html It's rare to see a tool/library offer this depth of language support out of the box.
In AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting

Showing the 15 most recent of 19 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.