ast-grep

Translate natural language queries into structural AST patterns for code search.

10|1|Updated Jun 29, 2026
One-click install
npx skills add https://github.com/mishahanin/heading-os --skill ast-grep-mishahanin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/mishahanin/heading-os/tree/main/.claude/skills/ast-grep
Command: npx skills add https://github.com/mishahanin/heading-os --skill ast-grep-mishahanin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill solves the limitation of traditional text-based search by allowing you to find code based on its structural characteristics, such as language constructs, node relationships, and AST patterns, rather than just matching strings.

Core Features & Use Cases

  • Structural Pattern Matching: Search for code patterns like async functions lacking error handling or specific function call structures.
  • Relational Queries: Use relational logic like inside, has, precedes, and follows to find code within specific contexts.
  • Use Case: Quickly identify all instances of a specific API usage across a large codebase to ensure migration compliance or to debug structural anti-patterns.

Quick Start

Use the ast-grep skill to find all async functions that do not contain a try-catch block in the current directory.

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 based on structural patterns instead of text matching?

Structural code search uses abstract syntax tree patterns to match code based on language constructs and node relationships rather than exact strings. This allows you to find specific API usage or function call structures across a large codebase.

How do I find async functions that are missing error handling?

You can find async functions lacking error handling by translating a natural language query into an AST pattern. This structural matching technique identifies all asynchronous functions that do not contain a try-catch block within their scope.

Can I search for code within specific contexts like inside or preceding other blocks?

Relational queries support structural matching using inside, has, precedes, and follows logic. This allows you to find code patterns situated within specific contexts, such as function calls nested inside conditional blocks.

Does structural code search require any specific CLI tools to execute queries?

Executing structural code search queries requires the ast-grep CLI tool. This command-line application validates your structural patterns against language-specific grammars to perform precise code analysis.

What is the best way to identify structural anti-patterns across a large codebase?

The best way to identify structural anti-patterns is using structural matching to query abstract syntax trees. This approach detects non-compliant code patterns across large-scale codebases for security auditing and architectural pattern enforcement.

When should I use structural matching instead of traditional text-based search?

Structural matching is necessary when text-based search fails to capture language constructs, node relationships, and AST patterns. Use it for large-scale codebase refactoring, security auditing, and ensuring API migration compliance.