Inspiration
Code reviews are essential, but they often slow down development. In many teams, even small changes can sit unreviewed for hours or days. I wanted to explore whether AI could act as a first-pass reviewer — something that gives immediate feedback and reduces the initial review burden.
The goal wasn’t to replace human reviewers, but to add a lightweight layer of automation that improves developer productivity.
What it does
This project is an AI-powered pull request reviewer for GitLab.
Whenever a merge request is created or updated:
- A GitLab CI pipeline is triggered automatically
- The pipeline runs a Python script that fetches the code changes
- The changes are sent to Gemini AI for analysis
- The AI generates structured feedback (issues, improvements, and risk level)
- The feedback is posted directly on the merge request as a comment
Additionally, the system can apply labels (like high risk) based on the AI’s assessment.
How we built it
The solution is built using:
- GitLab CI/CD for automation
- Python for scripting
- GitLab REST APIs to fetch merge request data and post comments
- Gemini API for AI-based code analysis
The core logic lives in a single script (review.py) that:
- Reads merge request details from environment variables
- Fetches the diff using GitLab APIs
- Sends a structured prompt to Gemini
- Parses the response
- Posts the result back to the merge request
The pipeline is defined in .gitlab-ci.yml and is triggered on merge request events.
Challenges we ran into
API limitations and model compatibility
Initially tried OpenAI but ran into quota issues. Switching to Gemini required figuring out the correct model names and endpoints.Managing input size for AI
Full diffs can be large, so we had to limit the number of files and truncate diffs to stay within token limits.Ensuring structured AI output
Getting consistent and usable responses required refining the prompt multiple times.
Accomplishments that we're proud of
- Built a working end-to-end AI reviewer integrated directly into GitLab
- Automated the full flow from merge request → analysis → feedback → action
- Added risk-based labeling to make the system actionable, not just informative
- Kept the implementation simple while still demonstrating real value
What we learned
- CI/CD pipelines can be used for much more than builds and deployments
- AI is easy to integrate, but making it reliable and structured takes effort
- Small design decisions (like prompt format and filtering) significantly impact output quality
- Understanding how tools like GitLab actually execute pipelines is critical for debugging
What's next for AI Powered Merge Request Review with Gemini AI
- Add inline comments on specific lines of code instead of a single summary
- Improve diff handling to include more context intelligently
- Add security and best-practice checks
- Make model selection configurable via environment variables
- Explore multi-agent workflows for deeper analysis
Built With
- ci/cd
- devops
- gitlab-api
- gitlab-ci/cd
- google-gemini-api
- pipelines
- python
- requests-library
- rest-apis
Log in or sign up for Devpost to join the conversation.