ast-grep
scriptablepopularlocal-onlyshell utilitiesbrew
ast-grep · Structural search and replace for code, not just text.
$ brew install ast-grepOne-liner to try
$ sg --pattern 'console.log($$$)' srcAgent pack
Quick reference
Install
brew install ast-grepVerify
sg --versionFirst command
sg --pattern 'console.log($$$)' srcMachine JSON
/cli/ast-grep.jsonAbout
Structural search and replace for code, not just text. Built by ast-grep. Start with `sg --pattern 'console.log($$$)' src` and go from there. Supports structured output — good for scripts and agents. Runs entirely on your machine.
Example workflow
1. sg --pattern 'console.log($$$)' src2. sg --pattern 'console.log($$$)' --rewrite 'logger.debug($$$)' --dry-run src3. sg scan