ast-grep-patterns

Identify and extract code patterns via ast-grep structural search across Python, TypeScript, Go, Rust, and JavaScript.

9|5|Updated Aug 8, 2025
One-click install
npx skills add https://github.com/AnExiledDev/CodeForge --skill ast-grep-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep-patterns
Source: https://github.com/AnExiledDev/CodeForge/tree/main/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns
Command: npx skills add https://github.com/AnExiledDev/CodeForge --skill ast-grep-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Codebases often require finding complex code patterns that go beyond simple text search. This skill enables precise, structural searches to locate constructs like function calls, class definitions, and imports using ast-grep patterns.

Core Features & Use Cases

  • Structural search with ast-grep across languages (Python, JavaScript/TypeScript, Go, Rust).
  • Meta-variable driven patterns to capture and reuse matched nodes.
  • Comprehensive reference material (language patterns) to accelerate pattern authoring.

Quick Start

Provide a language and pattern to search, and ast-grep will return all matching code structures.

Frequently Asked Questions about ast-grep-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find complex code patterns that simple text search cannot match?

Structural search with ast-grep identifies and extracts complex code patterns like function calls and class definitions using tree-sitter, moving beyond simple text matching.

Can I use ast-grep structural search for Python, TypeScript, and Rust refactors?

Yes, ast-grep structural search applies to Python, TypeScript, Go, Rust, and JavaScript projects for refactors, bug hunts, and security reviews.

How do meta-variable patterns work for matching code structures across languages?

Meta-variable driven patterns capture and reuse matched code nodes, enabling precise structural matching across multiple programming languages using tree-sitter syntax.

What is the best way to locate function calls and imports without exact string matching?

Using ast-grep structural search is the best way to locate constructs like function calls, class definitions, and imports by matching the code's abstract syntax tree.

Does ast-grep require tree-sitter grammar knowledge to write custom search patterns?

No, you provide a language and pattern and ast-grep returns matching structures, though comprehensive reference material accelerates authoring meta-variable patterns.

Why use structural search over regular expressions for security reviews?

Structural search understands code syntax through tree-sitter, avoiding false positives from regex string matching when hunting bugs or conducting security reviews.