ast-grep
ast-grep is an open-source, fast, polyglot tool for structural code search, linting, and rewriting at scale. It lets developers use code-like patterns against abstract syntax trees rather than imprecise text matching, with CLI, editor, library, and AI-oriented workflows.
At a Glance
- Software developers and developer-tool teams
- Open-source maintainers and framework authors
- Organizations performing large codebase migrations
- Teams needing custom linting/static analysis
- +2 more
AI Tools by ast-grep
(1)ast-grep
Structural Code Search and Rewrite
Discussions
No discussions yet
Be the first to start a discussion about ast-grep
Latest News
How ast-grep Rewrote Tree-sitter in Rust and Made It 30% Faster
Rewriting Tree-sitter's C Core in Rust: Migration and Compatibility
Improving Tree-sitter's GLR Algorithm and Memory Layout
Optimizing Tree-sitter for End-to-End ast-grep Performance
Products & Services
MIT-licensed Rust command-line tool for AST-based structural search, linting, rewriting, interactive codemods, rule testing, and language-server operation; installable through npm, pip, Cargo, Homebrew and other package managers.
YAML- and pattern-based linter/rule system with composable matching, constraints, rewrites, diagnostics, tests, JSON output, and interactive fixes.
Programmatic Node.js bindings for traversing and manipulating syntax trees, including opt-in type safety; published as @ast-grep/napi.
Browser-based interactive environment for trying patterns, rules, searches, and rewrites, powered by WebAssembly.
Market Position
ast-grep positions itself between text grep/sed and heavier AST tooling: it offers grep-like, code-shaped patterns with AST precision, Rust/multi-core performance, and a progression from one-line CLI queries to YAML lint rules, interactive codemods, language-server tooling, and programmatic APIs. Its official documentation names Semgrep, comby, shisho, gogocode, and gritQL as comparable or predecessor tools; its differentiation is polyglot syntax matching, batteries-included rewriting, and native Rust performance.
Leadership
Founders
Herrington Darkholme
Web developer and open-source enthusiast specializing in TypeScript and Rust; previously worked at ByteDance contributing to React.js and Flow. He identifies himself as ast-grep's author and describes ast-grep as his hobby project.
Founding Story
Herrington Darkholme started ast-grep as a hobby project to make searching and rewriting code easier using abstract syntax trees. The initial vision was to combine the accessibility of grep/sed with syntax-aware precision, while progressively supporting linting, codemods, editor integration, and programmatic APIs.
Business Model
Revenue Model
The core software is open source and MIT-licensed. Project sustainability is supported through GitHub sponsorships and sales of the Mastering ast-grep book; there is no evidence of a paid hosted SaaS or usage-based API for ast-grep itself.
Pricing Tiers
Paid Leanpub technical book; the author page says book purchases directly support ongoing development and maintenance of the project.
Target Markets
- Software developers and developer-tool teams
- Open-source maintainers and framework authors
- Organizations performing large codebase migrations
- Teams needing custom linting/static analysis
- AI coding-tool and agent developers
- Users of Rust, TypeScript/JavaScript, Python, Go, Java, C/C++, HTML/CSS, Kotlin, Swift, YAML and related ecosystems
- Large-scale API migrations and breaking-change upgrades
- Automated refactoring and codemods
- Custom static analysis and lint rules
- Code review and policy enforcement in CI
- Searching large polyglot repositories by syntax rather than text
- Editor-assisted interactive code fixes
- SWC
- Shopify Hydrogen
- Modern.js
- CodeRabbit