Skip to content

feat(claude-code): share Bun's store across projects; keep sandbox volumes separate - #239

Merged
gatezh merged 3 commits into
fix/sandbox-firewall-sudofrom
feat/shared-volumes
Oct 22, 2026
Merged

gatezh merged 3 commits into
fix/sandbox-firewall-sudofrom
feat/shared-volumes

Conversation

@gatezh

@gatezh gatezh commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What

Every project's default variant now shares one Bun package store. The sandbox and the default variant deliberately share no volumes, and the docs now say so.

Why

  • claude-code: share volumes via fixed compose names (variants per project, Bun store across projects) #236: each devcontainer kept its own Bun cache plus a full node_modules, which filled Docker's disk in a downstream pilot. Bun 1.4.4 (2026-10-22) fixes the global-store bug that blocked the pilot.
  • [BUG] default and sandbox variants don't share volumes (Compose project-name prefix) #209: the template and README said the variants share Claude config, history and the gh and cf logins. They never did: Compose prefixes devcontainer.json mounts with the project name (myproject_… vs myproject-sandbox_…). This PR first made them share through fixed-name compose volumes. Review showed that this is a sandbox escape, so the second commit keeps them separate and corrects the docs instead:
    • Claude Code honors bypassPermissions and skips workspace trust only for user settings (~/.claude/settings.json), and edits there don't show in git diff. A sandbox agent, which runs with prompts skipped, could plant a hook or bypass mode that runs in the default variant (passwordless sudo, no firewall).
    • A shared ~/.config/gh hands the sandbox the gh auth login token (repo, gist scopes) while GitHub is allowlisted. The cf login and shell history leak the same way.

Changes

  • Shared Bun store: the default variant mounts bun-global-store at ~/.bun/install/cache, declared in docker-compose.yml with a fixed name: so every project shares it. The sandbox doesn't mount it.
  • Image: pre-creates /home/node/.bun/install/cache node-owned, so a new store volume is seeded with the right owner. verify-image.sh checks the owner on both targets.
  • Config volumes stay in mounts, one set per variant and worktree, as on master. No volume is renamed, so existing projects keep their sign-ins.
  • Template comments: both devcontainer.json files drop "default and sandbox variants share volumes", and the sandbox's CLAUDE_CODE_OAUTH_TOKEN is now the documented sign-in path, not an optional one.
  • README:
    • New "Volumes" table, a "Why the variants don't share volumes" section with the reason for each volume, and a "Shared Bun store" section (linker = "isolated", globalStore = true, trust model, CI cache note, reset).
    • Sandbox Authentication, the cf login and the gh one-time setup now describe separate sign-in, with a token for the sandbox and a fine-grained PAT for gh.
  • Guardrails so this isn't reopened: a "Sandbox Volumes" rule in .claude/rules/devcontainer.md (now also loaded for docker-compose.yml), and the devcontainer-upstream-sync skill reports a project that shares sandbox volumes as a security finding.
  • Template mise.toml: Bun 1.3.8 → 1.4.4, Hugo 0.155.1 → 0.168.0.
  • Review follow-ups: the store reset uses bun pm cache rm, Bun's documented way to clear the cache including the global store. The sandbox gh sign-in pastes the token on stdin instead of reading a token.txt, which in a devcontainer tends to land in /workspace.

Notes

Testing

End-to-end with the devcontainer CLI 0.89.0 on the first commit, in a helper container. Two projects were made from the template with React 19, cmdk, TypeScript, linker = "isolated", globalStore = true and Bun 1.4.4:

Check Result
Project A, default variant bun-global-store is unprefixed and owned by node with no chown. react links into ~/.bun/install/cache/links/. tsc passes.
Project B, default variant First bun install took 39 ms, linking react from the same store entry as project A. tsc passes.
Sandbox bun-global-store not mounted. Firewall verification passed.
Bun version, plain oven/bun images 1.4.3 fails with the pilot's TS7006 (cmdk loses React types). 1.4.4 typechecks cleanly.

On the second commit: docker compose config on both compose files, a JSONC parse of both devcontainer.json files (the config mounts match master), and a check that every README #anchor resolves.

Closes #236
Closes #209

@gatezh gatezh changed the title feat(claude-code): share config volumes across variants and Bun's store across projects feat(claude-code): share Bun's store across projects; keep sandbox volumes separate Oct 22, 2026
…re across projects

devcontainer.json `mounts` reach Compose as service volumes, which Compose
prefixes with the project name. myproject and myproject-sandbox therefore
never shared the volumes the README said they shared (#209).

- Both compose files declare the Claude config, zsh history, gh and cf volumes
  with fixed `name:`s, so both variants mount the same ones.
- The default variant also mounts `bun-global-store` at ~/.bun/install/cache,
  shared by every project. The sandbox doesn't mount it.
- node_modules stays in `mounts`, per variant and per worktree: with Bun's
  global store, the default's node_modules link into a volume the sandbox
  lacks.
- The image pre-creates ~/.bun/install/cache node-owned, so a new store volume
  needs no chown. CI verify checks it.
- The template's mise.toml pins Bun 1.4.4, the first release whose global store
  keeps @types-peered packages' types (oven-sh/bun#36795).
- README: a new Volumes section covering the shared Bun store, how to opt in
  with globalStore, the trust model, and how to upgrade existing volumes. The
  upstream-sync skill substitutes the compose volume names.

Closes #236
Closes #209
…t variant

Sharing ~/.claude, the gh and cf logins and shell history with the sandbox let
a prompt-injected sandbox agent plant user-scope hooks or bypassPermissions
that run in the default variant (passwordless sudo, no firewall), and handed
it the gh token while GitHub is allowlisted.

- Config volumes go back to devcontainer.json `mounts`, where Compose's
  project prefix keeps each variant's own. No volume rename, so no migration.
- Only bun-global-store stays compose-declared with a fixed name.
- README: "Why the variants don't share volumes"; the sandbox signs in with
  CLAUDE_CODE_OAUTH_TOKEN, gh with a fine-grained token.
- Review rule and sync skill flag sharing as a security regression.
…urrent Hugo pin

- The Bun store reset uses `bun pm cache rm`, which the Bun docs give for
  clearing the cache including the global store, and needs no container
  stopped. Deleting the volume stays as the heavier option.
- The sandbox gh sign-in pastes the token on stdin instead of reading
  token.txt, which in a devcontainer tends to land in /workspace, the host repo.
- The template mise.toml pins Hugo 0.168.0 (was 0.155.1), the version
  ralphex-fe ships and one #211's safe.directory fix applies to.
@gatezh
gatezh force-pushed the feat/shared-volumes branch from 208a4cc to c7d1f10 Compare October 22, 2026 22:45
@gatezh
gatezh changed the base branch from master to fix/sandbox-firewall-sudo October 22, 2026 22:45
@gatezh
gatezh added this pull request to stack #244 October 22, 2026 22:46
@gatezh
gatezh merged commit e4fbd28 into master Oct 22, 2026
15 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant