AI agents
Jobs that run Claude Code or Codex on the prompts a group gives them. codex:review reviews every merge request push and hands its findings to claude:work, claude:review reviews one when you play it, claude:work and codex:work work on a branch when you play them, and claude:work also starts by itself on a new branch, such as one created from an issue. claude:scheduled runs on any schedule. The jobs ship no prompts: a group keeps them as commands in its own agent image, or sets them as text; see Prompts.
Import
pipelines/default.yaml includes the agent jobs, so a project that includes the default pipeline already has them. Each agent's jobs stay off until the project or its group has that agent's credential: the Claude jobs require CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY in their rules, and the Codex jobs CODEX_API_KEY or CODEX_ACCESS_TOKEN and an image in AGENT_CODEX_IMAGE, so without them the jobs don't appear in the pipeline at all. Setting the credential on a group turns that agent on for all of its projects; see Tokens.
Standalone include
A project that doesn't use the default pipeline includes the file itself:
include:
- project: hosstio/gitlab-pipelines
file: pipelines/agents.yamlThis file defines no workflow: block on purpose. Include it alongside another pipeline file that supplies one, because the last included workflow: wins and a file that set its own would override whatever it is combined with. The jobs gate themselves with strict rules instead.
agents stage
All agent jobs run in the agents stage, which helpers/default.yaml puts before extra. The review jobs wait for the earlier stages and run even when they fail, so they see their results. The work and scheduled jobs set needs: [], so they start with the pipeline, and a failed earlier stage never skips a play button. A project that defines its own stages: list has to add agents to it.
Jobs
| Job | When |
|---|---|
claude:work | Branch and merge request pipelines, except on the default branch and on schedules; automatic in the branch pipeline of a branch without changes, such as one created from an issue, manual everywhere else |
codex:work | The same pipelines as claude:work, always manual |
claude:review | Merge request pipelines, manual; automatic after the other stages on every push when AGENT_CLAUDE_REVIEW_AUTOMATIC is "true" |
codex:review | Merge request pipelines, automatic after the other stages on every push; manual when AGENT_CODEX_REVIEW_AUTOMATIC is "false". Plays claude:work when it opens threads; see Handing findings to claude:work |
claude:scheduled | Scheduled pipelines whose schedule sets AGENT_SCHEDULED_PROMPT |
Each job is named <agent>:<task>. Every manual job has allow_failure: true, so an unplayed button never blocks the merge request.
Runtime
The Claude jobs run Claude Code on the image in AGENT_CLAUDE_IMAGE, the agents:claude image by default, which also has glab and Git, and give it a GitLab token. The Codex jobs run the Codex CLI the same way, on the image in AGENT_CODEX_IMAGE, which has no default; see Agent image. Claude reads what it needs itself: the merge request, its linked issue, the discussions, the pipeline's jobs and their logs, and other issues or merge requests that those mention. It writes to GitLab itself too, with glab and git push. The prompts say what to read and what to write.
Before Claude starts, the Claude jobs remove the checked-out repository's .claude/settings.json and .claude/settings.local.json, so a branch can't add a model to the allowed models. The repository's CLAUDE.md, rules, skills, commands and subagents still load; permissions, environment variables and hooks for the agents go in the group's agent image.
The jobs keep the parts that must not depend on the model: when each job runs, the budget and turn caps, the checkout of the branch tip, the git identity, and posting the reports to Slack. Every commit Claude makes is in the name and email of the user that AGENT_CLAUDE_GITLAB_AUTH_TOKEN belongs to, or AGENT_CODEX_GITLAB_AUTH_TOKEN for a Codex job, so with a bot token no agent commit carries a person's name, and a commit-msg hook adds an Assisted-by: Claude Code (<job>) trailer, or Assisted-by: Codex (<job>) for a Codex job. Every comment, reply, issue and merge request description Claude posts ends with a line naming and linking the job, such as "Posted by claude:review", so readers can tell them apart from a person's even when the token is a person's.
Repositories and skills
The review, work and scheduled jobs check out the git repositories in GIT_REPOSITORIES for Claude to read, such as documentation or a specification the work has to agree with, and give it the skills of the repositories in AGENT_SKILLS. The startup scripts of the agents image do this after the job's token check: the checkouts go to /repositories/<group>/<project>, and every directory with a SKILL.md becomes a skill in ~/.claude/skills. They clone as the job's GitLab token, such as AGENT_CLAUDE_GITLAB_AUTH_TOKEN, so that token needs read access to every private repository on the lists. The checkouts are references: they can be open source projects you don't own, and the prompts never change or file anything in them.
Both lists are empty in these templates. A group sets them as CI/CD variables, or in the variables of its own pipelines repository:
glab variable set GIT_REPOSITORIES --group <group> \
--value "https://gitlab.com/<group>/docs.git https://github.com/<owner>/<project>.git"
glab variable set AGENT_SKILLS --group <group> --value "https://github.com/anthropics/skills.git"A group variable overrides any variable a job sets in YAML, so each job reads its own pair, which defaults to the shared lists: AGENT_REVIEW_REPOSITORIES and AGENT_REVIEW_SKILLS, AGENT_WORK_REPOSITORIES and AGENT_WORK_SKILLS, AGENT_SCHEDULED_REPOSITORIES and AGENT_SCHEDULED_SKILLS. To give claude:work more context than the review, set AGENT_WORK_REPOSITORIES on the group to $GIT_REPOSITORIES plus the extra URLs. A schedule's variables override the group's, so a schedule sets AGENT_SCHEDULED_REPOSITORIES for its own run.
Models and effort
Each job sets AGENT_CLAUDE_MODEL and AGENT_CLAUDE_EFFORT for its kind of work:
| Job | Model | Effort | Why |
|---|---|---|---|
claude:review | opus | high | Finding subtle bugs is what a review is for |
claude:work | opus | high | Multi-step coding with tests and git, and conflict resolutions, where merging two changes wrongly still builds |
claude:scheduled | sonnet | high | Long, read-heavy tasks such as updates; a schedule sets AGENT_CLAUDE_MODEL and AGENT_CLAUDE_EFFORT for other work, such as haiku for a status update |
The aliases resolve in the Claude Code CLI, which the agents:claude image pins, so a job keeps its model until the image moves to a newer Claude Code. Override either variable on a job to change it, for example AGENT_CLAUDE_EFFORT: "xhigh" on claude:work for harder issues.
The Claude jobs run only the models in AGENT_CLAUDE_AVAILABLE_MODELS: Opus 5.5, Sonnet 5.5 and Haiku 5.5. A request Claude's safety classifier flags fails the job: Claude Code doesn't re-run it on another model (CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK), such as Opus 4.8, Opus 5 or Sonnet 5, where prompt injections succeed far more often. A job whose AGENT_CLAUDE_MODEL is another model, such as fable, fails until that model is in the list; see Allowed models.
codex:review and codex:work set AGENT_CODEX_EFFORT to high and leave AGENT_CODEX_MODEL empty, so they run the default model of the Codex CLI in the image. Set AGENT_CODEX_MODEL on the group to pin one.
Work jobs
claude:work shows in every branch and merge request pipeline, except on the default branch and on schedules, once a group or project sets AGENT_PROMPT_WORK. codex:work shows in the same pipelines, always as a button, and works the same way with Codex. The job only checks out the branch's latest commit, so it's fine to play it in an older pipeline, and hands Claude that prompt. Its timeout is 60 minutes, which leaves room for a prompt that waits for the pipeline of its own push.
Issue branches
GitLab's Create merge request button on an issue creates a branch named after the issue, such as 7-update-inventree, and a merge request without commits. GitLab gives a merge request without commits no merge request pipeline, so the only pipeline is the branch pipeline it starts when it creates the branch. That branch has no changes against the default branch, so claude:work runs there automatically. A work prompt that reads the issue from the branch name can implement it and push, which starts the merge request pipeline. The branch pipeline still runs the other jobs, on the default branch's code.
codex:work doesn't start by itself here: play it in that branch pipeline to have Codex implement the issue instead.
From the command line, push a new branch that starts with the issue number, and claude:work starts the same way:
git switch --create 42-add-a-status-page origin/main
git push --set-upstream origin 42-add-a-status-page
glab mr create --related-issue 42 --description "Closes #42" --draft --yesPlayed runs
On a branch with changes, the job is a manual play button: play it after a review or a failed job, and the prompt decides what Claude does with the unresolved threads, the failed jobs and a conflict with the target branch. Conflicts usually appear when the target branch moves, which starts no pipeline on the merge request, so play claude:work from the latest pipeline. The job isn't interruptible: its own pushes start new pipelines, and with the project's Auto-cancel redundant pipelines setting on, those would cancel an interruptible job before it finishes.
Rules
The play button shows in every merge request pipeline and on every branch with changes, because GitLab rules cannot see threads or failed jobs. A branch pipeline compares changes with the default branch (rules:changes:compare_to), so claude:work on a branch without changes matches the automatic rule instead. In a merge request pipeline, claude:work is always a button.
Review jobs
codex:review runs in every merge request pipeline once a group or project sets a review prompt, after the other stages and also when they fail, so every push gets a review. claude:review is a manual job in the same pipelines, so a second opinion costs nothing until someone plays it; play it from the MR's latest pipeline once the other stages are done. Each agent has a switch that flips its review between the two: set AGENT_CODEX_REVIEW_AUTOMATIC to "false" to make codex:review a button, or AGENT_CLAUDE_REVIEW_AUTOMATIC to "true" to have Claude review every push, for example in a group without a Codex credential. You can retry either job from its job page. A review job skips the review when the MR has no changes, or when a newer push exists, which its own pipeline reviews.
The review jobs run after the other stages without needs, so GitLab unpacks their artifacts in the checkout, such as test reports or the Helm manifest diff, for the prompt to point the agent at. They check out the merge request's latest commit. claude:review allows read-only git, glab, printenv and the browser commands. Codex has no list of allowed commands, and its sandboxes that keep the checkout read-only also block the network that glab needs, so codex:review runs with AGENT_CODEX_SANDBOX set to danger-full-access: the prompt and the token's rights are what keep it from pushing. AGENT_REVIEW_MARKER is an HTML comment a review prompt can tag its summary note with, so a later review edits that note instead of adding one; codex:review has a marker of its own, so the two agents never edit each other's note. GitLab sends no notification when a note is edited, but each new thread notifies as usual.
Handing findings to claude:work
When Codex opens threads in its run, codex:review plays the claude:work button of its own pipeline, so Claude works through the findings and pushes, and the push's pipeline gets a new review. The job compares the unresolved threads that its GitLab user started on the merge request before and after Codex runs, so a reply to an older thread, a resolved thread or a plain note doesn't count. Without new threads, claude:work stays a button.
The hand-off happens once per merge request. Before it plays the job, codex:review checks the commits since the merge base for an Assisted-by trailer that ends in (claude:work), and when it finds one it only logs that claude:work stays a button. Codex's findings on Claude's push then wait for a person. A claude:work run that only replies on the threads pushes nothing and starts no new pipeline, so it can't start another review either.
The hand-off needs two things:
- A
claude:workjob in the pipeline, so the group or project sets a Claude credential andAGENT_PROMPT_WORK. Without one,codex:reviewlogs that it has nothing to play. - A Codex token with at least the Developer role, and push or merge rights when the branch is protected, because GitLab runs a played job as the user who played it.
That last part also changes who claude:work runs as. The job's GITLAB_USER_NAME and GITLAB_USER_EMAIL are those of the Codex token's user, and so are the rights of the job's CI_JOB_TOKEN. Claude still reads, writes and commits as the user of AGENT_CLAUDE_GITLAB_AUTH_TOKEN, and its commits still get the Assisted-by: Claude Code (claude:work) trailer.
Failures
Reviews are advisory. The job runs with allow_failure: true, like the other merge request jobs, so a failed, over-budget or timed-out review never blocks the merge request. The scheduled jobs are not allowed to fail: nobody watches a nightly run, so a failure turns the pipeline red and GitLab sends its failed-pipeline email. With the project's Auto-cancel redundant pipelines setting on, a newer push cancels a review that is still running for an older one.
Docker
Every agent job extends .docker from the Docker helper, so it runs a docker:dind service and logs in to the project's container registry. The review jobs use it only for the browser. The agent can then run a tool the image lacks in a container, for example docker run --rm -v "$CI_PROJECT_DIR:$CI_PROJECT_DIR" -w "$CI_PROJECT_DIR" alpine/helm lint charts/example, or pull the project's own images. GitLab shares the /builds directory between a job and its services, so the checkout mounts into such a container. Claude can also start the project's docker compose services, such as a database; their published ports are reachable at host docker, not localhost. The service needs a runner that allows privileged containers, as GitLab's hosted runners do. On a runner without privileged mode, turn Docker off for the project in its .gitlab-ci.yml:
claude:work:
services: []
before_script:
- !reference [.claude, before_script]
claude:scheduled:
services: []
before_script:
- !reference [.claude, before_script]
codex:work:
services: []
before_script:
- !reference [.codex, before_script]
claude:review:
services: []
before_script:
- !reference [.claude, before_script]
codex:review:
services: []
before_script:
- !reference [.codex, before_script]Without the service, the jobs have no browser either.
Browser
Every agent job can open, test and screenshot web pages, such as the pages a merge request changes on its preview environment. Before the agent starts, the job writes two commands that run Playwright in AGENT_PLAYWRIGHT_IMAGE through the docker:dind service:
playwrightruns the Playwright CLI, such asplaywright screenshot --viewport-size=1280,800 <url> screenshots/home.png.playwright-pythonruns a Python script from stdin, for a check that clicks, fills in a form or reads text from a page.
A file saved under screenshots/ lands in AGENT_SCREENSHOTS_DIR, a directory in the checkout that git ignores, where the agent reads it. The job fixes the image, the Docker flags and that one mount when it writes the commands, so the agent can't hand a job variable such as a token to the container, and claude:review allows the two commands instead of docker run.
Playwright image
The default image has Chromium; its firefox and webkit tags have the other browsers. A job pulls it with its job token, so a group outside the image project's job token allowlist sets AGENT_PLAYWRIGHT_IMAGE to an image of its own with the playwright command and Python's playwright package.
Network access
The browser opens any URL, so claude:review can reach any host, not only GitLab. A prompt injection in a merge request could make the reviewer put what printenv reads, such as the job's tokens, into a URL. Keep the review token's rights narrow, see Tokens, or take the commands out of the review's allowed tools:
claude:review:
variables:
AGENT_CLAUDE_ALLOWED_TOOLS: "Read,Grep,Glob,Bash(git diff *),Bash(git log *),Bash(git show *),Bash(glab *),Bash(printenv *)"Tokens
Anthropic
Claude authenticates one of two ways:
| Variable | Where it comes from |
|---|---|
CLAUDE_CODE_OAUTH_TOKEN | claude setup-token (subscription auth). Set it as a masked group-level CI/CD variable; these tokens last one year |
ANTHROPIC_API_KEY | An Anthropic API key. Takes precedence when both are set |
OpenAI
Codex authenticates one of two ways too:
| Variable | Where it comes from |
|---|---|
CODEX_API_KEY | An OpenAI API key. Set it as a masked group-level CI/CD variable |
CODEX_ACCESS_TOKEN | An access token of a ChatGPT Business or Enterprise workspace, for runs on the workspace's plan. These tokens expire after the window chosen when creating them |
GitLab
For GitLab, the jobs hand AGENT_GITLAB_AUTH_TOKEN to glab and to git push. Without it they fall back to GITLAB_AUTH_TOKEN, which defaults to CI_JOB_TOKEN; that token cannot read MR discussions, post notes or threads, create issues, or push, so with it the agent jobs fail with an error. Give the agents their own token rather than a personal one: their threads and pushes then show as a bot instead of a colleague, the token carries only the rights the agents need, and revoking it leaves the other jobs alone. Set AGENT_GITLAB_AUTH_TOKEN as a masked, hidden CI/CD variable to one of these:
- A project access token with the Developer role and
apiandwrite_repositoryscope, set on the project. Claude can then read and write in that project only. This is the setup GitLab's own Claude Code integration uses. - A group access token with the same role and scopes, set once on the group. Claude can then also read related projects in the group, such as an issue or merge request in a sibling repository. It can also write to every one of them.
- On GitLab.com's Free plan, where project and group access tokens are not available: a personal access token with the same scopes of a group service account, which the top-level group's Owner creates and which takes no seat, added to the group with the Developer role.
When AGENT_GITLAB_AUTH_TOKEN is unset and GITLAB_AUTH_TOKEN is a person's token, the agents act and commit as that person, with all of their rights.
Each agent can have a GitLab identity of its own: the Claude jobs read and write as AGENT_CLAUDE_GITLAB_AUTH_TOKEN and the Codex jobs as AGENT_CODEX_GITLAB_AUTH_TOKEN, and both default to AGENT_GITLAB_AUTH_TOKEN. Set them on the group to tokens of two separate accounts, such as a service account per agent, so a thread or push shows which agent made it:
glab variable set AGENT_CLAUDE_GITLAB_AUTH_TOKEN --group <group> --masked --hidden --value <claude-token>
glab variable set AGENT_CODEX_GITLAB_AUTH_TOKEN --group <group> --masked --hidden --value <codex-token>The Codex token needs at least the Developer role for codex:review to play claude:work; see Handing findings to claude:work.
With the Developer role, Claude can push to merge request branches and open issues and merge requests, but cannot push to protected branches. It can merge into one only when the branch's Allowed to merge includes Developers, which a merge prompt needs.
Claude reads text that anyone with access to the project can write: issue descriptions, comments, commit messages. Such text can contain instructions, and Claude can follow them with everything its job has: the token's rights on GitLab, and every CI/CD variable of the job; see Secrets.
Slack
SLACK_AUTHENTICATION_TOKEN lets claude:scheduled post its final answer; see the Slack helper.
Secrets
An agent job sees every CI/CD variable of its job, the group's and the project's included, so the command-line tools the agent runs can use the credentials they read from their environment, such as doctl with DIGITALOCEAN_ACCESS_TOKEN. The agent can read every one of them, also when instructions in an issue or a comment ask it to. Unsetting a variable in the job's script doesn't hide it, since GitLab Runner starts the job's container with every variable of the job.
A token that an agent shouldn't use has to stay out of the agent's job through the variable's settings:
- Scope it to the environments of the jobs that use it, such as
preview/*,stagingandproduction. No agent job has an environment, so none of them gets it. On GitLab's Free plan only a project variable has an environment scope; a group variable needs Premium. - Or protect it, when no job on an unprotected branch needs it. Preview deploys and the
helm:<environment>dry runs in merge request pipelines do. A protected variable still reachesclaude:scheduledwhen its schedule runs on a protected branch, such as the default branch.
The model credential and the agent's GitLab token have to be in the agent's job, and so does SLACK_AUTHENTICATION_TOKEN in claude:scheduled, which posts the agent's answer, so they're always within the agent's reach.
Variable names
Every variable these jobs define starts with AGENT_: AGENT_ alone for one that every agent shares, such as AGENT_GITLAB_AUTH_TOKEN, AGENT_PROMPT_ for the prompt of a job, such as AGENT_PROMPT_REVIEW, AGENT_CLAUDE_ for a Claude setting, such as AGENT_CLAUDE_MODEL, and AGENT_CODEX_ for a Codex setting. An OpenCode sibling would use AGENT_OPENCODE_. Variables a CLI reads itself keep the CLI's own names, so CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_API_KEY are the Claude CLI's, and CODEX_API_KEY and CODEX_ACCESS_TOKEN the Codex CLI's, not the pipelines'.
Variables
Claude
| Variable | Default | Description |
|---|---|---|
AGENT_CLAUDE_IMAGE | registry.gitlab.com/hosstio/docker-images/agents/main:claude | The image the agent jobs run; see Agent image |
AGENT_CLAUDE_MODEL | "" | Model to use, as an alias or a full model name; each job sets its own, see Models and effort |
AGENT_CLAUDE_EFFORT | "" | Effort level; each job sets its own |
AGENT_CLAUDE_AVAILABLE_MODELS | claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5 | Comma-separated models Claude may run; see Allowed models |
AGENT_CLAUDE_MAX_BUDGET_USD | 1.00 | Dollar ceiling per invocation |
AGENT_CLAUDE_MAX_TURNS | 30 | Turn ceiling per invocation |
AGENT_CLAUDE_PERMISSION_MODE | dontAsk | Denies anything outside AGENT_CLAUDE_ALLOWED_TOOLS and the read-only set |
AGENT_CLAUDE_ALLOWED_TOOLS | Read,Grep,Glob,Bash(git diff *),Bash(git log *) | Tools the model may use |
AGENT_CLAUDE_OUTPUT_FILE | /tmp/claude-output.json | Where the JSON run output is written |
AGENT_ASSISTED_BY | Claude Code | Tool name in the Assisted-by trailer of agent commits |
AGENT_GITLAB_AUTH_TOKEN | $GITLAB_AUTH_TOKEN | GitLab token the agents read and write with; see Tokens |
AGENT_CLAUDE_GITLAB_AUTH_TOKEN | $AGENT_GITLAB_AUTH_TOKEN | GitLab token of the Claude jobs |
AGENT_CLAUDE_SLACK_USER, AGENT_CLAUDE_SLACK_ICON_URL | "" | Sender name and icon URL of the Claude jobs' Slack posts; see Reports |
Codex
| Variable | Default | Description |
|---|---|---|
AGENT_CODEX_IMAGE | "" | The image the Codex jobs run; they don't appear without one, see Agent image |
AGENT_CODEX_MODEL | "" | Model to use; empty uses the default of the image's Codex CLI |
AGENT_CODEX_EFFORT | high | Reasoning effort; both Codex jobs set high |
AGENT_CODEX_SANDBOX | danger-full-access | Both Codex jobs need the network for glab and git push, which the other sandboxes block |
AGENT_CODEX_PROMPT_REVIEW, AGENT_CODEX_PROMPT_WORK | "" | The Codex prompts; empty uses AGENT_PROMPT_REVIEW and AGENT_PROMPT_WORK, see Prompts |
AGENT_ASSISTED_BY | Codex | Tool name in the Assisted-by trailer of Codex commits |
AGENT_CODEX_GITLAB_AUTH_TOKEN | $AGENT_GITLAB_AUTH_TOKEN | GitLab token of the Codex jobs |
AGENT_CODEX_SLACK_USER, AGENT_CODEX_SLACK_ICON_URL | "" | Sender name and icon URL of a Codex job's Slack posts; see Reports |
See the Codex helper for the rest.
Repositories and skills
| Variable | Default | Description |
|---|---|---|
GIT_REPOSITORIES | "" | Git URLs, separated by spaces, of the repositories the agents read; see Repositories and skills |
AGENT_SKILLS | "" | Git URLs of skill repositories |
GIT_REPOSITORIES_DIR | /repositories | Where the checkouts go |
AGENT_REVIEW_REPOSITORIES, AGENT_WORK_REPOSITORIES, AGENT_SCHEDULED_REPOSITORIES | $GIT_REPOSITORIES | The repositories of one job |
AGENT_REVIEW_SKILLS, AGENT_WORK_SKILLS, AGENT_SCHEDULED_SKILLS | $AGENT_SKILLS | The skill repositories of one job |
Work
| Variable | Default | Description |
|---|---|---|
AGENT_PROMPT_WORK | The prompt; the job runs only when it's set, see Prompts | |
AGENT_CLAUDE_PERMISSION_MODE | acceptEdits | Per-job override so Claude may write files |
AGENT_CLAUDE_ALLOWED_TOOLS | Read,Grep,Glob,Edit,Write,Bash | Per-job override: all Bash commands, for git, glab, docker and quick checks |
AGENT_CLAUDE_MAX_BUDGET_USD | 5.00 | Per-job budget override |
AGENT_CLAUDE_MAX_TURNS | 100 | Per-job turn override |
Review
| Variable | Default | Description |
|---|---|---|
AGENT_PROMPT_REVIEW | The prompt; the job runs only when it's set, see Prompts | |
AGENT_CLAUDE_REVIEW_AUTOMATIC | "false" | "true" has claude:review review every push automatically |
AGENT_CODEX_REVIEW_AUTOMATIC | "true" | "false" makes codex:review a manual job |
AGENT_REVIEW_MARKER | <!-- gitlab-pipelines:review --> | HTML comment a review prompt can tag its summary note with, so a later review edits that note |
AGENT_CLAUDE_ALLOWED_TOOLS | Read,Grep,Glob,Bash(git diff *),Bash(git log *),Bash(git show *),Bash(glab *),Bash(printenv *),Bash(playwright *),Bash(playwright-python *) | Per-job override: read-only git, glab, printenv for the CI variables a prompt names, and the browser commands |
AGENT_CLAUDE_MAX_BUDGET_USD | 2.00 | Per-job budget override |
AGENT_CLAUDE_MAX_TURNS | 60 | Per-job turn override |
Scheduled
| Variable | Default | Description |
|---|---|---|
AGENT_SCHEDULED_PROMPT | The task, set on the schedule as text or a command of the agent image, such as /update; see Prompts | |
AGENT_SCHEDULED_AGENT | The agent that runs the schedule; unset or claude runs claude:scheduled | |
AGENT_CLAUDE_MODEL | sonnet | Per-job override; a schedule sets its own for its run |
AGENT_CLAUDE_EFFORT | high | Per-job override |
AGENT_CLAUDE_PERMISSION_MODE | acceptEdits | Per-job override so Claude may write files |
AGENT_CLAUDE_ALLOWED_TOOLS | Read,Grep,Glob,Edit,Write,Bash,WebFetch | Per-job override: Bash for git, glab, docker and curl, WebFetch for release notes and docs |
AGENT_CLAUDE_MAX_BUDGET_USD | 5.00 | Per-job budget override |
AGENT_CLAUDE_MAX_TURNS | 150 | Per-job turn override |
Browser
| Variable | Default | Description |
|---|---|---|
AGENT_PLAYWRIGHT_IMAGE | registry.gitlab.com/hosstio/docker-images/playwright/main:latest | The image the playwright and playwright-python commands run; see Browser |
AGENT_SCREENSHOTS_DIR | $CI_PROJECT_DIR/.agent-screenshots | Where those commands save the files they write under screenshots/ |
Prompts
The jobs bring no prompt of their own. claude:review runs AGENT_PROMPT_REVIEW, claude:work runs AGENT_PROMPT_WORK, and claude:scheduled runs the schedule's AGENT_SCHEDULED_PROMPT; a job without its prompt doesn't appear in the pipeline. A prompt is text, or a Claude Code command that the image carries, such as /review.
Codex doesn't run Claude Code commands, so codex:review and codex:work run AGENT_CODEX_PROMPT_REVIEW and AGENT_CODEX_PROMPT_WORK when a group sets them, and the shared prompt otherwise. A group whose shared prompts are commands sets the Codex prompts as text. Text after a command's name narrows one run, such as /audit Only check the docs/ directory., and Claude Code appends it to the command.
Agent image
A group keeps its prompts as Claude Code commands in an image of its own, built on the agents image, with one Markdown file per prompt in /root/.claude/commands/:
FROM registry.gitlab.com/hosstio/docker-images/agents/main:claude
COPY prompts/ /root/.claude/commands/Then the group points the jobs at the image and its commands:
glab variable set AGENT_CLAUDE_IMAGE --group <group> --value registry.gitlab.com/<group>/agents/main:latest
glab variable set AGENT_PROMPT_REVIEW --group <group> --value /review
glab variable set AGENT_PROMPT_WORK --group <group> --value /workThe Codex jobs have no default image, because the agents image has no Codex CLI yet. A group builds one with the Codex CLI, glab, Git and jq, and a docker-entrypoint.sh command, which the jobs run once they have the token, such as the agents image's startup scripts that clone GIT_REPOSITORIES and AGENT_SKILLS. Then it sets AGENT_CODEX_IMAGE; until then the Codex jobs don't appear.
A job pulls an image from another project's registry with its job token, so that project lists the group in its job token allowlist (Settings > CI/CD > Job token permissions).
Give each command disable-model-invocation: true in its frontmatter, so Claude never starts one by itself, such as a merge command during a review. Claude Code doesn't expand a variable such as $CI_PROJECT_PATH in a command's file, so the image's agent instructions, such as ~/AGENTS.md, tell Claude to read such names with printenv, which every agent job allows.
Reports
claude:scheduled posts Claude's final answer to Slack. When the answer is only NO_REPORT, it posts nothing, so a prompt that ends with "When you changed nothing, reply with only NO_REPORT." keeps the runs that changed nothing out of the channel.
The post shows the Slack app's name and icon, unless the group gives each agent a sender of its own. That needs the chat:write.customize scope on SLACK_AUTHENTICATION_TOKEN, and an icon URL that Slack can fetch without signing in, such as the GitLab avatar of the agent's service account:
glab variable set AGENT_CLAUDE_SLACK_USER --group <group> --value "Claude"
glab variable set AGENT_CLAUDE_SLACK_ICON_URL --group <group> \
--value "https://gitlab.com/uploads/-/system/user/avatar/<user id>/<file>"AGENT_CODEX_SLACK_USER and AGENT_CODEX_SLACK_ICON_URL do the same for a Codex job. When an agent's variable is empty, its post keeps SLACK_MESSAGE_USER or SLACK_MESSAGE_USER_ICON_URL, so a group that sets those for all its posts still gets them on the agent posts.
Schedules
claude:scheduled runs on every pipeline schedule that sets AGENT_SCHEDULED_PROMPT. The variable is the task: a command of the agent image, such as /update, or the prompt itself. A project can have several schedules with different prompts and cadences, and each schedule can set other variables of the job for its run, such as AGENT_CLAUDE_MODEL. A schedule runs on one branch, so develop and main can have schedules and prompts of their own; an update schedule on develop opens its merge requests against develop. A schedule without AGENT_SCHEDULED_PROMPT runs the pipeline without an agent. The job posts Claude's final answer to Slack (SLACK_MESSAGE_CHANNEL, the project name by default) unless the answer is only NO_REPORT (see Reports); a schedule that shouldn't post at all sets SLACK_AUTHENTICATION_TOKEN to an empty value.
Example schedules
With commands for these tasks in the agent image, a project's schedules can look like this:
| Schedule | AGENT_SCHEDULED_PROMPT | Cadence | Set alongside |
|---|---|---|---|
| Update | /update | Weekly or nightly | |
| Audit | /audit | Weekly | AGENT_CLAUDE_MODEL=opus for a deeper read, AGENT_SCHEDULED_REPOSITORIES for the related repositories |
| Backlog | /backlog | Daily | |
| Merge | /merge | Daily | AGENT_CLAUDE_MODEL=opus, AGENT_CLAUDE_EFFORT=xhigh |
| Status | /status | Weekly | AGENT_CLAUDE_MODEL=haiku, AGENT_CLAUDE_EFFORT=medium |
A merge prompt deploys in most projects, since merging deploys, under the name of the user behind AGENT_GITLAB_AUTH_TOKEN, so run it after the update and audit runs.
Other jobs
A scheduled pipeline runs the project's other jobs too, all of them except the deploys: linting, tests and image builds run next to the agent job. For an image project, that makes the nightly update also a nightly rebuild with fresh base packages.
Cost controls
Every Claude invocation is capped three ways: a dollar budget (AGENT_CLAUDE_MAX_BUDGET_USD), a turn limit (AGENT_CLAUDE_MAX_TURNS), and a job timeout (15 minutes for review, 60 minutes for work, 2 hours for scheduled runs). The Codex CLI has no budget or turn cap, so only the job timeout bounds a Codex run. codex:review runs Codex once per push, and claude:review runs Claude once per play; either runs once per push when it's automatic. claude:work and codex:work run their agent once per play, and claude:work also once per new branch without changes and at most once per merge request when codex:review plays it. Claude fetches its own context with glab, so a run spends a few turns on reading before it starts on the task. Each job attaches a Claude report with the model, effort, turns, duration, cost and tokens of every run, which merge requests link as "Claude report"; see the Claude helper. The Codex jobs attach a "Codex report" with tokens instead of cost, since the Codex CLI reports no cost; see the Codex helper.