
GitHub Stats
Stars
0
Forks
1
Release Date
4/10/2025
about 2 months ago
Detailed Description
GitLab MR Reviewer
An AI-powered GitLab Merge Request code reviewer that integrates with Anthropic's Claude models to provide automated code reviews and checklist compliance evaluation.
Features
- Automatically reviews code when a merge request is opened or updated
- Analyzes code for style, quality, security issues, and best practices
- Evaluates MRs against a customized checklist based on team standards
- Provides detailed feedback on each file
- Gives an overall assessment with a final recommendation (APPROVE, APPROVE WITH MINOR CHANGES, REQUEST CHANGES)
- Can be triggered manually or via GitLab webhooks
- Sends notifications to Slack (optional)
Prerequisites
- Node.js (v14 or later)
- npm or yarn
- GitLab account with API access
- Anthropic Claude API key
Installation
-
Clone the repository:
git clone <repository-url> cd gitlab-mr-reviewer
-
Install dependencies:
npm install
-
Copy the example environment file and update it with your configuration:
cp .env.example .env
Edit the
.env
file with your GitLab and Claude credentials.
Configuration
Update the .env
file with the following variables:
# GitLab Configuration
GITLAB_API_URL=https://gitlab.example.com/api/v4
GITLAB_PRIVATE_TOKEN=your_private_token_here
GITLAB_WEBHOOK_SECRET=your_webhook_secret_here
# Anthropic Claude Configuration
CLAUDE_API_KEY=your_claude_api_key_here
CLAUDE_MODEL=claude-3-opus-20240229
# Application Configuration
PORT=3000
NODE_ENV=development
# Logging Configuration
LOG_LEVEL=info
# Slack Notification (optional)
SLACK_WEBHOOK_URL=your_slack_webhook_url_here
MR Checklist
The tool evaluates merge requests against the following checklist:
- Diff description is clear and complete
- Trello card is linked
- Version has been increased in version.json
- Trello card has proper description
- Proto files are updated if needed
- Error handling with try-catch is properly implemented, with Slack notifications where appropriate
- Functions are not over 50 lines (or have explanation if they are)
- Merge request focuses on a single purpose (logic change or refactoring)
- Null checks are implemented where needed (using lodash or other methods)
- Code is concise and not unnecessarily verbose
- Lambda functions are used instead of 1-2 loops where appropriate
- Early returns are used where possible
- Promise.all() is not used (as per team guidelines)
- Localization strings are not mixed with code
These checklist items are customized based on the team's standards and are automatically evaluated for each merge request.
Usage
Starting the Service
npm start
For development with auto-reload:
npm run dev
Setting Up GitLab Webhook
- Go to your GitLab project or group
- Navigate to Settings > Webhooks
- Add a new webhook with the following settings:
- URL:
https://your-server.com/api/gitlab
- Secret Token: The same value as
GITLAB_WEBHOOK_SECRET
in your.env
file - Trigger: Check "Merge request events"
- URL:
- Click "Add webhook"
Manually Triggering a Review
You can manually trigger a review by making a POST request to:
POST /api/review
Content-Type: application/json
{
"projectId": 123,
"mergeRequestIid": 456
}
Code Review Process
When a merge request is created or updated, the service:
- Fetches the merge request details from GitLab
- Gets the list of changed files
- Reviews each file using Claude
- Evaluates the changes against the team's checklist
- Provides an overall assessment of the changes
- Posts comments on the merge request with the review findings and checklist compliance
- Optionally approves the merge request if no issues are found
- Sends a notification to Slack with the review status
Claude Models
This project supports various Claude models:
claude-3-opus-20240229
(default) - Highest performance, most thorough code reviewsclaude-3-sonnet-20240229
- Good balance of performance and speedclaude-3-haiku-20240307
- Fastest, but less comprehensive reviews
You can specify which model to use in the .env
file.
Customizing the Checklist
You can customize the checklist to match your team's standards by editing the MR_CHECKLIST
constant in src/services/claude.service.js
. The checklist evaluation functions can also be customized to better match your specific requirements.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
About the Project
This app has not been claimed by its owner yet.
Claim OwnershipReceive Updates
Security Updates
Get notified about trust rating changes
to receive email notifications.