> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coderabbit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure a monorepo

> Give each package or service its own review instructions, file filters and tool configuration inside one repository.

A monorepo usually needs one set of repository-wide settings and a few rules that apply to a single package. This guide shows how to scope instructions, filters and tool configuration per package, and how to vary settings by the files a pull request changes.

## Before you start

* Nested `.coderabbit/` documents need GitHub Cloud with CodeRabbit Cloud. On other providers, use `reviews.path_instructions` with package paths instead.
* Know how [documents scope to a directory](https://docs.coderabbit.ai/configuration/documents.md#scope-a-document-to-paths) and how [configuration layers resolve](https://docs.coderabbit.ai/configuration/resolution.md).
* Keep repository-wide settings in one [configuration file](https://docs.coderabbit.ai/configuration/file.md) 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/`.

```text theme={null}
.
├── .coderabbit.yaml
├── .coderabbit/
│   └── instructions/
│       └── general.md
└── services/
    └── api/
        └── .coderabbit/
            └── instructions/
                └── api-security.md
```

**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/**`.

```markdown theme={null}
---
id: api-security
paths:
  - "src/**"
---

Check that every new endpoint validates its input and requires authentication.
```

**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.

> [!NOTE]
>
> Nested documents add no level to the settings hierarchy and don't need `inheritance: true`. See [Inheritance and merging](https://docs.coderabbit.ai/configuration/inheritance-and-merging.md).

On providers without directory documents, scope the same rule in the configuration file.

> [tab] YAML V2
>
> ```yaml theme={null}
> reviews:
>   path_instructions:
>     - path: "services/api/src/**"
>       instructions: "Check that every new endpoint validates its input."
> ```

> [tab] YAML V3
>
> Early Access (This feature is in early access. Enable it by setting `early_access: true` in your `.coderabbit.yaml`, or by toggling Early Access on the web interface.)
>
> V3 is a limited preview. Adding `version: 3` doesn't give your organization access.
>
> V3 YAML has no `reviews.path_instructions`. Use the nested documents above.

## 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](https://docs.coderabbit.ai/pr-reviews/which-files.md#files-skipped-by-default). An exclusion always wins regardless of order.

> [tab] YAML V2
>
> ```yaml theme={null}
> reviews:
>   path_filters:
>     - "!packages/legacy-*/**"
>     - "!**/generated/**"
> ```

> [tab] YAML V3
>
> Early Access (This feature is in early access. Enable it by setting `early_access: true` in your `.coderabbit.yaml`, or by toggling Early Access on the web interface.)
>
> V3 is a limited preview. Adding `version: 3` doesn't give your organization access.
>
> ```yaml theme={null}
> reviews:
>   behavior:
>     path_filters:
>       - "!packages/legacy-*/**"
>       - "!**/generated/**"
> ```

The default exclusions for generated code match directories named `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

Without `config_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](https://docs.coderabbit.ai/tools/index.md) for each tool's settings.

## Vary settings by changed paths

In a [TypeScript configuration](https://docs.coderabbit.ai/configuration/typescript.md), `ctx.pr.changedFiles` lists the changed paths, including both the old and new path of a rename.

```ts .coderabbit.config.ts theme={null}
import { defineConfig, type CodeRabbitConfig } from "@coderabbitai/config"

export default defineConfig((ctx): CodeRabbitConfig => {
  const changed = ctx.pr?.changedFiles
  const paths = changed?.status === "resolved" ? changed.paths : []
  const docsOnly = paths.length > 0 && paths.every((p) => p.startsWith("docs/"))

  return { reviews: { profile: docsOnly ? "quiet" : "chill" } }
})
```

When `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 in `base_branches`. Each entry is a regular expression, and it isn't anchored.

```yaml theme={null}
reviews:
  auto_review:
    base_branches:
      - "release/.*"
```

## 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](https://docs.coderabbit.ai/configuration/guides/check-effective-configuration.md).

## What's next

> [card] [.coderabbit/ documents](https://docs.coderabbit.ai/configuration/documents.md)
>
> See front matter, nesting rules and limits for instruction and check documents.

> [card] [Choose which files are reviewed](https://docs.coderabbit.ai/pr-reviews/which-files.md)
>
> Learn how path filters and exclusions decide what CodeRabbit reviews.

> [card] [TypeScript configuration](https://docs.coderabbit.ai/configuration/typescript.md)
>
> Adapt configuration to the pull request with the context object.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.