# ast-grep/ast-grep

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/ast-grep-ast-grep).**

12,522 stars · 318 forks · Rust · mit

## Links

- GitHub: https://github.com/ast-grep/ast-grep
- Homepage: https://ast-grep.github.io/
- awesome-repositories: https://awesome-repositories.com/repository/ast-grep-ast-grep.md

## Topics

`ast` `babel` `codemod` `codereview` `command-line` `command-line-tool` `grep` `linter` `refactoring` `rust` `search` `static-analysis` `structural-search` `tree-sitter` `typescript`

## Description

ast-grep is a command-line utility and static analysis engine designed for searching, linting, and refactoring source code. It operates by identifying and transforming code blocks based on their underlying syntactic structure rather than relying on text-based or regular expression matching.

The tool utilizes a language-agnostic abstraction to normalize diverse programming grammars into a unified tree structure. By employing a rule-driven engine, it allows users to define complex patterns that capture syntax nodes as variables, enabling consistent and syntactically valid modifications across entire codebases.

This framework supports large-scale refactoring, automated codebase migrations, and the enforcement of custom static analysis rules. It maintains performance during analysis by leveraging incremental parsing to process source code efficiently. The project is distributed as a command-line interface for integration into development workflows and automation pipelines.

## Tags

### Development Tools & Productivity

- [Static Analysis Engines](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines.md) — Acts as a framework for performing large-scale codebase modifications that ensures all changes remain syntactically valid and contextually accurate.
- [Automated Code Refactoring](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/code-analysis-and-transformation/automated-code-refactoring.md) — Modifies code structures across large projects using pattern matching to ensure transformations remain syntactically valid and contextually accurate. ([source](https://ast-grep.github.io/))
- [Static Analysis Rules](https://awesome-repositories.com/f/development-tools-productivity/code-quality-analysis/static-analysis-engines/static-analysis-tools/static-analysis-rules.md) — Defines and applies custom linting rules to identify and fix problematic code patterns or security vulnerabilities throughout a software project.
- [Automated Migration Codemods](https://awesome-repositories.com/f/development-tools-productivity/project-scaffolding-config-code-generation/migration-tools/automated-migration-codemods.md) — Updates legacy code structures or deprecated library APIs across an entire project by matching patterns and applying consistent transformations.

### Software Engineering & Architecture

- [Abstract Syntax Tree Tools](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools.md) — Provides a command-line utility for searching, linting, and refactoring source code using structural patterns that respect the underlying syntax tree.
- [Code Transformation Engines](https://awesome-repositories.com/f/software-engineering-architecture/code-transformation-engines.md) — "Replaces matched code segments by binding captured syntax nodes to variables and injecting them into new templates during the transformation process."
- [Pattern Matching Libraries](https://awesome-repositories.com/f/software-engineering-architecture/pattern-matching-libraries.md) — Matches code structures by comparing user-defined patterns against syntax tree nodes to identify specific logical constructs.
- [Syntax Parsing Engines](https://awesome-repositories.com/f/software-engineering-architecture/syntax-parsing-engines.md) — Converts source code into a concrete syntax tree using an incremental parsing library that maintains high performance during large-scale analysis.
- [Rule Engines](https://awesome-repositories.com/f/software-engineering-architecture/rule-engines.md) — Executes complex refactoring operations by chaining multiple pattern-matching rules and conditional logic to ensure consistent code updates.
- [Syntax Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/abstraction-domain-modeling/language-agnostic-logic-models/syntax-abstractions.md) — Normalizes diverse programming language grammars into a unified tree structure to allow cross-language pattern matching and refactoring.

### Data & Databases

- [Structural Code Searchers](https://awesome-repositories.com/f/data-databases/search-indexing-technologies/search-indexing/search-information-retrieval/code-context-search/structural-code-searchers.md) — Identifies and transforms code blocks based on their syntactic structure rather than simple text or regular expressions.
