Optimizing PR Labels with /generate_labels Command

Optimizing the labeling process for your pull requests has never been easier. The /generate_labels tool in CodiumAI’s PR-Agent simplifies the task by automatically suggesting labels based on the code changes in your PR. This blog will guide you through the functionalities, configurations, and benefits of incorporating this powerful tool into your workflow.

What is /generate_labels?

The /generate_labels command is designed to enhance your PR management experience. By analyzing the code changes within a pull request, it suggests relevant labels, streamlining the categorization process. This tool ensures that your PRs are accurately labeled, aiding in better organization and faster reviews.

How to Use /generate_labels

To invoke the /generate_labels tool, simply comment /generate_labels on your pull request. PR-Agent will then analyze the code modifications and suggest applicable labels.

Custom Labels for Precise Categorization

PR-Agent goes a step further by allowing you to define custom labels based on specific conditions. This is particularly useful when you want to categorize PRs according to unique criteria. Let's explore how to set up custom labels and leverage them for a more tailored labeling approach.

Enabling Custom Labels

To enable custom labels, make the following changes to your configuration:


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"

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


Setting Up Custom Labels

  • CLI (Local Configuration File): Apply configuration changes to the custom_labels.toml file when working from the command line.
  • Repo Configuration File: Modify the local .pr_agent.toml file in your repository to enable custom labels.
  • Repository Labels Page (PR-Agent Pro): Directly handle custom labels from your repository's labels page on GitHub or GitLab.

Benefits and Use-Cases

Automated Categorization

  • Save Time: Automate the label assignment process, reducing manual effort.
  • Consistent Labeling: Ensure consistent and accurate labeling across your PRs.

Customization for Specific Criteria

  • Tailored Categories: Create labels based on your project's unique criteria.
  • Granular Organization: Improve organization by categorizing PRs with specific labels.

Frequently Asked Questions

  • Can I customize label suggestions for specific code changes?

    Yes, by configuring custom labels, you can precisely define when specific labels should be suggested.

  • How do custom labels integrate with the describe tool?

    Custom labels set up in the /generate_labels tool will also be utilized by the describe tool, offering a comprehensive labeling experience.

Have More Questions?