Skip to main content
ast-grep is an open-source static analysis tool that uses abstract syntax trees (AST) to find patterns in your codebase, helping identify security vulnerabilities and enforce code quality standards. CodeRabbit runs ast-grep version 0.45.2 on supported changed files using the essentials package and any custom rules you configure.

Configuration Options

You can configure ast-grep in your .coderabbit.yaml file or through CodeRabbit’s settings page under “Reviews → Tools → ast-grep”. The following options are available:
  • rule_dirs: List of directories containing your custom ast-grep rules, relative to the repository root (default: [])
  • util_dirs: List of directories containing utility configs to support rule management, relative to the repository root (default: [])
  • essential_rules: Enable the ast-grep essentials package (default: true)
  • packages: List of GitHub packages to use in owner/repository format (default: [])

Example Configuration

CodeRabbit will only run ast-grep if you have configured at least one of the following:
  • Custom rule directories (rule_dirs)
  • Essential rules enabled (essential_rules: true)
  • Custom packages (packages)
util_dirs can be used to support shared utility configs, but by itself it does not cause ast-grep to run.CodeRabbit also skips ast-grep when the pull request contains no changed files with a supported extension. Individual files that are 8 MiB or larger are skipped.

Files

ast-grep runs on changed files with the following extensions:
  • .bash
  • .c
  • .cpp
  • .cs
  • .css
  • .erb (parsed as HTML)
  • .ex
  • .exs
  • .go
  • .h
  • .hpp
  • .hs
  • .html
  • .java
  • .js
  • .json
  • .jsx
  • .kt
  • .lua
  • .php
  • .py
  • .rb
  • .rs
  • .scala
  • .sh
  • .sql
  • .swift
  • .ts
  • .tsx
  • .yaml
  • .yml