ast-grep

Match code syntactic structures for search and refactoring across codebases.

Updated Nov 24, 2025
One-click install
npx skills add https://github.com/ByronWilliamsCPA/.claude --skill ast-grep-byronwilliamscpa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/ByronWilliamsCPA/.claude/tree/main/.claude/skills/ast-grep
Command: npx skills add https://github.com/ByronWilliamsCPA/.claude --skill ast-grep-byronwilliamscpa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the limitations of text-based code search and manual cross-file refactoring, which fail when code formatting varies or when you need to match syntactic patterns instead of literal strings.

Core Features & Use Cases

  • Structural Code Search: Match code patterns including function calls, decorators, import statements, and class definitions regardless of whitespace or formatting differences.
  • Automated Cross-File Refactoring: Rewrite matching code patterns across entire codebases using consistent meta-variables to avoid manual errors.
  • Use Case: For example, if you need to rename a function parameter across 50 Python files, this Skill will match all instances of the old parameter in function calls and rewrite them to the new name without missing any due to formatting variations.

Quick Start

Use the ast-grep skill to find all Python function calls using the old 'timeout' parameter and rewrite them to use the new 'connect_timeout' parameter across the entire src/ 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 patterns by syntax structure instead of literal text?

Structural code search matches syntactic structures like function calls and import statements rather than literal strings, ensuring accurate pattern detection regardless of whitespace or formatting variations across files.

How do I rename a function parameter across multiple Python files without missing formatting variations?

Automated cross-file refactoring uses meta-variables to match syntactic patterns of function calls, rewriting matching code patterns across entire codebases to consistently rename parameters without manual errors.

What is the best way to run a codebase-wide codemod for syntax matching?

Syntax-aware code modifications use YAML rule files and meta-variables to define complex relational pattern matching, enabling deterministic codebase-wide codemods for structural search and refactoring tasks.

Does structural code search work with Go, Rust, and TypeScript?

Structural code search supports multiple programming languages including Python, JavaScript, TypeScript, Rust, Go, and Bash, matching decorators, import statements, and class definitions across these environments.

Why does text-based code search fail when refactoring syntax patterns?

Text-based code search fails when code formatting varies or when matching syntactic patterns instead of literal strings is required, making structural search necessary for accurate cross-file refactoring.

How do I match decorators and import statements regardless of code formatting?

Match code patterns including decorators, import statements, and class definitions using structural search, which identifies syntactic structures instead of literal text to ignore whitespace and formatting differences.