grep-ast

0.9.0 · active · verified Sat Apr 11

grep-ast is a command-line tool designed to search through the Abstract Syntax Tree (AST) of source code files. Unlike traditional `grep` which operates on text, `grep-ast` provides a context-aware output, showing how matching lines fit into the broader code structure (functions, classes, etc.). It leverages `tree-sitter` and `tree-sitter-languages` for parsing various programming languages. The current version is 0.9.0, released in May 2025.

Warnings

Install

Quickstart

To quickly search for a pattern in a specific file or recursively in the current directory, use the `grep-ast` command followed by your pattern and optional filenames or paths. By default, it respects .gitignore. You can also use `gast` as an alias.

grep-ast "function_name" my_module.py
grep-ast "class MyClass" .

view raw JSON →