ast-grep

Convert natural-language code search requests into ast-grep rules for structural matching across repositories.

9|1|Updated Jan 15, 2016
One-click install
npx skills add https://github.com/wadackel/dotfiles --skill ast-grep-wadackel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/wadackel/dotfiles/tree/main/home/programs/claude/skills/ast-grep
Command: npx skills add https://github.com/wadackel/dotfiles --skill ast-grep-wadackel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Translates natural language queries into ast-grep rules for structural code search, enabling precise matches based on code structure rather than plain text.

Core Features & Use Cases

  • Translate NL queries into AST-based search patterns for JavaScript, Python, and other languages.
  • Create robust rules that locate specific constructs, like async functions or particular parameter patterns.
  • Debug and test rules against sample code to refine accuracy before running on a codebase.

Quick Start

Write a simple ast-grep rule to match all async functions in a JavaScript 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 specific code constructs like async functions in a JavaScript project?

ast-grep structural matching translates natural-language code search requests into rules, enabling you to identify patterns like async usage or specific constructs across multi-language codebases.

What is the difference between structural matching and plain text code search?

Structural matching analyzes the abstract syntax tree (AST) to locate exact code constructs and nesting scenarios, whereas plain text search only matches string literals regardless of the underlying code structure.

Can I use ast-grep rules to search across multi-language codebases?

Yes, ast-grep applies to multi-language codebases, allowing you to create robust rules that locate specific constructs in JavaScript, Python, and other programming languages across repositories.

How do I test and refine ast-grep rules before running them on a repository?

You can debug and test ast-grep rules against sample code files to refine accuracy. This ensures the structural matching patterns correctly identify the targeted constructs before applying them to the full codebase.

Why should I use stopBy: end when writing relational ast-grep rules?

You should use stopBy: end for relational ast-grep rules to ensure full subtree traversal. This guarantees that the structural matching engine accurately evaluates the entire code structure nested within the targeted pattern.