> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qodo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate labels

<Badge color="outline-provider" size="sm" shape="pill" icon="github">GitHub</Badge>
<Badge color="outline-provider" size="sm" shape="pill" icon="gitlab">GitLab</Badge>

<Warning>
  **Git Integration (formerly Qodo Merge)** – AI code review agents for pull requests. This documentation describes the Qodo v1 experience. For the Qodo v2 documentation, click [here.](/code-review)
</Warning>

The `generate_labels` tool analyzes the PR code changes and automatically suggests relevant labels, based on a list of predefined labels and their descriptions.

## How to use the `generate_labels` tool

**Manual usage**

Comment on the PR:

```bash theme={null}
/generate_labels
```

### Enabling custom labels

There are 3 ways to enable custom labels:

#### 1. CLI (local configuration file)

When working from CLI, you need to apply the [configuration changes](/v1/tools/tools-list/generate-labels#configuration-options) to the [custom\_labels file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/custom_labels.toml).

#### 2. Repository configuration file

To enable custom labels, you need to apply the [configuration changes](/v1/tools/tools-list/generate-labels#configuration-options) to the local `.pr_agent.toml` file in your repository.

#### 3. Handle custom labels from the repo's labels page

<Note>
  **Platforms supported: GitHub, GitLab**
</Note>

* **GitHub:** `https://github.com/{owner}/{repo}/labels`, or click the **Labels** tab in the issues or PR's page.
* **GitLab:** `https://gitlab.com/{owner}/{repo}/-/labels`, or click **Manage** and then **Labels** from the left menu.

### Adding custom labels

Custom labels should be formatted as:

* **Label name**: The name of the custom label.
* **Description**: Start the description with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.

  The description should be comprehensive and detailed, indicating when to add the desired label.

  <Frame>
    <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-173.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=5739e5da38baee9214365ac1e366b7fe" alt="" width="1129" height="262" data-path="images/v1/image-173.png" />
  </Frame>

### Using `generate_labels`

After adding labels, they will be available for generation in `generate_labels`.

* Set `enable_custom_labels` to `True`: This will turn off the default labels and enable the custom labels provided in the `custom_labels.toml` file.
* Add the custom labels. It should be formatted as follows:

```bash theme={null}
[config]
enable_custom_labels=true

[custom_labels."Custom Label Name"]
description = "Description of when AI should suggest this label"

[custom_labels."Custom Label 2"]
description = "Description of when AI should suggest this label 2"
```

## Example usage

If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description:

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-174.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=0722ba0a796e377718ffe57c2ae1072c" alt="" width="901" height="435" data-path="images/v1/image-174.png" />
</Frame>

When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label:

<Frame>
  <img src="https://mintcdn.com/qodo/uIkZ6kAWHm6WXqrW/images/v1/image-175.png?fit=max&auto=format&n=uIkZ6kAWHm6WXqrW&q=85&s=24c5567b26a0cb9eb3c2e043db65dc6d" alt="" width="1145" height="668" data-path="images/v1/image-175.png" />
</Frame>

<Note>
  Note that in addition to the dedicated tool `generate_labels`, the custom labels will also be used by the `describe` tool.
</Note>
