Skip to content

Code Suggestions on GitLab SaaS (FREE SAAS)

Write code more efficiently by using generative AI to suggest code while you're developing.

Usage of GitLab Duo Code Suggestions is governed by the GitLab Testing Agreement. Learn about data usage when using Code Suggestions.

Enable Code Suggestions

A group owner must enable Code Suggestions for your top-level group.

NOTE: If you are having issues enabling Code Suggestions, view the troubleshooting guide.

Use Code Suggestions

Prerequisites:

To use Code Suggestions:

  1. Author your code. As you type, suggestions are displayed. Code Suggestions provide code snippets or complete the current line, depending on the cursor position.
  2. Describe the requirements in natural language. Code Suggestions generates functions and code snippets based on the context provided. To get the best results from code generation:
    • Be as specific as possible while remaining concise. State the outcome you want to generate (for example, a function) and provide details on what you want to achieve. Add additional information, such as the framework or library you want to use when applicable. For example, to create a Python web service with some specific requirements, you might write something similar to the following:

      # Create a web service using Tornado that allows a user to log in, run a security scan, and review the scan results.
      # Each action (log in, run a scan, and review results) should be its own resource in the web service
      ...
    • Add a space or go to a new line after each comment. This tells the code generator that you have completed your instructions.

  3. To accept a suggestion, press Tab.
  4. To ignore a suggestion, keep typing as you usually would.
  5. To explicitly reject a suggestion, press Esc.

Things to remember:

  • AI is non-deterministic, so you may not get the same suggestion every time with the same input.
  • Just like product requirements, writing clear, descriptive, and specific tasks results in quality generated code.

Disable Code Suggestions

Individual users can disable Code Suggestions by disabling the feature in their installed IDE editor extension.