ast-grep

Search, rewrite, and lint code using AST pattern matching with tree-sitter grammars.

4|2|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/drunkcoding/AgentSkillsArxiv --skill ast-grep-drunkcoding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/drunkcoding/AgentSkillsArxiv/tree/main/skills/ast-grep
Command: npx skills add https://github.com/drunkcoding/AgentSkillsArxiv --skill ast-grep-drunkcoding

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

AST-aware search, rewrite, and linting enable precise code pattern matching based on structure rather than text, reducing false positives and enabling safe automated edits across languages.

Core Features & Use Cases

  • AST-based search with meta-variables to locate complex code patterns
  • Rewriting and automated fixes derived from captured patterns
  • YAML-based lint rules for static checks and style enforcement
  • Cross-language applicability thanks to tree-sitter grammars

Quick Start

Install ast-grep and run a structural search to locate and rewrite target patterns across your codebase.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How does AST-aware code search differ from plain text grep?

AST-aware code search matches structural syntax patterns rather than literal strings, reducing false positives and enabling precise function call and pattern matching across multi-language codebases using tree-sitter grammars.

What is the best way to automate code refactoring across multiple programming languages?

Automated code refactoring across languages is handled by specifying language-aware structural patterns and YAML rules, capturing matched meta-variables to generate and apply fixed code snippets safely across tree-sitter supported codebases.

Can I use YAML rules for static code analysis and linting?

Yes, YAML-based lint rules enable static checks and style enforcement by defining structural code patterns to scan for, allowing consistent quality checks across supported multi-language codebases.

Does ast-grep work with tree-sitter grammars for cross-language codebase refactoring?

Yes, cross-language applicability is supported through tree-sitter grammars, allowing structural pattern matching, linting, and automated rewriting for function calls and structural equivalents across different programming languages.

How do I rewrite function calls using structural pattern matching?

Function call rewriting uses AST-aware pattern matching to locate target structures, captures matched code into meta-variables, and generates fixed code snippets derived from those captured patterns for automated edits.