ast-grep

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

10|Updated Dec 13, 2016
One-click install
npx skills add https://github.com/vitallium/dotfiles --skill ast-grep-vitallium
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/vitallium/dotfiles/tree/main/dot_agents/skills/ast-grep
Command: npx skills add https://github.com/vitallium/dotfiles --skill ast-grep-vitallium

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Ast-grep enables code teams to perform structural code search by translating natural language queries into AST-based rules, allowing precise matching beyond plain text searches.

Core Features & Use Cases

  • Translate natural language descriptions into ast-grep rules that target AST patterns.
  • Support multi-language structural searches and complex queries using atomic, relational, and composite rules.
  • Provide debugging and testing guidance with references for iteratively refining rules and validating results.

Quick Start

Tell me the code pattern you want to find and I will generate an ast-grep rule that matches its AST structure.

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 based on syntax structure instead of plain text?

Structure-aware code search with AST patterns translates natural language requests into ast-grep rules, matching code by syntax structure. This targets AST node shapes rather than raw strings to locate specific code structures.

What is the best way to find all async functions matching a specific pattern in a multi-language codebase?

Translating natural language requests into ast-grep rules enables structural matching across multi-language codebases. You use atomic rules and composite logic to target specific node types like async functions by their AST shapes.

Can I use ast-grep to find code patterns that appear inside or follow other specific structures?

Yes, ast-grep supports relational rules like inside, has, precedes, and follows. These allow you to match AST patterns based on their structural relationship to surrounding code elements.

How do I translate a natural language code search request into a valid ast-grep rule?

You describe the code pattern you want to find, and the skill generates an ast-grep rule using atomic, relational, or composite logic. It also provides references for iteratively refining and validating the structural matching results.

Does static analysis with AST patterns support complex queries using composite logic and metavariables?

Yes, static analysis with AST patterns supports composite logic using all, any, and not operators alongside metavariables. This enables complex structural matching for multi-language codebases.