tool-ast-grep-rules

Create and apply AST-based code search and rewrite rules with ast-grep YAML.

339|58|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/Heyvhuang/ship-faster --skill tool-ast-grep-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tool-ast-grep-rules
Source: https://github.com/Heyvhuang/ship-faster/tree/main/skills/tool-ast-grep-rules
Command: npx skills add https://github.com/Heyvhuang/ship-faster --skill tool-ast-grep-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables teams to define and reuse AST-based code search and rewrite rules using ast-grep YAML. It helps coders implement automated linting, code modernization, and API migrations with precise pattern matching.

Core Features & Use Cases

  • Pattern-based code search: Define YAML rules that find specific AST patterns across large codebases.
  • Automated refactors & migrations: Apply safe rewrites and migrations across projects to modernize code.
  • Use Case: Quickly migrate API usage from old APIs to new ones by creating rules that match patterns and provide fixes.

Quick Start

Create a rules directory with YAML files under rules/ and run the tool to generate and apply rules using ast-grep. Then run ast-grep scan to locate patterns across your codebase.

Frequently Asked Questions about tool-ast-grep-rules

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

FAQPage Schema
How do I automate API migration and refactoring using AST patterns?

Automate API migration by defining AST-based search and rewrite rules in YAML using ast-grep. You create pattern definitions to locate outdated API usage across multi-language codebases and apply safe automated rewrites to modernize code.

How do I lint code across different programming languages without writing custom parsers?

Lint multi-language codebases by defining YAML rules with ast-grep that leverage tree-sitter pattern definitions. This allows you to enforce code standards and find specific structural patterns without writing language-specific parsers.

What is the best way to search for specific code structures in a large codebase?

The best way to search large codebases for specific code structures is using ast-grep YAML rules. By defining Abstract Syntax Tree patterns, you can precisely locate matching code segments across real-world projects for analysis or refactoring.

Do I need a specific configuration file to run ast-grep rules?

Yes, you need a configured rules directory specified in an sgconfig.yml file. The configuration must include ruleDirs pointing to your YAML rules directory so ast-grep can locate and apply the defined patterns during the scan.

How do I create and run automated code rewrite rules for project modernization?

Create a rules directory containing YAML files with ast-grep pattern definitions, then run the ast-grep scan command. This applies your defined rules to locate patterns across the codebase and execute safe rewrites for modernization workflows.