ast-grep-rules

Craft and validate YAML ast-grep rules for JavaScript and TypeScript code analysis.

1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/hafley66/claude-research --skill ast-grep-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ast-grep-rules
Source: https://github.com/hafley66/claude-research/tree/main/skills/ast-grep-rules
Command: npx skills add https://github.com/hafley66/claude-research --skill ast-grep-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AST rule configuration for code analysis tools that enable precise linting and automated transformations through YAML-based rules.

Core Features & Use Cases

  • Atomic, relational, and composite rules for matching code patterns
  • Constraint-based metavariable filtering and reusable utilities
  • File scope control with includes/ignores and easy integration into CI

Quick Start

Write an initial YAML rule file describing a simple pattern to match a function call and extend it with constraints and utilities as needed.

Frequently Asked Questions about ast-grep-rules

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

FAQPage Schema
How do I write YAML AST rules for linting JavaScript and TypeScript code?

Constraint-based metavariable filtering in YAML AST rules restricts matches to specific code patterns. By applying constraints alongside reusable utilities, you can precisely target and transform complex structural code combinations within your linting workflows.

Can I scope YAML AST code analysis to specific files and ignore others?

Yes, you can scope YAML AST code analysis using file filtering configurations. By defining includes and ignores within your YAML rules, you control exactly which files the linter processes, ensuring targeted analysis and easy integration into CI pipelines.

What is the best way to validate the structure of ast-grep rules before running them?

The best way to validate ast-grep rules is ensuring proper YAML structure with mandatory id, language, and rule fields. This validation guarantees clear linting outputs and verifies that optional utilities and constraints are correctly configured for code analysis.

How do composite AST rules differ from atomic rules for code transformation?

Composite AST rules combine multiple matching patterns, whereas atomic rules target single, specific code structures. Both rule types support code transformation workflows, allowing you to apply automated fixes across matched JavaScript and TypeScript code segments.