# Ast Grep > Thank you for your interest in adding a new language to ast-grep! ## Pages - [Add New Language to ast-grep](add-lang.md): Thank you for your interest in adding a new language to ast-grep! - [API Usage](api-usage.md): ast-grep allows you to craft complicated rules, but it is not easy to do arbitrary AST manipulation. - [API Reference](api.md): ast-grep currently has an experimental API for [Node.js](https://nodejs.org/). - [Atomic Rule](atomic-rule.md): ast-grep has three categories of rules. Let's start with the most basic one: atomic rule. - [Avoid Duplicated Exports](avoid-duplicated-exports.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IiIsImNvbmZpZyI6InJ1bGU6XG4g... - [Avoid Jsx Short Circuit](avoid-jsx-short-circuit.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InRzeCIsInF1ZXJ5IjoiY29uc29sZS5sb2coJE1BVENIKSIs... - [Avoid Nested Links](avoid-nested-links.md): * [Playground Link](https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InRzeCIsInF1ZXJ5IjoiaW... - [Boshen Footgun](boshen-footgun.md): * [Playground Link](https://ast-grep.github.io/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoicnVzdCIsInF1ZXJ5IjoiJE... - [C](c.md): This page curates a list of example ast-grep rules to check and to rewrite C code. - [Command Line Reference](cli.md): You can always see up-to-date command line options using`ast-grep --help`. - [Composite Rule](composite-rule.md): Composite rule can accept another rule or a list of rules recursively. - [Core Concepts in ast-grep's Pattern](core-concepts.md): One key highlight of ast-grep is its pattern. - [Cpp](cpp.md): This page curates a list of example ast-grep rules to check and to rewrite Cpp code. - [Custom Language Support](custom-language.md): In this guide, we will show you how to use a custom language that is not built into ast-grep. - [Defer Func Call Antipattern](defer-func-call-antipattern.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoiZ28iLCJxdWVyeSI6InsgXG4gICAgZGVmZXIgJEEuJEIodCwg... - [Pattern 1: Rails.root.join with variable](detect-path-traversal.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1YnkiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIiLCJzdHJp... - [Development Guide](development.md): ast-grep is written in [Rust](https://www.rust-lang.org/) and hosted by [git](https://git-scm.com/). - [Editor Integration](editors.md): ast-grep is a **command line tool** for structural search/replace. But it can be readily integrated into your editors... - [Ensure Clean Architecture](ensure-clean-architecture.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImtvdGxpbiIsInF1ZXJ5IjoiIiwicmV3cml0ZSI6IiIsInN0... - [Extract I18N Key](extract-i18n-key.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6Imh0bWwiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIiLCJzdHJp... - [Frequently Asked Questions](faq.md): 1. **Use the Playground**: Test your pattern in the [ast-grep playground](/playground.html). - [Find Field With Type](find-field-with-type.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmEiLCJxdWVyeSI6ImAkVEFHYCIsInJld3JpdGUiOiIi... - [Find Func Declaration With Prefix](find-func-declaration-with-prefix.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImdvIiwicXVlcnkiOiJyJ15bQS1aYS16MC05Xy1dKyciLCJy... - [Find Import File Without Extension](find-import-file-without-extension.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImNvbnNvbGUubG9nKCRN... - [find-all-imports-and-identifiers.yaml](find-import-identifiers.md): * [Playground Link](https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InR5cGVzY3JpcHQiLCJxdW... - [Find Import Usage](find-import-usage.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InR5cGVzY3JpcHQiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIi... - [Find Key Value](find-key-value.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InlhbWwiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIiLCJzdHJp... - [Find & Patch: A Novel Functional Programming like Code Rewrite Scheme](find-n-patch.md): Code transformation is a powerful technique that allows you to modify your code programmatically. There are many tool... - [Find Struct Inheritance](find-struct-inheritance.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoiY3BwIiwicXVlcnkiOiJzdHJ1Y3QgJFNPTUVUSElORzogICRJ... - [Fix Format Vuln](fix-format-vuln.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImNwcCIsInF1ZXJ5IjoiIiwicmV3cml0ZSI6IiIsInN0cmlj... - [Fix](fix.md): ast-grep has two kinds of fixes:`string`and`FixConfig`. - [Get Digit Count In Usize](get-digit-count-in-usize.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoicnVzdCIsInF1ZXJ5IjoiJE5VTS50b19zdHJpbmcoKS5jaGFy... - [Go](go.md): This page curates a list of example ast-grep rules to check and to rewrite Go code. - [How ast-grep Works: A bird's-eye view](how-ast-grep-works.md): In the world of software development, efficiently searching, rewriting, linting, and analyzing code is essential for ... - [Contributing](how-to.md): :tada: ***We are thrilled that you are interested in contributing to the ast-grep project!*** :tada: - [HTML](html.md): This page curates a list of example ast-grep rules to check and to rewrite HTML code. - [Java](java.md): This page curates a list of example ast-grep rules to check and to rewrite Java code. - [JavaScript API](js-api.md): Powered by [napi.rs](https://napi.rs/), ast-grep's JavaScript API enables you to write JavaScript to programmatically... - [JSON Mode](json.md): Composability is a key perk of command line tooling. ast-grep is no exception. - [Kotlin](kotlin.md): This page curates a list of example ast-grep rules to check and to rewrite Kotlin code. - [Search Multi-language Documents in ast-grep](language-injection.md): ast-grep works well searching files of one single language, but it is hard to extract a sub language embedded inside ... - [List of Languages with Built-in Support](languages.md): The table below lists all languages that are supported by ast-grep. - [Lint Rule](lint-rule.md): A lint rule is a configuration file that specifies how to find, report and fix issues in the codebase. - [Deep Dive into ast-grep's Match Algorithm](match-algorithm.md): By default, ast-grep uses a smart strategy to match pattern against the AST node. All nodes in the pattern must be ma... - [Match Function Call](match-function-call.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImMiLCJxdWVyeSI6InRlc3QoJCQkKSIsInJld3JpdGUiOiIi... - [Match Package Import](match-package-import.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImdvIiwicXVlcnkiOiIiLCJyZXdyaXRlIjoiIiwic3RyaWN0... - [Migrate Action Filter](migrate-action-filter.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1YnkiLCJxdWVyeSI6ImNvbnNvbGUubG9nKCRNQVRDSCki... - [Migrate Openai Sdk](migrate-openai-sdk.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiZGVmICRGVU5DKCQkJEFSR1Mp... - [Migrate Xstate V5](migrate-xstate-v5.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImlmICgkQSkgeyAkJCRC... - [Missing Component Decorator](missing-component-decorator.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImltcG9ydCAkQSBmcm9t... - [`ast-grep new`](new.md): Create new ast-grep project or items like rules/tests. Also see the step by step [guide](/guide/scan-project.html). - [No Await In Promise All](no-await-in-promise-all.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImNvbnNvbGUubG9nKCRN... - [No Console Except Catch](no-console-except-catch.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImlmICRBLmhhc19mZWF0... - [No Unused Vars](no-unused-vars.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmEiLCJxdWVyeSI6ImlmKHRydWUpeyQkJEJPRFl9Iiwi... - [Optional To None Union](optional-to-none-union.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiIiwicmV3cml0ZSI6IiIsInN0... - [Deep Dive into ast-grep's Pattern Syntax](pattern-parse.md): ast-grep's pattern is easy to learn but hard to master. While it's easy to get started with, mastering its nuances ca... - [Pattern Syntax](pattern-syntax.md): In this guide we will walk through ast-grep's pattern syntax. The example will be written in JavaScript, but the basi... - [Performance Tip for napi usage](performance-tip.md): Using`napi`to parse code and search for nodes [isn't always faster](https://medium.com/@hchan_nvim/benchmark-typesc... - [ast-grep Playground Manual](playground.md): The [ast-grep playground](/playground.html) is an online tool that allows you to try out ast-grep without installing ... - [Prefer Generator Expressions](prefer-generator-expressions.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiWyQkJEFdIiwicmV3cml0ZSI6... - [Prefer Symbol Over Proc](prefer-symbol-over-proc.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1YnkiLCJxdWVyeSI6IiRMSVNULnNlbGVjdCB7IHwkVnwg... - [Project Configuration](project-config.md): ast-grep supports using [YAML](https://yaml.org/) to configure its linting rules to scan your code repository. - [Using ast-grep with AI Tools](prompting.md): This guide outlines several existing methods for leveraging AI with ast-grep. - [Python API](py-api.md): ast-grep's Python API is powered by [PyO3](https://pyo3.rs/). - [Python](python.md): This page curates a list of example ast-grep rules to check and to rewrite Python code. - [Quick Start](quick-start.md): You can unleash`ast-grep`'s power at your fingertips in a few keystrokes on the command line! - [Redundant Unsafe Function](redundant-unsafe-function.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IntcbiAgZGVzY3JpcHRpb24gPSAk... - [Redundant Usestate Type](redundant-usestate-type.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoidHlwZXNjcmlwdCIsInF1ZXJ5IjoidXNlU3RhdGU8c3RyaW5n... - [Refactor Pytest Fixtures](refactor-pytest-fixtures.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiZGVmIGZvbygkWCk6XG4gICRT... - [Relational Rules](relational-rule.md): Atomic rule can only match the target node directly. But sometimes we want to match a node based on its surrounding n... - [define a rewriter to remove the await keyword](remove-async-await.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiYXdhaXQgJCQkQ0FMTCIsInJl... - [Rename Svg Attribute](rename-svg-attribute.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InRzeCIsInF1ZXJ5IjoiIiwicmV3cml0ZSI6IiIsInN0cmlj... - [Reverse React Compiler](reverse-react-compiler.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InRzeCIsInF1ZXJ5IjoiIiwicmV3cml0ZSI6IiIsInN0cmlj... - [Rewrite Code](rewrite-code.md): One of the powers of ast-grep is that it can not only find code patterns, but also transform them into new code. - [Rewrite Indoc Macro](rewrite-indoc-macro.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoicnVzdCIsInF1ZXJ5IjoiaW5kb2MhIHsgciNcIiQkJEFcIiMg... - [Rewrite Method To Function Call](rewrite-method-to-function-call.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImMiLCJxdWVyeSI6IiRDT1VOVCA9ICRcbiIsInJld3JpdGUi... - [Rewrite Mobx Component](rewrite-mobx-component.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6ImNvbnNvbGUubG9nKCRN... - [Should not be transformed](rewrite-sqlalchemy-mapped-column.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiYShudWxsYWJsZT1UcnVlKSIs... - [Rewriter in Fix](rewriter.md): `rewriters`allow you to apply rules to specific parts of the matching AST nodes. - [TODO:](roadmap.md): * \[x] Add replace - [Ruby](ruby.md): This page curates a list of example ast-grep rules to check and to rewrite Ruby applications. - [Rule Essentials](rule-config.md): Now you have learnt the basic of ast-grep's pattern syntax and searching. - [or without fixer](rule-template.md): * [Playground Link](/playground.html#) - [Rule Cheat Sheet](rule.md): This cheat sheet provides a concise overview of ast-grep's rule object configuration, covering Atomic, Relational, an... - [`ast-grep run`](run.md): Run one time search or rewrite in command line. - [Rust](rust.md): This page curates a list of example ast-grep rules to check and to rewrite Rust applications. - [Scan Your Project!](scan-project.md): Let's explore its power to run scan on your code repository in a scalable way! - [`ast-grep scan`](scan.md): Scan and rewrite code by configuration. - [Handle Error Reports](severity.md): ast-grep supports these severity levels for rules: - [`sgconfig.yml` Reference](sgconfig.md): To scan a project with multiple rules, you need to specify the root of a project by maintaining a`sgconfig.yml`file. - [find the barrel import statement](speed-up-barrel-import.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIi... - [Switch From Should To Expect](switch-from-should-to-expect.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InJ1c3QiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIiLCJzdHJp... - [Test Your Rule](test-rule.md): Though it is easy to write a simple rule to match some code in ast-grep, writing a robust and comprehensive rule to c... - [`ast-grep test`](test.md): Test ast-grep rules. - [Comparison With Other Frameworks](tool-comparison.md): :::danger Disclaimer - [Command Line Tooling Overview](tooling-overview.md): ast-grep's tooling supports multiple stages of your development. Here is a list of the tools and their purpose: - [`transform` Code in Rewrite](transform.md): Sometimes, we may want to apply some transformations to the meta variables in the fix part of a YAML rule. For exampl... - [Transformation Object](transformation.md): A transformation object is used to manipulate meta variables. It is a dictionary with the following structure: - [TSX](tsx.md): This page curates a list of example ast-grep rules to check and to rewrite TypeScript with JSX syntax. - [TypeScript](typescript.md): This page curates a list of example ast-grep rules to check and to rewrite TypeScript applications. - [Unmarshal Tag Is Dash](unmarshal-tag-is-dash.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImdvIiwicXVlcnkiOiJgJFRBR2AiLCJyZXdyaXRlIjoiIiwi... - [Unnecessary React Hook](unnecessary-react-hook.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIi... - [ensure it only matches modal/tooltip but not tag](upgrade-ant-design-vue.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6Imh0bWwiLCJxdWVyeSI6IiIsInJld3JpdGUiOiIiLCJzdHJp... - [Use Logical Assignment](use-logical-assignment.md): * [Playground Link](/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoiamF2YXNjcmlwdCIsInF1ZXJ5IjoiJEEgPSAkQSB8fCAkQiIs... - [Use Walrus Operator In If](use-walrus-operator-in-if.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiZm4gbWFpbigpIHsgXG4gICAg... - [Reusing Rule as Utility](utility-rule.md): ast-grep chooses to use YAML for rule representation. While this decision makes writing rules easier, it does impose ... - [YAML](yaml.md): This page curates a list of example ast-grep rules to check and to rewrite YAML code. - [Yoda Condition](yoda-condition.md): * [Playground Link](/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImMiLCJxdWVyeSI6IiRDOiAkVCA9IHJlbGF0aW9uc2hpcCgk...