What problem does it solve?
This Skill solves the problem of imprecise code searching and refactoring by understanding code structure rather than just text. It helps developers quickly find specific patterns, identify deprecated APIs, and enforce coding standards, saving time and reducing errors in large codebases.
Core Features & Use Cases
- Syntax-Aware Search: Finds code patterns based on Abstract Syntax Trees (AST), avoiding false positives from comments or or strings.
- Multi-Language Support: Works across JavaScript, TypeScript, Python, Go, Rust, Java, and more, making it versatile for polyglot environments.
- Refactoring Aid: Ideal for identifying all instances of a deprecated function or a specific code structure before a large-scale refactor.
- Use Case: You need to refactor all
console.log() statements in your TypeScript project. Instead of a naive text search, use ast-grep --pattern 'console.log($MSG)' --lang ts to precisely locate only executable console.log calls, ignoring those in comments or strings.
Quick Start
Use ast-grep to find all useState calls in my TypeScript files.
ast-grep --pattern 'useState($INIT)' --lang ts