Code Review Flow

  • Tier: Premium, Ultimate
  • Add-on: GitLab Duo Core or Pro
  • Offering: GitLab.com, GitLab Self-Managed
  • Status: Beta

The availability of this feature is controlled by a feature flag. For more information, see the history.

The Code Review Flow helps you streamline code reviews with agentic AI.

This flow:

  • Analyzes code changes, merge request comments, and linked issues.
  • Provides enhanced contextual understanding of repository structure and cross-file dependencies.
  • Delivers detailed review comments with actionable feedback.
  • Supports custom review instructions tailored to your project.

This flow is available in the GitLab UI only.

The Code Review Flow is different from classic GitLab Duo Code Review.

Use the flow

Prerequisites:

To trigger a Code Review Flow on a merge request:

  1. On the left sidebar, select Code > Merge requests and find your merge request.
  2. Use one of these methods to trigger the review:
    • Assign the review to @GitLabDuo
    • Mention @GitLabDuo in a comment

You can interact with GitLab Duo by:

  • Replying to its review comments to ask for clarification or alternative approaches.
  • Mentioning @GitLabDuo in any discussion thread to ask follow-up questions.

Automatic code reviews

You can configure automatic code reviews for projects or groups to ensure all merge requests receive an initial review by GitLab Duo. After you create a merge request, 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.

Enable automatic reviews for a project

Prerequisites:

To enable @GitLabDuo to automatically review merge requests:

  1. On the top bar, select Search or go to and find your project.
  2. Select Settings > Merge requests.
  3. In the GitLab Duo Code Review section, select Enable automatic reviews by GitLab Duo.
  4. Select Save changes.

Enable automatic reviews for a group or application

Use group or application settings to enable automatic reviews for multiple projects.

Prerequisites:

  • To turn on automatic reviews for groups, have the Owner role for the group.
  • To turn on automatic reviews for all projects, be an administrator.

To enable automatic reviews for groups:

  1. On the top bar, select Search or go to and find your group.
  2. Select Settings > General.
  3. Expand the Merge requests section.
  4. In the GitLab Duo Code Review section, select Enable automatic reviews by GitLab Duo.
  5. Select Save changes.

To enable automatic reviews for all projects:

  1. In the upper-right corner, select Admin.
  2. Select Settings > General.
  3. In the GitLab Duo Code Review section, select Enable automatic reviews by GitLab Duo.
  4. Select Save changes.

Settings cascade from application to group to project. More specific settings override broader ones.

Custom instructions

Customize the behavior of Code Review Flow with repository-specific review instructions. You can guide the agent to:

  • Focus on specific code quality aspects (such as security, performance, and maintainability).
  • Enforce coding standards and best practices unique to your project.
  • Target specific file patterns with tailored review criteria.
  • Provide more detailed explanations for certain types of changes.

To configure custom instructions:

  1. In the root of your repository, create a .gitlab/duo directory if it doesn’t already exist.

  2. In the .gitlab/duo directory, create a file named mr-review-instructions.yaml.

  3. 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"           # Ruby files in the root directory
          - "lib/**/*.rb"    # Ruby files in lib and its subdirectories
          - "!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"        # Typescript files in any directory
          - "!**/*.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" # Ruby test files in spec directory
        instructions: |
          1. Test both happy paths and edge cases
          2. Include error scenarios
          3. Use shared examples to reduce duplication
  4. Optional: Add a Code Owners entry to protect changes to the mr-review-instructions.yaml file.

    [GitLab Duo]
    .gitlab/duo @default-owner @tech-lead
  5. Create a merge request to review and merge the changes:

    • Code Review automatically applies your custom instructions when the file patterns match.
    • Multiple instruction groups can apply to a single file.
  6. Optional:

    • Review the feedback and refine your instructions as needed.
    • Test the patterns to ensure they match the intended files.

Differences from classic GitLab Duo Code Review

While the Code Review Flow provides the same core functionality as the classic GitLab Duo Code Review, the GitLab Duo Agent Platform implementation offers:

  • Improved context awareness: Better understanding of repository structure and cross-file dependencies.
  • Agentic capabilities: Multi-step reasoning for more thorough analysis.
  • Modern architecture: Built on the scalable GitLab Duo Agent Platform.

All existing features including custom instructions, automatic reviews, and interaction patterns remain compatible.