Source: https://keypaste.com/developers/sandbox-your-ai-tool/
Last updated: 2026-12-01

# Sandbox your AI tool

You’ll have an AI tool whose agent’s shell commands can’t rewrite keypaste’s settings, your vault, or the tool’s own configuration, so they can’t reach around keypaste.

An agent’s commands run as you. Unconfined, they could rename an agent in the tool’s configuration, replace the `keypaste` the tool starts, or change keypaste’s settings. This guide sets up Claude Code; Codex and Cursor are in [Full details](https://github.com/notinferred/keypaste/blob/main/docs/safe-agents.md#codex).

## Prerequisites

- Claude Code on macOS, Linux or WSL2. On Linux and WSL2, `bubblewrap` and `socat` installed.
- Your vault and its key file in a folder outside every project, here `~/Vaults`.

## 1\. Turn on the sandbox

Put this in `~/.claude/settings.json`, with `~/Vaults` replaced by your vault’s folder:

```
{  "sandbox": {    "enabled": true,    "failIfUnavailable": true,    "allowUnsandboxedCommands": false,    "filesystem": {      "denyWrite": ["~/.keypaste", "~/Vaults"],      "denyRead": ["~/.keypaste", "~/Vaults"]    }  },  "permissions": {    "deny": ["Edit(~/.keypaste/**)", "Edit(~/Vaults/**)", "Read(~/.keypaste/**)", "Read(~/Vaults/**)"]  }}
```

The sandbox never lets commands write Claude Code’s own configuration. The `permissions` rules cover Claude’s file tools, which the sandbox doesn’t.

## 2\. Protect the `keypaste` it starts

If your account can write the `keypaste` Claude Code starts, add it to both lists, with `//` before an absolute path in the `Edit` rules: `~/.local/bin/keypaste` and the AppImage on Linux, `/Applications/keypaste.app` on macOS.

## 3\. Start Claude Code with your settings first

Terminal window

```
alias claude="claude --settings '{\"sandbox\": {\"allowUnsandboxedCommands\": false}}'"
```

Without `--settings`, a repository’s `.claude/settings.json` outranks yours and can weaken the sandbox.

## 4\. Keep it on

- Start the agent in the project’s folder, never your home folder or one holding the vault.
- Don’t use `--dangerously-skip-permissions`.
- Read a repository’s own `.claude/` and `.mcp.json` before you trust it.

A sandbox doesn’t change what keypaste releases: an agent still gets what you allow, and a command run through keypaste receives the values it asked for.

## Next steps

- [Full details](https://github.com/notinferred/keypaste/blob/main/docs/safe-agents.md): Codex, Cursor, each platform, and what a sandbox leaves open
- [How keypaste keeps agents in check](https://keypaste.com/developers/how-keypaste-keeps-agents-in-check/)
- [Set what each agent gets](https://keypaste.com/developers/set-what-each-agent-gets/)
