[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111776":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":14,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":22,"topics":23,"createdAt":10,"pushedAt":31,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":15,"starSnapshotCount":15,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},111776,"blackhole","tommy0103\u002Fblackhole","tommy0103","A blackhole for your Claude Code. ","https:\u002F\u002Ftommy0103.github.io\u002Fblackhole\u002F",null,"Shell",112,19,1,0,3,10,46.4,"MIT License",false,"main",true,[24,25,26,27,28,29,30],"agent","claude-code","colima","container-isolation","macos","sandbox","virtio-fs","2026-11-10 16:24:45","2026-11-20 15:07:36","# Blackhole\n\nEnglish · [中文](README.zh-CN.md)\n\nRun [Claude Code](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code) in a Linux container using [Colima](https:\u002F\u002Fgithub.com\u002Fabiosoft\u002Fcolima) on macOS or an existing Docker engine on Linux\u002FWindows WSL2. Only the current project directory is mounted, and login volumes persist between sessions. Windows clipboard capture and proxy-only network access are available on WSL2.\n\n## Background\n\nRunning `claude` directly on a macOS host exposes two things at once: your local filesystem (`~\u002F.ssh`, cloud credentials, Docker sockets, sibling repositories) and your **host environment fingerprint** (macOS hardware identifiers, locale\u002Ftimezone settings, host username, environment variables, and direct network interfaces if a proxy drops).\n\nBlackhole replaces the host `claude` command with a pure Bash launcher (`~\u002F.local\u002Fbin\u002Fclaude -> bin\u002Fblackhole`). **Claude Code does not need to be installed on the host** — the actual `@anthropic-ai\u002Fclaude-code` package lives inside the Docker image. Typing `claude` in a project starts an ephemeral Linux container using Colima on macOS or the existing Docker engine on Linux\u002FWSL2. The Colima features below have Docker equivalents described under installation and network control:\n\n- **Directory-scoped mount**: Only `$PWD` is mounted at `\u002Fworkspace` over Colima's `virtiofs`. Host `$HOME`, SSH agents, and Docker sockets are never mounted.\n- **Host fingerprint isolation**: Runs inside a clean Debian container with `--hostname blackhole`, a remapped `node` user matching `\u002Fworkspace` UID\u002FGID, and a strict environment variable allowlist (`TERM`, `COLORTERM`, `NO_COLOR`, and optional API keys) — hiding macOS host telemetry, usernames, and environment variables.\n- **Fail-close network egress protection**: Built-in `net ipv6 off`, guest `iptables` airgap (`net off`), and a fail-close proxy watcher (`net-watch`) with a companion heartbeat guard ensure VMs are immediately cut off if your host TUN proxy drops, preventing accidental direct-connection IP leaks.\n- **Persistent login & session registry**: Credentials and transcripts live in a per-profile Docker volume (`blackhole-claude-home-\u003Cprofile>`), with `SessionStart` \u002F `SessionEnd` hooks tracking `profile \u003C-> session \u003C-> host path`.\n- **Clipboard image passthrough & visual identity**: Pasted terminal screenshots in host `$TMPDIR` are mirrored read-only at identical paths inside the container, while a persistent magenta `⬤ BLACKHOLE` status line badge makes isolated sessions unmistakable.\n\n## Usage\n\n> **Tip: Let an agent drive it.** You do not need to memorize every subcommand below. Point your host coding agent at this repository (see [`AGENTS.md`](AGENTS.md)) and let it handle setup, Colima profile binding, `.blackhole\u002FDockerfile` tool customization, `net-watch` protection, and session exports or migrations on your behalf.\n\nRun `claude` inside any project directory under `$HOME`:\n\n```bash\n$ cd ~\u002FCode\u002Fmy-app\n$ claude\n ⬤ BLACKHOLE  Colima VM isolated session · default\n\u002FUsers\u002Fyou\u002FCode\u002Fmy-app (only this directory is mounted)\n```\n\nAll standard arguments pass straight through to Claude Code inside the VM:\n\n```bash\nclaude -p \"explain this repository\"\nclaude --resume\n```\n\nCheck launcher protection, image state, and active containers from another terminal:\n\n```bash\n$ blackhole status\nBackend:        colima\nProfile:        default\nClaude launcher: protected (\u002FUsers\u002Fyou\u002F.local\u002Fbin\u002Fclaude)\nColima:         running\nImage:          blackhole-claude:latest\nImage status:   built\nClaude Code:    1.0.x (Claude Code)\nImage ID:       sha256:...\nConfig volume:  blackhole-claude-home-default\nActive sessions:\n  blackhole-default-48210  \u002FUsers\u002Fyou\u002FCode\u002Fmy-app\n```\n\nBind a project directory to a dedicated Colima VM profile (inherited by subdirectories, stored in `~\u002F.blackhole\u002Fbindings\u002F` outside the repo):\n\n```bash\n$ cd ~\u002FCode\u002Fheavy-repo\n$ blackhole bind work\nblackhole: bound \u002FUsers\u002Fyou\u002FCode\u002Fheavy-repo -> profile 'work'\n```\n\nInspect profiles, recorded sessions across all running VMs, and resume any session by ID prefix from anywhere:\n\n```bash\n$ blackhole profiles\nPROFILE  STATUS   MEMORY  BLACKHOLE  PROJECTS  SESSIONS  LAST USED\ndefault  Running  8GiB    yes        3         12        2026-11-08 11:20\nwork     Running  16GiB   yes        1         4         2026-11-08 12:05\nscratch  Stopped  4GiB    -          -         -         -\n\n$ blackhole sessions\nPROFILE  SESSION                               PATH                        STARTED           LAST ACTIVE       STATUS\nwork     89e4f9ec-8960-4175-9bb0-4bbea4780fa9  \u002FUsers\u002Fyou\u002FCode\u002Fheavy-repo  2026-11-08 10:12  2026-11-08 12:05  ended\n\n$ blackhole resume 89e4\nblackhole: resuming 89e4f9ec-8960-4175-9bb0-4bbea4780fa9 on profile 'work' in \u002FUsers\u002Fyou\u002FCode\u002Fheavy-repo\n```\n\nOpen an interactive debugging shell in the exact same isolated container environment:\n\n```bash\nblackhole shell\n```\n\n## Install\n\n### macOS\n\nRequires **macOS**, **[Colima](https:\u002F\u002Fgithub.com\u002Fabiosoft\u002Fcolima)**, and the **Docker CLI** (`brew install colima docker`). You do **not** need to install Claude Code or Node.js on the host (`blackhole setup` installs `@anthropic-ai\u002Fclaude-code` inside the VM image). Start your Colima VM with Apple Virtualization (`vz`) and `virtiofs` for near-native filesystem performance:\n\n```bash\ncolima start --vm-type vz --mount-type virtiofs --cpu 4 --memory 8 --disk 60\n```\n\nBuild the base image and install the `claude` and `blackhole` symlinks (defaults to `~\u002F.local\u002Fbin`):\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Ftommy0103\u002Fblackhole.git ~\u002FCode\u002Fblackhole\ncd ~\u002FCode\u002Fblackhole\n.\u002Fbin\u002Fblackhole setup\n.\u002Fbin\u002Fblackhole install\n```\n\nEnsure `~\u002F.local\u002Fbin` precedes other binary directories in your `PATH`:\n\n```bash\nexport PATH=\"$HOME\u002F.local\u002Fbin:$PATH\"\n```\n\nTo install into another directory or replace an existing host `claude` binary:\n\n```bash\n.\u002Fbin\u002Fblackhole install --prefix \u002Fopt\u002Fhomebrew\u002Fbin --force\n```\n\nTo uninstall, remove the symlinks (`rm -f ~\u002F.local\u002Fbin\u002Fclaude ~\u002F.local\u002Fbin\u002Fblackhole`) and optionally remove `~\u002F.blackhole`, the `blackhole-claude:latest` image, and `blackhole-claude-home-*` Docker volumes.\n\n### Windows (WSL2) and Linux\n\nRun the launcher **inside a Linux\u002FWSL2 terminal**. The lightweight route is [Docker Engine in Ubuntu](https:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Fubuntu\u002F), reusing your existing WSL2 distribution. Docker Desktop is optional: if already installed, enable its [WSL2 integration](https:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Ffeatures\u002Fwsl\u002F). No Colima, nested VM, host Node.js, or host Claude Code installation is needed.\n\nFirst make `docker info` work as your normal WSL user with a rootful Docker Engine (see Docker's [post-install instructions](https:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002Flinux-postinstall\u002F)). Rootless Docker is currently unsupported: it maps host-owned project files to container UID 0, which prevents Blackhole's non-root session user from editing ordinary `0755` directories and `0644` files. The launcher rejects rootless sessions before building images or creating containers; select a rootful Docker context accessible to your normal user. Avoid running the launcher with `sudo`, which changes the home directory and profile state. Then, in WSL:\n\n```bash\ndocker info\nmkdir -p ~\u002FCode\ngit clone https:\u002F\u002Fgithub.com\u002Ftommy0103\u002Fblackhole.git ~\u002FCode\u002Fblackhole\ncd ~\u002FCode\u002Fblackhole\n.\u002Fbin\u002Fblackhole setup\n.\u002Fbin\u002Fblackhole install\nexport PATH=\"$HOME\u002F.local\u002Fbin:$PATH\"\ncd ~\u002FCode\u002Fmy-app\nclaude\n```\n\nThe backend defaults to `colima` on macOS and `docker` on Linux\u002FWSL2. `BLACKHOLE_BACKEND` overrides detection. Docker profiles share the selected engine and image cache, with separate `blackhole-claude-home-\u003Cprofile>` credential\u002Fsession volumes; `blackhole bind work` creates no VM. Existing Docker contexts and `DOCKER_HOST` are respected. Keep projects under `~\u002FCode` for [WSL filesystem performance](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002Ffilesystems); `\u002Fmnt\u002Fc\u002F...` paths, spaces, and Unicode are supported too. `.gitattributes` keeps executable scripts in LF format when cloning on Windows.\n\n| Capability | macOS \u002F Colima | Linux \u002F WSL2 Docker |\n| --- | --- | --- |\n| Project mount, profiles, sessions, export, custom images | Supported | Supported, one shared engine |\n| Fail-close egress | VM `net-watch` \u002F `iptables` | Opt-in proxy-only internal network, `net off\u002Fon\u002Fstatus` |\n| Clipboard images | Automatic macOS temp-file mirror | On-demand `clipboard paste` via Windows interop |\n\nOrdinary sessions add no watcher or extra daemon beyond Docker. Proxy-only sessions add one unprivileged Node relay using the same image, capped at **64 MiB RAM and 0.25 CPU**, removed on normal session exit. No GPU is requested. Each proxy session has its own internal network; idle networks are removed with the relay. A forcibly killed launcher may need its labeled relay\u002Fcontainer cleaned up manually.\n\nThe `column` utility is optional: profile, binding, project, and session lists fall back to tab-separated output when it is unavailable.\n\n## CLI & Configuration\n\n### Subcommands\n\n| Command | Description |\n| --- | --- |\n| `claude [args...]` | Launch Claude Code inside the selected backend's container for `$PWD` |\n| `blackhole setup [--claude-version VER]` | Build or rebuild the base image (and project image if `.blackhole\u002FDockerfile` exists) |\n| `blackhole update [--claude-version VER]` | Alias for `setup` to rebuild with the latest (or specified) Claude Code version |\n| `blackhole install [--prefix DIR] [--force]` | Symlink `claude` and `blackhole` into `DIR` (default `~\u002F.local\u002Fbin`) |\n| `blackhole status` | Show profile, launcher protection, image ID, FUSE state, and active sessions |\n| `blackhole shell` | Start an interactive `bash` shell inside the project's isolated container |\n| `blackhole bind \u003Cprofile> [dir]` | Bind a project directory (and its subdirectories) to a profile |\n| `blackhole bindings` \u002F `blackhole unbind [dir]` | List directory bindings or remove a directory's binding |\n| `blackhole profiles` | List profiles and recorded project\u002Fsession counts (Docker profiles share engine resources) |\n| `blackhole projects` | List mapped projects (`PROFILE`, `PATH`, `LAST USED`, `SESSIONS`) across running VMs |\n| `blackhole sessions` | List recorded sessions across running VMs with live `active` \u002F `ended` \u002F `unknown` status |\n| `blackhole resume [--profile P] [--dry-run] \u003Cprefix>` | `cd` to the recorded host path and resume the matching session on its profile |\n| `blackhole export [--profile P] [-o FILE] \u003Cprefix>` | Export a session JSONL transcript from the Docker volume to `~\u002F.blackhole\u002Fsessions\u002F\u003Cprofile>\u002F` |\n| `blackhole export-watch start\\|status\\|stop` | Background daemon that atomically re-exports a session JSONL when its contents change |\n| `blackhole net off\\|on\\|status [--all \\| --profile P]` | Colima VM airgap, or Docker profile proxy relay controls |\n| `blackhole net ipv6 off\\|on\\|status [--all \\| --profile P]` | Disable or enable guest IPv6 via `sysctl` and `ip6tables` |\n| `blackhole net-watch start\\|status\\|stop` | Fail-close proxy watcher that blocks VM networking when the host TUN\u002Fproxy drops |\n| `blackhole clipboard start\\|status\\|stop\\|disable\\|enable` | Manage the host `$TMPDIR` screenshot mirror for terminal image paste |\n| `blackhole clipboard paste [relative.png]` | WSL2: capture a Windows clipboard image into the project and print its `\u002Fworkspace\u002F...` path |\n| `blackhole signal send --file PATH (--data JSON \\| --message TEXT \\| --stdin)` | Atomically write a signal file from the host to wake `blackhole-signal wait` inside the container |\n\n### Environment Variables\n\n| Variable | Default | Description |\n| --- | --- | --- |\n| `BLACKHOLE_BACKEND` | `auto` | `colima` on macOS, `docker` on Linux\u002FWSL2; either can be selected explicitly |\n| `BLACKHOLE_PROFILE` | `default` (or binding) | Generic profile override; takes precedence over `BLACKHOLE_COLIMA_PROFILE` |\n| `BLACKHOLE_COLIMA_PROFILE` | `default` (or bound profile) | Override Colima profile selection (`env` > directory binding > `default`) |\n| `BLACKHOLE_PROXY` | *(not set)* | Docker proxy-only egress, `http:\u002F\u002Fhost:port` without credentials; saved per profile and reused across terminals |\n| `BLACKHOLE_IMAGE` | `blackhole-claude:latest` | Force a specific container image and bypass `.blackhole\u002FDockerfile` |\n| `BLACKHOLE_HOME_VOLUME` | `blackhole-claude-home-\u003Cprofile>` | Override the Docker volume mounted at `\u002Fhome\u002Fnode` |\n| `BLACKHOLE_STATE_DIR` | `~\u002F.blackhole` | Host directory for bindings, exported transcripts, clipboard mirror, and watcher state |\n| `BLACKHOLE_CLIPBOARD` | `1` | Set to `0` to disable `$TMPDIR` image mirroring and container mounting for a session |\n| `BLACKHOLE_FUSE` | `0` | Set to `1` to enable `\u002Fdev\u002Ffuse` inside the container (or `touch .blackhole\u002Ffuse`) |\n| `BLACKHOLE_ALLOW_BROAD_MOUNT` | `0` | Set to `1` to bypass the safety check blocking `\u002F`, `\u002FUsers`, and `$HOME` |\n| `ANTHROPIC_API_KEY` | *(not set)* | Passed through to the container only if exported on the host |\n| `CLAUDE_CODE_OAUTH_TOKEN` | *(not set)* | Passed through to the container only if exported on the host |\n| `NO_COLOR` | *(not set)* | Disable ANSI colors in the launch banner, status line, and shell prompt |\n\n### Per-Project Linux Tools\n\nmacOS Mach-O binaries under `\u002Fopt\u002Fhomebrew\u002Fbin` cannot run inside a Linux VM. To give a project extra Linux CLI tools or build dependencies, create `.blackhole\u002FDockerfile`:\n\n```dockerfile\nARG BLACKHOLE_BASE=blackhole-claude:latest\nFROM ${BLACKHOLE_BASE}\n\nRUN apt-get update \\\n    && apt-get install -y --no-install-recommends \\\n        gh jq ffmpeg libfuse3-dev \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n```\n\nRun `blackhole setup` (or simply `claude`, which builds missing project images automatically). Only `.blackhole\u002F` is sent as the Docker build context, and the image tag (`blackhole-claude:project-\u003Chash>`) is derived from the project path and Dockerfile content hash.\n\n### Network Control & Proxy Kill Switch\n\nBlock or restore outbound internet access inside running VMs using the guest `BLACKHOLE_AIRGAP` `iptables`\u002F`ip6tables` chain (loopback, Docker internal `172.16.0.0\u002F12`, and the host gateway stay reachable so `colima ssh` and `docker` keep working):\n\n```bash\nblackhole net off --all\nblackhole net status\nblackhole net on --all\nblackhole net ipv6 off --all\n```\n\nIf you route host traffic through a TUN proxy (such as Shadowrocket, Surge, or Clash) and want VMs cut off immediately if the proxy drops, start `net-watch`:\n\n```bash\nblackhole net-watch start\nblackhole net-watch status\nblackhole net-watch stop   # Leaves network blocked (fail-close); run 'blackhole net on --all' to restore\n```\n\n`net-watch` is **fail-close**: it blocks VM networking before probing `https:\u002F\u002Fwww.google.com\u002Fgenerate_204` (defaults: `--interval 1`, `--fail-after 2`, `--recover-after 2`, `--timeout 15`, requires default route over `utun*`), and spawns an independent `__net-guard` process that blocks all VMs if the watcher's heartbeat goes stale or gets killed with `SIGKILL`. For non-TUN HTTP proxies, pass `--no-require-tun --proxy URL --url URL`.\n\n#### Linux \u002F WSL2 proxy-only egress\n\nFor Docker, set an explicit HTTP proxy reachable **from Docker containers**, such as the HTTP\u002Fmixed port of a Windows proxy. An HTTP proxy can tunnel HTTPS destinations with CONNECT. Only unauthenticated `http:\u002F\u002Fhost:port` endpoints are currently supported. For native Docker in WSL2 NAT mode, the Windows host is usually the WSL default gateway; the proxy must listen on an address reachable from WSL. For Docker Desktop, `host.docker.internal` addresses the host. Native Engine maps that name to its Docker host (WSL itself), which is not necessarily Windows. Check the endpoint for your network mode; Blackhole does not modify Windows proxy settings or firewall rules.\n\n```bash\n# Example for native Docker in WSL2 NAT mode; replace the port as needed.\nexport BLACKHOLE_PROXY=\"http:\u002F\u002F$(ip route show default | awk '{print $3; exit}'):7890\"\nclaude\n# From another terminal, in the same bound project\u002Fprofile:\nblackhole net status\nblackhole net off\nblackhole net on\n```\n\nClaude joins only a Docker `--internal` network. An unprivileged relay, with no project\u002Fcredential mounts or published ports, forwards TCP to the configured proxy. `HTTP_PROXY`\u002F`HTTPS_PROXY` and their lowercase equivalents point to this relay. Programs ignoring these variables fail to reach the internet. A stopped proxy or relay cannot fall back to a direct external route, so no TUN polling or heartbeat process is needed. The upstream proxy's own routing policy still determines its public exit IP; this does not anonymize accounts or sandbox a hostile kernel.\n\nGuarded sessions use an explicit container-local DNS upstream (`127.0.0.1`), retaining Docker's local relay alias resolution while preventing inherited host DNS forwarding on older engines affected by [CVE-2024-29018](https:\u002F\u002Fgithub.com\u002Fmoby\u002Fmoby\u002Fsecurity\u002Fadvisories\u002FGHSA-mq39-4gv4-mvpx). The relay resolves its configured upstream normally.\n\nThe endpoint persists at `~\u002F.blackhole\u002Fdocker-proxy\u002F\u003Cprofile>.proxy`, preventing accidental direct access in a fresh terminal. `net off` stops only that profile's relays and latches future sessions offline; `net on` restarts them. Neither command changes networking for other WSL services or Docker containers. Existing unguarded sessions must be restarted with proxy mode before network controls can protect them. Status checks running containers: it reports `unguarded-sessions` or `BLOCK-FAILED` instead of claiming isolation when protection is incomplete. `--all` attempts all configured profiles and returns an error if any profile cannot be controlled. `net-watch` and VM-wide `net ipv6` remain Colima-only. To deliberately return a profile to ordinary Docker networking, end its sessions and remove its `.proxy` and `.proxy.blocked` state files.\n\nDocker internal networks still permit access to their gateway's host services, as described in [Docker's network documentation](https:\u002F\u002Fdocs.docker.com\u002Freference\u002Fcli\u002Fdocker\u002Fnetwork\u002Fcreate\u002F#network-internal-mode---internal); they do not isolate the container from every local host service.\n\n#### Windows clipboard capture\n\nTake a screenshot with **Win+Shift+S**, then run this from a second WSL terminal in the same project:\n\n```bash\nblackhole clipboard paste\n# \u002Fworkspace\u002F.blackhole\u002Fclipboard\u002F20261110-120000-1234.png\n# Paste the printed path into Claude, or use a chosen relative destination:\nblackhole clipboard paste images\u002Fscreenshot.png\n```\n\nThis invokes Windows PowerShell in STA mode once and returns PNG data via .NET without opening a project path from Windows. A Python helper saves the complete image using pinned directory handles and an atomic hard link that refuses existing targets, including concurrent symlink replacements. Parent-directory symlinks and traversal are rejected. It preserves the Windows clipboard. WSL interop, `powershell.exe`, `wslpath`, Python 3, and a filesystem supporting hard links are required. There is no background clipboard polling or automatic TUI key injection. On Linux without Windows interop, put image files in the project instead.\n\n### Cross-Process File Signals\n\nBecause Claude Code has no official API to push messages into an idle interactive TUI, external host runners (such as Codex or CI scripts) can synchronize with Claude inside the container via file signals inside the project workspace:\n\n```bash\n# Inside the container (Claude): block until .blackhole\u002Fsignals\u002Ftests.json is created or updated\nblackhole-signal wait --file .blackhole\u002Fsignals\u002Ftests.json --timeout 1800\n\n# On the host (external runner): atomically write the result\nblackhole signal send --file .blackhole\u002Fsignals\u002Ftests.json \\\n  --data '{\"status\":\"passed\",\"summary\":\"42 tests passed\"}'\n```\n\n`blackhole-signal wait` waits for content to stabilize across a poll interval (`--interval 500` ms default, `--since \u003Cepoch|ISO>` supported, 1 MiB max file size; exit codes: `0` signal, `1` error, `124` timeout). Treat signal payloads as untrusted data — never `eval` them.\n\n### Migrating Sessions Across Profiles\n\nSession transcripts live inside the profile's Docker volume at `\u002Fhome\u002Fnode\u002F.claude\u002Fprojects\u002F-workspace\u002F\u003Csession-id>.jsonl`. To copy credentials and a session between profiles, stage the archive under `$HOME` (Colima does not mount `\u002Ftmp`):\n\n```bash\nstage=\"$HOME\u002F.cache\u002Fblackhole-migrate\" && mkdir -p \"$stage\"\nDOCKER_HOST=\"unix:\u002F\u002F$HOME\u002F.colima\u002Fdefault\u002Fdocker.sock\" docker run --rm \\\n  -v blackhole-claude-home-default:\u002Fhome\u002Fnode:ro -v \"$stage:\u002Fbackup\" \\\n  --entrypoint tar blackhole-claude:latest -C \u002Fhome\u002Fnode -cf \u002Fbackup\u002Fsession.tar \\\n  .claude\u002F.credentials.json .claude\u002Fprojects\u002F-workspace\u002F\u003Csession-id>.jsonl\nDOCKER_HOST=\"unix:\u002F\u002F$HOME\u002F.colima\u002Fwork\u002Fdocker.sock\" docker volume create blackhole-claude-home-work\nDOCKER_HOST=\"unix:\u002F\u002F$HOME\u002F.colima\u002Fwork\u002Fdocker.sock\" docker run --rm \\\n  -v blackhole-claude-home-work:\u002Fhome\u002Fnode -v \"$stage:\u002Fbackup:ro\" \\\n  --entrypoint tar blackhole-claude:latest -C \u002Fhome\u002Fnode -xf \u002Fbackup\u002Fsession.tar\nrm -rf \"$stage\"\n```\n\n## Caveats\n\n### Mount & Isolation Boundary\n\nEvery `claude` container starts with `--security-opt no-new-privileges`, `--pids-limit 512`, and at most three mounts (the clipboard mirror is macOS-only):\n\n| Host \u002F Volume Source | Container Target | Mode | Purpose |\n| --- | --- | --- | --- |\n| `$PWD` | `\u002Fworkspace` | `rw` | Live project bind mount (`virtiofs` on Colima) |\n| `blackhole-claude-home-\u003Cprofile>` | `\u002Fhome\u002Fnode` | `rw` | Claude login credentials, settings, and session registry |\n| `~\u002F.blackhole\u002Fclipboard` | Host `$TMPDIR` path | `ro` | Mirrored terminal clipboard screenshots |\n\n- **Filesystem isolation, not a hostile-kernel sandbox**: Containers have outbound network access to reach the Anthropic API unless `blackhole net off` is active. Guest `iptables` rules (`net off` \u002F `net-watch`) are a convenience kill switch, not a hard boundary against root processes inside the VM. Do not set `BLACKHOLE_IMAGE` to an untrusted image.\n- **FUSE mode reduces isolation**: Enabling FUSE (`touch .blackhole\u002Ffuse` or `BLACKHOLE_FUSE=1`) drops `no-new-privileges` and adds `--device \u002Fdev\u002Ffuse --cap-add SYS_ADMIN --security-opt apparmor=unconfined` so `fusermount3` can mount filesystems inside the container. Enable only for trusted projects.\n- **Clipboard scope & timing**: Only image files (`png`, `jpg`, `jpeg`, `gif`, `webp`, `heic`, `tiff`, `bmp`) created in host `$TMPDIR` are mirrored (polled every `0.5s`, pruned after 7 days). Files dragged from `~\u002FDesktop` or `~\u002FDownloads` are not mounted unless copied into the project directory.\n- **Shared profile volume**: Running multiple concurrent sessions on the same Colima profile shares one `\u002Fhome\u002Fnode` volume; configuration writes can race. Modifying `bin\u002Fblackhole` or rebuilding the image with `blackhole setup` only affects newly launched sessions, not containers already running.\n\n### virtiofs Performance\n\nBenchmarked on Apple Silicon macOS comparing host native `APFS`, container `\u002Fworkspace` (`virtiofs` shared mount), and container `\u002Ftmp` (VM-internal `ext4` disk):\n\n| Workload | Host Native (`APFS`) | Container `\u002Fworkspace` (`virtiofs`) | Container `\u002Ftmp` (`ext4`) | Notes |\n| --- | :---: | :---: | :---: | --- |\n| **64 MB sequential write (`fsync`)** | `16.4 ms` (3.9 GB\u002Fs) | **`53.7 ms` (1.2 GB\u002Fs)** | `37.4 ms` (1.7 GB\u002Fs) | GB\u002Fs throughput; no bottleneck for large files |\n| **64 MB sequential read** | `5.0 ms` (12.8 GB\u002Fs) | **`20.1 ms` (3.2 GB\u002Fs)** | `3.6 ms` (17.7 GB\u002Fs) | Near-native cached read speed |\n| **Create 1,000 × 1 KB files** | `58.4 ms` | **`196.0 ms`** (0.19 ms\u002Ffile) | `15.4 ms` | ~0.2s per 1,000 files |\n| **`stat` 1,000 files** | `4.7 ms` | **`33.9 ms`** (0.03 ms\u002Ffile) | `3.6 ms` | Scanning a 10k-file repo takes ~0.3s |\n| **Read 1,000 × 1 KB files** | `10.4 ms` | **`126.3 ms`** (0.12 ms\u002Ffile) | `5.1 ms` | Indistinguishable for `rg` and code edits |\n| **Delete 1,000 × 1 KB files** | `35.2 ms` | **`109.2 ms`** (0.11 ms\u002Ffile) | `5.3 ms` | ~0.1s per 1,000 files |\n\nFor metadata-heavy builds with tens of thousands of temporary files (such as Rust `cargo build`), point build caches at `\u002Ftmp` inside the container (e.g., `CARGO_TARGET_DIR=\u002Ftmp\u002Ftarget`) to run at native VM `ext4` speed while keeping source files synced in `\u002Fworkspace`.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","Blackhole 是一个为 macOS（及 Linux\u002FWSL2）设计的轻量级安全沙箱工具，用于隔离运行 Anthropic 的 Claude Code CLI。它通过 Colima 或 Docker 启动专用 Linux 容器，仅挂载当前项目目录，屏蔽主机敏感路径（如 ~\u002F.ssh、Docker socket）、环境变量和硬件指纹，并提供网络代理失效自动断网、持久化登录状态、剪贴板图像透传等安全增强功能。核心基于 Shell 实现，依赖 virtio-fs 隔离与 iptables 空气墙机制，无需在宿主安装 Claude Code。适用于开发者在本地安全调用 AI 编程助手，尤其适合处理含敏感凭证或需规避主机信息泄露的代码审查、原型开发等场景。",2,"2026-11-24 04:41:45","CREATED_QUERY"]