Skip to content
zero2vibecodelearn vibe coding
Level 1 · Permissions and safety 6 min Reviewed by the author · Oct 15, 2026 Verified against Claude Code v2.1.292 · Oct 15, 2026Official docs: SandboxSomething out of date? Tell us

The sandbox: a boundary the system enforces

Permission rules decide what Claude may run. The sandbox decides what a running command may do — and that limit is enforced by the operating system. Turn it on with /sandbox.

Level 1 · 0 / 4 lessons0%
In this lesson

In the last lesson you learned to allow and deny actions with rules. But rules have a blind spot. The rule Bash(npm test) lets the tests run — and has no idea what is inside them. If a test or one of its dependencies starts writing into someone else’s folder or sending data over the network, the rule will not notice.

That is what the second layer is for — the .

What the sandbox does

The sandbox wraps the shell commands Claude runs in a boundary enforced by the operating system. By default, a command inside it:

  • writes only to the project folder, the user’s temp folder, and folders you added with --add-dir or /add-dir;
  • reaches the network only through a proxy that lets through allowed hosts and nothing else.

If a command tries to write a file into your home folder, the system refuses: on macOS you see Operation not permitted, on Linux Read-only file system.

How to turn it on

The sandbox is off by default. Inside a session, type:

/sandbox

and on the Mode tab choose the auto-allow mode. In it, a command that runs inside the sandbox does not need approval: the boundary already keeps it in check. Claude Code saves the choice to your personal .claude/settings.local.json.

In the settings file it looks like this:

{
  "sandbox": {
    "enabled": true
  }
}

What stays outside

This matters if you do not want to overestimate the protection:

  • Claude’s own tools for reading and editing files and for the web run outside the sandbox — the permission rules from the last lesson govern them;
  • hooks and local MCP servers run outside the sandbox with your full user rights.

The sandbox does not replace rules; it adds to them. Rules decide what may be run. The sandbox decides what the running thing may do.

Quick check

With the sandbox on, Claude ran npm test, and the test script tried to write a file to ~/Documents. What happens?

Careful

Practice in the terminal

Check your understanding

Answered 0/3
Mode:

How is the sandbox different from permission rules?

By default, what can a command inside the sandbox do?

What does NOT go inside the sandbox?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Task

Turn on the sandbox for yourself in this project — in the personal settings file that stays out of git.

Tab complete · ↑ history · Ctrl+L clear · help commands

  • Not done: Personal project settings file created
  • Not done: It has a sandbox block
  • Not done: The sandbox is enabled

Lesson Q&A

How is the sandbox different from permission rules?

Rules decide whether a command may run; the sandbox limits what a running command can do, and the operating system enforces it — A rule like "allow npm test" lets the command run, but it does not know that the test script will reach into someone else's folder or out to the network. The sandbox sets the boundary at the system level.

By default, what can a command inside the sandbox do?

Write only to the project, the temp folder and added folders; reach the network only through a proxy to allowed hosts — By default, writes are limited to the project, the temp folder and folders added with --add-dir or /add-dir, and network access goes through a proxy that checks the host.

What does NOT go inside the sandbox?

Claude's own file and web tools, plus hooks and local MCP servers — The sandbox wraps only shell commands. Claude's file and web tools follow the permission rules, and hooks and local MCP servers run with your full user rights.

With the sandbox on, Claude ran npm test, and the test script tried to write a file to ~/Documents. What happens?

The rule let the command itself run, but the sandbox boundary does not let it write outside the project and the temp folder.

Commands in this lesson

Move between lessons with ← → · search with ⌘K

Written and reviewed by Mikhail Kuzmitskii