<h1 align="center">
<a href="https://prompts.chat">
This project leverages Anthropic's Claude Code product in GitLab CI pipelines, providing access to powerful AI tools in your build pipeline.
Sign in to like and favorite skills
This project leverages Anthropic's Claude Code product in GitLab CI pipelines, providing access to powerful AI tools in your build pipeline.
AI-Powered Code Reviews (
review_merge_request job): Analyzes merge request diffs and posts line-specific feedback as GitLab discussions, covering bugs, security, performance, and code quality. Triggered automatically on MR events or by commenting @claude-code review.
Conversational Code Assistant (
claude_comment_response job): Responds to any @claude-code mention in MR comments with contextual help, code explanations, and targeted suggestions. Can investigate your codebase and provide detailed answers about specific files or functions.
Code Modification on Request: When asked via comments, Claude can read your code, implement requested changes, and push commits directly to your branch with clear attribution and descriptive commit messages.
@claude-code review) to reduce noise and costClone this repository into your GitLab project.
Install dependencies (for local development or debugging):
pip install -r requirements.txt pip install -r requirements-test.txt # For running tests
Set up environment variables in your GitLab project under Settings > CI/CD > Variables:
ANTHROPIC_API_KEY: Your Claude API keyCLAUDE_BOT_USERNAME: The username of your GitLab bot user (e.g., claude-bot)CLAUDE_COMMENTER_TOKEN: Project Access Token for commenting and pushing changesGITLAB_AUTOFIX_TOKEN: Project Access Token for auto-fix pushesEdit
(recommended model: .claude-gitlab.yml
claude-opus-4-20250514):(Optional) Edit
:settings.json
Fine-tune tool permissions and ignore patterns.
python -m orchestrator --review-mode python -m orchestrator --fix-failure python -m orchestrator --comment-mode
The webhook handler includes comprehensive diagnostic tools for easy troubleshooting:
Deploy and diagnose:
cd webhook-handler ./deploy-to-gcp.sh # Deploy to Google Cloud Run ./diagnose_webhook.py # Full health check ./verify_gcp_secrets.sh # Validate secret configuration
Test and debug:
./run_pipeline_trigger.py # Test triggers directly ./test_webhook_locally.py # Test webhook handler locally
See
for complete diagnostic workflow.webhook-handler/CLAUDE.md
.claude-gitlab.yml and settings.json@claude-code to trigger a review or code changeorchestrator/ directory and .gitlab-ci.yml into your own GitLab project.@claude-code to trigger a review or code change.For a minimal working example, follow the checklist above or see the documentation for more details.
@claude-code in a merge request comment.@claude-code is mentioned in an MR comment, Claude can answer questions, review code, or even push code changes in response.@claude-code review on the MR to trigger an on-demand review.@claude-code in any MR comment to ask a question, request a change, or get help.This project is built around a modular orchestrator package and a dedicated webhook handler, enabling robust, maintainable, and extensible AI-powered automation in GitLab CI/CD.
Purpose:
The orchestrator is the core engine that manages all AI-driven automation, including code reviews, auto-fixes, and comment responses.
Key Modules:
main.py / cli.py: Entry points and command-line interface.config_manager.py: Loads and merges configuration from YAML, JSON, and environment variables.gitlab_client.py: Handles all GitLab API interactions (MRs, comments, CI jobs).claude_sdk_client.py: Invokes the Claude Code CLI for all AI operations (not the Python SDK).comment_handler.py: Processes @claude-code mentions and formats context for Claude.git_operations.py: Handles git diffs, commits, and pushes as needed.logger.py, exceptions.py, utils.py: Logging, error handling, and shared utilities.Design Principles:
orchestrator.py script.@claude-code mentions, enabling real-time, comment-driven automation.⚠️ Test-Driven Development (TDD) is MANDATORY
python3 -m pytest (runs in ~0.5 seconds)tests/CLAUDE.md for details)Webhook Issues:
cd webhook-handler ./diagnose_webhook.py # Comprehensive health check ./run_pipeline_trigger.py # Test pipeline triggers directly ./verify_gcp_secrets.sh # Check Google Secret Manager
Common Issues:
./run_pipeline_trigger.py as workaroundSee WEBHOOK_TROUBLESHOOTING.md for detailed solutions.
Project-wide and Workflow Documentation:
See
in the project root for context management, workflow, and best practices.CLAUDE.md
Orchestrator Module Details:
See
for a deep dive into the modular architecture, configuration, and error handling.orchestrator/CLAUDE.md
Test Suite and TDD Practices:
See
for details on test-driven development, test coverage, and testing patterns.tests/CLAUDE.md
Webhook Handler Documentation:
See
for information on the webhook service, deployment, and troubleshooting.webhook-handler/CLAUDE.md
Additional Technical Docs:
Taskmaster Integration:
This project uses Taskmaster AI for task management and planning.