Effortless PR Handling: CodiumAI's PR-Agent for Developers
Tags: opensource, github, development, ai
Published: 2023-12-17 20:26:32

Developers rely on pull requests (PRs) for vital contributions to projects through code review and integration. However, the PR review process can be time-consuming, often stalling overall development.

Today, the solution lies in AI-powered tools like PR-Agent by CodiumAI, revolutionizing PR reviews and enhancements.

## What is Codium AI?
[CodiumAI](https://github.com/Codium-ai), an open-source provider, offers AI-driven products that simplify developers' lives and boost productivity.

## What is PR-Agent?
CodiumAI's [PR-Agent](https://github.com/Codium-ai/pr-agent), a free open-source tool, streamlines pull request reviews efficiently.

It offers a suite of PR functionalities across various git platforms and supports multiple models (GPT-4, GPT -3.5, Anthropic, Cohere, Llama2). Explore detailed usage in this [article](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md).

## Installation of PR-Agent
To integrate PR-Agent into GitHub, install CodiumAI PR-Agent.
![Pr-Agent marketplace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lj6ud1h2hql1vnm1p9b6.png)

Since it's free, you won't have to add any banking details or be charged a single penny.
![PR-Agent billing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agph7smg9xh37gntlp4p.png)

Once PR-Agent is added to Github, it is easy to give access and apply PR-Agent to all repositories or a single repository. Profile Icon -> Settings -> Integrations -> Applications -> CodiumAI PR-Agent
![github codium-ai access](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxocyz6oxxo94ikujjgl.png)

## Types of Command:
PR-Agent automatically analyzes the pull request and can provide several types of commands:

* [Generate Custom Labels (/generate_labels)](#/generate_labels): Automatically suggests custom labels based on the PR code changes.
* [Auto Description (/describe)](#/describe): Automatically generating PR description - title, type, summary, code walkthrough, and labels.
* [Auto Review (/review)](#/review): Adjustable feedback about the PR main theme, type, relevant tests, security issues, score, and various suggestions for the PR content.
* [PR Reflection (/reflect_and_review)](#/reflect_and_review): Poses question based on the code changes analysis.
* [Question Answering (/ask ...)](#/ask): Provide free-text questions about the PR.
* [Code Suggestions (/improve)](#/improve): Provide code improvment suggestions anout the PR.
* [Update Changelog (/update_changelog)](#/update_changelog): Maitain the CHANGELOG.md file with the PR changes.

Explore these commands using [this PR](https://github.com/mritunjaysri28/CodeScrapper/pull/1/).

### Generate Custom Labels (/generate_labels)<a name="/generate_labels"></a> 
PR-Agent scans the code base, suggesting labels based on PR code changes. Enable custom labels by creating .pr_agent.toml in the repository. It also be used by `/describe` and `/review` commands. By default custom labels feature is false in PR-Agent to enable and config custom labels have to create `.pr_agent.toml` in the repository

* Enable the custom labels add `enable_custom_labels` it will turn off the default label and use custom labels
* Add custom label add `custom_labels."Label name`

```
[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"
```
![PR-Agent custom labels /generate_labels](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utw73o0ut0f36sgkqalj.png)


### Auto Description (/describe)<a name="/describe"></a>
Auto Description tool automatically generates PR descriptions - title, type, summary, walkthrough, and labels based on PR code changes.

* PR-Agent will update the title by analyzing the commit message and code 

![PR-Agent description update PR summary](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c77s87jwy02dugrg0dy8.png)

* PR-Agent will scan the code changes and add a description.

![PR-Agent will add a detailed description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozn69nc39esto2gglt2i.png)

### Auto Review (/review)<a name="/review"></a>
Auto Review tool provides comprehensive feedback on PR analysis, including the main theme, relevant tests, and security concerns.

* The review tool will provide a detailed PR Analysis with details like (PR summary, Type Of PR, Relevant test added, code effort, and security concerns...)
* The review tool will also provide suggestions on how PR is structured and a few points need to be verified for a reviewer 

![Auto Review (PR Analysis and PR Feedback)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u4moat3pe6bexk6mlstc.png)

### PR Reflection (/reflect_and_review)<a name="/reflect_and_review"></a>
PR-Agent asks basic questions via /reflect_and_review and analyzes author-provided answers, enhancing reviewers' and the author can answer these questions using the command `/answer`. Once an answer is provided by the author PR-Agent will analyze the answer and add the attribute *Insights from user's answer* in PR-Analysis, it's one of the features that help the reviewer to get more insight into PR.

![PR-Agent ask question using /reflect_and_review](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qf5i2v66xywtnr76jqtd.png)

![PR-Agent answer using /answer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ima7yd683sfvmusoobq1.png)

![PR-Agent insight from user answer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dg93hmtgsiie25moyr8j.png)

### Question Answering (/ask "...")<a name="/ask"></a>
The tool answers reviewers' questions based on PR code changes.

![PR-Agent /ask](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcca6s3attst2u9xwzvo.png)

![PR-Agent /ask](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h90sm3jxmx9eqbdfs588.png)

### Code Suggestions (/improve)<a name="/improve"></a>
PR-Agent gives us a handle `/improve` to find possible bugs/errors. It will generate and suggest the improved code for the PR code.

![PR-Agent /improve](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4l8yp5n70h8x6kcpcil.png)

PR-Agent will also provide the different committable suggestions that will be combined into a single compact comment `/improve --pr_code_suggestions.summarize=true`

![PR-Agent /improve](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ps71ixau1x5b9bjajrf.png)

### Update Changelog (/update_changelog)<a name="/update_changelog"></a>
Update Changelog will help to maintain the CHANGELOG.md that keeps track of all the changes that were made in a specific version. 

![PR-Agent /update_changelog](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2qn5fqyb35qorhyiygy.png)

## Conclusion
PR-Agent emerges as a game-changer in the development landscape. This open-source, free tool not only streamlines PR reviews but also redefines efficiency, minimizing manual efforts while maximizing precision.

By leveraging CodiumAI's PR-Agent, developers dive into processes, accelerating productivity and ensuring code quality. Its seamless integration across various git platforms and versatile command options mark a significant leap towards efficient PR handling.

Explore more about [Codium AI PR-Agent](https://github.com/Codium-ai/pr-agent)  and unlock a new era of hassle-free PR management.