The GitLab Docs website is now available in Japanese!

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:

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.

  1. Create a custom rules file in your user configuration directory:

    • If you have set the GLAB_CONFIG_DIR environment 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_HOME environment 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
      • Windows: %APPDATA%\GitLab\duo\chat-rules.md
  2. 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 strings
  3. Save the file.

  4. 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.

  1. In your IDE workspace, create a custom rules file: .gitlab/duo/chat-rules.md.

  2. 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 strings
  3. Save the file.

  4. 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.