13 KiB
stage, group, info, description, title
stage | group | info | description | title |
---|---|---|---|---|
Create | Code Creation | To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments | Use AI-assisted features for relevant information about a merge request. | GitLab Duo in merge requests |
{{< alert type="disclaimer" />}}
GitLab Duo is designed to provide contextually relevant information during the lifecycle of a merge request.
Generate a description by summarizing code changes
{{< details >}}
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Enterprise
- Offering: GitLab.com, GitLab Self-Managed
- Status: Beta
- LLM: Anthropic Claude 3.7 Sonnet
{{< /details >}}
{{< history >}}
- Introduced in GitLab 16.2 as an experiment.
- Changed to beta in GitLab 16.10.
- Changed to require GitLab Duo add-on in GitLab 17.6 and later.
- LLM updated to Claude 3.7 Sonnet in GitLab 17.10
- Feature flag
add_ai_summary_for_new_mr
enabled by default in GitLab 17.11. - Changed to include Premium in GitLab 18.0.
{{< /history >}}
When you create or edit a merge request, use GitLab Duo Merge Request Summary to create a merge request description.
-
In the Description field, put your cursor where you want to insert the description.
-
On the toolbar above the text area, select Summarize code changes ({{< icon name="tanuki-ai" >}}).
The description is inserted where your cursor was.
Provide feedback on this feature in issue 443236.
Data usage: The diff of changes between the source branch's head and the target branch is sent to the large language model.
Have GitLab Duo review your code
{{< details >}}
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Enterprise
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- LLM: Anthropic Claude 3.7 Sonnet
{{< /details >}}
{{< history >}}
- Introduced in GitLab 17.5 as an experiment behind two feature flags named
ai_review_merge_request
andduo_code_review_chat
, both disabled by default. - Feature flags
ai_review_merge_request
andduo_code_review_chat
enabled by default on GitLab.com, GitLab Self-Managed, and GitLab Dedicated in 17.10. - Changed to beta in GitLab 17.10.
- Changed to include Premium in GitLab 18.0.
- Feature flag
ai_review_merge_request
removed in GitLab 18.1. - Feature flag
duo_code_review_chat
removed in GitLab 18.1. - Generally available in GitLab 18.1.
{{< /history >}}
When your merge request is ready to be reviewed, use GitLab Duo Code Review to perform an initial review:
- On the left sidebar, select Search or go to and find your project.
- Select Code > Merge requests and find your merge request.
- In a comment box, enter the quick action
/assign_reviewer @GitLabDuo
, or assign GitLab Duo as reviewer.
{{< alert type="note" >}}
Provide feedback on this feature in issue 517386.
{{< /alert >}}
Data usage: When you use this feature, the following data is sent to the large language model:
- Contents of the changed files
- Filenames
- Merge request title
- Merge request description
Interact with GitLab Duo in reviews
You can mention @GitLabDuo
in comments to interact with GitLab Duo on your merge request. You can ask follow-up questions on its review comments, or ask questions on any discussion thread in your merge request.
Interactions with GitLab Duo can help to improve the suggestions and feedback as you work to improve your merge request.
Automatic reviews from GitLab Duo
{{< history >}}
- Changed to a UI setting in GitLab 18.0.
{{< /history >}}
Automatic reviews from GitLab Duo ensure that all merge requests in your project receive an initial review. After a merge request is created, GitLab Duo reviews it unless:
- It's marked as draft. For GitLab Duo to review the merge request, mark it ready.
- It contains no changes. For GitLab Duo to review the merge request, add changes to it.
Prerequisites:
- You must have at least the Maintainer role in a project.
To enable @GitLabDuo
to automatically review merge requests:
- On the left sidebar, select Search or go to and find your project.
- Select Settings > Merge requests.
- In the GitLab Duo Code Review section, select Enable automatic reviews by GitLab Duo.
- Select Save changes.
Customize instructions for GitLab Duo Code Review
{{< details >}}
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Enterprise
- Offering: GitLab.com
- Status: Beta
- LLM: Anthropic Claude 4.0 Sonnet
{{< /details >}}
{{< history >}}
- Introduced in GitLab 18.2 as a beta with a flag named
duo_code_review_custom_instructions
. Disabled by default.
{{< /history >}}
{{< alert type="flag" >}}
The availability of this feature is controlled by a feature flag. For more information, see the history.
{{< /alert >}}
GitLab Duo Code Review can help ensure consistent code review standards in your project. Define a glob pattern for files, and create custom instructions for files matching that pattern. For example, enforce Ruby style conventions only on Ruby files, and Go style conventions on Go files. GitLab Duo appends your custom instructions to its standard review criteria.
To configure custom instructions:
- In the root of your repository, create a
.gitlab/duo
directory if it doesn't already exist. - In the
.gitlab/duo
directory, create a file namedmr-review-instructions.yaml
. - Add your custom instructions using this format:
instructions:
- name: <instruction_group_name>
fileFilters:
- <glob_pattern_1>
- <glob_pattern_2>
- !<exclude_pattern> # Exclude files matching this pattern
instructions: |
<your_custom_review_instructions>
For example:
instructions:
- name: Ruby Style Guide
fileFilters:
- "*.rb"
- "lib/**/*.rb"
- "!spec/**/*.rb" # Exclude test files
instructions: |
1. Ensure all methods have proper documentation
2. Follow Ruby style guide conventions
3. Prefer symbols over strings for hash keys
- name: TypeScript Source Files
fileFilters:
- "**/*.ts"
- "!**/*.test.ts" # Exclude test files
- "!**/*.spec.ts" # Exclude spec files
instructions: |
1. Ensure proper TypeScript types (avoid 'any')
2. Follow naming conventions
3. Document complex functions
- name: All Files Except Tests
fileFilters:
- "!**/*.test.*" # Exclude all test files
- "!**/*.spec.*" # Exclude all spec files
- "!test/**/*" # Exclude test directories
- "!spec/**/*" # Exclude spec directories
instructions: |
1. Follow consistent code style
2. Add meaningful comments for complex logic
3. Ensure proper error handling
- name: Test Coverage
fileFilters:
- "spec/**/*_spec.rb"
instructions: |
1. Test both happy paths and edge cases
2. Include error scenarios
3. Use shared examples to reduce duplication
Customized code review comments
When GitLab Duo Code Review generates code review comments based on your custom instructions, they follow this format:
According to custom instructions in '[instruction_name]': [specific feedback]
For example:
According to custom instructions in 'Ruby Style Guide': This method should have proper documentation explaining its purpose and parameters.
The instruction_name
value corresponds to the name
property from your .gitlab/duo/mr-review-instructions.yaml
file. Standard GitLab Duo comments don't use this citation format.
Summarize a code review
{{< details >}}
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Enterprise
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Experiment
- LLM: Anthropic Claude 3.7 Sonnet
{{< /details >}}
{{< history >}}
- Introduced in GitLab 16.0 as an experiment.
- Feature flag
summarize_my_code_review
enabled by default in GitLab 17.10. - LLM updated to Claude 3.7 Sonnet in GitLab 17.11.
- Changed to include Premium in GitLab 18.0.
{{< /history >}}
When you've completed your review of a merge request and are ready to submit your review, use GitLab Duo Code Review Summary to generate a summary of your comments.
- On the left sidebar, select Search or go to and find your project.
- Select Code > Merge requests and find the merge request you want to review.
- When you are ready to submit your review, select Finish review.
- Select Add Summary.
The summary is displayed in the comment box. You can edit and refine the summary prior to submitting your review.
Provide feedback on this experimental feature in issue 408991.
Data usage: When you use this feature, the following data is sent to the large language model:
- Draft comment's text
Generate a merge commit message
{{< details >}}
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Enterprise
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- LLM: Anthropic Claude 3.7 Sonnet
{{< /details >}}
{{< history >}}
- Introduced in GitLab 16.2 as an experiment with a flag named
generate_commit_message_flag
. Disabled by default. - Feature flag
generate_commit_message_flag
enabled by default in GitLab 17.2. - Feature flag
generate_commit_message_flag
removed in GitLab 17.7. - Changed to include Premium in GitLab 18.0.
{{< /history >}}
When preparing to merge your merge request, edit the proposed merge commit message by using GitLab Duo Merge Commit Message Generation.
- On the left sidebar, select Search or go to and find your project.
- Select Code > Merge requests and find your merge request.
- Select the Edit commit message checkbox on the merge widget.
- Select Generate commit message.
- Review the commit message provided and choose Insert to add it to the commit.
Data usage: When you use this feature, the following data is sent to the large language model:
- Contents of the file
- The filename