grep-ast
A tool to grep through the AST of a source file
Decision gist · record as of 2026-08-14
Yes, if you work with source code search and want to understand context. Low install friction and permissive license make it a low-risk addition. Aging maintenance (463 days since last release) is a minor concern but the repository is active and has reasonable adoption. No known vulnerabilities. Install if you need AST-aware code search; skip if you only need simple text grep.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction; pure Python wheel.
- Maintenance status is aging—last release was 463 days ago—but the repository is active and not archived, with 362 stars.
License · maintenance · safety
permissive license (permissive) — Licensed under Apache Software License (permissive), so you can use, modify, and distribute the package freely with minimal restrictions.
last release 2025-05-08 (463 days) · last repo commit 2025-05-08 · 362 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,768,321 downloads/mo, #3,574 on PyPI
Alternatives
Verify before relying
pip install grep-ast
grep-ast 'pattern' /path/to/code
# or with options:
grep-ast -i --color 'pattern' src/- Whether Python version support is truly unspecified or if there is a practical minimum version requirement
- How well the tool handles very large codebases or deeply nested syntax trees
- Whether the .gitignore-respecting behavior works correctly across all supported operating systems
What it is and what it does
grep-ast is a command-line search tool that finds patterns in source code and displays matching lines along with their syntactic context—the enclosing functions, classes, loops, and other code blocks they belong to. It uses tree-sitter to parse code into an abstract syntax tree, then shows you not just the match but how it fits into the broader structure of the file. This is useful when you need to understand not just where a pattern appears, but what code context surrounds it.
The tool respects .gitignore by default and recurses through directories, so you can run it from a repository root without specifying files. It supports many popular programming languages via tree-sitter-language-pack and can be invoked as either `grep-ast` or `gast`. It offers basic options like case-insensitive matching, color control, and encoding specification.
Use it for
- Find all uses of a function name and see which functions or classes call it and in what context
- Search for a variable name and understand the scope and surrounding logic where it appears
- Locate a specific pattern across a codebase and see the class or method definitions that contain each match
- Explore a large unfamiliar codebase by searching for key terms and seeing their structural context
- Refactor code by finding all occurrences of a pattern and understanding their relationships to surrounding code
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you work with source code search and want to understand context.
Low install friction and permissive license make it a low-risk addition. Aging maintenance (463 days since last release) is a minor concern but the repository is active and has reasonable adoption. No known vulnerabilities. Install if you need AST-aware code search; skip if you only need simple text grep.
Install
grep-ast on PyPI
Before you install
Low install friction; pure Python wheel. Maintenance status is aging—last release was 463 days ago—but the repository is active and not archived, with 362 stars.
License in practice
Licensed under Apache Software License (permissive), so you can use, modify, and distribute the package freely with minimal restrictions.
Quickstart
pip install grep-ast
grep-ast 'pattern' /path/to/code
# or with options:
grep-ast -i --color 'pattern' src/
Verify before relying
- Whether Python version support is truly unspecified or if there is a practical minimum version requirement
- How well the tool handles very large codebases or deeply nested syntax trees
- Whether the .gitignore-respecting behavior works correctly across all supported operating systems
Package facts
| License | permissive license permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestree-sitter-language-packpathspec |
| Maintenance | Aging 463 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,768,321 / month, #3,574 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software License |
Evidence: grep_ast-0.9.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “grep source code ast context”
- grep-astSearch source code files by pattern and display matching lines with…
- jcodemunch-mcpAn MCP server that retrieves precise source code symbols and context…
- tensor-grepA high-performance grep-compatible command-line search tool with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also ast-grep-cli · tensor-grep · gron · tree-sitter-zig · trailmark · ast-grep-py · ripgrep · tree-sitter-powershell · tree-sitter-julia · tree-sitter-groovy