AI coding tools
What does the Claude Code sandbox protect?
Updated 24 Nov 2026
The local sandbox limits what a shell command can read, change and contact. A package can still change files inside an allowed project. Check both the boundary and the package before you approve an install.
Which work stays inside the sandbox?
When sandboxing is active, Claude Code starts its Bash commands and their child processes inside the configured boundary. A package manager launched by that shell inherits the restrictions. The operating system enforces filesystem rules. A proxy checks network destinations against the configured rules.
A command can usually write inside the project. Its allowed reads can cover a wider area. Check the effective rules for the session, including any sensitive directories that the process must never read. Give a test project only the files and credentials it needs.
Other Claude Code tools have separate controls. Review the permissions for file tools, hooks and MCP servers whenever the task uses them. A sandbox setting for Bash answers only the shell part of that review. Read Anthropic’s sandbox documentation.
Check the machine that runs the command
macOS
Open the sandbox panel in the same Claude Code session you plan to use. Check its enabled state and review the allowed project directories and network hosts.
Linux
The local sandbox needs operating-system support and the required tools, including bubblewrap and socat. Check the dependencies shown in the sandbox panel. Resolve a missing prerequisite before running the install.
Windows
Run the session inside a supported WSL2 distribution to use this shell sandbox. A Windows terminal can open several shells. Confirm that the shell running Claude Code belongs to WSL2.
In the session, open the panel with the command below. Review the current filesystem and network settings. If a sandboxed command fails, inspect the requested access before granting new permissions.
/sandbox
What changes when you approve an install?
Permission to run an install answers a question about access. The package manager also resolves a publisher, registry, package name and version. Check those details against the project’s lockfile and the publisher’s own instructions.
For example, a test project can legitimately write build files in its working directory. A dependency running there can also change application source or build settings. A clean shell exit tells you that the command finished. Inspect the resulting changes before committing or using that build.
If a tool asks to run outside its normal boundary, read the exact command and the reason for the request. For a package installation, keep the existing limits while you check the proposed dependency. Skipping permission prompts removes a chance to review a command. It gives no evidence about the origin or contents of the package.
Match each approval to the boundary it controls
| Question | Where to look | What the answer tells you |
|---|---|---|
| Which files can the shell reach? | The active sandbox’s read and write rules on this machine. | Separate the files a process can inspect from those it can change. Review the checkout, shared directories and credentials separately. |
| Which network destinations can it contact? | The effective network rules for this session. | A permitted registry can host many publishers. Permission to contact the registry still leaves a choice of package and release. |
| Which tool requested approval? | The permission prompt, tool name, proposed operation and working directory. | A shell command, a file edit and a connector call can reach different resources. Check the tool that will actually perform the action. |
| Who approved the dependency? | The pull request, publisher’s installation documentation, manifest and lockfile. | Trace the exact dependency to a requirement in the project. Record who reviewed the change so the next release owner can find that decision. |
For example, a command can contact an approved registry and write its result into the checkout. Both actions can fit the sandbox policy while the proposed dependency still belongs to the wrong publisher. The developer reviewing the dependency has the information to catch that mismatch.
A worked review for a spreadsheet import
Suppose a small team asks Claude Code to add a CSV import to a reporting tool. The test file contains invented names and amounts. The assistant proposes a new parser and asks to run the package manager. Here is a review the team can perform before approval.
Start from the requirement
Write down one input and the output you expect. In this example, a quoted comma inside a customer name must stay in the same column. Ask which existing project dependency, if any, already handles that case. If the current parser passes a small test, the feature can use the dependency already in the lockfile.
Verify a new dependency at the source
If the project needs another parser, open the publisher’s documentation independently. Match the complete package name, including its scope, to the documented install. Compare the proposed release with its release notes. Look at changes to installation behavior as well as changes to the parser itself. Record the expected package in the change request.
If a release changes its publisher or registry, record the change in the review. Ask the original maintainer for a release announcement before allowing the new source into the project.
Check the approved action
Read the working directory shown for the command. Confirm the test checkout contains the invented CSV and only the files needed for this change. If the request includes access to another project, check why the parser needs it. For this example, it only needs the sample in this checkout.
Inspect the result before merging
Read the changes to the manifest, lockfile and application code. Check that the resolved package and its version match the release you reviewed. Look for extra dependencies or configuration edits outside the import feature. Run the parser test against the example and check the resulting columns. Keep the test and dependency review with the pull request.
A passing parser test proves that the sample produced the expected columns. It cannot establish everything the installation did. The file diff, dependency record and test result answer separate questions. Keep all three when another person owns the production release.
A real package check
In March 2026 the axios maintainer confirmed that npm versions 1.14.1 and 0.30.4 included a malicious dependency. A developer checking the package name alone would see the familiar name. The exact release and the new dependency identify the affected installs. Read the maintainer’s report.
If your historical lockfile names one of those versions, check the install date, build logs and machines that ran it. Record which credentials the process had at that time. Refer to the published response steps for that incident. This example illustrates a release review. The maintainer’s report does not establish that the affected users ran Claude Code.
Review the build that leaves the sandbox
Read the dependency changes before handing a build to another person. Check new install scripts, changed registry URLs and unexpected changes to source or configuration. For an unexpected package, ask for the documented reason it belongs in the project.
Check where the next step runs. A local test and a production build can have different credentials, network rules and filesystem access. Keep unverified dependencies away from the account that signs releases or publishes packages. Verify the approved version again when CI builds the release.
If the team uses a container, review the mounts and credentials supplied to it. A writable mount exposes real project files to processes inside the container. A saved image can carry changes into the next job. Compare Anthropic’s documented isolation options.
Questions about the Claude Code sandbox
Can I sandbox Claude Code on a Mac?
Yes. Open the sandbox panel in the Claude Code session and check that the sandbox is enabled. macOS provides the underlying enforcement. Review the allowed paths and network destinations for your project.
Does the sandbox work on Windows?
Anthropic supports the shell sandbox inside WSL2. Native Windows and WSL1 do not provide this sandbox. Confirm the environment of the actual session before approving an install.
How does the sandbox differ from Docker?
The local shell sandbox applies restrictions to the shell command and its child processes. Docker runs a container with its own filesystem view. Mounted directories, exposed credentials and network access depend on the container configuration.
Does enabling the sandbox make a downloaded dependency safe?
No. A dependency can still modify the part of the project where it has write access. Check its release, source and expected behavior before allowing its installation.
Who can see my Claude Code prompts?
Anthropic documents data use and retention for its products. The answer depends on the service and your account. Review its data usage policy and your organization’s settings before sharing project data.
Anthropic’s data usage policy explains the account-specific settings.
Compare two package versions
Choose a package and inspect the files that changed. The demo reads the published files in your browser.