ast-grep
ast-grep(sg) is a fast and polyglot tool for code structural search, lint, rewriting at large scale.
AST-GREP
Find Code by Syntax
ast-grep(sg) is a fast and polyglot tool for code structural search, lint, rewriting at large scale.
Table of Contents
Guide
- Quick Start: Learn how to install ast-grep and use it to quickly find and refactor code in your codebase. This powerful tool can help you save time and improve the quality of your code.
- Pattern Syntax
- Rule Essentials
- Scan Your Project!
- Rewrite Code
- Command Line Tooling Overview
- API Usage
Rule Essentials
Project Setup
Rewrite Code
Tooling Overview
API Usage
Examples
Cheat Sheet
Reference
- Command Line Reference
sgconfig.ymlReference- Configuration Reference
- Rule Object Reference
- API Reference
- List of Languages with Built-in Support
- ast-grep Playground Manual
Command Line Interface
Rule Config
Rule Object
Advanced Topics
- Using ast-grep with AI Tools
- Frequently Asked Questions
- How ast-grep Works: A bird's-eye view
- Custom Language Support
- Search Multi-language Documents in ast-grep
- Comparison With Other Frameworks
How ast-grep Works
- Core Concepts in ast-grep's Pattern
- Deep Dive into ast-grep's Pattern Syntax
- Deep Dive into ast-grep's Match Algorithm
- Find & Patch: A Novel Functional Programming like Code Rewrite Scheme
Contributing
Links
- Playground: ast-grep playground is an online tool that lets you explore AST, debug custom lint rules, and inspect code rewriting with instant feedback.
Other
- define a rewriter to remove the await keyword
- efine test(x) (2*x)
- ensure it only matches modal/tooltip but not tag
- find the barrel import statement
- find-all-imports-and-identifiers.yaml
- or without fixer
- Pattern 1: Rails.root.join with variable
- rewrite Optional[T] to T | None
- Should not be transformed
- TODO:
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
- Untitled
Meet the modern standard for public facing documentation. Beautiful out of the box, easy to maintain, and optimized for user engagement.
Search through billions of items for similar matches to any object, in milliseconds. It’s the next generation of search, an API call away.
Build and deploy reliable background jobs with no timeouts and no infrastructure to manage.
Get the simple developer experience of SQLite in production, and scale your multi-tenant backend with unlimited databases.
Upstash is a serverless data platform providing low latency and high scalability for real-time applications.
One-click deployments built for teams, tuned for Laravel, loaded with tools and goodies you're going to love.