ast-grep

Translate natural language queries into AST-based structural code search rules.

Updated Jan 16, 2026
One-click install
npx skills add https://github.com/jeninh/ampskills-dotfile --skill ast-grep-jeninh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/jeninh/ampskills-dotfile/tree/main/.agents/skills/ast-grep
Command: npx skills add https://github.com/jeninh/ampskills-dotfile --skill ast-grep-jeninh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

AST-based code search requires understanding code structure and crafting patterns to find language constructs. This skill guides users to translate natural-language queries into ast-grep rules for precise, structural searches across codebases.

Core Features & Use Cases

  • Translate natural-language queries into AST-pattern rules for structural search.
  • Debug, test, and iterate rules against example snippets and real projects.
  • Use cases include locating specific language constructs, identifying refactoring opportunities, and performing deep code analysis beyond text matching.

Quick Start

Install the ast-grep CLI, write a simple YAML rule, and run a scan on your codebase to verify matches.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I translate natural language queries into AST-based rules for structural code search?

To translate natural language queries into AST-based rules for structural code search, you define YAML-based rules using fields like pattern, kind, inside, has, all, any, and not to locate precise language constructs beyond text matching.

What is the difference between AST pattern matching and regular text search for locating code?

AST pattern matching analyzes the structural syntax tree of code to locate language constructs, whereas regular text search only matches literal strings. AST search understands code structure, enabling precise identification of refactoring opportunities across languages.

How do I write and test YAML rules to find specific language constructs?

You write YAML rules utilizing fields such as pattern, kind, and inside to define structural matches, then test and iterate these rules against example snippets and real projects by running scans via the ast-grep CLI.

Does ast-grep work for structural code analysis across different programming languages?

Yes, ast-grep applies to software projects across multiple programming languages. It helps locate code patterns, extract language constructs, and analyze architecture beyond text search using language-agnostic YAML rule definitions.

When should I use AST-based code search instead of standard text matching?

You should use AST-based code search when you need to locate specific language constructs, identify refactoring opportunities, or perform deep code analysis that requires understanding code structure beyond what standard text matching can provide.