AI is transforming the way we get work done, from helping automate mundane tasks to optimizing aspects of our day-to-day workflow. Of particular relevance has been generative AI’s ability to support developers in getting the job done, from code snippet suggestions to concise summaries of technical questions. These AI tools have been embedded in the development lifecycle through integrations with existing software like code editors and CI/CD platforms. Thanks to these integrations, particularly in the case of code editors, developers can have an AI assistant that complements their skills within their development environment.
While these AI tools can help boost productivity, setting them up in an existing development environment may not be preferable. For example, you may not want to install a new dependency on your local workstation that could affect your setup, you may have security or privacy concerns about running AI tools on your computer, or you may find it hard to give the tooling context on your existing workflow. GitLab resolves these issues by providing a suite of tools that allow you to leverage the power of AI in a remote development workspace right out of the box. In this blog, you'll learn about the GitLab features that make this possible and how to set up your workspace environment to get started.
GitLab workflow extension for VS Code
GitLab workflow extension for VS Code integrates GitLab into the VS Code editor. It brings into scope key elements of your GitLab workflow such as issues, merge requests, and pipeline status. For more information, visit the GitLab workflow extension documentation.
GitLab Workspaces
GitLab Workspaces provide an isolated development environment to make changes to your GitLab projects. Workspaces offer a platform to work on your projects without the complexity of setting up local dependencies. Workspaces also provide reproducible development setups, as a workspace environment configuration created by one developer can be shared with others. GitLab Workspaces are configured to use the VS Code editor and ship with the workflow extension preinstalled. To learn more, visit the GitLab Workspaces documentation.
GitLab Duo Chat and Code Suggestions
GitLab Duo Chat and GitLab Duo Code Suggestions are part of the GitLab Duo suite of AI features enhancing developer productivity. Chat and Code Suggestions are integrated into the workflow extension and are GitLab context-aware. This allows you to ask GitLab Duo questions about items like issues and merge requests and to automatically have access to code suggestions and code completion. This integration requires a GitLab Duo license. See the GitLab Duo Chat documentation and GitLab Duo Code Suggestions documentation for more information.
How to set up the Workflow extension, Workspaces, and GitLab Duo to work together
While these features are impressive on their own, when combined they deliver on the promise of an easy-to-spin-up, isolated, AI-driven development environment. Here are the steps to get this powerhouse up and running.
Create a workspace
Follow this comprehensive but easy-to-follow tutorial to create a remote development workspace.
Validate GitLab Workflow is active
After your workspace is up and running, you should see a GitLab icon on the side of your editor like the following:
You can then use the workflow extension to bring up merge requests assigned to you in the current project in GitLab. To do this, access the command palette by hitting command + shift + P and entering GitLab: Show Merge Requests Assigned to Me. This will redirect you to GitLab and show your assigned MRs.
For more tips and tricks, read Visual Studio code editor: Eight tips for using GitLab VS Code.
Use GitLab Duo Chat
You should also see a second, smaller GitLab icon on your sidebar. This gives you access to GitLab Duo Chat. Feel free to ask it a question.
Use GitLab Duo Code Suggestions
Open up any source file in your directory. You can begin typing code and have predictive suggestions, powered by GitLab Duo Code Suggestions, pop up – you can insert them by hitting the tab key. The example below shows my attempt to write a string processing function. Code Suggestions has inferred I would want to split the passed string into spaces, which is indeed my intention.
Suppose I have completed my string processing function above and would like to generate unit tests for it but want to avoid the chore of writing boilerplate code. You can provide a comment in your editor and have Code Suggestions generate code for you like the following:
Code Suggestions implements a whole unit test for my function, covering happy and sad paths.
For more exciting uses of the GitLab Duo suite, check out these articles:
- 10 best practices for using AI-powered GitLab Duo Chat
- Top tips for efficient AI-powered Code Suggestions with GitLab Duo
- "Developing GitLab Duo" blog series
Next steps
GitLab Workspaces is coming up with more exciting integrations and features that will enhance your remote development experience, be sure to check out the category epic to know what’s coming next!
Sign up for a free trial of GitLab Duo today!