Before you start
- Nested
.coderabbit/documents need GitHub Cloud with CodeRabbit Cloud. On other providers, usereviews.path_instructionswith package paths instead. - Know how documents scope to a directory and how configuration layers resolve.
- Keep repository-wide settings in one configuration file at the repository root.
Scope instructions per package
Put a.coderabbit/instructions/ folder next to each package that needs its own rules. Patterns are relative to the directory that contains .coderabbit/.
1
Create the package folder
Add
services/api/.coderabbit/instructions/ and a document with a unique id.2
Write package-relative patterns
In
services/api/.coderabbit/instructions/api-security.md, the pattern src/** means services/api/src/**.3
Pick IDs on purpose
A nested document with the same kind and ID as a parent replaces the parent for that package. Use a different ID to add a rule next to the parent.
Nested documents add no level to the settings hierarchy and don’t need
inheritance: true. See Inheritance and merging.- YAML V2
- YAML V3
Filter files per package
Path filters apply to the whole repository. Use exclusions alone so every other file stays eligible. A single include pattern turns the list into an allowlist, unless it exactly matches a default exclusion. An exclusion always wins regardless of order.- YAML V2
- YAML V3
gen or generated at any depth. To review hand-written code in such a directory, add its exact default pattern without the !, for example **/gen/**.
Use per-package tool configuration files
Withoutconfig_file, ESLint keeps the configuration files that sit in a directory with a reviewed file. A nested config such as packages/web/.eslintrc.js applies only to files under packages/web/, in addition to any parent configuration. See Tools for each tool’s settings.
Vary settings by changed paths
In a TypeScript configuration,ctx.pr.changedFiles lists the changed paths, including both the old and new path of a rename.
.coderabbit.config.ts
status isn’t resolved, paths is empty. Treat that case as “unknown” in your logic.
Limit reviews to the branches you merge into
CodeRabbit reviews pull requests that target the default branch. Add the other long-lived branches inbase_branches. Each entry is a regular expression, and it isn’t anchored.
Check the result
Open a pull request that touches two packages, then post@coderabbitai configuration. Confirm that each package’s instructions apply to its own files and that the filters match your expectations. See Check which configuration a review used.
What’s next
.coderabbit/ documents
See front matter, nesting rules and limits for instruction and check documents.
Choose which files are reviewed
Learn how path filters and exclusions decide what CodeRabbit reviews.
TypeScript configuration
Adapt configuration to the pull request with the context object.