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

# Code Guidelines

> CodeRabbit automatically detects coding guideline files such as .cursorrules, CLAUDE.md, and AGENTS.md in your repository and applies them as review criteria—no extra configuration required.

CodeRabbit scans your repository for well-known AI coding assistant configuration files and uses their content as review criteria. If your team already writes instructions for tools like Cursor, Claude, or Windsurf, CodeRabbit picks those up automatically and enforces the same standards during code review.

## Supported files

The following file patterns are detected by default:

| File pattern                             | Associated tool                      |
| ---------------------------------------- | ------------------------------------ |
| `**/AGENTS.md`                           | AI agent instructions                |
| `**/.cursorrules`                        | Cursor                               |
| `.github/copilot-instructions.md`        | GitHub Copilot                       |
| `.github/instructions/*.instructions.md` | GitHub Copilot (scoped instructions) |
| `**/CLAUDE.md`                           | Claude Code                          |
| `**/GEMINI.md`                           | Gemini CLI                           |
| `**/.cursor/rules/*`                     | Cursor (rules directory)             |
| `**/.windsurfrules`                      | Windsurf                             |
| `**/.clinerules/*`                       | Cline                                |
| `**/.rules/*`                            | Generic team rules                   |
| `**/AGENT.md`                            | AI agent instructions                |

<Info>
  File names are case-sensitive. A file named `claude.md` is not matched by the `**/CLAUDE.md` pattern.
</Info>

## How scoping works

A guideline file applies to the directory it lives in and all of its subdirectories. CodeRabbit does not apply guidelines from one part of your repository tree to unrelated paths.

**Examples:**

* `CLAUDE.md` at the repository root → applies to all files
* `src/frontend/CLAUDE.md` → applies only to files under `src/frontend/`
* `src/backend/.cursorrules` → applies only to files under `src/backend/`

This directory-scoped behaviour means you can maintain separate, purpose-fit guidelines for different areas of a monorepo without them interfering with each other.

<Info>
  Guidelines in a documentation or tooling directory will not affect code review
  unless the code files you are reviewing live inside that same directory tree.
</Info>

<Warning>
  A common mistake is adding guideline file names (for example `CLAUDE.md`) to
  `path_instructions`. This tells CodeRabbit to **review** those files as
  changed code, not to **use** them as guidelines. Use `filePatterns` instead
  (see below), or rely on auto-detection.
</Warning>

## Adding custom file patterns

If your team stores coding standards in files that are not in the default list, you can extend the detected patterns by setting `knowledge_base.code_guidelines.filePatterns` in your `.coderabbit.yaml`.

Custom patterns are **added on top of** the defaults—they do not replace them.

```yaml .coderabbit.yaml theme={null}
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
knowledge_base:
  code_guidelines:
    filePatterns:
      - "**/CODING_STANDARDS.md"
      - "**/docs/style-guide.md"
      - "**/.teamrules"
```

Glob patterns follow the same syntax used elsewhere in CodeRabbit configuration. The `**` wildcard matches any number of path segments.

## Configuration reference

```yaml .coderabbit.yaml theme={null}
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
knowledge_base:
  code_guidelines:
    enabled: true
    filePatterns:
      - "**/CODING_STANDARDS.md"
```

| Field          | Type             | Default | Description                                                                                                                            |
| -------------- | ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled`      | boolean          | `true`  | Apply coding guideline files as review criteria. Set to `false` to disable auto-detection entirely.                                    |
| `filePatterns` | array of strings | `[]`    | Additional glob patterns for guideline files. Supplements the built-in defaults; does not replace them. File names are case-sensitive. |

<Note>
  Setting `filePatterns` to an empty list (`[]`) keeps the default patterns
  active. To disable code guidelines entirely, set `enabled: false`.
</Note>

## What's next

<CardGroup cols={1}>
  <Card title="Knowledge base overview" href="/knowledge-base" horizontal>
    Learn about all knowledge base capabilities: learnings, code guidelines, and linked repositories.
  </Card>

  <Card title="Learnings" href="/knowledge-base/learnings" horizontal>
    Teach CodeRabbit your team's review preferences through natural conversation.
  </Card>

  <Card title="Configuration reference" href="/reference/configuration#knowledge-base" horizontal>
    Full reference for all `knowledge_base` configuration options.
  </Card>
</CardGroup>
