How I made Claude write commits and handle Merge Requests — even on GitLab’s free tier
Automation used to mean “run my tests and deploy my code.”
Now it means “let the AI handle the boring stuff while I focus on the real problems.”
Recently, Anthropic published a guide showing how to connect Claude directly to GitLab CI/CD so it can read, fix, and even commit code automatically.
Here’s the original documentation:
https://docs.claude.com/en/docs/claude-code/gitlab-ci-cd
But there’s one challenge — if you’re using the free version of GitLab, you’ll need to wire things together yourself.
That’s exactly what I did.
The setup that worked for me
To make Claude interact with GitLab, I used two components:
An MCP server – a middleware that allows AI agents to safely talk to external APIs.
For GitLab, there’s a ready-made module:@zereight/mcp-gitlab.A webhook handler – a lightweight FastAPI service that listens for GitLab events (new issues, comments, MRs) and triggers the AI workflow.
I open-sourced my implementation here:
https://github.com/Devs-Infrastructure/gitlab-hooks-api
(Bonus: includes a method to register hooks across every project in a GitLab group.)
What I learned
- On average, each task costs about $1 in Claude API usage — mostly due to code scanning.
- Occasionally, the CI pipeline behaves unpredictably: the agent might forget to commit changes or stop mid-task.
Still, this kind of automation is becoming a core part of modern development.
The agent handles repetitive chores so humans can focus on design, logic, and innovation.
How to improve the setup
Switch to Cursor CLI – it’s not only more stable and better at model selection,
but its basic subscription already includes a generous token allowance and native MCP support,
so you can integrate AI workflows without worrying about API limits.Add loop control – restrict the number of iterations the agent can run to avoid runaway tasks.
Run post-checks after the agent finishes:
bash
npm run lint --fix
npm test
git add . && git commit -m "AI fixes" && git push
Top comments (0)