ast-grep

Consolidate best practices for writing, validating, and debugging ast-grep rules.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/pohlai88/afenda-vite-react --skill ast-grep-pohlai88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep
Source: https://github.com/pohlai88/afenda-vite-react/tree/main/.agents/skills/ast-grep
Command: npx skills add https://github.com/pohlai88/afenda-vite-react --skill ast-grep-pohlai88

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Provides a centralized, scalable framework for writing, reviewing, and debugging ast-grep rules by codifying best practices, reducing false positives, and accelerating rule authoring across languages.

Core Features & Use Cases

  • Comprehensive guidance on pattern syntax, meta variables, constraint design, rule composition, rewrites, testing, and project organization.
  • Practical examples, anti-patterns, and checklists to improve accuracy, performance, and maintainability of AST-based rules.
  • Real-world workflows for validating, testing, and transforming code with ast-grep, AGENTS collaboration notes, and templated references.

Quick Start

Run this skill to obtain actionable guidance for creating or refining ast-grep rules; write or review YAML rule files, inspect ASTs, and apply transformations with confidence.

Frequently Asked Questions about ast-grep

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

FAQPage Schema
How do I write ast-grep YAML rules for code linting and rewriting?

To write ast-grep YAML rules, define pattern syntax, meta variables, and constraints to match AST structures. This Skill provides best practices for rule authoring, ensuring safe rewrites, clear messages, and reliable validation across languages.

Why does my ast-grep rule produce false positives when matching code patterns?

False positives in ast-grep rules occur when patterns are too broad or constraints are missing. This Skill helps refine meta variables and apply strict validation techniques to reduce false positives and improve AST matching accuracy.

What is the best way to test and validate ast-grep rules before applying rewrites?

The best way to validate ast-grep rules is using structured testing workflows and checklists. This Skill offers practical examples for inspecting ASTs, validating rule definitions, and applying transformations with confidence to ensure safe rewrites.

Can I use ast-grep rules across different programming languages?

Yes, ast-grep rules can be applied across multiple programming languages. This Skill provides guidance on standardizing project structure, rule composition, and meta variable design to ensure consistent pattern matching and rewrites across different language syntaxes.

How do I structure an ast-grep project for maintaining multiple lint rules?

Structure an ast-grep project by organizing YAML rule files and references according to standard project guidelines. This Skill codifies best practices for project organization, maintainability, and AGENTS collaboration to scale rule authoring effectively.

What are the limitations of using pattern syntax for AST matching in ast-grep?

Limitations of ast-grep pattern syntax include potential performance bottlenecks with complex rules and unexpected matches without proper constraints. This Skill highlights anti-patterns and checklists to navigate these constraints and maintain rule accuracy.