Run Claude Code in a box when you want an interactive coding agent inside a remote, forkable workspace. This works well when you want to prepare one baseline once, then open parallel task boxes that all start from the same repo and tools.
Prepare the box
sys9 run box create claude-lab --image docker.io/library/node:22-bookworm
sys9 run box exec claude-lab -it bash
Inside that shell:
# inside the shell:
apt-get update
apt-get install -y git
npm install -g @anthropic-ai/claude-code
mkdir -p /work
git clone <your-repo-url> /work/your-repo
ls /work/your-repo
exit
Replace <your-repo-url> with the repo URL you actually use. For the smoothest first setup, start with the HTTPS URL for that repo. If the repo is private, or you prefer an SSH repo URL, prepare the Git credential you need inside claude-lab first. Product SSH only gets you into the box: it does not forward your laptop SSH agent, and the Profile / SSH Keys entry only authenticates box login.
If git clone succeeds and ls /work/your-repo shows your files, later task boxes will inherit that checkout path.
Treat claude-lab as the reusable baseline box. Put your repo, language toolchain, and project dependencies here before you fork, so later task boxes all start from the same prepared state.
That baseline is what lets you Fork & Scale naturally: one snap can become claude-fix-login, claude-write-tests, claude-repro-bug, or any other isolated task branch you need.
Configure Anthropic
Before starting Claude Code, create a Project Secret in the project that owns your box:
printf '%s' "$REAL_ANTHROPIC_API_KEY" | sys9 run project secrets create \
--name anthropic \
--value-file - \
--allowed-host api.anthropic.com \
--header-name X-Api-Key
Copy the generated Placeholder; you will use it as ANTHROPIC_API_KEY inside the box. You can also create the same rule in Portal from Project Settings -> Secrets. To keep the rule limited to one task box, use sys9 run box secrets create <box-id> or create it from that box’s Secrets tab.
Project Secrets only run on boxes with Network = Managed. Create the Claude task box with --network managed, or choose Managed in Portal before starting the Claude Code exec.
Fork a task box from the prepared baseline
When claude-lab has the repo and tools you want every task to inherit, freeze that state and branch from it:
sys9 run box stop claude-lab
sys9 run snap fork --from-box claude-lab
sys9 run box create claude-fix-login --snap <forked-snap-id> --network managed
sys9 run box create claude-write-tests --snap <forked-snap-id> --network managed
sys9 run box create claude-repro-bug --snap <forked-snap-id> --network managed
Keep claude-lab as the reusable baseline. Use claude-fix-login for the real Claude Code session below so later forks still start from the clean prepared state.
Start Claude Code with a Project Secret
sys9 run box exec claude-fix-login -it bash
Then move into the repo checkout you prepared in claude-lab before you start Claude Code.
Inside that shell:
# inside the shell:
cd /work/your-repo
export ANTHROPIC_API_KEY=<project-secret-placeholder>
claude
Replace /work/your-repo with the path you prepared in claude-lab. Start Claude Code from that checkout so the task session opens on the inherited repo instead of the shell’s default directory.
This export is shell-local. Re-export it in each new shell, or save it in the shell profile or wrapper script you use to launch Claude Code.
Inside the box, Claude Code still talks to the normal Anthropic endpoint. The placeholder only appears in the X-Api-Key header; run9 replaces it with the real Project Secret when the request leaves the managed box for api.anthropic.com.
If Claude Code fails before the first prompt, check the box is Managed, the Project Secret allows api.anthropic.com, and this shell still has ANTHROPIC_API_KEY=<project-secret-placeholder>.
claude-fix-login starts with Claude Code, Git, and anything else you prepared in the parent box. Create more boxes from the same snap when you want parallel Claude task branches.