# How do I guard coding agents on a remote box or in a dev container?

> One line in the box's setup puts a fail-closed Immiscible hook in front of every coding agent before any of them runs, so a fleet of agents on cloud VMs or dev containers is held to the same rules as the one on your laptop.

Source: https://immiscible.fly.dev/docs/answers/coding-agents-on-a-remote-box

Add `npx immiscible guard --agents all --yes` to the box's setup script, image or dev container. `--agents all` writes the hook for every agent Immiscible covers (Claude Code, Codex, Cursor, Windsurf, Gemini CLI, Factory Droid, opencode and Amp) whether or not it is installed yet, so an agent added to the box later starts guarded. `guard` and `--agents all` are in the next CLI release, 0.3.0, not yet on npm; until then, run it from a checkout of the repository.

## Why not just run guard after the agents are installed?

On a laptop, `guard` finds the agents by the folders they keep in your home directory. A box built from an image, or a container created a minute ago, has none of those folders until each agent first runs, so there is nothing to find. Naming them all closes that gap: the hook is in place before the first session.

## In a dev container

```json
{
  "image": "mcr.microsoft.com/devcontainers/javascript-node:22",
  "postCreateCommand": "npx immiscible guard --agents all --yes"
}
```

The hook is a Node script, so the box needs Node 22.13 or later. With no account the hooks decide on the box from local rules and send nothing anywhere.

## For every user on a shared box

Run it once as root: `sudo npx immiscible guard --agents all --scope managed --yes`. That writes each agent's managed settings, the files an administrator owns, for everyone on the box. opencode and Amp have no managed file, so they are left out and named; run `guard --agents opencode,amp` as each user for those.

## Who approves when nobody is watching the terminal?

In local mode, Claude Code, Cursor and Factory Droid ask at the keyboard, and the others refuse what needs a person, with the reason. For agents left running on a box, connect the hooks to your workspace instead:

```bash
IMMISCIBLE_AGENT_KEY=<agent key> npx immiscible guard --agents all --connect --yes
```

Each question then reaches a named person in Slack, Teams, email or on the phone, and every decision is signed. Keep the key in the box provider's secrets, not in the image.

## What else carries over

- `npx immiscible undo` puts back files an agent deleted or overwrote in a git repository on the box, from the checkpoints the hooks take.
- `npx immiscible scan` reads the history the agents keep on the machine it runs on, and the guard's own log there, so run it on the box to see what the agents there did.
- `npx immiscible scan --ci` in the repository's own CI checks the agent configuration committed to it, wherever the agents run. See [scan in CI](https://immiscible.fly.dev/docs/cli.md#scan-ci).

## What does it not do?

- It governs the calls each agent's hook sees: shell commands, file writes, web tools and MCP tools. It is not a sandbox and does not filter the box's own network.
- Someone with root on the box can remove the managed files. Pair it with the box provider's own access controls.
- `guard --off` puts back every file guard wrote, from `~/.immiscible/guard.json` on that box; a managed install is undone with `sudo npx immiscible guard --off --scope managed`.
- With `--agents all`, an agent that is not installed still gets its hook folder, so `guard` and `scan` name it as found from then on.
