GitLab Duo Chat

Tier: Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated
History

GitLab Duo Chat is your personal AI-powered assistant for boosting productivity. It can assist various tasks of your daily work with the AI-generated content.

For a limited time, the following users have free access to GitLab Duo Chat:

  • GitLab.com users who are members of at least one group with a Premium or Ultimate subscription.
  • GitLab self-managed users with a Premium or Ultimate subscription.
  • GitLab Dedicated users.

Eventually a subscription add-on will be required for continued access to GitLab Duo Chat. Learn more about Duo Pro and Duo Enterprise pricing.

Here are examples of common use cases:

Feature Use case example License requirement Supported interfaces Supported deployments
Ask about GitLab I want to know how to create an issue in GitLab. Duo Pro or Duo Enterprise GitLab, VS Code, JetBrains IDEs, and Web IDE GitLab.com
Ask about code I want to understand how this code works. Duo Pro or Duo Enterprise GitLab, VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Ask about CI/CD I want to create a new CI/CD pipeline configuration. Duo Pro or Duo Enterprise GitLab, VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Explain code in the IDE I want to understand how this code works. Duo Pro or Duo Enterprise VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Refactor code in the IDE I want to refactor this code. Duo Pro or Duo Enterprise VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Write tests in the IDE I want to write a test for this code. Duo Pro or Duo Enterprise VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Ask about a specific issue I want to summarize this issue. Duo Enterprise GitLab, VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated
Ask about a specific epic I want to summarize this epic. Duo Enterprise GitLab, VS Code, JetBrains IDEs, and Web IDE GitLab.com, self-managed, and GitLab Dedicated

Watch a demo and get tips

For tips and tricks about integrating GitLab Duo Chat into your AI-powered DevSecOps workflows, read the blog post: 10 best practices for using AI-powered GitLab Duo Chat.

What GitLab Duo Chat can help with

GitLab Duo Chat can help in a variety of areas.

Ask about GitLab

History

You can ask questions about how GitLab works. Things like:

  • Explain the concept of a 'fork' in a concise manner.
  • Provide step-by-step instructions on how to reset a user's password.
note
This feature is not currently supported in self-managed instances. For more information, see issue 451215.

Ask about code

History

You can also ask GitLab Duo Chat to generate code:

  • Write a Ruby function that prints 'Hello, World!' when called.
  • Develop a JavaScript program that simulates a two-player Tic-Tac-Toe game. Provide both game logic and user interface, if applicable.
  • Create a regular expression for parsing IPv4 and IPv6 addresses in Python.
  • Generate code for parsing a syslog log file in Java. Use regular expressions when possible, and store the results in a hash map.
  • Create a product-consumer example with threads and shared memory in C++. Use atomic locks when possible.
  • Generate Rust code for high performance gRPC calls. Provide a source code example for a server and client.

And you can ask GitLab Duo Chat to explain code:

  • Provide a clear explanation of the given Ruby code: def sum(a, b) a + b end. Describe what this code does and how it works.

Alternatively, you can use the /explain command to explain the selected code in your editor.

For more practical examples, see the GitLab Duo examples.

Ask about CI/CD

History

You can ask GitLab Duo Chat to create a CI/CD configuration:

  • Create a .gitlab-ci.yml configuration file for testing and building a Ruby on Rails application in a GitLab CI/CD pipeline.
  • Create a CI/CD configuration for building and linting a Python application.
  • Create a CI/CD configuration to build and test Rust code.
  • Create a CI/CD configuration for C++. Use gcc as compiler, and cmake as build tool.
  • Create a CI/CD configuration for VueJS. Use npm, and add SAST security scanning.
  • Generate a security scanning pipeline configuration, optimized for Java.

You can also ask to explain specific job errors by copy-pasting the error message, prefixed with Please explain this CI/CD job error message, in the context of <language>::

  • Please explain this CI/CD job error message in the context of a Go project: build.sh: line 14: go command not found

Alternatively, you can use root cause analysis in CI/CD.

For more practical examples, see the GitLab Duo examples.

Explain code in the IDE

History
note
This feature is available in VS Code, JetBrains IDEs, and the Web IDE only.

/explain is a special command to explain the selected code in your editor. You can also add additional instructions to be considered, for example: /explain the performance See Use GitLab Duo Chat in VS Code for more information.

  • /explain focus on the algorithm
  • /explain the performance gains or losses using this code
  • /explain the object inheritance (classes, object-oriented)
  • /explain why a static variable is used here (C++)
  • /explain how this function would cause a segmentation fault (C)
  • /explain how concurrency works in this context (Go)
  • /explain how the request reaches the client (REST API, database)

For more practical examples, see the GitLab Duo examples.

Refactor code in the IDE

History
note
This feature is available in VS Code, JetBrains IDEs, and the Web IDE only.

/refactor is a special command to generate a refactoring suggestion for the selected code in your editor. You can include additional instructions to be considered. For example:

  • Use a specific coding pattern, for example /refactor with ActiveRecord or /refactor into a class providing static functions.
  • Use a specific library, for example /refactor using mysql.
  • Use a specific function/algorithm, for example /refactor into a stringstream with multiple lines in C++.
  • Refactor to a different programming language, for example /refactor to TypeScript.
  • Focus on performance, for example /refactor improving performance.
  • Focus on potential vulnerabilities, for example /refactor avoiding memory leaks and exploits.

See Use GitLab Duo Chat in the VS Code for more information.

For more practical examples, see the GitLab Duo examples.

Write tests in the IDE

History
note
This feature is available in VS Code, JetBrains IDEs, and the Web IDE only.

/tests is a special command to generate a testing suggestion for the selected code in your editor. You can also add additional instructions to be considered, for example: /tests using the Boost.Test framework See Use GitLab Duo Chat in the VS Code for more information.

  • Use a specific test framework, for example /tests using the Boost.test framework (C++) or /tests using Jest (JavaScript).
  • Focus on extreme test cases, for example /tests focus on extreme cases, force regression testing.
  • Focus on performance, for example /tests focus on performance.
  • Focus on regressions and potential exploits, for example /tests focus on regressions and potential exploits.

For more practical examples, see the GitLab Duo examples.

Ask about a specific issue

History

You can ask about a specific GitLab issue. For example:

  • Generate a summary for the issue identified via this link: <link to your issue>
  • When you are viewing an issue in GitLab, you can ask Generate a concise summary of the current issue.
  • How can I improve the description of <link to your issue> so that readers understand the value and problems to be solved?
note
If the issue contains a large amount of text (more than 40,000 words), GitLab Duo Chat might not be able to consider every word. The AI model has a limit to the amount of input it can process at one time.

For tips on how GitLab Duo Chat can improve your productivity with issues and epics, see Boost your productivity with GitLab Duo Chat.

Ask about a specific epic

History

You can ask about a specific GitLab epic. For example:

  • Generate a summary for the epic identified via this link: <link to your epic>
  • When you are viewing an epic in GitLab, you can ask Generate a concise summary of the opened epic.
  • What are the unique use cases raised by commenters in <link to your epic>?
note
If the epic contains a large amount of text (more than 40,000 words), GitLab Duo Chat might not be able to consider every word. The AI model has a limit to the amount of input it can process at one time.

Ask about errors

Programming languages that require compiling the source code may throw cryptic error messages. Similarly, a script or a web application could throw a stack trace. You can ask GitLab Duo Chat by prefixing the copied error message with, for example, Please explain this error message:. Add the specific context, like the programming language.

  • Explain this error message in Java: Int and system cannot be resolved to a type
  • Explain when this C function would cause a segmentation fault: sqlite3_prepare_v2()
  • Explain what would cause this error in Python: ValueError: invalid literal for int()
  • Why is "this" undefined in VueJS? Provide common error cases, and explain how to avoid them.
  • How to debug a Ruby on Rails stacktrace? Share common strategies and an example exception.

For more practical examples, see the GitLab Duo examples.

Ask follow up questions

You can ask follow-up questions to delve deeper into the topic or task at hand. This helps you get more detailed and precise responses tailored to your specific needs, whether it’s for further clarification, elaboration, or additional assistance.

A follow-up to the question Write a Ruby function that prints 'Hello, World!' when called could be:

  • Can you also explain how I can call and execute this Ruby function in a typical Ruby environment, such as the command line?

A follow-up to the question How to start a C# project? could be:

  • Can you also please explain how to add a .gitignore and .gitlab-ci.yml file for C#?

For more practical examples, see the GitLab Duo examples.

Supported editor extensions

To use Chat, use one of these editor extensions:

IDE Extension
VSCode VS Code GitLab Workflow extension
GitLab WebIDE (VS Code in the Cloud) No configuration required.
JetBrains IDEs GitLab Duo Plugin for JetBrains

Visual Studio support is under active development. You can express interest in other IDE extension support in this issue.

Enable GitLab Duo Chat

For the GitLab Duo Chat button to be displayed in the GitLab UI, you must enable GitLab Duo Chat.

For GitLab.com

For a limited time, GitLab Duo Chat is available for all GitLab.com users who are members of at least one group with a Premium or Ultimate subscription.

For self-managed

To enable GitLab Duo Chat on a self-managed instance, you must have the following prerequisites.

Prerequisites:

  • You must have GitLab version 16.8 or later. You should use the latest GitLab version to benefit from the latest improvements to GitLab Duo Chat. The generally available version of GitLab Duo Chat in GitLab 16.11 has significant improvements in the quality of the answers.
  • You must have a Premium or Ultimate subscription that is synchronized with GitLab. To make sure GitLab Duo Chat works immediately, administrators can manually synchronize your subscription.
  • Your firewalls and HTTP proxy servers must allow outbound connections to cloud.gitlab.com. To use an HTTP proxy, both gitLab _workhorse and gitLab_rails have the necessary web proxy environment variables set.
  • All of the users in your instance have the latest version of their IDE extension.

Then, depending on the version of GitLab you have, you can enable GitLab Duo Chat.

In GitLab 16.11 and later

In GitLab 16.11 and later, GitLab Duo Chat is generally available and automatically enabled for all users who have a subscription to the Premium or Ultimate tier.

You do not need to do anything to enable GitLab Duo Chat if you have GitLab 16.11 or later.

In earlier GitLab versions

In GitLab 16.8, 16.9, and 16.10, GitLab Duo Chat is available in Beta. To enable GitLab Duo Chat for your self-managed GitLab instance, an administrator must enable Experiment and Beta features:

  1. On the left sidebar, at the bottom, select Admin Area.
  2. Select Settings > General.
  3. Expand AI-powered features and select Enable Experiment and Beta AI-powered features.
  4. Select Save changes.
  5. To make sure GitLab Duo Chat works immediately, you must manually synchronize your subscription.
note
Usage of GitLab Duo Chat Beta is governed by the GitLab Testing Agreement. Learn about data usage when using GitLab Duo Chat.

Manually synchronize your subscription

You can manually synchronize your subscription if either:

  • You have just purchased a subscription for the Premium or Ultimate tier, or have recently assigned seats for Duo Pro, and you have upgraded to GitLab 16.8.
  • You already have a subscription for the Premium or Ultimate tier, or you have recently assigned seats for Duo Pro, and you have upgraded to GitLab 16.8.

Without the manual synchronization, it might take up to 24 hours to activate GitLab Duo Chat on your instance.

For GitLab Dedicated

In GitLab 16.11 and later, on GitLab Dedicated, GitLab Duo Chat is generally available and automatically enabled.

In GitLab 16.8, 16.9, and 16.10, on GitLab Dedicated, GitLab Duo Chat is available in Beta.

Disable GitLab Duo Chat

To disable GitLab Duo Chat, follow the instructions for disabling GitLab Duo features.

When you disable GitLab Duo features, GitLab Duo Chat no longer uses your organization’s data when responding to questions. For example, you can no longer ask about your issues or epics.

However, the GitLab Duo Chat button continues to be displayed in the upper-right corner and on the left sidebar under Help, and you can continue to ask generic questions about GitLab.

Use GitLab Duo Chat in the GitLab UI

  1. In the upper-right corner, select GitLab Duo Chat. A drawer opens on the right side of your screen.
  2. Enter your question in the chat input box and press Enter or select Send. It may take a few seconds for the interactive AI chat to produce an answer.
  3. Optional. Ask a follow-up question.

To ask a new question unrelated to the previous conversation, you might receive better answers if you clear the context by typing /reset and selecting Send.

note
Only the last 50 messages are retained in the chat history. The chat history expires 3 days after last use.

Delete all conversations

To delete all previous conversations:

  • In the text box, type /clear and select Send.

Use GitLab Duo Chat in the Web IDE

History
  • Introduced in GitLab 16.6 as an Experiment.
  • Changed to Generally Available in GitLab 16.11.

To use GitLab Duo Chat in the Web IDE on GitLab:

  1. Open the Web IDE:
    1. In the GitLab UI, on the left sidebar, select Search or go to and find your project.
    2. Select a file. Then in the upper right, select Edit > Open in Web IDE.
  2. Then open Chat by using one of the following methods:
    • On the left sidebar, select GitLab Duo Chat.
    • In the file that you have open in the editor, select some code.
      1. Right-click and select GitLab Duo Chat.
      2. Select Explain selected code or Generate Tests.
    • Use the keyboard shortcut: ALT+d (on Windows and Linux) or Option+d (on Mac)
  3. In the message box, enter your question and press Enter or select Send.

If you have selected code in the editor, this selection is sent along with your question to the AI. This way you can ask questions about this code selection. For instance, Could you simplify this?.

note
GitLab Duo Chat is not available in the Web IDE on self-managed.

Perform standard task in the IDE from the context menu or by using slash commands

Get code explained, refactored, or generate tests for code.

  1. In VS Code or in the Web IDE, select code in your editor.
  2. In the Chat box, type one the following slash commands:

Alternatively, use the context menu to perform these tasks.

When you use a slash command, you can also add additional instructions, for example: /tests using the Boost.Test framework.

Use GitLab Duo Chat in VS Code

History
  • Introduced in GitLab 16.6 as an Experiment.
  • Changed to Generally Available in GitLab 16.11.

To use GitLab Duo Chat in GitLab Workflow extension for VS Code:

  1. Install and set up the Workflow extension for VS Code:
    1. In VS Code, download and install the GitLab Workflow extension for VS Code.
    2. Configure the GitLab Workflow extension.
  2. In VS Code, open a file. The file does not need to be a file in a Git repository.
  3. Open Chat by using one of the following methods:
    • On the left sidebar, select GitLab Duo Chat.
    • In the file that you have open in the editor, select some code.
      1. Right-click and select GitLab Duo Chat.
      2. Select Explain selected code or Generate Tests.
    • Use the keyboard shortcut: ALT+d (on Windows and Linux) or Option+d (on Mac)
  4. In the message box, enter your question and press Enter or select Send.

If you have selected code in the editor, this selection is sent along with your question to the AI. This way you can ask questions about this code selection. For instance, Could you simplify this?.

Perform standard task in the IDE from the context menu or by using slash commands

Get code explained, code refactored or get tests generated for code. To do so:

  1. Select code in your editor in VS Code, JetBrains IDEs, or in the Web IDE.
  2. Type one the following slash commands into the chat field: /explain, /refactor or /tests. Alternatively, use the context menu to perform these tasks.

When you use one of the slash commands you can also add additional instructions to be considered, for example: /tests using the Boost.Test framework

Disable Chat in VS Code

To disable GitLab Duo Chat in VS Code:

  1. Go to Settings > Extensions > GitLab Workflow (GitLab VS Code Extension).
  2. Clear the Enable GitLab Duo Chat assistant checkbox.

Use GitLab Duo Chat in JetBrains IDEs

History
  • Introduced as Generally Available in GitLab 16.11.

To use GitLab Duo Chat in the GitLab Duo plugin for JetBrains IDEs:

  1. Install and set up the GitLab Duo plugin for JetBrains IDEs:
    1. In the JetBrains marketplace, download and install the GitLab Duo plugin.
    2. Configure the GitLab Duo plugin.
  2. In a JetBrains IDE, open a project.
  3. Open Chat by using one of the following methods:
    • On the right tool window bar, select GitLab Duo Chat.
    • In the file that you have open in the editor, select some code.
      1. Right-click and select GitLab Duo Chat.
      2. Select Explain Code or Generate Tests or Refactor Code.
    • Add keyboard or mouse shortcuts for each action under Keymap in the Settings.
  4. In the message box, enter your question and press Enter or select Send.

Give feedback

Your feedback is important to us as we continually enhance your GitLab Duo Chat experience. Leaving feedback helps us customize the Chat for your needs and improve its performance for everyone.

To give feedback about a specific response, use the feedback buttons in the response message. Or, you can add a comment in the feedback issue.

Troubleshooting

When working with GitLab Duo Chat, you might encounter the following issues.

The GitLab Duo Chat button is not displayed

If the button is not visible in the upper-right of the UI, ensure GitLab Duo Chat is enabled.

The GitLab Duo Chat button is not displayed on personal projects, as well as groups and projects with GitLab Duo features disabled.

After you enable GitLab Duo Chat, it might take a few minutes for the button to appear.

This feature is only allowed in groups or projects that enable this feature

This error occurs when you ask about resources that do have GitLab Duo disabled.

If any of the settings are not enabled, information about resources (like issues, epics, and merge requests) in the group or project cannot be processed by GitLab Duo Chat.

I am sorry, I am unable to find what you are looking for

This error occurs when you ask GitLab Duo Chat about resources you don’t have access to, or about resources that do not exist.

Try again, asking about resources you have access to.

I'm sorry, I can't find the answer, but it's my fault, not yours. Please try something different

This is a fallback error that occurs when there is a problem with GitLab Duo Chat. Please try your request again, or leave feedback to help us improve.