What problem does it solve?
This skill enables developers to translate natural language queries into ast-grep rules for structural code search, allowing precise matching based on code structure rather than textual content.
Core Features & Use Cases
- Rule creation: Define atomic, relational, and composite rules to match language constructs by AST.
- Codebase search: Locate functions, calls, and patterns across large codebases using AST patterns.
- Testing & debugging: Use inline tests and debugging options to validate rules against sample code and inspect ASTs.
- Use Case: Find all async functions that contain await expressions within a given project to audit async patterns.
Quick Start
Install the ast-grep CLI and ensure it is on your PATH. Write a simple rule file (e.g., test_rule.yml) using a basic pattern. Run a search against a repository with ast-grep scan --rule test_rule.yml /path/to/project.