|
| 1 | +--- |
| 2 | +title: Initial configuration guide |
| 3 | +description: A tour through some initial configuration setup. |
| 4 | +--- |
| 5 | + |
| 6 | +This page provides a tour through a selection of key CodeRabbit configuration options. |
| 7 | + |
| 8 | +For a general overview of how configuration in CodeRabbit works, see [Configure CodeRabbit](/guides/configuration-overview). For an exhaustive reference of all configuration options, see [Configuration reference](/reference/configuration). |
| 9 | + |
| 10 | +## How to use this guide {#use} |
| 11 | + |
| 12 | +This guide walks you through several CodeRabbit configuration options that you |
| 13 | +can set in order to tune CodeRabbit code review behavior for your repositories. |
| 14 | + |
| 15 | +The default behavior and settings of CodeRabbit |
| 16 | +works for most repositories, in most situations. However, becoming familiar with |
| 17 | +the key settings described by this page can help you tune the behavior of |
| 18 | +CodeRabbit for the specific needs of your team. You can use this guide when initially setting up your organization and repositories with CodeRabbit, or you can return to it after using CodeRabbit |
| 19 | +for a while, when you feel ready to customize its behavior. |
| 20 | + |
| 21 | +Each section in the guide links to specific entries in the configuration reference. Each entry in the linked reference specifies the location of its configuration setting, in either the CodeRabbit web UI or your `.coderabbit.yaml` file. |
| 22 | + |
| 23 | +## Data retention and knowledge base settings {#data-retention} |
| 24 | + |
| 25 | +These settings help you control how much data about your code that CodeRabbit retains. |
| 26 | +CodeRabbit temporarily stores information about your repositories in order to tailored reviews more quickly and better tailored to your team's needs. You can opt of these features if your organization has stricter data-retention policies. |
| 27 | + |
| 28 | +For more information about CodeRabbit data-retention policies, see |
| 29 | +[Data privacy and security](/#data-privacy-and-security). |
| 30 | + |
| 31 | +### Enable or disable data retention globally {#data-retention-setting} |
| 32 | + |
| 33 | +:::note |
| 34 | +This setting is available only at the organization level, and not per-repository. |
| 35 | +::: |
| 36 | + |
| 37 | +Your CodeRabbit organization has a data-retention setting which acts as a master-switch to all CodeRabbit features that require it to store its own data about your repositories. If you disable data retention, then none of your repositories can use knowledge base or caching features, even if you configure those repositories to enable them. |
| 38 | + |
| 39 | +We recommend leaving this on. However, if your use of CodeRabbit requires strict data retention policy, then you can turn this off. |
| 40 | + |
| 41 | +For more information, see |
| 42 | +[Data retention](/reference/configuration#data-retention) in the configuration reference. |
| 43 | + |
| 44 | +### Configure cache use {#cache} |
| 45 | + |
| 46 | +By default, CodeRabbit keeps a temporary cache of data about your repository in order to make subsequent code reviews faster. If this conflicts with your organization's data-retention policies, then you can disable this feature. |
| 47 | + |
| 48 | +For more information, see |
| 49 | +[Disable cache](/reference/configuration#disable-cache) in the configuration reference. |
| 50 | + |
| 51 | +### Configure knowledge base retention {#opt-out} |
| 52 | + |
| 53 | +By default, CodeRabbit keeps its own [_knowledge base_](/integrations/knowledge-base): a store of metadata about your repositories, your team's history of pull requests, linked issues, and learnings about how CodeRabbit should tailor its own review behavior to best serve your team. If this long-term knowledge base storage conflicts with your organization's data-retention policies, then you can disable this feature. |
| 54 | + |
| 55 | +For more information, see |
| 56 | +[Opt out](/reference/configuration#opt-out) in the configuration reference. |
| 57 | + |
| 58 | +### Configure learnings {#learnings} |
| 59 | + |
| 60 | +CodeRabbit learns your team's review preferences by letting you [teach it your preferences in plain language during code reviews](/integrations/knowledge-base#learnings). CodeRabbit remembers these preferences, and applies them to subsequent code reviews in the same repository. |
| 61 | + |
| 62 | +This setting lets you set the scope of which stored learnings that CodeRabbit should apply to its code reviews. For more information, see [Learnings](/reference/configuration#learnings) in the configuration reference. |
| 63 | + |
| 64 | +## Tune the length of code reviews {#content} |
| 65 | + |
| 66 | +By default, CodeRabbit writes thorough code reviews with several sub-sections. If you'd rather have CodeRabbit generated shorter reviews then you can change some of the following settings: |
| 67 | + |
| 68 | +- [Collapse walkthrough](/reference/configuration#collapse-walkthrough): wraps the detailed summary of proposed changes in collapsed-but-expandable container. (Off by default.) |
| 69 | +- [Changed files summary](/reference/configuration#changed-files-summary): lists of files affected by this pull request. |
| 70 | +- [Sequence diagrams](/reference/configuration#sequence-diagrams): includes a visual diagram of object interactions. |
| 71 | +- [Assess linked issues](/reference/configuration#assess-linked-issues): assesses how well the pull request addresses any linked issues. |
| 72 | +- [Related issues](/reference/configuration#related-issues): lists issues found in your issue tracker that might be related to this pull request. |
| 73 | +- [Related pull requests](/reference/configuration#realted-prs): lists pull requests that might be related to this pull request. |
| 74 | +- [Suggested labels](/reference/configuration#suggested-labels): Suggests labels for this pull request. |
| 75 | +- [Suggested reviewers](/reference/configuration#suggested-reveiwers): automatically suggest reviewers for PR |
| 76 | +- [Poem](/reference/configuration#poem): generates a short poem about this pull request. |
| 77 | + |
| 78 | +## Adjust path-specific CodeRabbit behavior {#path} |
| 79 | + |
| 80 | +These settings direct CodeRabbit to treat various files and and locations in |
| 81 | +your repository differently. |
| 82 | + |
| 83 | +For an overview about using path-based instructions in CodeRabbit, see [Path-based instructions](/guides/review-instructions#path-based). |
| 84 | + |
| 85 | +### Add path filters {#filters} |
| 86 | + |
| 87 | +If your repository contains files or locations that CodeRabbit should disregard when preparing code reviews—or you want CodeRabbit to limit its consideration to only certain files—then you can define one or more _path filters_. Adding path filters to a large repository containing a lot of data, generated files, or other non-code content can let CodeRabbit work faster. |
| 88 | + |
| 89 | +For example, the following `.coderabbit.yaml` excerpt instructs CodeRabbit to take review context only the contents of directories named `src/` in your repository, while disregarding any individual files with `.bin` or `.csv` extensions. |
| 90 | + |
| 91 | +```yaml |
| 92 | +path_filters: |
| 93 | + - "!**/*.bin" |
| 94 | + - "!**/*.csv" |
| 95 | + - "**/src/**" |
| 96 | +``` |
| 97 | +
|
| 98 | +For more information, see [Path filters](/reference/configuration#path-filters) in the CodeRabbit configuration reference. |
| 99 | +
|
| 100 | +### Add general path instructions {#review-path} |
| 101 | +
|
| 102 | +You can set _path instructions_ that provide CodeRabbit with additional review instructions for various files or locations in your repository. Each path instruction specifies a path specification and a set of instructions, the latter of which you express using natural language. |
| 103 | +
|
| 104 | +For example, to give CodeRabbit review instructions specific to JavaScript and TypeScript files, you can add a section like this to your repository's `.coderabbit.yaml` file: |
| 105 | + |
| 106 | +```yaml |
| 107 | +path_instructions: |
| 108 | + - path: `src/**/*.{ts,tsx,js}` |
| 109 | + instructions: "Review the React.js, TypeScript, JavaScript code for best practices. Check for common security vulnerabilities, such as SQL injection, insecure dependencies, and sensitive data exposure." |
| 110 | +``` |
| 111 | +
|
| 112 | +For more information, see [Path instructions](/reference/configuration#path-instructions) in the configuration reference. |
| 113 | +
|
| 114 | +### Add documentation or unit-test path instructions {#doc-path} |
| 115 | +
|
| 116 | +Similar to the general path instructions described by the previous section, you |
| 117 | +can define path-based instructions that direct CodeRabbit to generate inline |
| 118 | +documentation or unit tests, with specific instructions associated with different |
| 119 | +locations or filenames. |
| 120 | +
|
| 121 | +For more information, see [Docstrings](/reference/configuration#docstrings) and [Unit tests](/reference/configuration#unit-tests) in the configuration reference. |
| 122 | +
|
| 123 | +## Set Automatic review behavior {#auto} |
| 124 | +
|
| 125 | +By default, CodeRabbit automatically generates incremental code reviews for every new or updated pull request made against a repository's default branch. These settings listed in this section let you tune the behavior. |
| 126 | +
|
| 127 | +### Configure incremental reviews {#incremental} |
| 128 | +
|
| 129 | +By default, CodeRabbit generates a new automated review comment every time the branch of an existing pull request gets an additional commit pushed to it. |
| 130 | +
|
| 131 | +If you want to limit CodeRabbit to posting only an initial automated review for a new pull request, with no automated response to further updates, then you can turn off this incremental-review behavior. If you do turn it off, then you can still [manually request reviews](/guides/commands#request). |
| 132 | +
|
| 133 | +For more information, see [Automatic incremental review](/reference/configuration#automatic-incremental-review) in the configuration reference. |
| 134 | +
|
| 135 | +### Restrict automatic reviews to certain labels {#labels} |
| 136 | +
|
| 137 | +If you want to be choosier about which pull requests CodeRabbit should automatically review, then you can restrict it to review only pull requests that you mark with certain labels. |
| 138 | +
|
| 139 | +For more information, see [Labels](/reference/configuration#labels) in the configuration reference. |
| 140 | +
|
| 141 | +### Automatically review more branches {#branches} |
| 142 | +
|
| 143 | +If you want CodeRabbit to extend its automatic-review attention beyond the default branch of your repository—that is, `main` or `master`, usually—then you can give CodeRabbit a list of other branches that it is allowed to review. |
| 144 | + |
| 145 | +For more information, see [Base branches](/reference/configuration#base-branches) in the configuration reference. |
| 146 | + |
| 147 | +## Configure tools {#tools} |
| 148 | + |
| 149 | +CodeRabbit has access to dozens of industry-standard open-source tools to help it perform its code reviews. These tools include a variety of linters, security analyzers, and other utilities. For a full list, see [List of supported tools](/tools/list). CodeRabbit chooses which tools to apply to a given code review on a case-by-case basis. |
| 150 | + |
| 151 | +By default, CodeRabbit considers every tool available to it during code reviews. If you want CodeRabbit to disregard certain tools, then you can disable them. |
| 152 | + |
| 153 | +Several tools that CodeRabbit uses also allow you to specify a path to a tool-specific configuration file in your repository. For example, the following `.coderabbit.yaml` excerpt directs CodeRabbit to use configuration files in the repository's `/pmd-config` directory when using the `pmd` tool: |
| 154 | + |
| 155 | +```yaml |
| 156 | +reviews: |
| 157 | + tools: |
| 158 | + pmd: |
| 159 | + enabled: true |
| 160 | + config_file: /pmd-config/*.yml |
| 161 | +``` |
| 162 | + |
| 163 | +For more information, see [Tools](/reference/configuration#tools) in the configuration reference. |
| 164 | + |
| 165 | +## Other code review settings {#other} |
| 166 | + |
| 167 | +### Adjust code-review strictness {#profile} |
| 168 | + |
| 169 | +If you want CodeRabbit to apply a much stricter and more nitpicky stance to its code reviews, then you can switch its _profile_ setting from `chill` to `assertive`. |
| 170 | + |
| 171 | +CodeRabbit is aware of nitpickier output from the linters and other tools that it applies to code reviews, but includes less of it in its own review comments when the profile is set to `chill`. To have CodeRabbit include more nitpicky tool output in reviews, use the `assertive` profile. |
| 172 | + |
| 173 | +For more information, see [Profile](/reference/configuration#profile) in the configuration reference. |
| 174 | + |
| 175 | +### Configure pull request approval {#request-changes} |
| 176 | + |
| 177 | +By default, CodeRabbit doesn't mark pull requests as approved after any code review, even if CodeRabbit doesn't have any further significant changes to suggest. This leaves the job of formal pull request approval entirely up to human reviewers. |
| 178 | + |
| 179 | +If you want to allow CodeRabbit to mark pull requests as approved, then you can enable the _request changes workflow_ setting. If you do, then CodeRabbit can approve pull requests after it reviewed a pull request and had all of its comments resolved. |
| 180 | + |
| 181 | +This can be useful if you have a workflow that requires several reviewers to approve a pull request before anyone can merge it. For example, if you have configured your repository on your Git platform to require two approvals for any pull request, then activating this CodeRabbit setting lets you merge a pull request after approval from CodeRabbit plus one human reviewer. This can help reduce your team's code-review load. |
| 182 | + |
| 183 | +:::note |
| 184 | +We recommend a policy of always requiring the approval of at least one human reviewer, even if you allow CodeRabbit to approve pull requests. As with an generative AI technology, CodeRabbit works best as a helpful partner to your team, and not as a replacement for human expertise or judgment. |
| 185 | +::: |
| 186 | + |
| 187 | +For more information, see [Request Changes Workflow](/reference/configuration#request-changes-workflow) in the configuration reference. |
| 188 | + |
| 189 | +### Configure chat-based issue creation {#chat-issues} |
| 190 | + |
| 191 | +You can [ask CodeRabbit to create issues for you](https://docs.coderabbit.ai/guides/issue-creation) in the comments of a pull request that it's reviewing. |
| 192 | + |
| 193 | +If you have integrated CodeRabbit with Jira or Linear, then you can tune this behavior a little more, restricting this feature to private repositories—the default setting—or disabling it entirely. |
| 194 | + |
| 195 | +For more information, see [Integrations](/reference/configuration#integrations) in the configuration reference. |
| 196 | + |
| 197 | +## What's next {#whats-next} |
| 198 | + |
| 199 | +- [Setup and configuration best practices](/guides/setup-best-practices) |
0 commit comments