ast-grep

Installation
SKILL.md

ast-grep — Structural Code Search, Lint, and Rewrite

Content verified against ast-grep 0.45.1. Flags can drift between versions — when a command fails, check ast-grep <cmd> --help.

Overview

ast-grep is a fast, Rust-based CLI tool. It parses code with tree-sitter and matches the syntax tree, not the text. You write patterns that look like the code you search for. Metavariables ($NAME, $$$ARGS) act as wildcards for AST nodes.

Three main modes:

Mode Command Use for
Search / rewrite ast-grep run -p '<pattern>' (default command) One-time queries and codemods
Lint ast-grep scan YAML rule sets, CI checks, complex rules
Explore ast-grep outline Symbols, imports, exports of files

It supports 25+ languages: JavaScript, TypeScript, TSX, Python, Rust, Go, Java, C, C++, C#, Kotlin, Swift, Ruby, PHP, and more. See the language table in references/cli-reference.md.

Installation

Installs
2
GitHub Stars
4
First Seen
Aug 13, 2026
ast-grep — rolandbrecht/agent-skills