ast-grep

Perform structural code search and refactoring with AST pattern matching.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/alangeb/tau --skill ast-grep-alangeb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/alangeb/tau/tree/main/src/skills/ast-grep
Command: npx skills add https://github.com/alangeb/tau --skill ast-grep-alangeb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This skill solves the difficulty of performing complex, structural code searches and refactors that standard text-based grep tools cannot handle, such as identifying specific AST patterns or transforming code syntax across a large codebase.

Core Features & Use Cases

  • Structural Pattern Matching: Search for code based on its abstract syntax tree rather than just text, allowing for precise identification of function calls, class definitions, or control flow structures.
  • Automated Code Transformation: Perform safe, structural code rewrites across multiple files using pattern-based replacement.
  • Use Case: Use this skill to identify all instances of a specific deprecated function call pattern and automatically rewrite them to the new API signature across the entire project.

Quick Start

Use the ast-grep skill to search for all class definitions in the current directory and display the results.

Frequently Asked Questions about ast-grep

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I search for code based on abstract syntax tree patterns instead of text?

Automated code transformation performs structural rewrites based on abstract syntax tree pattern matching to safely replace syntax across multiple files. You define search and rewrite patterns to update deprecated function calls to new API signatures.

Why does text-based grep fail to find specific function call patterns in my codebase?

Text-based grep fails to find specific function call patterns because it cannot understand code structure or abstract syntax trees. Structural code search identifies function calls and class definitions by their syntax tree shape rather than exact text matches.

Do I need the ast-grep CLI tool to perform structural code analysis?

Structural code search identifies specific abstract syntax tree patterns like class structures and control flow across a complex codebase. This enables precise identification of structural syntax that standard text-based search tools cannot match.

Can I automatically rewrite deprecated function calls to a new API signature across multiple files?

Yes, automated code transformation rewrites deprecated function calls to a new API signature across multiple files. You define structural search and replacement patterns to safely transform code syntax throughout the entire project.

What's the best way to refactor code syntax across a large codebase safely?

Structural code refactoring using abstract syntax tree pattern matching is the best way to safely transform code syntax across a large codebase. It targets precise structural patterns for function calls and class definitions rather than fragile text replacements.