ast-grep

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

1|Updated Apr 13, 2015
One-click install
npx skills add https://github.com/tyler-dot-earth/.dotfiles --skill ast-grep-tyler-dot-earth
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/tyler-dot-earth/.dotfiles/tree/main/agents/skills/ast-grep
Command: npx skills add https://github.com/tyler-dot-earth/.dotfiles --skill ast-grep-tyler-dot-earth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Translates natural language requests into ast-grep rules to perform structural code search across diverse languages, enabling precise queries that go beyond text matching.

Core Features & Use Cases

  • Convert natural language descriptions into atomic, relational, and composite rules.
  • Use stopBy: end and metavariables for robust, scalable code searches over large codebases.
  • Example: find all async functions that contain await expressions within a class method.

Quick Start

Describe the code pattern you want to find and I will generate the corresponding ast-grep rule you can test in your project.

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

Structural code search uses AST patterns to locate language constructs like async functions containing await expressions, going beyond simple text matching by understanding code structure.

Can I find async functions that contain await expressions within a class method?▼

Yes, you can describe the code pattern in natural language and the tool generates ast-grep rules using atomic, relational, and composite rules to find complex structural matches.

What is the best way to analyze codebases across different programming languages for specific language constructs?▼

Using ast-grep rules with tree-sitter ASTs lets you analyze codebases across diverse languages by generating structural rules to locate specific language constructs precisely.

Does ast-grep support metavariables and composite rules for complex code searches?▼

Yes, ast-grep supports metavariables, composite rules, and stopBy: end settings to express complex queries and ensure robust matches over large codebases.

Why use structural code search when simple text search finds my query strings?▼

Structural code search understands AST shapes, so it locates patterns not captured by simple text search, such as class methods with specific nested constructs or relational rules.

Do I need to write ast-grep rules manually to search for structural patterns?▼

No, you can describe the code pattern you want to find in natural language and the tool will generate the corresponding ast-grep rule for you to test in your project.