$npx skillfedfor your agent

ast-grep-cli

Structural Search and Rewrite code at large scale using precise AST pattern.

With conditionsPyPI Software DevelopmentReleased Aug 20262.8M downloads / mopermissive licensePlatform wheel

Decision gist · record as of 2026-08-14

platform wheels — ast_grep_cli-0.45.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl · ast_grep_cli-0.45.1-py3-none-macosx_10_12_x86_64.whl · ast_grep_cli-0.45.1-py3-none-manylinux_2_28_aarch64.whl
v0.45.1 · released 2026-08-07

Yes, if you need to search or refactor code at scale using syntax-aware patterns. The tool is actively maintained, has no known vulnerabilities, and solves a real problem that text-based grep cannot. Medium install friction (compiled binary) is typical for performance-critical tools. Verify Python version support before committing to a project dependency.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires a supported language (ts, js, python, etc.) to be specified via --lang flag; pattern syntax must match valid code structure for the target language.
  • Medium install friction due to platform-specific wheels (compiled Rust binary).
  • Actively maintained with recent releases; last commit 2026-08-14 and 15516 repository stars indicate solid ongoing support.

License · maintenance · safety

permissive license (permissive) — MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions.

last release 2026-08-07 (7 days) · last repo commit 2026-08-14 · 15,516 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,791,546 downloads/mo, #2,887 on PyPI

Verify before relying

pip install ast-grep-cli

ast-grep --pattern 'var code = $PATTERN' --rewrite 'let code = new $PATTERN' --lang ts
  • Whether the Python package wraps the compiled Rust binary or requires separate installation of the Rust tool.
  • What Python versions are officially supported (requires_python is unspecified in metadata).
  • Performance characteristics and scalability limits for very large codebases.
Same gist for agents: .md · .json

What it is and what it does

ast-grep-cli is a structural code search and rewrite tool built on tree-sitter parsing. Instead of matching text patterns like grep, it matches abstract syntax tree nodes, letting you write patterns as ordinary code with wildcards (like `$MATCH`) to find and replace code with identical syntactical structure across a codebase.

The tool is written in Rust for performance and supports multiple languages. It's designed for large-scale code manipulation tasks: library authors can use it to help users adopt breaking changes, teams can enforce code best practices, and security researchers can write detection rules. It can be driven from the command line with pattern and rewrite flags, or configured via YAML for custom linting rules.

Use it for

  • Migrate code to use null coalescing operators or other modern syntax patterns across a large TypeScript codebase.
  • Enforce team code standards by writing AST-based linting rules in YAML without writing custom ESLint plugins.
  • Perform large-scale library API migrations by defining structural patterns that match the old API and rewrite them to the new one.
  • Detect security anti-patterns or code smells by searching for specific AST structures across multiple files and languages.
  • Refactor code idiomatically (e.g., replace callback patterns with async/await) by matching syntactic structure rather than text.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need to search or refactor code at scale using syntax-aware patterns.

The tool is actively maintained, has no known vulnerabilities, and solves a real problem that text-based grep cannot. Medium install friction (compiled binary) is typical for performance-critical tools. Verify Python version support before committing to a project dependency.

Install

ast-grep-cli on PyPI

Before you install

Medium install friction due to platform-specific wheels (compiled Rust binary). Actively maintained with recent releases; last commit 2026-08-14 and 15516 repository stars indicate solid ongoing support.

Requires a supported language (ts, js, python, etc.) to be specified via --lang flag; pattern syntax must match valid code structure for the target language.

License in practice

MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

pip install ast-grep-cli

ast-grep --pattern 'var code = $PATTERN' --rewrite 'let code = new $PATTERN' --lang ts

Verify before relying

  • Whether the Python package wraps the compiled Rust binary or requires separate installation of the Rust tool.
  • What Python versions are officially supported (requires_python is unspecified in metadata).
  • Performance characteristics and scalability limits for very large codebases.

Package facts

Licensepermissive license permissive
Python supportNot specified
Install frictionMedium. Platform-specific wheel
Runtime dependenciesNone
MaintenanceActively maintained 7 days since the last release
Last repo commit
First released
Downloads2,791,546 / month, #2,887 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 3 - AlphaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: RustTopic :: SecurityTopic :: Software DevelopmentTopic :: Software Development :: Quality AssuranceTopic :: Text Processing

Evidence: ast_grep_cli-0.45.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; ast_grep_cli-0.45.1-py3-none-macosx_10_12_x86_64.whl; ast_grep_cli-0.45.1-py3-none-manylinux_2_28_aarch64.whl; ast_grep_cli-0.45.1-py3-none-manylinux_2_28_x86_64.whl; ast_grep_cli-0.45.1-py3-none-win32.whl; ast_grep_cli-0.45.1-py3-none-win_amd64.whl; ast_grep_cli-0.45.1-py3-none-win_arm64.whl

Tags

Capabilities
ast pattern matching code searchstructural code search and rewritecodemod tool ast-basedcode linting with ast patternstree-sitter pattern matchinglarge-scale code refactoringsyntax tree code analysis
Topics
codemodast-based-searchrefactoring
PyPI keywords
astpatterncodemodstructural searchrewrite

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 › “ast pattern matching code search”

  • ast-grep-cliast-grep-cli is a command-line tool for searching, linting, and…
  • ast-grep-pyast-grep-py is a Python binding for ast-grep, a tool that searches,…
  • grep-astSearch source code files by pattern and display matching lines with…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

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.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

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.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

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.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

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.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

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.

permissive licensepure Python
323.3Mdownloads / mo

See also ast-grep-py · grep-ast · gritql · tensor-grep · gron · astatine · libcst · tree-sitter-rust · trailmark · ast-decompiler