Lightweight sandbox for terminal agents.
Fence wraps any command in a pragmatic OS sandbox for macOS and Linux: default-deny outbound network, scoped filesystem access, dangerous command blocking, and reviewable policy for agents, CI, and unfamiliar repos.
Quick start
Get one workflow working.
Install Fence with the instructions above. Start from the built-in code template, observe what your workflow actually needs, then run it normally with a policy you can keep. Here's an example for sandboxing Claude Code:
- 1
Create a starter policy
Start from the built-in
codetemplate for common coding workflows.$fence config init - 2
Run in monitor mode
Wrap your agent or command so you can see what gets blocked.
$fence -m claude - 3
Refine the policy
Allow only the domains, paths, and commands your workflow actually needs.
- 4
Run normally
Once the policy feels right, run the same workflow without monitor mode.
$fence claude
Already use Claude Code? Import its existing permissions instead:
fence import --claude --saveWhy Fence
Clear policy, real local workflows, and no VM overhead.
Fence is intentionally narrow: it lets you keep using the repos, tools, and local state you already have, while putting clear limits around what a command can touch. That gives you practical guardrails for agents and risky workflows without moving everything into a VM or container.
Default-deny outbound network
Block network access by default, then allowlist only the domains a repo or agent actually needs.
Path-scoped filesystem policy
Writes stay denied until you opt into specific paths, while sensitive targets remain protected.
Command-level guardrails
Stop risky commands like git push, npm publish, or destructive shells before they execute.
Monitor blocked attempts
Use -m to see what a workflow tried to access and tune the smallest policy that still works.
Templates that match real workflows
Start from the provided templates, then refine rules based on your needs.
Config inheritance without copy-paste
Inherit a built-in template or shared team config, then layer only the extra domains, paths, and command rules as required.
{ "extends": "code", "network": { "allowedDomains": ["api.anthropic.com", "github.com"] }, "filesystem": { "allowWrite": ["."], "denyRead": ["~/.ssh", ".env"] }, "command": { "deny": ["git push", "npm publish"] }}Platforms
Native on macOS and Linux.
Fence keeps one policy model across both OSes, but the sandbox backend and visibility stack adapt to each platform.
On macOS, Fence keeps the workflow close to normal local development: same repo, same local tools, and clear visibility when something gets blocked.
- Sandbox engine
- Generated Seatbelt profiles via
sandbox-exec - Filesystem model
- Path allow/deny rules plus macOS Unix socket allowlisting
- Interactive sessions
allowPtysupport for terminal apps, editors, and TUIs- Visibility
- Log-stream based violation visibility with no extra sandbox dependency
Agent compatibility
Fence wraps the agents you already use.
Start with code.
The code template gives CLI agents a practical coding baseline: common model APIs, Git hosts, and package registries are allowlisted; the workspace plus normal agent config and cache directories stay usable; and risky reads, writes, and commands like git push, npm publish, and sudo stay blocked by default.
Use the built-in template directly when you want the shortest path into a guarded session.
fence -t code -- claudecode?Once your own policy inherits from the template, you can wrap the same agent with the shorter command.
fence claude... and many more
Beyond these popular examples, Fence can also wrap other agent CLIs while keeping the same policy model across repos and CI jobs.
Comparison
Fence vs agent sandboxes vs containers.
Fence is built for real host-native workflows: the repos, tools, and local state you already have. Agent sandboxes stay product-specific, and containers can isolate more strongly, but usually with more setup and more friction.
| Capability | Fence | Agent sandbox | Containers |
|---|---|---|---|
| Works across CLI agents and plain commands | |||
| Policy you can commit and reuse across local dev and CI | |||
| Default-deny outbound with domain allowlisting | |||
| Scoped filesystem rules for host-repo workflows | |||
| Command-level blocking | |||
| No Docker or VM setup required | |||
| macOS and Linux host-native workflow |
FAQ