ast-grep

Converts natural language queries into executable ast-grep rules for structural code search.

Updated Jan 13, 2026
One-click install
npx skills add https://github.com/arielZusman/imai-dev-plugin --skill ast-grep-arielzusman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/arielZusman/imai-dev-plugin/tree/main/skills/ast-grep
Command: npx skills add https://github.com/arielZusman/imai-dev-plugin --skill ast-grep-arielzusman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill translates natural language queries into ast-grep rules to perform structural code search.

Core Features & Use Cases

  • Convert natural-language queries into ast-grep rules for structural matching.
  • Test and run AST-based searches across codebases to locate patterns or language constructs.
  • Use cases include finding all function declarations with specific constructs or identifying code with particular AST shapes.

Quick Start

Describe your search goal in natural language and translate it into an AST rule. Then run ast-grep with a simple rule to scan your codebase and review the matches.

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 structural code patterns using AST instead of plain text?

Structural code search with AST patterns translates natural language queries into ast-grep rules to locate code based on its abstract syntax tree shape. This allows you to find language constructs like async functions with specific nested elements rather than relying on regex string matching.

What is ast-grep used for in static analysis?

Ast-grep is used for static analysis to perform structural search across codebases. It applies atomic, relational, and composite rules with metavariables to identify code matching particular AST characteristics, satisfying the need to locate complex language constructs.

Can I use ast-grep to find all async functions with specific constructs?

Yes, you can find all async functions with specific constructs by describing your search goal in natural language. The skill translates this query into an ast-grep rule to scan your codebase and review the matching structural patterns.

Does ast-grep work across multiple programming languages?

Ast-grep works across codebases where structural patterns matter by utilizing tree-sitter. It relies on the ast-grep CLI and rule reference documentation to apply structural matching rules consistently across different programming languages.

How do I write ast-grep rules with metavariables for composite matching?

You write ast-grep rules with metavariables by translating natural language queries into atomic, relational, and composite rules. The skill generates these structural patterns based on the ast-grep CLI rule reference documentation to match specific AST characteristics.

What is the best way to run structural search and identify code with particular AST shapes?

The best way to identify code with particular AST shapes is to translate your natural language search goal into an ast-grep rule. You then run the ast-grep CLI with this rule to scan your codebase and review the structural matches.