Learn about integrating Claude Code into your development workflow with GitLab CI/CD
CLAUDE.md
guidelines and existing code patterns.gitlab-ci.yml
and a masked CI/CD variable@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.
.gitlab-ci.yml
and set your API key as a masked variable.
ANTHROPIC_API_KEY
(masked, protected as needed).gitlab-ci.yml
ANTHROPIC_API_KEY
variable, test by running the job manually from CI/CD → Pipelines, or trigger it from an MR to let Claude propose updates in a branch and open an MR if needed.
ANTHROPIC_API_KEY
as a masked CI/CD variableCI_JOB_TOKEN
by default, or create a Project Access Token with api
scopeGITLAB_ACCESS_TOKEN
(masked) if using a PAT.gitlab-ci.yml
(see examples below)
AI_FLOW_INPUT
and AI_FLOW_CONTEXT
when a comment contains @claude
AWS_ROLE_TO_ASSUME
(role ARN)AWS_REGION
(Bedrock region)AWS_ROLE_TO_ASSUME
AWS_REGION
AWS_ROLE_TO_ASSUME
: ARN of the IAM role for Bedrock accessAWS_REGION
: Bedrock region (for example, us-west-2
)us.anthropic.claude-3-7-sonnet-20250219-v1:0
). Pass the desired model via your job configuration or prompt if your workflow supports it.GCP_WORKLOAD_IDENTITY_PROVIDER
: Full provider resource nameGCP_SERVICE_ACCOUNT
: Service account emailCLOUD_ML_REGION
: Vertex region (for example, us-east5
)CLAUDE.md
file at the repository root to define coding standards, review criteria, and project-specific rules. Claude reads this file during runs and follows your conventions when proposing changes.
ANTHROPIC_API_KEY
as a masked variable (and protect it if needed)CLAUDE.md
focused and concise@claude
commands to reduce unnecessary turnsmax_turns
and job timeout valuesANTHROPIC_API_KEY
or cloud provider settings) are present and unmasked@claude
(not /claude
) and that your mention trigger is configuredCI_JOB_TOKEN
has sufficient permissions for the project, or use a Project Access Token with api
scopemcp__gitlab
tool is enabled in --allowedTools
AI_FLOW_*
variablesANTHROPIC_API_KEY
is valid and unexpiredprompt
/ prompt_file
: Provide instructions inline (-p
) or via a filemax_turns
: Limit the number of back-and-forth iterationstimeout_minutes
: Limit total execution timeANTHROPIC_API_KEY
: Required for the Claude API (not used for Bedrock/Vertex)AWS_REGION
, project/region vars for Vertex@anthropic-ai/claude-code
. Run claude --help
in your job to see supported options.prompt
/prompt_file
in the job. Use different prompts for different jobs (for example, review, implement, refactor).