{"meta":{"title":"Using local sandboxing","intro":"Enable local sandboxing so that Copilot CLI runs the commands and tools it invokes on your behalf inside an operating-system sandbox.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/copilot","title":"GitHub Copilot"},{"href":"/en/copilot/how-tos","title":"How-tos"},{"href":"/en/copilot/how-tos/cloud-and-local-sandboxes","title":"Sandbox Copilot"},{"href":"/en/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing","title":"Use local sandboxing"}],"documentType":"article"},"body":"# Using local sandboxing\n\nEnable local sandboxing so that Copilot CLI runs the commands and tools it invokes on your behalf inside an operating-system sandbox.\n\n> \\[!NOTE]\n> Local sandboxes for GitHub Copilot are in public preview and subject to change.\n\n> \\[!IMPORTANT]\n> Local sandboxing on Windows requires a Windows Insiders build.\n\n## About local sandboxing\n\nSandboxing is currently an experimental feature. To use it, start Copilot CLI with the `‑‑experimental` command line option, or enter `/experimental on` during a session.\n\nWhen you enable local sandboxing, Copilot CLI runs most of the commands and tools it invokes on your behalf inside an operating-system sandbox. After you enable local sandboxing, it is used for all your Copilot CLI sessions until you disable it, or turn it off for a specific session. If enterprise managed settings require sandboxing, you cannot disable it.\n\nBy default, sandboxed commands and tools can write within your current working directory and temporary folders. Your user profile (home) directory, along with system and tool locations are read-only. Other disk locations are blocked. In a Git repository, the rest of the repository above your current working directory is readable but not writable. Access to your local and private network is permitted, as is outbound internet access.\n\nBy default, authenticated Git and GitHub CLI (`gh`) operations continue to work inside the sandbox, because Copilot CLI makes your GitHub credentials available to sandboxed commands. This allows actions such as `git push` and `gh pr create` to succeed. You can turn this off in your sandbox settings.\n\nFor a conceptual overview of sandboxing in Copilot CLI, see [About cloud and local sandboxes for GitHub Copilot](/en/copilot/concepts/about-cloud-and-local-sandboxes).\n\n## Sandbox commands\n\nYou manage local sandboxing from within a Copilot CLI session using the `/sandbox` slash command. It has the following subcommands.\n\n| Command            | Description                                                                                                                                                                                                                                                                                                                          |\n| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `/sandbox status`  | Show whether sandboxing is currently being used for the session. See [Checking whether sandboxing is being used](#checking-whether-sandboxing-is-being-used).                                                                                                                                                                        |\n| `/sandbox policy`  | Show the effective filesystem policy for the current directory—the paths that are readable, writable, or blocked, and the network access in force. For more information, see [Understanding filesystem policies for local sandboxing in GitHub Copilot CLI](/en/copilot/concepts/agents/copilot-cli/understanding-local-sandboxing). |\n| `/sandbox config`  | Open the interactive settings interface. Entering `/sandbox` on its own does the same thing. For more information, see [Configuring local sandbox settings](/en/copilot/how-tos/cloud-and-local-sandboxes/configuring-local-sandbox-settings).                                                                                       |\n| `/sandbox enable`  | Turn local sandboxing on. See [Enabling local sandboxing](#enabling-local-sandboxing).                                                                                                                                                                                                                                               |\n| `/sandbox disable` | Turn local sandboxing off. If enterprise managed settings require sandboxing, this is refused. See [Disabling local sandboxing](#disabling-local-sandboxing).                                                                                                                                                                        |\n\n## Enabling local sandboxing\n\nTo enable local sandboxing, enter the following command in an interactive Copilot CLI session:\n\n```shell copy\n/sandbox enable\n```\n\nSandboxing starts being used immediately for the current session.\n\nAfter you enable local sandboxing, it continues to be used for the current and future interactive sessions, and for programmatic sessions.\n\n> \\[!NOTE]\n> If you have other sessions open when you enter `/sandbox enable`, sandboxing is not immediately used in those sessions. To use sandboxing in an already-open session, do either of the following in that session:\n>\n> * Close the session and restart it, for example by running `copilot --continue`.\n> * Enter `/sandbox enable`.\n\n## Disabling local sandboxing\n\nIf enterprise managed settings require sandboxing, you cannot disable it, and `/sandbox disable` is refused.\n\nTo stop using local sandboxing, enter the following command in an interactive Copilot CLI session:\n\n```shell copy\n/sandbox disable\n```\n\nSandboxing is no longer used in the current session, or in new and restarted sessions.\n\nYour choice of whether to use local sandboxing is saved as the `sandbox.enabled` setting in your personal settings file for the CLI (`~/.copilot/settings.json` by default).\n\n## Using sandboxing for a single session\n\nYou can use the `--sandbox` command line option to use sandboxing for a single session, without enabling sandboxing for your other sessions. If sandboxing is already enabled, you can disable it for a single session by using the `--no-sandbox` option. The `--no-sandbox` option cannot override enterprise managed settings that require sandboxing.\n\nYou can combine these options with the `-p` command line option to control sandboxing for programmatic use of the CLI. For example:\n\n```shell copy\ncopilot --sandbox -p \"PROMPT\"\n```\n\n## Running a single command outside the sandbox\n\nWhen a command needs broader access than the sandbox allows, Copilot can request to run that single command outside the sandbox. You are shown a confirmation prompt describing the command, and it runs outside the sandbox only if you approve it; otherwise it stays sandboxed. The rest of your session remains sandboxed either way.\n\nThis behavior is enabled by default and can be turned off in your sandbox settings.\n\n## Checking whether sandboxing is being used\n\nTo check whether local sandboxing is being used for the current session, enter:\n\n```shell copy\n/sandbox status\n```\n\nCopilot CLI reports whether sandboxing is enabled for the session. If your organization's managed settings require sandboxing, the status notes this too. Because the status reflects what the session actually enforces, it is the reliable way to confirm whether the commands Copilot runs are being sandboxed.\n\nTo see not only whether sandboxing is on, but exactly which paths are readable, writable, or blocked, enter `/sandbox policy`. For more information, see [Understanding filesystem policies for local sandboxing in GitHub Copilot CLI](/en/copilot/concepts/agents/copilot-cli/understanding-local-sandboxing).\n\nYou can also see sandbox status at a glance in the status line, which contains `sandbox enabled` when sandboxing is being used. Display of sandbox information in the status line is turned on by default. If it has been turned off, you can turn it back on:\n\n1. Enter `/statusline`.\n2. Move the selection down the list of options to **sandbox**.\n3. Press <kbd>Enter</kbd> to toggle the setting so that it shows a check mark.\n\n## Further reading\n\n* [About cloud and local sandboxes for GitHub Copilot](/en/copilot/concepts/about-cloud-and-local-sandboxes)\n* [Configuring local sandbox settings](/en/copilot/how-tos/cloud-and-local-sandboxes/configuring-local-sandbox-settings)"}