ast-grep

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

6|2|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/trotsky1997/My-Claude-Agent-Skills --skill ast-grep-trotsky1997
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/trotsky1997/My-Claude-Agent-Skills/tree/main/ast-grep
Command: npx skills add https://github.com/trotsky1997/My-Claude-Agent-Skills --skill ast-grep-trotsky1997

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps translate natural language queries into ast-grep rules for structural code search, enabling precise matching of code patterns across large codebases.

Core Features & Use Cases

  • Generate ast-grep rules from natural language queries to locate code patterns based on structure rather than text.
  • Provide example rules and a workflow to test them against sample code with the ast-grep CLI.
  • Use Case: Quickly identify all async functions that contain await expressions in a JavaScript project to assess async patterns.

Quick Start

Use the ast-grep skill to generate a rule that finds all async functions containing await in a sample file and verify it with the ast-grep tool.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I find specific code patterns using AST instead of plain text search?▼

Structural code search uses Abstract Syntax Trees to match code constructs based on syntax rather than text. By translating natural language queries into ast-grep rules, you can precisely locate patterns like async functions containing await across large codebases.

What is the best way to generate structural code search rules from natural language?▼

Generating structural code search rules involves translating natural language queries into ast-grep patterns, inside/has relations, and metavariables. This approach enables structural code intelligence and auditing workflows to locate code constructs across multiple programming languages.

Can I use tree-sitter based AST search to audit large codebases?▼

Yes, you can audit large codebases by generating testable ast-grep rules from natural language queries. This workflow allows you to validate the structural code search results against your real codebase using the ast-grep CLI tool.

How does AST-based code analysis handle different programming languages?▼

AST-based code analysis leverages tree-sitter to parse and locate code constructs across different languages. The generated ast-grep rules use structural patterns and metavariables to enable precise code intelligence independent of specific programming language syntax.

Do I need the ast-grep CLI installed to test generated code search rules?▼

Yes, you need the ast-grep CLI installed to test generated code search rules. The skill provides a workflow to test the generated structural rules against sample code and validate the matching results in your actual codebase.