Code Suggestions on GitLab SaaS (FREE SAAS)
- Introduced in GitLab 15.9 as Beta for early access Ultimate customers on GitLab.com.
- Enabled as opt-in with GitLab 15.11 as Beta.
- Moved from GitLab Ultimate to GitLab Premium in 16.0.
- Moved from GitLab Premium to GitLab Free in 16.0.
- Enabled by default in GitLab 16.1.
- Generally available in GitLab 16.7.
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
- Introduced in GitLab 16.1 as Beta.
- Enabled on GitLab.com and self-managed in GitLab 16.8. UI user setting removed.
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:
- You must have configured Code Suggestions in a supported IDE editor extension.
- Code Suggestions must be enabled for the top-level group.
To use Code Suggestions:
- Author your code. As you type, suggestions are displayed. Code Suggestions provide code snippets or complete the current line, depending on the cursor position.
- 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.
-
- To accept a suggestion, press Tab.
- To ignore a suggestion, keep typing as you usually would.
- 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.