# Install ast-grep with Homebrew, apk, MacPorts, Nix, pacman, scoop, winget, zypper

Code searching, linting, rewriting. Version 0.44.1 via Homebrew; verified 2026-07-04.

## Install

```sh
sudo av install brew:ast-grep
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install ast-grep
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install ast-grep
```

  Evidence: MacPorts ports tree: devel/ast-grep/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add ast-grep
```

  Evidence: Alpine Linux edge package indexes: ast-grep from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz

- Nix (92%):

```sh
nix profile install nixpkgs#ast-grep
```

  Evidence: nixpkgs package indexes: pkgs/by-name/as/ast-grep/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S ast-grep
```

  Evidence: Arch Linux sync databases: ast-grep from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install ast-grep
```

  Evidence: openSUSE Tumbleweed package metadata: ast-grep from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst

### Windows

- Scoop (92%):

```sh
scoop install main/ast-grep
```

  Evidence: Scoop official bucket manifest trees: bucket/ast-grep.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id ast-grep.ast-grep -e
```

  Evidence: Windows Package Manager source index: ast-grep.ast-grep from https://cdn.winget.microsoft.com/cache/source.msix

## Package facts

- **Package key:** brew:ast-grep
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/ast-grep>
- **Version:** 0.44.1
- **Source summary:** Code searching, linting, rewriting
- **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
- **Generated:** 2026-07-08T07:18:31+00:00

## Executables

- ast-grep (cli)
- sg (cli)
- ast-grep (alias)
- sg (alias)

## Build dependencies

- rust

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, sonoma, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 0.44.1
- Package-manager updated: 2026-07-04
- Local data: ok
- Upstream repository: https://github.com/ast-grep/ast-grep
- Upstream latest detected: 0.44.1 (current)
## Project history and usage

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.

### Project history

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.

### Adoption history

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.

### How it is used

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.

### Why package nerds care

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.

### Timeline

- 2022: ast-grep/ast-grep repository created on GitHub.
- 2022-present: Official docs copyright period begins.
- 2020s: README documents installation via npm, pip, cargo, Homebrew, Scoop, mise, MacPorts, Nix shell, and source builds.
- 2026: GitHub metadata showed active development and a large star/fork footprint for a developer-tool CLI.

### Related projects

- tree-sitter supplies the parsing foundation for ast-grep's AST matching.
- ESLint and tsconfig.json are referenced by the docs as familiar configuration analogies.
- semgrep, codemod tools, ripgrep/grep, and language-specific linters occupy adjacent search, rewrite, and policy-enforcement space, though the official sources emphasize ast-grep's code-pattern syntax and tree-sitter core.

### Sources

- <https://api.github.com/repos/ast-grep/ast-grep>
- <https://ast-grep.github.io/guide/project/project-config.html>
- <https://ast-grep.github.io/reference/sgconfig.html>
- <https://github.com/ast-grep/ast-grep#readme>
- source_facts.package-manager


## Security Notes

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.



## Configuration and credential file locations

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.


## Configuration files

- Unix: ./sgconfig.yml, ~/sgconfig.yml
## Source Database Details

- **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:** head, stable

## Other Package-Manager Records

- Nix - ast-grep: normalized package name match | nixpkgs package indexes: pkgs/by-name/as/ast-grep/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- apk - ast-grep - 0.28.1-r0: normalized package name match | Alpine Linux edge package indexes: ast-grep from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | A CLI tool for code structural search, lint and rewriting | https://github.com/ast-grep/ast-grep
- apk - ast-grep-bash-completion - 0.28.1-r0: normalized package name match | Alpine Linux edge package indexes: ast-grep-bash-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Bash completions for ast-grep | https://github.com/ast-grep/ast-grep
- apk - ast-grep-fish-completion - 0.28.1-r0: normalized package name match | Alpine Linux edge package indexes: ast-grep-fish-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Fish completions for ast-grep | https://github.com/ast-grep/ast-grep
- apk - ast-grep-zsh-completion - 0.28.1-r0: normalized package name match | Alpine Linux edge package indexes: ast-grep-zsh-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Zsh completions for ast-grep | https://github.com/ast-grep/ast-grep
- pacman - ast-grep - 0.43.0-1: normalized package name match | Arch Linux sync databases: ast-grep from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | CLI tool for code structural search, lint and rewriting | https://ast-grep.github.io/
- zypper - ast-grep - 0.43.0-1.1: normalized package name match | openSUSE Tumbleweed package metadata: ast-grep from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst | A CLI tool for code structural search, lint and rewriting | https://ast-grep.github.io/
- MacPorts - ast-grep: normalized package name match | MacPorts ports tree: devel/ast-grep/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - main/ast-grep: normalized package name match | Scoop official bucket manifest trees: bucket/ast-grep.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - ast-grep.ast-grep: normalized package name match | Windows Package Manager source index: ast-grep.ast-grep from https://cdn.winget.microsoft.com/cache/source.msix


## Related links

- [Source-control packages](https://www.automicvault.com/pkg/source-control-tools/) - Belongs to a source-control command family.
- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [rust](https://www.automicvault.com/pkg/brew/rust/) - Build dependency declared by Homebrew.
- [ack](https://www.automicvault.com/pkg/brew/ack/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [astgen](https://www.automicvault.com/pkg/brew/astgen/) - Shares av.db curated category or tags: ast, cli, developer-tools.
- [castxml](https://www.automicvault.com/pkg/brew/castxml/) - Shares av.db curated category or tags: ast, cli, developer-tools.
- [cgrep](https://www.automicvault.com/pkg/brew/cgrep/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [cgvg](https://www.automicvault.com/pkg/brew/cgvg/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [codequery](https://www.automicvault.com/pkg/brew/codequery/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [comby](https://www.automicvault.com/pkg/brew/comby/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [cscope](https://www.automicvault.com/pkg/brew/cscope/) - Shares av.db curated category or tags: cli, code-search, developer-tools.
- [ast-grep](https://www.automicvault.com/pkg/npm/ast-grep/) - Same normalized package name appears in another local ecosystem. Shared terms: ast, ast-grep, code, grep.
- [ast-grep](https://www.automicvault.com/pkg/npm/ast-grep/) - Same normalized package name in another local ecosystem.

## Combined YAML source

View the package source record on GitHub. [combined/ast-grep.yml](https://github.com/automic-vault/db/blob/main/combined/ast-grep.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated configuration and credential file locations
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
