Skip to content

Instantly share code, notes, and snippets.

@crusaderky
Last active May 18, 2026 14:40
Show Gist options
  • Select an option

  • Save crusaderky/f4f68ffb196136bb33e7113dca803b3d to your computer and use it in GitHub Desktop.

Select an option

Save crusaderky/f4f68ffb196136bb33e7113dca803b3d to your computer and use it in GitHub Desktop.
Bubblewrap for Claude and Pi
# /etc/apparmor.d/bwrap
# To load: sudo apparmor_parser -r /etc/apparmor.d/bwrap
abi <abi/4.0>,
include <tunables/global>
profile bwrap /usr/bin/bwrap flags=(unconfined) {
userns,
include if exists <local/bwrap>
}
#!/bin/bash
# Run Claude with read/write permissions in pwd and no access anywhere else
DIR="$(realpath "$PWD")"
exec bwrap \
--ro-bind / / \
--dev /dev \
--proc /proc \
--tmpfs /tmp \
--tmpfs /home \
--tmpfs /root \
--ro-bind "$HOME/.pixi" "$HOME/.pixi" \
--ro-bind "$HOME/.local/bin/claude" "$HOME/.local/bin/claude" \
--ro-bind "$HOME/.local/state/claude" "$HOME/.local/state/claude" \
--ro-bind "$HOME/.local/share/claude" "$HOME/.local/share/claude" \
--bind "$HOME/.claude" "$HOME/.claude" \
--bind "$HOME/.claude.json" "$HOME/.claude.json" \
--bind "$HOME/.cache/claude" "$HOME/.cache/claude" \
--bind "$HOME/.cache/claude-cli-nodejs" "$HOME/.cache/claude-cli-nodejs" \
--bind "$DIR" "$DIR" \
--chdir "$DIR" \
--die-with-parent \
--unshare-all --share-net \
-- claude --dangerously-skip-permissions "$@"
# Run Pi with read/write permissions in pwd and no access anywhere else
DIR="$(realpath "$PWD")"
exec bwrap \
--ro-bind / / \
--dev /dev \
--proc /proc \
--tmpfs /tmp \
--tmpfs /home \
--tmpfs /root \
--ro-bind "$HOME/.pixi" "$HOME/.pixi" \
--ro-bind "$HOME/.nvm" "$HOME/.nvm" \
--bind "$HOME/.pi" "$HOME/.pi" \
--bind "$DIR" "$DIR" \
--chdir "$DIR" \
--die-with-parent \
--unshare-all --share-net \
-- pi "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment