GitLab MR Reviewer
Killian0812
README
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 .envEdit the
.envfile 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_SECRETin your.envfile - 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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor
Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.
Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.