ast-grep

Translate user queries into AST-based code search patterns for Tree-sitter languages.

13|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/ulpi-io/browse --skill ast-grep-ulpi-io
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/ulpi-io/browse/tree/main/.agents/skills/ast-grep
Command: npx skills add https://github.com/ulpi-io/browse --skill ast-grep-ulpi-io

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Structural code search relies on textual matching being insufficient for identifying meaningful patterns; ast-grep enables finding code by its actual structure using AST patterns.

Core Features & Use Cases

  • Structural search: Find code by syntax and semantics, not just text.
  • Pattern-driven queries: Express targeted queries across languages supported by tree-sitter.
  • Use Case: Locate all async functions that lack proper error handling or locate specific API call patterns in a codebase.

Quick Start

Run a sample search against a small code snippet to verify the rule works.

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 by its syntax structure instead of plain text?

Structural code search uses AST pattern matching to find code by syntax and semantics rather than exact text. You write pattern-driven queries using metavariables to locate structural matches across large codebases.

How does AST pattern matching handle async functions and API call patterns?

AST pattern matching parses code into syntax trees to locate async functions and API call patterns. It uses atomic, relational, and composite rules with metavariables to express targeted queries across supported languages.

Can I use tree-sitter languages for structural code search?

Yes, structural code search applies to all languages supported by tree-sitter. It translates user queries into AST-based search patterns to find structural matches across large codebases.

What is the best way to find async functions lacking error handling in a large codebase?

Using AST-based code search is the best way to find async functions lacking error handling. It applies structural rules and metavariables to locate structural matches precisely across large codebases.

Do I need the ast-grep CLI installed to run structural code search rules?

Yes, running AST-based code search requires the ast-grep CLI. It executes the translated user queries, applying atomic, relational, and composite rules with stopBy conditions to find structural matches.

How do metavariables work in structural code search patterns?

Metavariables in structural code search patterns act as flexible placeholders for matching varying syntax structures. They enable pattern-driven queries to locate structural matches across supported tree-sitter languages.