sg Command Examples

Ast-grep is a tool for code structural search, lint, and rewriting. More information: https://ast-grep.github.io/guide/introduction.html.

sg scan --interactive

sg run --pattern '{{foo}}' --rewrite '{{bar}}' --lang {{python}}

sg run --pattern '{{useState<number>($A)}}' --rewrite '{{useState($A)}}' --lang {{typescript}}

sg run --pattern '{{Some($A)}}' --rewrite '{{None}}' --json | jq '{{.[].replacement}}' | jless