macOS
brew install ast-greplocal Homebrew formula metadata
sudo port install ast-grepMacPorts ports tree · devel/ast-grep/Portfile · source: api.github.com
brew
Code searching, linting, rewriting. Version 0.44.1 via Homebrew; verified 2026-07-04.
install
brew install ast-greplocal Homebrew formula metadata
sudo port install ast-grepMacPorts ports tree · devel/ast-grep/Portfile · source: api.github.com
sudo apk add ast-grepAlpine Linux edge package indexes · ast-grep · source: dl-cdn.alpinelinux.org
nix profile install nixpkgs#ast-grepnixpkgs package indexes · pkgs/by-name/as/ast-grep/package.nix · source: api.github.com
sudo pacman -S ast-grepArch Linux sync databases · ast-grep · source: geo.mirror.pkgbuild.com
sudo zypper install ast-grepopenSUSE Tumbleweed package metadata · ast-grep · source: download.opensuse.org
scoop install main/ast-grepScoop official bucket manifest trees · bucket/ast-grep.json · source: api.github.com
winget install --id ast-grep.ast-grep -eWindows Package Manager source index · ast-grep.ast-grep · source: cdn.winget.microsoft.com
overview
Code searching, linting, rewriting
history
ast-grep is a Rust command-line tool for structural code search, linting, and rewriting. It combines a grep-like user experience with tree-sitter-backed abstract syntax tree matching, so patterns are written as code snippets rather than as only text regular expressions.
The ast-grep repository was created in 2022 and the official docs carry a 2022-present copyright. The README presents the tool as ast-grep or sg, with a core algorithm that searches and rewrites code using tree-sitter-produced ASTs.
The project expanded beyond one-off search into project configuration, YAML lint rules, transformations, rewriters, custom languages, language injections, editor integrations, JavaScript and Python APIs, and a browser playground. The official sgconfig documentation positions sgconfig.yml as the root configuration file for multi-rule scans, similar in role to tsconfig.json or ESLint configuration.
ast-grep was packaged early across developer ecosystems rather than through a single language channel. The official README lists npm, pip, cargo, cargo-binstall, Homebrew, Scoop, mise, MacPorts, Nix shell, and source builds, while the supplied package facts add Alpine, Arch, winget, zypper, and Nix availability.
The tool gained attention because it serves several audiences with one binary: maintainers doing codemods for breaking changes, teams enforcing project-specific static rules, and security researchers writing structural queries faster than full compiler plugins.
The simplest usage is a command such as ast-grep --pattern ... --rewrite ... --lang ts. Larger projects add sgconfig.yml at the project root, define ruleDirs, and run scan; ast-grep discovers sgconfig.yml by walking up from the working directory, and can also use a home-directory sgconfig.yml for global configuration.
ast-grep is significant because it occupies the middle ground between grep, semgrep-style structural search, ESLint-style linting, and codemod frameworks. Package maintainers care because it ships as a native Rust CLI but is distributed through npm, pip, cargo, Homebrew, and OS package managers, which makes binary packaging, completions, and config discovery part of the user experience.
security posture
No matching local secret-handling manifest was found for ast-grep. Nucleus package metadata is still published here so future coverage has a stable package URL.
Before unattended agent use, check whether the tool reads plaintext credentials, writes remote state, publishes artifacts, or shells out to plugins.
local files
These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.
Config paths the tool may read or write during local use.
./sgconfig.yml~/sgconfig.ymlexecutables
| Command | Kind | Exposure | Note |
|---|---|---|---|
ast-grep | cli | global executable | |
sg | cli | global executable |
freshness
These signals separate page generation age, package-manager activity, and upstream release comparison. Version lag is warned only when an evidence URL and comparable versions are present.
https://github.com/ast-grep/ast-grep
install metadata
| Package key | brew:ast-grep |
|---|---|
| Version | 0.44.1 |
| Package manager | Homebrew |
| Package manager page | https://formulae.brew.sh/formula/ast-grep |
| Homepage | https://ast-grep.github.io/ |
| Repository | https://github.com/ast-grep/ast-grep |
| Upstream docs | https://ast-grep.github.io/ |
| License | MIT |
| Source archive | https://github.com/ast-grep/ast-grep/archive/refs/tags/0.44.1.tar.gz |
| Last updated | 2026-07-04T14:40:32Z |
| Pulse | updated |
| Build dependencies | rust |
| Bottle | available (on arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, sonoma, x86_64_linux) |
| Homebrew post-install | not defined |
| Service | none declared |
registry facts
| Source Database | Homebrew formula API |
|---|---|
| Tap | homebrew/core |
| Full Name | ast-grep |
| Version Scheme | 0 |
| Revision | 0 |
| Head Version | HEAD |
| Bottle Stable Root URL | https://ghcr.io/v2/homebrew/core |
| Deprecated | no |
| Disabled | no |
| Keg Only | no |
| URL Keys |
|
source database matches
Matches are pulled from external package-manager indexes and kept separate from local Automic Vault package links.
ast-grep
nix profile install nixpkgs#ast-grepast-grep 0.28.1-r0
A CLI tool for code structural search, lint and rewriting
https://github.com/ast-grep/ast-grep
sudo apk add ast-grepast-grep-bash-completion 0.28.1-r0
Bash completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-bash-completionast-grep-fish-completion 0.28.1-r0
Fish completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-fish-completionast-grep-zsh-completion 0.28.1-r0
Zsh completions for ast-grep
https://github.com/ast-grep/ast-grep
sudo apk add ast-grep-zsh-completionast-grep 0.43.0-1
CLI tool for code structural search, lint and rewriting
sudo pacman -S ast-grepast-grep 0.43.0-1.1
A CLI tool for code structural search, lint and rewriting
sudo zypper install ast-grepast-grep
sudo port install ast-grepmain/ast-grep
scoop install main/ast-grepast-grep.ast-grep
winget install --id ast-grep.ast-grep -esource trail
This page is generated by av-web from the private package SQLite artifact built by scripts/generate-pkg-sqlite.py.
View the package source record on GitHub.