Skip to Content
caffeine docs

Pipelines

Steps, conditions, flow control, verify, review and fix, skills, memory, caches, sandboxes, network, pull requests.

A pipeline is a YAML file in ~/.caffeine/pipelines/. Its file name, without .yaml, is its name. Unknown keys are refused, and caffeine doctor loads every pipeline and reports errors.

description: "Weekly news watch, then update the site content"
rules: prompts/rules.md          # appended to every agent's system prompt
branch_prefix: bot/news-watch     # branch for git targets: <prefix>/<date>
max_budget_usd: 5                # per agent step (claude runner)
mcp: [docs]                      # MCP servers from config.yaml
allowed_tools: [Read, Grep]      # default for steps that do not set their own
skills: [house-style]            # default skills of agent steps, see "Skills"
guard_allow: [".github/workflows/main.yml"]

steps:
  - name: 01-inventory
    run: python3 {{pack}}/checks/inventory.py

  - name: 02-scan
    prompt: prompts/news-watch/02-scan.md
    model: smart
    max_turns: 60
    allowed_tools: [Read, Write, WebSearch, WebFetch, "mcp__docs__*"]
    verify: python3 {{pack}}/checks/has_sources.py .agent/DELTA.md

  - name: 03-apply
    prompt: prompts/news-watch/03-apply.md
    model: cheap
    fallback: smart
    allowed_tools: [Read, Edit, Write, Grep, Glob]
    verify: caffeine scope 'templates/**' 'docs/**'

  - name: 99-pr
    run: caffeine pr

Pipeline keys

KeyDefaultMeaning
descriptionShown by caffeine list and at the start of a run.
rulesprompts/rules.md if it existsFile (relative to the home) appended to the system prompt of every agent step.
branch_prefixcaffeine/<pipeline>Branch created in git clones: <prefix>/<YYYY-MM-DD>.
max_budget_usdnoneSpending cap per agent step, for the claude runner. max_budget_usd_per_step is accepted too.
mcp[]Names of MCP servers from config.yaml.
allowed_tools[]Default tool allowlist for steps that do not set allowed_tools.
skillsnoneDefault skills of agent and review steps that do not set skills. See Skills.
guard_allow[]Globs of protected paths this pipeline may change on purpose. See Safety.
claude_connectorsfalseAlso load your claude.ai connectors (Gmail, Notion…) in claude steps. Only tools listed in allowed_tools can be called. See Inbox.
actionsnoneallowed kinds and max count for .agent/ACTIONS.json, checked by caffeine check actions. See Inbox.
apply[]Steps run by caffeine approve, with the approved actions. See Inbox.
memoryfalseKeep .agent/memory/ from one successful run to the next, per target. See Memory.
cache[]Build caches kept between runs (a Rust target/, downloaded registries…). See Caches.
sandboxsandbox_default, else noneWhere the steps run: a name from sandboxes: in config.yaml, or none for the host. See Sandboxes.
networktarget's network_default, else fullWhat the steps may reach: none, a list of host list names, or full. See Network.
stepsrequiredAt least one step.

Step keys

A step is a script (run:), an agent (prompt:) or a review (review:), one of the three.

KeyApplies toDefaultMeaning
nameallrequiredUnique in the pipeline. Also the log file name.
ifallRun the step only when this condition is true. See Conditional steps.
runscriptShell command (sh -c) run in the workspace.
promptagentPrompt file, relative to the home.
reviewreviewA cold review of the run so far: a file with what to check, or true. See Review steps.
fixreviewAn agent fixes the blocking issues, then the review runs again. See Fixing what the review found.
modelagentdefaultModel role from config.yaml (or .caffeine.conf), or a ladder [cheap, mid, smart]: one role per attempt. See Attempts.
fallbackagentRole added at the end of the ladder: one more attempt when verify fails.
attemptsagentladder lengthAttempts until verify passes. Past the ladder, the last role tries again.
max_turnsagent30Turn limit for the claude runner.
allowed_toolsagentpipeline'sTools the agent may use. See Runners.
skillsagent, reviewpipeline'sSkills loaded into the agent; replaces the pipeline's list (skills: [] loads none). See Skills.
verifyallShell command run after the step. A non-zero exit fails the step.
inputsagent (llm)[]Files added to the prompt for the llm runner.
outputagent (llm)required for llmFile the llm runner writes its answer to.
retriesagent, review2Retries after a transient failure: network, rate limit, overloaded API. See Runners.
continue_on_errorallfalseA failure of this step does not stop the pipeline.
alwaysallfalseRun even after an earlier step failed (cleanup, notification). if: failed for failure-only steps.
foreachallRun the step once per item: a list, files("glob"), or vars.X / context.X / env.X split on commas and new lines. {{item}}, {{item_index}}.
foreach_maxall50More items than this fails the step.
envall{}Extra environment variables, with {{variables}}.
cwdallworkspaceFolder inside the workspace the step runs in (and its verify).
sandboxallpipeline'sWhere the step and its verify run. none keeps one step on the host. See Sandboxes.
networkallpipeline'sWhat the step and its verify may reach. See Network.
usesallStart from a step template. See Step templates.
timeoutall3600Seconds. The step (script, agent of any runner, llm request) and its verify are killed past it, with everything they started.

How a run goes

  1. Workspace. A git target is cloned on a new branch. A dir target or the current folder is used in place. Otherwise a scratch folder is created. An empty .agent/ folder is created in it.
  2. Steps, in order. For each step:
    • a script runs, or the agent runs with its role's runner;
    • verify:, if set, runs next;
    • for an agent step whose verify failed and that has attempts left, the next role of its ladder tries again. Its prompt is the original prompt plus the last 60 lines of the check output. Then verify runs again;
    • the guard checks every file changed since the start of the run (see Safety);
    • what the step wrote in .agent/vars becomes vars.KEY for the next steps. A failed step stops the pipeline: later steps do not run, except always: true ones. continue_on_error: true lets a step fail without stopping it. loop: and parallel: blocks group steps (see Flow control).
  3. End. .agent/ is copied into the run's log folder, the diff is saved (changes.diff, git workspaces only), and the workspace is cleaned: a clone or scratch folder is deleted, and in a dir target only .agent/ is removed.

Conditional steps: if:

One pipeline can serve targets that differ by a step or two, instead of copies that drift apart:

steps:
  - name: 03-bump
    if: target != "nines" && kind == "git"
    run: python3 {{pack}}/checks/bump_patch.py

  - name: 04-smoke
    if: context.smoke_routes || exists("Dockerfile")
    run: caffeine check smoke --start "cargo run -q --release" --url http://127.0.0.1:8080 {{smoke_routes}}

  - name: 99-pr
    if: repo =~ "github.com/me/*"
    run: caffeine pr --auto-merge

A step whose condition is false is skipped: it does not run, nor its verify:, the terminal shows why, and summary.json marks it "skipped": true. The condition is evaluated when the step would start, so exists() sees what earlier steps wrote.

NameValue
target, pipelinenames
repothe target's git repo, normalized: github.com/owner/name (same as folder matching, whatever the URL spelling). For a folder, its origin. Empty otherwise
kindgit, dir or scratch
dry_runtrue or false
today, weekday2026-11-29, mon … sun
context.KEYa key of the target's context (or the project's .caffeine.conf), empty when unset
env.NAMEan environment variable, empty when unset
vars.KEYwhat an earlier step wrote in .agent/vars, empty when unset
steps.NAME.ok, .skipped, .failed, .exit, .costan earlier step's result (false / empty when it did not run)
failedtrue once a step failed (for always: steps)
item, item_indexthe current foreach item, and its number from 1
OperatorMeaning
==, !=equal, different
=~, !~matches, does not match a glob: * (also across /), ?
in ["a", "b"]one of
<, <=, >, >=as numbers when both sides are numbers (context.max_cases > 5), as text otherwise (ISO dates compare right)
&&, ||, !, ( )and, or, not, grouping (&& before ||)
exists("path")the file or folder exists in the workspace

A value alone is true unless it is empty, false or 0: if: dry_run, if: context.smoke_routes. Strings go in double quotes, bare words are names.

Conditions are checked when the pipeline loads: a syntax error or an unknown name (targt, or notes without quotes) fails caffeine doctor and the run before anything starts. Nothing goes through a shell. In YAML, quote a condition that starts with ", ! or (: if: '!dry_run'.

Flow control

Variables between steps: .agent/vars

A step writes key=value lines in .agent/vars; later steps read them as vars.KEY in if: and {{vars.KEY}} in prompts, run, verify and env. A key written again keeps the last value.

  - name: 01-count
    run: echo "todo=$(grep -c TODO src/*.rs)" >> .agent/vars
  - name: 02-fix
    if: vars.todo > 0 && steps.01-count.ok
    prompt: prompts/fix-todos.md          # "there are {{vars.todo}} TODOs"

Failures: continue_on_error, always

  - name: lint
    run: cargo clippy -q
    continue_on_error: true               # reported, not fatal
  - name: build
    run: cargo build
  - name: notify
    always: true                          # runs whatever happened
    if: failed                            # ... but only when something failed
    run: curl -d "{{target}} failed" https://ntfy.sh/my-topic

The run still fails when a step failed, and summary.json names the first one in failed_step. A step that failed with continue_on_error is marked "continued": true.

Attempts and model ladders

  - name: fix
    prompt: prompts/fix.md
    model: [cheap, mid, smart]            # one role per attempt
    verify: cargo test -q

The first attempt uses cheap; when verify fails, mid tries again with the check's output, then smart. attempts: 3 with a single role gives that role three tries. An agent that fails by itself (not its check) is not retried this way: retries: covers transient errors. summary.json records attempts, and in fallback the role of the last attempt.

Loops: loop:

  - loop:
      name: refine
      max: 3                              # 1 to 100 passes
      until: exists(".agent/DONE") || vars.score >= 8
      steps:
        - name: draft
          prompt: prompts/draft.md
        - name: score
          run: python3 {{pack}}/checks/score.py   # writes score=… in .agent/vars

The block's steps run in order, then until is checked: true stops the loop. Without until, it runs max times. Reaching max is not a failure. A failed step stops the loop and the pipeline as usual. Passes after the first are logged as draft.2, draft.3.

Parallel steps: parallel:

  - parallel:                             # or { name: checks, steps: [...] }
      - name: scan-news
        prompt: prompts/news.md
      - name: scan-blogs
        prompt: prompts/blogs.md

At least two steps, each a plain step (no foreach, loop or parallel inside). They start together, the block waits for all of them, then their .agent/vars, the guard and the results are taken in order. Give them separate output files: they share the workspace.

One step per item: foreach

  - name: translate
    foreach: context.langs                # "fr, de, es" in the target's context
    prompt: prompts/translate.md          # "translate README.md into {{item}}"
  - name: lint-page
    foreach: files("content/**/*.md")
    if: item !~ "*/drafts/*"
    run: npx markdownlint "{{item}}"

Each item runs as its own step, logged as translate.1, translate.2… An empty list skips the step. More than foreach_max items (50) fails it, so a wrong glob cannot start a thousand agents.

Step templates: uses

A step you repeat goes in steps/<name>.yaml, in your home or a pack:

# ~/.caffeine/steps/pr.yaml
name: 99-pr
run: caffeine pr
verify: caffeine scope 'src/**' Cargo.toml Cargo.lock
steps:
  - uses: pr                              # your home first, then the packs
  - uses: tools/notify                    # a template from the pack `tools`
    name: 98-notify                       # any key here replaces the template's

{{pack}} and prompt: paths in a template point to the template's own folder. A template cannot use another one.

Per-step env and cwd

  - name: api-tests
    cwd: crates/api                       # inside the workspace, no `..`
    env: { RUST_LOG: debug, TARGET_NAME: "{{target}}" }
    run: cargo test -q

Steps talk through .agent/

Steps share nothing in memory. A step writes files in .agent/, and the next steps read them. Keep each step's job small and its output explicit, for example .agent/CANDIDATES.md, then .agent/SELECTED.md, then .agent/REPORT.md.

.agent/ is never committed: it is excluded in git clones and ignored by the guard. .agent/REPORT.md is the pull request body used by caffeine pr.

Variables

{{name}} is replaced in prompts, run, verify and the cmd runner's command. An unknown {{name}} is left as is, so code blocks with braces and templates such as Jinja or Tera survive.

VariableValue
{{target}}Target name (the folder name for the current folder). {{repo}} is the same.
{{pipeline}}Pipeline name.
{{today}}Run date, YYYY-MM-DD. One date for the whole run, even past midnight.
{{last_run}}Date of the last successful run of this pipeline on this target, or today - since_days.
{{home}}The caffeine home.
{{pack}}The folder the pipeline comes from: your home, or its pack. Use {{pack}}/checks/... for the pipeline's own scripts.
{{key}}Any key of the target's context or the project's .caffeine.conf.
{{prompt_file}}cmd runner only: path of the rendered prompt.
{{cache.NAME}}The run's copy of the dir: cache NAME. See Caches.
{{skill.NAME}}The folder of a skill the step loads (/ in a plugin skill's name becomes .), e.g. verify: python3 {{skill.team-techdoc}}/scripts/techdoc.py check docs/techdoc. Only in that step.

Scripts and checks also get environment variables: see Command reference.

Gates: exit 78 means "nothing to do"

A run: step that exits with 78 stops the pipeline as a success, marked as skipped. Put cheap deterministic checks first, so agents only run when there is work:

  - name: 01-gate
    run: |
      latest=$(curl -s https://api.github.com/repos/org/project/releases/latest | jq -r .tag_name)
      grep -q "$latest" VERSION && { echo "already on $latest"; exit 78; } || echo "new release $latest"

The last line of the output is shown in the terminal and the receipt. A skipped run moves {{last_run}} like any successful run.

Ready-made gates exist for the common cases: caffeine gate changed, gate release, gate cargo, gate npm. See Automation.

Built-in checks for verify:

CheckFails when
caffeine scope <globs>The run changed a file outside the globs.
caffeine check unchanged <globs>The run changed a file under the globs.
caffeine check urls <files>A URL in the files is broken (404, 410, 5xx, DNS…). 401, 403 and 429 only warn, since many sites refuse robots; --strict fails on them too.
caffeine check json <files>A file is not valid JSON.
caffeine check actions [file].agent/ACTIONS.json breaks the shape or the pipeline's actions rules.
caffeine check smoke …The app's routes no longer answer as before.

Smoke tests: the app still works

Record the routes before the change, compare after:

steps:
  - name: 00-smoke-before
    run: caffeine check smoke --save --start "cargo run -q --release" --url http://127.0.0.1:8080 / /blog /about
  - name: 01-update
    prompt: prompts/update.md
    verify: caffeine check smoke --start "cargo run -q --release" --url http://127.0.0.1:8080 / /blog /about

--start runs in the workspace. caffeine waits for --url to answer (--wait, 120 s by default), requests each route, and stops the app with everything it started. With --save, the status and a hash of each route's body are recorded in the run's log folder; without it, they are compared with that recording, and a different status or body fails the check. Use --status-only for pages with dates, tokens or anything that changes on every request.

Put the routes in the target's context (smoke_routes: "/ /blog /about") and write {{smoke_routes}} in the pipeline: each target lists its own pages.

Review steps: a second opinion

A review: step gives the run's changes to a reviewer with fresh eyes, whose only job is to find what is wrong. It works best with another model family than the one that did the work.

  - name: 05-review
    review: prompts/watch/review.md      # what to check; `review: true` uses only the built-in instructions
    model: api                           # another provider than the producer
    inputs: [.agent/SELECTED.md]         # files to read (the llm runner gets their content)

caffeine builds the reviewer's prompt: built-in instructions (judge, do not fix, check claims against sources), your file, the files to read, and the diff of everything the run changed so far (new files in full, cut at 150,000 characters). The reviewer answers with a verdict in .agent/REVIEW.json:

{"verdict": "fail", "issues": [{"severity": "blocking", "where": "SELECTED.md", "detail": "the fine is 18 M$ in the source, not 23 M$"}]}

The step fails when the verdict is fail or an issue is blocking; minor issues are shown and kept. It also fails when the reviewer changed any file, wrote no verdict, or wrote something that is not JSON (prose or code fences around the object are tolerated). A claude reviewer gets Read, Grep, Glob and Write by default; set allowed_tools to give it WebFetch to check sources.

Fixing what the review found: fix

Without fix, one blocking issue fails the step, and everything the run produced is thrown away. With it, an agent fixes the blocking issues and the review runs again:

  - name: 07-review
    review: prompts/techdoc/review.md
    model: cheap
    fix:
      model: mid                         # the fixer's role: claude or cmd (llm cannot edit files)
      prompt: prompts/techdoc/fix.md     # optional: how to fix, added to the built-in instructions
      rounds: 2                          # fix-then-review rounds after the first review (default 1, at most 5)
      max_turns: 30
      allowed_tools: [Read, Edit, Glob, Grep]   # default: the pipeline's allowed_tools
      verify: python3 {{pack}}/checks/check_docs.py   # after each fix, before the review runs again
  • The fixer gets built-in instructions (fix exactly these issues, check each one against its sources since the reviewer can be wrong too, change nothing else), your prompt, and the blocking issues as JSON. It gets the step's skills and the pipeline's rules, like an agent step. A fail with no blocking issue hands it every issue.
  • If the fixer stops, or its verify fails, the step fails with the review's error and the fix's.
  • The next review is a fresh reviewer. Its prompt lists the previous round's blocking issues, to check again, then the diff of the whole run.
  • The step passes as soon as a review passes. When every round is used and blocking issues remain, it fails as without fix.
  • Logs: <step>.fix1.log, <step>.round2.log… summary.json gives the number of fixes that ran ("fixes": 1), and the step's cost adds up every review and fix.

Skills: know-how for agent steps

A skill is a folder with a SKILL.md, the same format as Claude Code skills: a review checklist, a house style, a doc template. skills: loads them into an agent step, so the same know-how is not pasted into every prompt.

skills: [house-style]                   # pipeline default, like allowed_tools

steps:
  - name: 02-review
    prompt: prompts/review.md
    skills: [judge, diff-checklist]     # replaces the pipeline default

  - name: 03-docs
    prompt: prompts/docs.md
    skills:
      items: [team-techdoc]
      profiles: [docs]                  # only with the wska resolver

Where a name comes from, first match wins:

  1. <pipeline folder>/skills/<name>/SKILL.md: a pack ships its own skills next to its pipelines.
  2. ~/.caffeine/skills/<name>/SKILL.md.
  3. The external resolver, when config.yaml sets one (skills.resolver: wska, see Configuration). caffeine runs wska resolve --item <name>… --profile <name>… once per distinct selection when the pipeline loads, killed past skills.timeout (120 s). It links nothing and writes nothing in the workspace. profiles: needs the resolver.

How it is loaded. The body of each SKILL.md, frontmatter stripped, is added to the step's rules (after the pipeline's rules), under a ## Skill: <name> heading that gives the skill's folder. The skill is always loaded, whatever the runner and whatever the model decides:

  • claude: in --append-system-prompt-file (kept as <step>.system.md in the run's logs), plus --add-dir <skill folder> so the agent can read the files the skill points to (references/, templates). The Skill tool is not offered.
  • llm: in the system message.
  • cmd: in the prompt file, before the prompt.

Nothing is copied into the workspace: no diff noise, no clash with the guard, no race between parallel or foreach steps.

Rules.

  • Skills are resolved when the pipeline loads. An unknown name, a profiles: without a resolver, or skills on a run: step fail caffeine doctor and the run before anything starts.
  • From wska, a skill is loaded; a plugin loads its skills/*/SKILL.md (named <plugin>/<skill>), and its hooks, commands and agents are ignored, with a note. An installer, agent or mcp is an error.
  • Tools a wska item needs and PATH lacks (missing) are a warning in doctor and at the start of the run, never a failure.
  • The text a step's skills inject is capped by skills.max_kb (64 KB by default). Past it, the pipeline does not load.
  • {{skill.NAME}} is the skill's folder in that step's prompt, verify and env, so a check can run the skill's own scripts.
  • summary.json records each step's skills: name, source (pack, home or wska) and folder. caffeine run -n lists them before it starts.
  • A skill is prompt text the pipeline author chose, trusted like a pack. The resolver is set in your own config.yaml only, never by a project's .caffeine.conf.

Memory between runs

With memory: true, each target has a folder that survives from one run to the next: ~/.caffeine/memory/<target>_<pipeline>/, available to the steps as .agent/memory/. Use it for what a pipeline must not redo: threads already sorted, items already rejected, preferences learned from your feedback.

The memory moves forward only when the run succeeds and is not a dry run: a failed run starts again from the same memory. Each run's logs keep a copy of the memory as it ended.

That folder is on the machine that runs caffeine. When several machines run the same pipeline on the same target (a laptop and a CI runner), each would have its own memory. With memory_store: cache in config.yaml, the memory is kept on the cache's store instead, on S3 when the cache is, as memory/<pipeline>/<target>:

  • it is read at the start of the run into .agent/memory/, and written back only after a successful run that is not a dry run, as above. The last successful run wins, atomically;
  • a store that cannot be read fails the run (a cache would only warn): going on would replace the memory with one that forgot everything. A store that cannot be written warns;
  • it is never pruned by cache.max_gb, cache.max_age_days or caffeine gc. Only caffeine cache rm <pipeline> --memory [--target <t>] drops it.

The default, memory_store: local, is the folder above.

Caches between runs: cache:

Each run starts from scratch: a clone is deleted afterwards, so whatever a step built is lost. A cache: entry keeps it from one run to the next, keyed so that a change of inputs gets a fresh one.

cache:
  - name: cargo-target
    dir: CARGO_TARGET_DIR                       # the steps get the folder in this variable
    key: "{{os}}-{{arch}}-{{hash:Cargo.lock,rust-toolchain.toml}}"
    restore: ["{{os}}-{{arch}}-"]               # fallbacks when the exact key misses

  - name: mypy
    paths: [.mypy_cache/]                       # files in the workspace, archived and restored
    key: "{{hash:src/**}}"
KeyDefaultMeaning
namerequiredLetters, digits, - and _. {{cache.NAME}} is the folder.
dirdir or pathsEnvironment variable that gets a folder outside the workspace, for tools that take one (CARGO_TARGET_DIR, CARGO_HOME, npm_config_cache, PIP_CACHE_DIR). Not PATH, HOME or CAFFEINE_*.
pathsdir or pathsFolders or files in the workspace, for tools that only write next to the code (.mypy_cache/, node_modules/, .venv/). Restored before the first step, archived (tar.zst) after the last. A path outside the workspace, under .agent/ or protected by the guard is refused when the pipeline loads.
keyrequiredWhich entry the run uses. Rendered with the run's variables plus {{hash:<globs>}} (sha256 of the workspace files matching the comma-separated globs, at the start of the run), {{os}}, {{arch}} and {{sandbox}} (the pipeline's sandbox, none on the host). An unknown variable fails the run.
restore[]Key prefixes tried in turn when the exact key misses: the most recently saved entry starting with one wins. A miss is not an error: the folder starts empty.
saveon_successon_success: after a run that passed. always: after a failed or interrupted run too. never: read only, for an entry another pipeline fills. A dry run never saves.
sharepipelinepipeline: this pipeline on this target, like the memory. target: every pipeline of the target. global: every pipeline on every target, for what a workspace cannot poison (download caches).

Always a copy. The run never writes into a stored entry. The entry is copied into a folder of the run (next to the clone, under ~/.caffeine/app/, deleted with the run), and saving copies that folder into a new entry that replaces the old one at once. A failed, interrupted or killed run cannot leave a half-built cache behind, and two runs sharing an entry never write into the same folder. The copies share their blocks on filesystems that can (btrfs, XFS, APFS), so a big target/ costs little; elsewhere it is a plain copy.

When. Entries are restored after the workspace is prepared and before the run's snapshot, and saved after the last step. Restored paths are therefore not changes of the run: they stay out of changed, the guard and caffeine changed; in a clone they are also kept out of changes.diff and of what caffeine pr commits. An archive whose sha256 does not match its manifest is not restored: a warning, and the run goes on without it. A cache never fails a run: a store that cannot be read or written is a warning, and the run goes on with an empty folder.

Keys and outcomes (hit, prefix, miss) are shown at the start of the run, caffeine run -n included, and recorded in summary.json. The store is set in config.yaml (see Configuration); a project's .caffeine.conf cannot change it.

Sandboxes: sandbox:

A step's processes (run:, verify:, the cmd runner, the Claude Code CLI) run on the host unless the step has a sandbox. Sandboxes are declared in config.yaml (see Configuration); a pipeline and its steps only name one:

sandbox: rust                 # the steps' default
steps:
  - name: 01-gate
    run: "{{pack}}/checks/gate.sh"
    sandbox: none             # this step stays on the host
  - name: 02-update
    prompt: prompts/update.md
    verify: cargo build -q && cargo test -q

A step's sandbox is its own sandbox:, else the pipeline's, else sandbox_default from config.yaml, else none. A kubernetes sandbox runs the whole run in one pod, so every step of the pipeline must use it (see Configuration); there, caffeine pr can only be the last step. {{sandbox}} in a cache key is the pipeline's. caffeine run -n shows where each step runs, and summary.json records each step's sandbox and engine.

Network: network:

An agent reads untrusted content, and a build runs project code (build.rs, postinstall): network: limits what a sandboxed step can reach.

sandbox: rust
steps:
  - name: 02-update            # the agent needs the model API and crates.io: full, by default
    prompt: prompts/update.md
  - name: 03-test
    run: cargo test -q --offline
    sandbox: rust-offline      # same image, another container (one network per container)
    network: none
ValueMeaning
noneNo network interface but loopback.
a list of namesOnly the hosts of those lists, from networks: in config.yaml (built in: crates is crates.io, index.crates.io, static.crates.io; npm is registry.npmjs.org; github is github.com, api.github.com, codeload.github.com, objects.githubusercontent.com, raw.githubusercontent.com, release-assets.githubusercontent.com).
fullThe sandbox's default network: today's behaviour.

A step's network is its own network:, else the pipeline's, else the target's network_default (in workspace.yaml), else full, so existing pipelines keep working. A project's .caffeine.conf can narrow it, never widen it (see Configuration).

What the runner needs is added to a list: the Anthropic API host (or the one of ANTHROPIC_BASE_URL, which a kubernetes pod then gets too) for a claude step, claude.ai with claude_connectors: true, the hosts of the pipeline's http MCP servers, and a cmd role's own network: lists. For a claude step, none therefore means "only the model API", a list. A claude step with any network but full also gets CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1, which turns off the CLI's telemetry, error reports and auto-updater: those hosts are not in the list, and their refused connections would fail a run under network_on_deny: fail. A step's env: can set it back.

How each engine applies it:

Enginenonea listfull
podman, docker--network none when the container is createdrefusedthe engine's default network
bwrap--unshare-net: a network namespace with loopback onlyrefusedthe host's network
kubernetesa NetworkPolicy with no egress rulewith cni: cilium, a CiliumNetworkPolicy with toFQDNs (a *. name is a pattern) and DNS to kube-dns allowed for those names only, and toCIDR for an IP address (/32, /128); refused otherwise. Write fully qualified names (proxy.corp.example.com, not proxy): the pod's resolver appends its search domains to a short one, which then matches nothingthe cluster's default
none (host)refusedrefusedthe host's network

On kubernetes, the policy is created with the run's pod, selects it by a label of the run, and is deleted with it. A pod has one network, so all the steps of a kubernetes run ask for the same one, and the pod's policy holds the hosts every step needs: the listed ones, plus each agent step's model API (a run: step in the same pod can reach it too); an llm step there is run by caffeine inside the pod, so its base_url host is added too. Only the listed names resolve: Cilium's DNS proxy refuses any other query, so a step can neither connect elsewhere nor smuggle data out in DNS queries.

<logdir>/network.log records the network applied to each step, with its sandbox and engine. On a kubernetes sandbox with hubble, the connections the policy refused during the run follow, one line each (denied <time> <host>:<port>), and summary.json counts them (network_denied). With network_on_deny: fail, a refused connection fails the run, even if every step passed, and the memory stays as it was: it is the strongest sign of an injection. The pod runs all steps, so a refused connection is the run's, not a step's.

Refused before anything starts, by the run and by caffeine doctor:

  • a network: other than full on a step without a sandbox (sandbox: none): caffeine cannot enforce it on the host;
  • a list of hosts, a claude step with none included, on podman, docker, bwrap, or kubernetes without cni: cilium: they cannot filter by host name;
  • two steps in the same podman, docker or kubernetes sandbox that ask for different networks: they share one container or pod, which has one network (the hosts a step's runner adds do not count: the pod gets them all);
  • full, the default included, with network_allow_full: false; network_on_deny: fail with a step that is not full and not on a kubernetes sandbox with hubble, the only place refused connections are seen;
  • a list name that is not declared.

caffeine doctor shows each step's network on each target that lists the pipeline, and summary.json records it per step (network).

Pull requests: caffeine pr

Opening a pull request is a step like any other, usually the last one:

  - name: 99-pr
    run: caffeine pr                 # or: caffeine pr --auto-merge

caffeine pr:

  • does nothing in a dry run (caffeine run -n);
  • refuses to run outside a git target's clone, so it never commits in your own checkout;
  • with no change in the clone, prints "nothing to commit" and exits 0;
  • otherwise commits everything except .agent/, force-pushes the run's branch to the target's git: URL (never to whatever origin a step left), and creates the pull request with gh on that repository, assigned to you (--assignee @me), with .agent/REPORT.md as its body. If a pull request already exists for the branch (a second run the same day), it updates its body;
  • with --auto-merge, squash-merges it and deletes the branch right away. Only use it on pipelines whose checks you trust (see Safety);
  • refuses to run in a podman, docker or bwrap sandbox (give its step sandbox: none); on a kubernetes sandbox it runs in the pod as the pipeline's last step, a run: of caffeine pr and its flags alone with no verify:, and only it gets the token (see Pull requests from a pod).

The pull request URL ends up in the run's summary and receipt.

caffeine scope: keep the diff in bounds

caffeine scope <glob>... fails when the run changed a file outside the globs. Use it in verify::

    verify: caffeine scope Cargo.toml Cargo.lock 'src/**' && cargo build -q

It compares with a snapshot of the workspace taken when the run started, so it only judges what the run changed: your uncommitted edits and untracked files in an in-place folder never count. It ignores .agent/, and works in git and non-git folders alike. In your own check scripts, use caffeine changed to get the same list. * also matches across /, and ** matches any depth.

Examples

Content watch, script + agents + check

description: "Find new public cases, check them, add them to existing pages"
steps:
  - name: 01-inventory           # exact and free
    run: python3 {{pack}}/checks/inventory.py          # writes .agent/INVENTORY.md
  - name: 02-scan
    prompt: prompts/watch/02-scan.md                    # writes .agent/CANDIDATES.md
    model: smart
    allowed_tools: [Read, Write, WebSearch, WebFetch]
  - name: 03-select
    prompt: prompts/watch/03-select.md                  # writes .agent/SELECTED.md
    model: smart
    allowed_tools: [Read, Write, WebFetch]
    verify: python3 {{pack}}/checks/selected_has_sources.py
  - name: 04-apply               # the format is strict: a script, not an agent
    run: python3 {{pack}}/checks/apply_selected.py
    verify: caffeine scope 'content/**'
  - name: 05-report
    prompt: prompts/watch/05-report.md
    model: local                                        # a local model writes the PR body
    inputs: [.agent/SELECTED.md]
    output: .agent/REPORT.md
  - name: 99-pr
    run: caffeine pr

MCP only, no repo

# a target with neither git nor dir, listing this pipeline
description: "Triage new tickets into a proposal file"
mcp: [tracker]
steps:
  - name: 01-triage
    prompt: prompts/triage.md
    allowed_tools: [Read, Write, "mcp__tracker__list_issues", "mcp__tracker__get_issue"]
    verify: python3 {{pack}}/checks/triage_schema.py .agent/ACTIONS.json

Give agents read tools on the MCP side, and let them write a proposal file. Apply the changes in a later, deterministic step, or by hand, once you have read it.

On this page