Customize Gemini Code Assist behavior in GitHub

  • You can customize Gemini Code Assist's code review by adding a styleguide.md file in the .gemini/ folder of your repository.

  • The enterprise version allows managing style guides and configurations for multiple repositories via the Google Cloud console.

  • Gemini Code Assist's standard code review focuses on correctness, efficiency, maintainability, security, and miscellaneous topics when a custom style guide is not provided.

  • A config.yaml file can be used to enable or disable various features and specify files to ignore using glob patterns.

  • When both repository-specific and Google Cloud console configurations exist, the repository's config.yaml overrides console settings, while styleguide.md files are combined.

You can modify Gemini Code Assist on GitHub behavior by adding a config.yaml file to a .gemini/ folder located in the root of your repository. The config.yaml file contains various configurable features that you can enable or disable, including specifying files to ignore using glob patterns.

Gemini Code Assist also supports adding a styleguide.md file to the .gemini/ folder, which instructs Gemini Code Assist with some specific rules that you want it to follow when performing a code review. For more information about style guides for Gemini Code Assist, see Code review style guide.

config.yaml example

The following code snippet is an example of a config.yaml file. In this example, each property is set to the default value used by Gemini Code Assist. You can use this snippet as a template to create your own config.yaml file:

have_fun: false
memory_config:
  disabled: false
code_review:
  disable: false
  comment_severity_threshold: MEDIUM
  max_review_comments: -1
  pull_request_opened:
    help: false
    summary: true
    code_review: true
    include_drafts: true
ignore_patterns: []

config.yaml schema

The following code snippet is the schema for the config.yaml file. It defines all of the possible configuration options and their accepted values:

$schema: "http://json-schema.org/draft-07/schema#"
title: RepoConfig
description: Configuration for Gemini Code Assist on a repository. All fields are optional and have default values.
type: object
properties:
  have_fun:
    type: boolean
    description: Enables fun features such as a poem in the initial pull request summary. Default: false.
  ignore_patterns:
    type: array
    items:
      type: string
    description: A list of glob patterns for files and directories that Gemini Code Assist should ignore. Files matching any pattern in this list will be skipped during interactions. Default: [].
  memory_config:
    type: object
    description: Configuration for persistent memory, which is used to improve responses.
    properties:
      disabled:
        type: boolean
        description: Whether to disable persistent memory for this specific repository, if Improve response quality has been enabled for multiple repositories. Default: false.
  code_review:
    type: object
    description: Configuration for code reviews. All fields are optional and have default values.
    properties:
      disable:
        type: boolean
        description: Disables Gemini from acting on pull requests. Default: false.
      comment_severity_threshold:
        type: string
        enum:
          - LOW
          - MEDIUM
          - HIGH
          - CRITICAL
        description: The minimum severity of review comments to consider. Default: MEDIUM.
      max_review_comments:
        type: integer
        format: int64
        description: The maximum number of review comments to consider. Use -1 for unlimited. Default: -1.
      pull_request_opened:
        type: object
        description: Configuration for pull request opened events. All fields are optional and have default values.
        properties:
          help:
            type: boolean
            description: Posts a help message on pull request open. Default: false.
          summary:
            type: boolean
            description: Posts a pull request summary on the pull request open. Default: true.
          code_review:
            type: boolean
            description: Posts a code review on pull request open. Default: true.
          include_drafts:
            type: boolean
            description: Enables agent functionality on draft pull requests. Default: true.

Manage configurations across multiple repositories

Some aspects of Gemini Code Assist on GitHub can be managed across multiple repositories:

  • If you have the consumer version, you can toggle certain settings for all repositories that are associated with an account.

  • If you have the enterprise version, you can toggle certain settings for multiple repositories grouped by a Developer Connect connection. When you do, you manage their collective settings through the Google Cloud console.

If a repository is managed as part of a group but also has its own config.yaml, the repository's config.yaml settings override the group settings.

For specific setting behavior and exceptions, review the config.yaml schema.

The following steps show how to control one set of configurations across multiple repositories. These steps assume you have previously set up Gemini Code Assist on GitHub.

Consumer

  1. In Gemini Code Assist, go to the settings page.

    Go to settings

  2. If prompted, click Log in with GitHub and follow the prompts to sign in to GitHub from within Gemini Code Assist.

  3. In the Gemini page, select the account you want to work with, review the terms of service, and click Continue.

  4. In the Free agent page, update the settings as needed.

  5. Click Save.

Enterprise

  1. In the Google Cloud console, go to the Gemini Code Assist Agents & Tools page.

    Go to Agents & Tools

  2. In the Agents section, locate the Code Assist Source Code Management card, and click Advanced.

    The Edit Code Assist Source Code Management pane opens.

  3. In the Connections table, click the name of the connection that you want to apply a configuration to.

    The details page for the connection opens.

  4. In the Settings tab, update the settings that you want to change.

  5. Click Save.

What's next