Semantic code linting with Decision Models
Opening the entry
Opening the entry
A CLI tool for code structural search, lint and rewriting. Written in Rust
ast-grep (sg) is a command-line tool for structural search, lint and rewriting of code. Instead of matching text like grep, it matches abstract syntax tree nodes produced by tree-sitter, so patterns written as ordinary code match all code with the same syntactic structure. Wildcards such as $MATCH match any single AST node. It is aimed at developers, library authors, tech leads and security researchers doing static analysis or large-scale code changes.
npm install --global @ast-grep/cli
ast-grep -p '$A && $A()' -l ts -r '$A?.()'
ast-grep/ast-grep is a third-party open-source project, listed here from public GitHub data. ImuTechz did not write it and has not reviewed or security-audited its code. Read the source and its permissions before you install or run it.