kosa8 / Guides

Guide · GitHub Copilot CLI

How do I run GitHub Copilot CLI in a sandbox?

Updated

Start it with kosa8 agent run copilot. kosa8's built-in copilot kit installs a pinned version of the Copilot CLI in a microVM of its own, shares only your project folder (at /work), and lets it reach only api.githubcopilot.com, api.github.com and registry.npmjs.org. One caveat: the Copilot CLI cannot be pointed at another address, so its GitHub token is passed into the sandbox rather than brokered; give it a token that can do nothing but Copilot requests.

01Steps

  1. Install kosa8 and sign in. It runs on an Apple silicon Mac, x86-64 Linux, or Windows through WSL2.

  2. Make a GitHub token for the Copilot CLI. Create a fine-grained personal access token with the Copilot Requests permission and nothing else, and put it in your shell. The kit passes GITHUB_TOKEN into the sandbox, so the agent can read it; a token scoped this narrowly can only spend Copilot requests.

  3. See what the run would do. --dry-run prints the image, the folder shared, the hosts allowed and how the token is handled, and creates nothing.

  4. Commit, then start it. The agent can change anything in the shared folder, .git included, so commit first. Options go before the kit's name.

  5. Or run one task headless. Arguments after the kit's name go to the Copilot CLI itself. -p runs one prompt and --allow-all-tools lets it act without asking, which is acceptable only because it is sealed in a sandbox that sees one folder.

  6. Review what it did. The sandbox is removed when the CLI exits; your folder keeps the changes. Every request the sandbox made, allowed or refused, is in the audit log.

02What the sandbox contains, and what it does not

  • Files. Only the folder given with -w (the current directory by default) is visible, at /work. Your home directory, SSH keys and other projects are not there.
  • Network. The kit allows api.githubcopilot.com, api.github.com and registry.npmjs.org. Everything else is refused on the host and logged. If your organization's Copilot uses other endpoints, copy the kit with kosa8 agent init copilot and add them to egress_allow.
  • The token. Passed in, not brokered, because the Copilot CLI has no setting for another base URL. kosa8 says so each time you run it.
  • Tool-call checks. The claude kit has a hook that checks each tool call against kosa8's rules before it runs; the copilot kit does not, so the sandbox and the folder you share are the controls.

03Give Copilot sandboxes as tools instead

If you run the Copilot CLI on your machine and only want the commands it runs contained, register kosa8 as an MCP server for it. Copilot can then create sandboxes, run code, read and write files and use git in them.

04Other options

  • The Copilot CLI's own approvals. Without --allow-all-tools it asks before running tools. That is a prompt, not a boundary.
  • A dev container or Codespace. A container or a cloud VM per project separates the agent from your laptop; containers share their host's kernel.
  • A separate VM. A full VM you keep for agents is a strong boundary, without per-run cleanup or an allow-listed network unless you build them.

05FAQ

Can the Copilot CLI read my GitHub token in the sandbox?

Yes. The Copilot CLI cannot be pointed at a different address, so kosa8 cannot broker its token, and the real value is in the sandbox's environment. Use a fine-grained token with only the Copilot Requests permission.

Which hosts can Copilot CLI reach in kosa8?

api.githubcopilot.com, api.github.com and registry.npmjs.org, enforced on the host. Others are refused and recorded in the audit log.

Does it work on Windows?

Yes, through WSL2, once kosa8 wsl setup has run.

What happens to the sandbox afterwards?

It is removed when the CLI exits, cleanly, with an error or on Ctrl-C. --keep keeps it for a look around.

06Get started

Install kosa8 on a Mac, Linux or Windows (WSL2) machine, or make an account and run the same sandboxes on kosa8 Cloud.

07Sources

Related

Updated 2026-11-14