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 on supported changed files using the essentials package and any custom rules you configure. CodeRabbit runs ast-grep v0.45.3.

Configuration

boolean
default:true
Enable ast-grep
array of string
default:[]
List of rules directories.
array of string
default:[]
List of utils directories.
boolean
default:true
Use ast-grep essentials package.
array of string
default:[]
Predefined packages to be used.
.coderabbit.yaml
rule_dirs lists directories with your custom ast-grep rules, and util_dirs lists directories with utility configs that support rule management. Both take paths relative to the repository root. packages takes GitHub repositories in owner/repository format. CodeRabbit ignores rule_dirs and util_dirs entries that do not exist in the review checkout, use absolute paths or parent-directory traversal, or contain control or shell-sensitive characters.
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