Test any Claude Code plugin without risking your Mac: a throwaway sandbox
Every week someone shares a Claude Code plugin that promises to do half your job: a reel that says "this plugin builds full apps for you", a GitHub repo with a few thousand stars, a link dropped in a Discord. Installing one takes a single command. What that command doesn't show you is what the plugin can do once it's in.
A plugin can bring hooks, commands Claude Code runs on its own at set moments (every prompt you send, every file it edits), and MCP servers, small programs that start on your computer. They run as you, with the same access you have: your SSH keys, the .env files that hold your API keys, your client projects, your Downloads folder. Claude Code's built-in sandbox mode doesn't cover them.
So this is the rule I follow on my own machines: anything from a source I don't know gets tried in a throwaway sandbox first. Setting it up takes about ten minutes, once. After that every test is one command, and the sandbox deletes itself when you leave.
Who this is for
- Freelancers. Your laptop holds three clients' repos and their live API keys. One bad hook is a leak you have to explain to all three.
- Students. You saw a plugin in a reel and want to try it tonight, on the same laptop you need for tomorrow's submission.
- Small business owners. Your Mac has customer lists, invoices and the folder your accountant asked for. None of that should be one install away from a stranger's code.
- Enthusiasts. You try five plugins a week and want every test to start clean, without old plugins and settings piling up.
What the sandbox does
Docker Sandboxes (the sbx command) runs Claude Code inside a small virtual machine on your computer. You don't need Docker Desktop for it.
What a plugin inside it can and can't reach
- Can: the one folder you hand it, to read and change. Keep it empty, or put a throwaway copy of something in it.
- Can: the internet, through a network policy. The "balanced" policy allows AI services, GitHub and package registries, and blocks everything else.
- Can't: the rest of your computer. No home folder, no SSH keys, no other projects.
- Can't: your Claude sign-in token. It stays on your computer, outside the sandbox.
- Gone when you leave: start it with
--rmand the whole sandbox, plugin included, is deleted on exit.
A sandbox lowers the risk, it doesn't remove it. Whatever you type, paste or drop into the lab folder, the plugin can see, and it can still send data to the sites the policy allows. Test with dummy data, never with your real project.
What you need
- A Mac with Apple silicon (M1 or newer) on macOS 14 Sonoma or later. Windows 11 and Ubuntu 24.04 work too, the steps are further down.
- A free Docker account. You can create one during the sign-in step.
- Claude: a Pro or Max subscription, or an Anthropic API key.
- Some free disk space and a decent connection. The first run downloads the Claude image.
Set it up on a Mac with one script
The script does every step in the next section for you. It checks your Mac, installs Homebrew if it's missing, installs sbx, signs you in to Docker, sets the network policy and creates an empty lab folder at ~/claude-lab. You can run it again any time: steps that are already done get skipped.
This whole guide is about not running code you haven't read, so read the script before you run it. It's short, and the full text is at the bottom of this page. Then, in Terminal:
cd ~/Downloads
bash setup-claude-sandbox.sh
Prefer to do it all in Terminal? Download it, page through it, then run it:
curl -fsSL https://blog.redefinedbyai.tech/downloads/claude-plugin-sandbox/setup-claude-sandbox.sh -o setup-claude-sandbox.sh
less setup-claude-sandbox.sh
bash setup-claude-sandbox.sh
It stops twice for you: once for your Mac password (only if it installs Homebrew) and once to sign in to Docker in the browser window it opens. To see what it would do without changing anything, run DRY_RUN=1 bash setup-claude-sandbox.sh.
Or set it up by hand
01Install Homebrew
Skip this if brew --version already works.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
When it finishes it prints two commands under "Next steps" that add Homebrew to your Terminal. Run them, then open a new Terminal window.
02Install sbx
brew trust docker/tap
brew install docker/tap/sbx
Newer versions of Homebrew only install from outside sources you've marked as trusted, which is what the first line does. If it says the command doesn't exist, your Homebrew is older and doesn't need it.
03Sign in to Docker
sbx login
A browser window opens. Sign in, or create a free account there.
04Pick the network policy
sbx policy init balanced
You do this once, and it applies to every sandbox. Balanced lets Claude reach AI services, GitHub and package registries like npm and PyPI, and blocks everything else. See the rules any time with sbx policy ls.
05Make an empty lab folder
mkdir -p ~/claude-lab
Windows and Linux
These steps come from Docker's install guide. I tested the Mac path. Once sbx is installed, the rest of this guide is the same everywhere.
Windows 11 (64-bit Intel or AMD)
Open PowerShell as administrator, turn on the hypervisor, restart, then install:
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All
winget install -h Docker.sbx
Then, in a new PowerShell window: sbx login and sbx policy init balanced.
Ubuntu 24.04 or later (Intel, AMD or Arm)
lsmod | grep kvm
sudo usermod -aG kvm $USER
newgrp kvm
curl -fsSL https://get.docker.com | sudo REPO_ONLY=1 sh
sudo apt install docker-sbx
sbx login
sbx policy init balanced
mkdir -p ~/claude-lab
If the first line prints nothing, KVM isn't available: turn on virtualization (VT-x or AMD-V) in your BIOS first. Docker doesn't support Ubuntu-based systems like Linux Mint or Pop!_OS.
Test a plugin, step by step
01Read the plugin before you run it
Open the plugin's repo. Two places run code on their own, so look there first: the hooks/ folder and any .mcp.json file.
- A hook that runs on every prompt and sends something to a website you don't recognise.
- Anything that reads
~/.ssh,~/.aws,.envfiles or your browser's folders. - Long scrambled strings (base64), or a script downloaded and piped straight into
bash. - An MCP server that installs a package with no source code, or one published by a brand-new account.
Nothing alarming? Test it in the sandbox anyway. Reading catches the obvious problems, the sandbox catches the rest.
02Start a throwaway sandbox
sbx run --rm --skills off --name plugin-lab claude ~/claude-lab
--rmdeletes the sandbox, plugin and all, when you exit.--skills offkeeps your own Claude skills out, so the test starts clean and the plugin can't read them.--name plugin-labgives it a name you'll recognise insbx ls.~/claude-labis the only folder on your computer it can see.
The first run downloads the Claude image, so give it a few minutes. Later runs reuse it.
03Sign in to Claude
Type /login and sign in with your Claude account. You'll do this in every new sandbox, because --rm throws each one away. The token stays on your computer, not inside the sandbox.
Using an API key instead? Store it once, on your computer, not inside the sandbox:
sbx secret set anthropic
It asks for the key and keeps it in your system's keychain. Docker adds it to Claude's requests on the way out, so the key never enters the sandbox.
04Install the plugin
/plugin marketplace add OWNER/REPO
/plugin install PLUGIN-NAME@MARKETPLACE-NAME
The plugin's README gives the exact names. Type /plugin afterwards to check it's installed and turned on.
05Give it fake work
Ask Claude to use the plugin on something you don't mind losing: a tiny demo app it writes for you, a sample spreadsheet, a public repo cloned into the lab folder. Watch what it does and what it asks to run.
If the plugin needs a website the policy blocks, it fails with a network error. Only if you trust that site, allow it for this one sandbox:
sbx policy allow network --sandbox plugin-lab example.com
Run that in a second Terminal window, on your computer, not inside the sandbox.
06Exit, and it's gone
/exit
Back in your Terminal, check nothing is left and empty the lab folder for next time:
sbx ls
rm -rf ~/claude-lab && mkdir ~/claude-lab
07Keep it or drop it
Did it earn a place? Install it for real, but only in the project that needs it:
cd ~/path/to/your-project
claude plugin marketplace add OWNER/REPO --scope project
claude plugin install PLUGIN-NAME@MARKETPLACE-NAME --scope project
Leave out --scope project and Claude Code installs it for your whole account, in every project you open. Didn't earn it? There's nothing to remove: you already deleted it when you exited.
Useful extras
A dashboard in Terminal
sbx tui
An interactive screen for your sandboxes, so you don't have to remember every command.
Keep a sandbox between sessions
Leave out --rm and the sandbox stays. Go back into it with sbx run --name plugin-lab, pause it with sbx stop plugin-lab, and delete it with sbx rm --force plugin-lab.
Add your own tools to every sandbox
Install what you need once inside a kept sandbox, then save it as a template and start new sandboxes from it:
sbx template save plugin-lab my-lab:v1
sbx run --rm --skills off -t my-lab:v1 claude ~/claude-lab
A template copies everything on the sandbox's disk, so save it before you add any keys or sign in to other tools inside it.
Running it on another Mac over SSH
I run my lab on a Mac mini at home and drive it from my laptop over SSH. Two things break there, because macOS keeps the login Keychain locked for SSH sessions, and sbx keeps your Docker sign-in in that Keychain. The setup script handles both when you run it over SSH. If you set it up by hand, here are the fixes.
Error: "macOS Keychain denied access"
Unlock the Keychain in the same command, then run sbx. Type the Mac's login password when it asks.
ssh -t you@your-mac 'zsh -lc "security unlock-keychain ~/Library/Keychains/login.keychain-db && sbx tui"'
Same pattern for sbx login, or any other sbx command that shows this error.
Error: "cannot prompt the user for password"
The sbx background service was started from SSH, so it can't read the Keychain. Restart it inside the Mac's desktop session by opening a tiny script there. On the remote Mac, once:
printf '#!/bin/zsh -l\nsbx daemon restart\n' > ~/sbx-daemon-restart.command
chmod +x ~/sbx-daemon-restart.command
Then, over SSH, every time that Mac restarts:
open ~/sbx-daemon-restart.command
open runs it in a Terminal window on the Mac's own screen, where the Keychain is unlocked. Someone has to be logged in on that Mac's desktop for this to work.
If your connection drops
Close the Terminal window, lose Wi-Fi or let the laptop sleep, and Claude inside the sandbox closes too. What's left depends on how you started the sandbox:
- With
--rm: the sandbox is deleted right away, chat and all. For a throwaway test that's fine: start a fresh one. - Without
--rm: the sandbox stays and your chat is saved inside it.sbxstops the sandbox 30 seconds after its last window closes.
Get your chat back
sbx run --name plugin-lab -- --continue
Anything after -- goes to Claude, and --continue opens your last chat instead of a new one. Already reconnected and landed in a fresh chat? Type /resume in it and pick the earlier one.
This brings back the chat, not the job Claude was doing when the connection dropped. That job stopped, so ask Claude to carry on.
Keep it running through a drop
On a remote Mac, start the sandbox inside screen, which comes with macOS. It keeps running on that Mac when your connection doesn't.
ssh -t you@your-mac 'zsh -lc "screen -dRR lab"'
In the window that opens, start the sandbox as usual, without --rm. If the connection drops, run the same ssh command again: you're back in the same window, and Claude never stopped. To leave on purpose and keep it running, press Ctrl-a, then d.
Make it one word. On your laptop, add this line to ~/.zshrc, open a new Terminal window, and type lab:
lab() { ssh -t you@your-mac "zsh -lc 'screen -dRR lab'"; }
A restart of the remote Mac stops screen and the sandbox. Your chat is still saved, so reconnect with --continue. If sbx then shows a Keychain error, use the fixes in the section above.
When something goes wrong
- "sbx: command not found" right after setup: open a new Terminal window. Still missing? Run
eval "$(/opt/homebrew/bin/brew shellenv)". - The plugin can't reach GitHub or npm: check the rules with
sbx policy ls. Picked the wrong policy?sbx policy reset, thensbx policy init balanced. - Anything else:
sbx diagnosechecks the install, the background service, your sign-in and the network policy, and says what's wrong.sbx daemon restartfixes most stuck states without deleting any sandbox. - Keychain errors on a remote Mac: see the section above.
Remove everything
sbx reset
brew uninstall sbx
rm -rf ~/Library/Application\ Support/com.docker.sandboxes ~/claude-lab ~/sbx-daemon-restart.command
sbx reset stops and deletes every sandbox, policy and stored secret. The last line clears what's left on disk.
Cheat sheet
sbx run --rm --skills off --name plugin-lab claude ~/claude-lab # new throwaway lab
sbx run --name plugin-lab -- --continue # back into a kept sandbox, last chat
sbx ls # list sandboxes
sbx tui # dashboard
sbx rm --force plugin-lab # delete one sandbox
sbx policy ls # network rules
sbx diagnose # health check
The full setup script
The same file as the download. Download setup-claude-sandbox.sh.
#!/usr/bin/env bash
# setup-claude-sandbox.sh
# One-time setup of Docker Sandboxes (sbx) on a Mac, for testing Claude Code
# plugins in a throwaway sandbox instead of on your real machine.
#
# Guide: https://blog.redefinedbyai.tech/posts/claude-plugin-sandbox.html
# Needs: an Apple silicon Mac (M1 or newer) on macOS 14 or later, and a free Docker account.
# Safe to run again: every step that is already done is skipped.
#
# bash setup-claude-sandbox.sh run the setup
# DRY_RUN=1 bash setup-claude-sandbox.sh only print what it would do
# LAB_DIR=~/my-lab bash setup-claude-sandbox.sh use another lab folder
set -euo pipefail
LAB_DIR="${LAB_DIR:-$HOME/claude-lab}"
DRY_RUN="${DRY_RUN:-0}"
say() { printf '\n\033[1m==> %s\033[0m\n' "$*"; }
run() { if [ "$DRY_RUN" = 1 ]; then printf ' [dry run] %s\n' "$*"; else "$@"; fi; }
die() { printf '\nStopped: %s\n' "$*" >&2; exit 1; }
# sbx diagnose prints JSON checks as "name": "...", then "status": "...".
check_passes() { sbx diagnose --json 2>/dev/null | grep -A1 "\"name\": \"$1\"" | grep -q '"status": "pass"'; }
# 1. This Mac
say "Checking this Mac"
[ "$(uname -s)" = Darwin ] || die "this script is for macOS. The Windows and Linux steps are in the guide."
[ "$(uname -m)" = arm64 ] || die "Docker Sandboxes needs an Apple silicon Mac (M1 or newer)."
macos="$(sw_vers -productVersion)"
[ "${macos%%.*}" -ge 14 ] || die "Docker Sandboxes needs macOS 14 (Sonoma) or later. This Mac has $macos."
echo " macOS $macos on Apple silicon: OK"
# 2. Homebrew
say "Homebrew"
if ! command -v brew >/dev/null 2>&1 && [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if command -v brew >/dev/null 2>&1; then
echo " already installed: $(brew --version | head -1)"
else
echo " Installing Homebrew. It asks for your Mac password and to press Return."
hb_url=https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
if [ "$DRY_RUN" = 1 ]; then
echo " [dry run] install Homebrew from $hb_url"
else
/bin/bash -c "$(curl -fsSL "$hb_url")"
eval "$(/opt/homebrew/bin/brew shellenv)"
# So brew and sbx also work in new Terminal windows.
grep -qs 'brew shellenv' "$HOME/.zprofile" || echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
fi
fi
# 3. The sbx command
say "Docker Sandboxes (sbx)"
if command -v sbx >/dev/null 2>&1; then
echo " already installed: $(sbx version | head -1)"
else
# Newer Homebrew only installs from third-party taps you have trusted.
# Older Homebrew has no "trust" command and doesn't need it.
run brew trust docker/tap || true
run brew install docker/tap/sbx
fi
# 4. Over SSH the Mac's Keychain is locked, and sbx keeps your Docker sign-in there.
if [ -n "${SSH_CONNECTION:-}" ]; then
say "Unlocking the Keychain (you are connected over SSH)"
echo " Type this Mac's login password. Nothing shows while you type."
run security unlock-keychain "$HOME/Library/Keychains/login.keychain-db"
fi
# 5. Docker sign-in
say "Docker sign-in"
if check_passes "Authentication"; then
echo " already signed in"
else
echo " Sign in with your Docker account in the browser that opens (sign up there if you have none)."
run sbx login
fi
# 6. Network rules for every sandbox
say "Network policy"
if check_passes "Global network policy"; then
echo " already set"
else
echo " Balanced: AI services, GitHub and package registries are allowed, everything else is blocked."
run sbx policy init balanced
fi
# 7. Over SSH, restart the sbx background service in the Mac's own desktop session.
# A service started from SSH cannot read the sign-in from the Keychain.
if [ -n "${SSH_CONNECTION:-}" ]; then
say "Restarting the sbx service on the Mac's desktop"
restart="$HOME/sbx-daemon-restart.command"
run sh -c "printf '#!/bin/zsh -l\nsbx daemon restart\n' > '$restart' && chmod +x '$restart' && open '$restart'"
echo " A Terminal window opens on the Mac's screen and restarts it."
echo " After every restart of that Mac, run this once over SSH: open ~/sbx-daemon-restart.command"
fi
# 8. An empty folder for tests
say "Lab folder"
run mkdir -p "$LAB_DIR"
echo " $LAB_DIR"
echo " Keep it empty. The plugin you test can read and change anything in it."
cat <<EOF
Done. To test a plugin in a throwaway sandbox:
sbx run --rm --skills off --name plugin-lab claude "$LAB_DIR"
Inside it:
/login sign in to Claude (every new sandbox)
/plugin marketplace add OWNER/REPO add the plugin's marketplace
/plugin install PLUGIN@MARKETPLACE install the plugin
/exit leave; the sandbox is deleted
The first run downloads the Claude image, so it takes a few minutes.
EOF
Why this is worth ten minutes
The first plugin that misbehaves on your real machine costs more than this setup ever will: rotated keys, emails to clients, an evening of checking what was touched. With a lab ready, trying something new stops being a gamble. Read it, run it in the sandbox, keep what works, and let --rm delete the rest.
Found this useful? Browse more articles or follow @m.redefinedbyai for more setups as they land.