ast-grep

Match code structures using Abstract Syntax Tree patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ast-grep, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of searching codebases efficiently using Abstract Syntax Tree (AST) patterns, enabling users to pinpoint specific code structures or patterns that go beyond simple text search.

Core Features & Use Cases

  • AST Pattern Matching: Locate code patterns and structures that are not easily searchable with text search.
  • Code Search: Perform complex queries that require understanding the structure of the code.
  • Use Case: For example, find all async functions in a codebase without error handling.

Quick Start

Use the ast-grep skill to find all async functions without error handling in your codebase by running the command 'ast-grep scan --inline-rules "id: find-async language: javascript rule: all: - kind: function_declaration - has: pattern: await $EXPR stopBy: end" /path/to/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 structures in a large JavaScript codebase?

To search for specific code structures in a large JavaScript codebase, use ast-grep to match Abstract Syntax Tree (AST) patterns. This enables precise structural queries that go beyond simple text search.

When do I need to use AST pattern matching instead of text search?

You need AST pattern matching when text search is insufficient to locate specific code structures. It allows you to pinpoint complex structural patterns in your code, such as finding all async functions without error handling.

What do I need to start running ast-grep commands?

To start running ast-grep commands, you need the ast-grep CLI installed and a basic understanding of AST patterns. You can then execute structural code searches directly against your project directory.

How can I find all async functions without error handling in my code?

You can find async functions without error handling by running an ast-grep scan with an inline rule. This command matches function declarations containing await expressions without requiring try-catch blocks.

Does ast-grep work for analyzing large codebases?

Yes, ast-grep is specifically suitable for analyzing large codebases. It uses Abstract Syntax Tree patterns to perform complex and precise structural queries that scale efficiently across extensive project directories.