Skip to main content
Claude Code for GitLab CI/CD is currently in beta. Features and functionality may evolve as we refine the experience.This integration is maintained by GitLab. For support, see the following GitLab issue.
This integration is built on top of the Claude Code CLI and Agent SDK, enabling programmatic use of Claude in your CI/CD jobs and custom automation workflows.

Why use Claude Code with GitLab?

  • Instant MR creation: Describe what you need, and Claude proposes a complete MR with changes and explanation
  • Automated implementation: Turn issues into working code with a single command or mention
  • Project-aware: Claude follows your CLAUDE.md guidelines and existing code patterns
  • Simple setup: Add one job to .gitlab-ci.yml and a masked CI/CD variable
  • Enterprise-ready: Choose Claude API, Amazon Bedrock, or Google Cloud’s Agent Platform to meet data residency and procurement needs
  • Secure by default: Runs in your GitLab runners with your branch protection and approvals

How it works

Claude Code uses GitLab CI/CD to run AI tasks in isolated jobs and commit results back via MRs:
  1. Event-driven orchestration: GitLab listens for your chosen triggers (for example, a comment that mentions @claude in an issue, MR, or review thread). The job collects context from the thread and repository, builds prompts from that input, and runs Claude Code.
  2. Provider abstraction: Use the provider that fits your environment:
    • Claude API (SaaS)
    • Amazon Bedrock (IAM-based access, cross-region options)
    • Google Cloud’s Agent Platform (GCP-native, Workload Identity Federation)
  3. Sandboxed execution: Each interaction runs in a container with strict network and filesystem rules. Claude Code enforces workspace-scoped permissions to constrain writes. Every change flows through an MR so reviewers see the diff and approvals still apply.
Pick regional endpoints to reduce latency and meet data-sovereignty requirements while using existing cloud agreements.

What can Claude do?

Claude Code enables powerful CI/CD workflows that transform how you work with code:
  • Create and update MRs from issue descriptions or comments
  • Analyze performance regressions and propose optimizations
  • Implement features directly in a branch, then open an MR
  • Fix bugs and regressions identified by tests or comments
  • Respond to follow-up comments to iterate on requested changes

Setup

Quick setup

The fastest way to get started is to add a minimal job to your .gitlab-ci.yml and set your API key as a masked variable.
  1. Add a masked CI/CD variable
    • Go to SettingsCI/CDVariables
    • Add ANTHROPIC_API_KEY (masked, protected as needed)
  2. Add a Claude job to .gitlab-ci.yml
After adding the job and your ANTHROPIC_API_KEY variable, test by running the job manually from CI/CDPipelines, or trigger it from an MR to let Claude propose updates in a branch and open an MR if needed.
To run on Amazon Bedrock or Google Cloud’s Agent Platform instead of the Claude API, see the Using with Amazon Bedrock and Google Cloud section below for authentication and environment setup.
If you prefer a more controlled setup or need enterprise providers:
  1. Configure provider access:
    • Claude API: Create and store ANTHROPIC_API_KEY as a masked CI/CD variable
    • Amazon Bedrock: Configure GitLabAWS OIDC and create an IAM role for Amazon Bedrock
    • Google Cloud’s Agent Platform: Configure Workload Identity Federation for GitLabGCP
  2. Add project credentials for GitLab API operations:
    • Use CI_JOB_TOKEN by default, or create a Project Access Token with api scope
    • Store as GITLAB_ACCESS_TOKEN (masked) if using a PAT
  3. Add the Claude job to .gitlab-ci.yml: use the Quick setup job for the Claude API, or a provider job from Configuration examples
  4. (Optional) Enable mention-driven triggers:
    • Add a project webhook for “Comments (notes)” to your event listener (if you use one)
    • Have the listener call the pipeline trigger API with variables like AI_FLOW_INPUT and AI_FLOW_CONTEXT when a comment contains @claude

Example use cases

Turn issues into MRs

In an issue comment:
Claude analyzes the issue and codebase, writes changes in a branch, and opens an MR for review.

Get implementation help

In an MR discussion:
Claude proposes changes, adds code with appropriate caching, and updates the MR.

Fix bugs quickly

In an issue or MR comment:
Claude locates the bug, implements a fix, and updates the branch or opens a new MR.

Using with Amazon Bedrock and Google Cloud

For enterprise environments, you can run Claude Code entirely on your cloud infrastructure with the same developer experience.

Prerequisites

Before setting up Claude Code with Amazon Bedrock, you need: