Inspiration
The motivation behind @hataiit9x/review-code-ai stemmed from the need to automate code reviews in GitLab Merge Requests, ensuring consistent, AI-powered feedback—especially in teams with private GitLab deployments or where OpenAI API access is restricted.
What it does
@hataiit9x/review-code-ai is a compact tool designed to automate code reviews for GitLab Merge Requests. By integrating directly with the GitLab API and leveraging OpenAI or Gemini models, it generates code review comments and appends them to the relevant code blocks within your Merge Requests. The tool is highly configurable, supporting private GitLab instances and custom AI endpoints.
How we built it
The project is implemented as a Node.js CLI utility, installable via NPM. It interacts with GitLab through the official API, fetching diff information and posting comments via merge request endpoints. For AI-powered review, it supports both OpenAI and Gemini models, with flexible proxy, organization, and key management. The utility is also CI/CD-friendly, supporting environment variable configuration for seamless automation.
Challenges we ran into
- Ensuring compatibility with both public and private GitLab deployments
- Handling API rate limits gracefully with retry mechanisms
- Managing multiple OpenAI keys for load balancing and reliability
- Providing a seamless setup for CI/CD pipelines with environment variables
Accomplishments that we're proud of
- Easy configuration for various enterprise setups (custom GitLab API, custom AI endpoints)
- Automatic inline commenting directly on Merge Requests
- Robust rate-limit handling and retry logic
- Flexible model and review mode selection (OpenAI/Gemini)
- Ready-to-use in both CLI and CI/CD workflows
What we learned
- The importance of flexibility in tool configuration to fit diverse infrastructure setups
- Real-world CI/CD integration challenges and how to solve them efficiently
- Best practices for robust API error handling and multi-key management for third-party services
What's next for review-code-ai
- Expand support for additional AI models and providers
- Enhance customization of review feedback and comment formatting
- Improve multi-language code analysis
- Broaden integration options (other SCM platforms, more CI systems)
[Optional: Mermaid Diagram for Architecture]
flowchart TD
A[Developer Pushes Code] --> B[GitLab Merge Request]
B --> C[CI/CD Triggers review-code-ai]
C --> D[Fetch Diff from GitLab API]
D --> E[Send Diff to OpenAI/Gemini API]
E --> F[Receive AI Review Feedback]
F --> G[Post Comments to Merge Request via GitLab API]
Log in or sign up for Devpost to join the conversation.