Custom rules
- Tier: Premium, Ultimate
- Add-on: GitLab Duo Core, Pro, or Enterprise
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta
Use custom rules to specify instructions for GitLab Duo Chat to follow for every conversation in your IDE. You can only use custom rules with GitLab Duo Chat.
Create custom rules
You can create custom rules at two levels:
- User-level rules: Apply to all of your projects and workspaces.
- Workspace-level rules: Apply only to a specific project or workspace.
If both user-level and workspace-level rules exist, GitLab Duo Chat applies both to conversations.
Prerequisites:
- For VS Code, install and configure the GitLab Workflow extension for VS Code version 6.32.2 or later.
- For a JetBrains IDE, install and configure the GitLab plugin for JetBrains version 3.12.2 or later.
- For Visual Studio, install and configure the GitLab extension for Visual Studio version 0.60.0 or later.
Conversations that existed before you created any custom rules do not follow those rules.
Create user-level custom rules
User-level custom rules apply to all of your projects and workspaces.
Create a custom rules file in your user configuration directory:
- If you have set the
GLAB_CONFIG_DIRenvironment variable, create the file at:$GLAB_CONFIG_DIR/chat-rules.md - Otherwise, create the file in your platform’s default configuration directory:
- macOS or Linux:
- If you use the
XDG_CONFIG_HOMEenvironment variable, create the file at:$XDG_CONFIG_HOME/gitlab/duo/chat-rules.md - Otherwise, create the file within your home directory at:
~/.gitlab/duo/chat-rules.md
- If you use the
- Windows:
%APPDATA%\GitLab\duo\chat-rules.md
- macOS or Linux:
- If you have set the
Add custom rules to the file. For example:
- Don't put comments in the generated code - Be brief in your explanations - Always use single quotes for JavaScript stringsSave the file.
To apply the new custom rules, start a new GitLab Duo conversation.
You must do this every time you change the custom rules.
Create workspace-level custom rules
Workspace-level custom rules apply only to a specific project or workspace.
In your IDE workspace, create a custom rules file:
.gitlab/duo/chat-rules.md.Add custom rules to the file. For example:
- Don't put comments in the generated code - Be brief in your explanations - Always use single quotes for JavaScript stringsSave the file.
To apply the new custom rules, start a new GitLab Duo conversation.
You must do this every time you change the custom rules.
For more information, see the Custom rules in GitLab Duo Agentic Chat blog.
Update custom rules
To update your custom rules, edit and save the custom rules file. Then, start a new GitLab Duo conversation to apply the updated rules.
You cannot use Chat to edit your custom rules file directly.
To manage who must approve any changes to custom rules, use Code Owners.