pmg sandbox exec runs the agent and every process it starts under one sandbox policy.
The sandbox:
- Blocks reads and writes of credential files in the repository and in your home directory.
- Removes secret variables, model API keys included, from the agent environment.
- Makes the agent hook configuration read-only, so the agent cannot remove a hook such as Gryph.
- Lets the agent write only in the repository, temporary directories, tool caches, and the state directory of its preset.
- Sends every outbound connection through a PMG proxy that applies a network policy.
pmg sandbox exec is experimental. It runs on macOS and on Linux with the Landlock driver. It does not run with Bubblewrap or on Windows. This page needs PMG v0.33.0 or later. Install PMG with the PMG quickstart.Run the agent in the sandbox
Each agent has a preset that adds its state directory, its own API key, and its own hosts.- Claude Code
- Codex
- Pi
Limit the hosts the agent can reach
By default the agent can reach every host, and PMG records each destination. Build a network policy from a session, then enforce it.1
Run a normal session
2
Propose a profile
agent in the PMG config directory, outside the repository, where the agent cannot change it. The profile allows each host that the session reached and denies every other destination. Open it with pmg sandbox profile edit agent and remove each host that the agent does not need.3
Run the agent under the profile
Fix a denied operation
The agent sees a permission error. After the session, find the cause and the command that allows it:Next steps
For the exec profile, custom profiles, the network flags, and the limits, see the sandbox exec documentation in the PMG repository. Read the hosts that a preset allows withpmg sandbox preset show claude.
Gryph
Record every file and command your coding agent touches.
Stop Install Scripts from Reading Your Secrets
Run package installs in the PMG sandbox.

