safety model

The checks decide,
not the model.

caffeine runs agents with nobody watching. Prompts can ask, but only commands can enforce. Here is every layer caffeine enforces around a step, and, just as plainly, what it leaves to you.

  1. 01allowlisttoolsonly listed tools exist
  2. 02sandboxengineno ~/.ssh, no home
  3. 03networknone · hostsreach only what's needed
  4. 04guardpaths.env, CI, keys untouched
  5. 05verifyyour commandsexit 0 or it failed
  6. 06inboxyoudecisions wait for you

// 01 · the guard

Some files are never an agent's business.

After every step that passed, script or agent, whatever the runner, caffeine lists every file added, changed or deleted since the start of the run, and fails the run if one of them matches a protected path. A protected file that is touched and then put back still counts as changed.

# protected by default
**/.env  **/.env.*  .github/**  .gitlab-ci.yml
**/*.pem  **/*.key  **/*.p12  **/*.pfx  **/id_rsa*  **/id_ed25519*
.caffeine.conf
  • Replace the list with guard.forbid in config.yaml.
  • Open a path for one pipeline on purpose: guard_allow: [".github/workflows/main.yml"].
  • A project's .caffeine.conf can never change the guard.
  • In a git workspace, files ignored by .gitignore are left out, so build output doesn't trip it.

// 02 · tool allowlist

An agent gets the tools you list. Nothing else exists.

For the claude runner, only the tools in the step's allowed_tools are loaded and approved. Everything else is refused without a prompt.

allowed_tools: [Read, Edit, Grep, Glob,
                "Bash(cargo build*)", "Bash(cargo test*)"]
  • Sub-agents (Agent, Task) are always disabled.
  • Only the pipeline's own MCP servers are loaded.
  • Checked after the run, too: any tool that ran without being in the list fails the step, whatever slipped past the CLI's own filtering.

// 03 · sandboxes

Steps run away from your home.

sandbox: runs a step's processes (run:, verify:, a cmd agent, the Claude Code CLI) in a container or under bubblewrap, or moves the whole run into a Kubernetes pod. A sandbox sees the workspace, the run's logs, the pipeline's files and skills. Nothing else: no ~/.ssh, no ~/.claude, no config.yaml, no other runs.

enginescoperuns ongood for
podman · dockerone container per run and targetmacOS, Linuxbuilds with a known image
bwrapbubblewrap, no imageLinuxlight isolation, host toolchain
kubernetesthe whole run in one podfrom Linuxshared clusters, host-list networks
  • Credentials come in by name only, through the sandbox's env:.
  • The workspace's .git is read-only, so a step can't plant a hook, an fsmonitor or a filter for caffeine's own git to run.
  • A cloned repo can't pick or drop its sandbox, and sandbox_required: true refuses any step left on the host.

// 04 · network

Reach only what the step needs.

network: limits what a sandboxed step can reach: none (loopback only), named host lists, or full. A setting caffeine can't enforce is refused when the run starts, never silently widened.

networks:                     # config.yaml
  pypi: [pypi.org, files.pythonhosted.org]

network: [crates, github]      # built-in lists: crates, npm, github
nonehost listsfull
podman · docker · bwrapenforcedrefusedyes
kubernetesNetworkPolicyCiliumNetworkPolicyyes
no sandboxrefusedrefusedyes
  • With Hubble, refused connections land in network.log and summary.json; network_on_deny: fail fails the run.
  • network_allow_full: false refuses full everywhere.
  • A project file can only narrow the network, never widen it.

// 05 · deterministic checks

Exit 0, or it didn't happen.

verify: is where quality is decided. A model can claim anything; a command can't. Checks that pay off:

caffeine scope <globs>

The diff stays inside the expected files.

cargo build && cargo test

Build and tests, the boring and essential part.

caffeine check smoke

Start the app, hit the routes that matter, compare with before the change.

caffeine check json · urls

Format checks on what an agent produced.

When the same correction comes up twice in your reviews, turn it into a check.

// 06 · review and fix

A second model, with fresh eyes.

A review: step hands the run's diff to a reviewer that returns a verdict. With fix:, an agent fixes the blocking issues, then a fresh review runs again, for up to five rounds. Model ladders (model: [cheap, mid, smart]) only climb when the check fails, so the expensive model is the exception.

// 07 · trust

Who gets to change what.

inputtrusted?
~/.caffeineYes: config, pipelines, prompts and checks are yours.
.caffeine.conf, current folder or dir: targetYes: you chose to run there.
.caffeine.conf in a git cloneNo, unless the target sets trust_project_conf: true.
files, web pages, tool resultsNo: agents are told to treat them as data.

A project file can change models, mcp, context and since_days, and narrow network. It can never change targets, the guard, sandboxes, networks or the Claude binary, and a role or MCP server it redefines adds no reachable host.

// 08 · pull requests and inbox

Your branch is never touched.

  • caffeine pr only commits in a fresh clone made by the run, on the run's own branch. Your checkout and default branch are never committed to.
  • Proposed actions and pull requests wait in the inbox for caffeine approve or caffeine reject.
  • --auto-merge merges only when every step and check passed. Earn it with caffeine stats first, ideally with a runtime smoke test: a green build is not a working site.
  • One run at a time per target and pipeline, with a lock. A budget cap (max_budget_usd) keeps the bill boring.
  • The first Ctrl-C stops the run cleanly: the step and everything it started are killed, the workspace is cleaned, the summary says interrupted.

// 09 · honest limits

What caffeine does not protect.

Every layer has an edge. We'd rather you know where they are.

run: steps are your code

Scripts and checks run with your permissions. The guard still checks their changes afterwards.

cmd agents

They follow their own CLI's permissions, not caffeine's allowlist. Give them a sandbox and a network limit if you don't trust them.

Builds run project code

cargo build and npm install execute scripts from the project and its dependencies. Sandbox them, with network: none once dependencies are there.

A sandbox is as tight as its engine

Containers share the host kernel; bwrap shows the host's /usr and /etc. Host lists need Kubernetes with Cilium; a CNI that ignores policies enforces nothing.

A pod checks itself

On Kubernetes, the guard and summary are made inside the pod where the steps ran. Treat a pod run's result like its changes, and give caffeine pr a short-lived, repo-scoped token.

In-place targets change in place

Running in the current folder edits your files. Use a git repo, or a git target that works on a throwaway clone.

A hard kill cleans nothing

A second Ctrl-C or kill -9 exits at once. A leftover .agent/ blocks the next run there until you delete it, on purpose.

Connectors reach real accounts

With claude.ai connectors, list only the tools a step needs and keep irreversible actions out of apply.