Run Claude Code, Codex, GitHub Copilot, Antigravity, OpenCode, and Pi in isolated containers - same commands, every OS, no Node.js or Python sprawl on your host. All tools share one image (aicontained) with a common runtime, each with its own persistent home directory, and it only ever sees the project directory you launch it from.
| Tool | Command | Entrypoint notes |
|---|---|---|
| Claude Code | claude |
IS_SANDBOX=1 so --dangerously-skip-permissions works as root |
| Codex | codex |
full-access sandbox mode inside the container |
| GitHub Copilot | copilot |
|
| Antigravity | agy |
|
| OpenCode | opencode |
provider-agnostic: ANTHROPIC / OPENAI / GEMINI keys all supported |
| Pi | pi |
provider-agnostic like OpenCode |
Auto-detected per OS, no configuration needed:
| OS | Engine |
|---|---|
| macOS | Apple container (Apple Silicon only, macOS 15+) |
| Linux | Podman (rootless) |
| Windows | WSL Containers (wslc.exe) - native, ships with WSL |
Images are stored per engine and per machine - you must build on each machine you use; there's no shared cache between container, Podman, and wslc.
Single Go binary; all the tool commands (claude, codex, ...) are links to it:
# on Linux/macOS
CGO_ENABLED=0 go run github.com/beppler/aicontained/cmd/aicontained@latest install
# on Windows
$env:CGO_ENABLED="0"; go run github.com/beppler/aicontained/cmd/aicontained@latest installOr from a checkout of this repo:
# on Linux/macOS
CGO_ENABLED=0 go run ./cmd/aicontained install
# on Windows
$env:CGO_ENABLED="0"; go run ./cmd/aicontained installNo Go on the target machine:
Run make from a checkout anywhere (GNU make; on Windows install it with e.g. winget install GnuWin32.Make - writes one binary per platform to dist/), copy the matching dist/aicontained-<os>-<arch> over, and use it as aicontained.
Same on every OS:
aicontained install # copy binary + create all six tool links
aicontained install claude agy # only some tools
aicontained build # build the image with every tool (no install)
aicontained build --no-cache # rebuild from scratch: picks up new tools + OS security patches the build cache can't see
aicontained build --prune-images # also prune dangling build imagesOn a fresh machine run install once, then build. install puts the binary in ~/.local/bin/ (Windows: %USERPROFILE%\.local\bin) and makes one link per tool - add that directory to your PATH.
Upgrading on Windows from a release that installed to %LOCALAPPDATA%\Programs\bin: after install, delete aicontained.exe and the tool .exe links from that old directory and replace it on your PATH with %USERPROFILE%\.local\bin. Otherwise the old binary keeps running.
SSH agent (Linux/macOS): if SSH_AUTH_SOCK is set and the socket exists on the host, it is mounted at /var/run/ssh-agent in the container with SSH_AUTH_SOCK pointing to it, so git pushes and ssh inside the container use your host agent. Windows is not supported yet.
Linux:
Podman is required and networking needs slirp4netns:
sudo apt update && sudo apt install -y slirp4netnsAnd in /etc/containers/containers.conf:
[network]
default_rootless_network_cmd = "slirp4netns"macOS:
Apple container requires Apple Silicon and macOS 15+ (full support on macOS 26). aicontained build starts the daemon for you; on some setups you may need container system start again after a reboot.
Windows (WSL Containers):
One-time setup in an elevated PowerShell if your version is lower than 3.0.1:
wsl --update
wsl --shutdownAfter aicontained install, claude, codex, copilot, agy, opencode, pi work from PowerShell or cmd.exe. Symlink creation there needs Developer Mode (or elevation); without it, install fails with a message saying exactly that. wslc.exe ships as part of WSL itself and runs each container in its own lightweight Hyper-V VM.
Same on every OS from any project directory:
cd ~/my-project
claude # or codex / copilot / agy / opencode / piShell into a tool's container: aicontained shell <tool> starts the same container (mounts, home, env, hardening) with bash as the entrypoint instead of the tool - handy for debugging, inspecting the persisted home, or running the tool with custom flags. Extra arguments go to bash. Inside the shell, a tool started by hand runs without the image's default flags (e.g. codex's sandbox_mode, copilot's --no-auto-update - see Flags in internal/tools/registry.go):
aicontained shell claude # interactive bash in the claude container
aicontained shell codex -c 'ls ~' # run a one-off commandLinked worktrees: launching from a linked worktree needs git 2.45+ on the host and the worktree created with relative paths (git -c worktree.useRelativePaths=true worktree add <path>, or set the config). The launcher mounts the common parent of the worktree and the main checkout — sibling directories are visible in the container — and git works through the relative .git pointer. A worktree with absolute paths (git < 2.45, or created without the config) is refused with instructions to recreate it, as is a worktree whose only common parent with the main checkout is the filesystem root (e.g. repo in ~/deep/nested/repo, worktree in /tmp): keep the worktree next to the main checkout instead. Per-project state is keyed by the mounted folder, so launches from worktrees under the same parent share session history with each other — not with the main checkout. Never run git worktree prune inside a container of a repo that has linked worktrees: registrations whose back-pointers point outside the mount would be deleted. Prune on the host instead.
How mounting works: the current directory is bind-mounted at /workspace/<hash-of-host-path>/<folder-name>. Inside a git repository, the repository root is mounted instead and the tool opens in your subdirectory, so state is shared across the whole repo. The hash is deliberate - these tools key per-project state (sessions, memory, folder trust) by path, so every project must map to a unique in-container path. Side effect: renaming or moving a project on the host gives it a fresh hash and a fresh session history. The same happens once when you start launching from a different directory within the same repo.
Auth persistence: each tool keeps its credentials in a dedicated host folder per tool under ~/.aicontained/ (macOS/Linux) or %USERPROFILE%\.aicontained\ (Windows), bind-mounted as /root in the container - log in once, stay logged in.
Profiles: to keep separate logins for a tool (e.g. work vs. personal), set a profile in ~/.aicontained/aicontained.toml:
[claude]
profile = "personal"The tool then uses claude-home-personal instead of claude-home. Tables are named after the command (claude, codex, copilot, agy, opencode, pi); a missing file, table or empty profile keeps the default folder. Profile names may only contain letters, digits, _, . and -, may not be . or .. or end with ., and are case-insensitive (always folded to lowercase). A table without a profile key is an error — this catches typos like profil that would otherwise silently fall back to the default folder; fix or delete the offending table.
| Tool | Method | Notes |
|---|---|---|
| Claude, Antigravity | Browser OAuth | prints a URL/code to paste into your host browser - like SSH login |
| Codex, Copilot | Device code | browser OAuth can't work: the callback server binds 127.0.0.1 inside the container, reachable from nowhere - no port-forwarding fix is possible |
| Antigravity (personal accounts) | API key | OAuth unavailable; set GEMINI_API_KEY in a .env in antigravity-home - get one at Google AI Studio |
| OpenCode | Any | reads whichever of ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY (or GOOGLE_API_KEY) is set, or opencode auth login in-container |
| Pi | Any | reads whichever of ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY is set, or /login in-container |
API keys from your shell are passed through automatically (the binary is a native Windows process, so PowerShell env vars work directly - no WSL-side configuration).
OpenAI device-code login is disabled by default and must be enabled first:
- Personal account: ChatGPT → Settings → Security → enable device code login
- Team/Enterprise/Edu: a workspace admin must allow it under Workspace Settings → Permissions → "Allow device code login" - it's greyed out for regular members otherwise
Or skip login entirely:
# on Linux/macOS
export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY / GEMINI_API_KEY
# on Windows
$env:ANTHROPIC_API_KEY = "..."Tools run as root inside their containers - that root is not your host root:
- rootless Podman maps container root to your own user
- Apple
containerandwslcrun each container in a lightweight per-container VM
Linux hardening (applied automatically by the launcher on Podman):
--security-opt no-new-privileges
--cap-drop=ALL --cap-add=CHOWN,DAC_OVERRIDE,FOWNER,FSETID,SETUID,SETGID
The retained capabilities are what file handling and apt-get install inside the container need; everything else is dropped (including network admin, raw sockets, kill, chroot, and capability editing), so no privilege escalation via setuid.
Claude skip-permissions: the image sets IS_SANDBOX=1, which lets claude --dangerously-skip-permissions run as root (Claude Code otherwise refuses it when running as root). It's still opt-in - plain claude asks for permissions as usual.
opencode keeps a service registration in its state directory, which can't be shared between running instances. Each opencode run therefore mounts its own temporary state folder over /root/.local/state/opencode, named after the launcher's PID and removed when the run ends:
~/.aicontained/opencode-home/.local/state/opencode-<pid>
A crash or kill -9 can leave one behind. To list orphans - folders whose PID has no running process (Linux/macOS):
for d in ~/.aicontained/opencode-home/.local/state/opencode-*; do
[ -d "$d" ] || continue
kill -0 "${d##*-}" 2>/dev/null || echo "orphan: $d"
doneOn Windows:
Get-ChildItem "$env:USERPROFILE\.aicontained\opencode-home\.local\state" -Directory -Filter 'opencode-*' |
Where-Object { -not (Get-Process -Id ($_.Name -replace '^opencode-','') -ErrorAction SilentlyContinue) } |
ForEach-Object { "orphan: $($_.FullName)" }Orphans are safe to delete. A reused PID can make an orphan look alive, so a folder that is never listed isn't proof that it's in use.
What persists between runs: model selection (model.json), prompt history (prompt-history.jsonl), and the release-highlights "seen" marker (latest/tui/highlights.json - without it the "What's new" dialog would open on every run) are seeded from, and saved back to, the shared state folder (~/.aicontained/opencode-home/.local/state/opencode) on every run. Only service.json (the per-run server registration) and the rest of latest/ and locks/ stay ephemeral. With concurrent instances, the last to exit wins for model.json and the marker; prompt history merges instead, because each run appends only entries not already in the shared JSONL file. If a run crashes before the save-back, the previous saved copy is used.
The launcher sets core.autocrlf=true and core.filemode=false for Git inside the container on Windows runs - via GIT_CONFIG_* env vars, so only Windows runs are affected and the images stay portable. That keeps repos cloned on Windows from showing every file as modified.
Two caveats:
- A committed
.gitattributesstill takes precedence. - These settings override the repo's
.git/config- a deliberately LF-only repo (core.autocrlf=false) can get files rewritten to CRLF by agit checkoutorgit stash popinside the container.
Go tools (gofmt -l lists every file): gofmt treats CRLF as unformatted, and core.autocrlf can't help because the files really are CRLF on disk. Commit a .gitattributes with *.go text eol=lf (this repo does), then refresh the working tree: git rm --cached -r -q . && git reset --hard (commit or stash changes first).
Still seeing phantom diffs? Check with git diff --ignore-cr-at-eol --stat; if needed, set the same two values in the repo's .git/config and add to the project's CLAUDE.md/AGENTS.md: "This working tree uses Windows line endings. Never convert or 'fix' line endings." Don't run dos2unix - it only moves the phantom changes to the Windows side and breaks .bat/.cmd files.
Tools now run from the single aicontained image, so run aicontained build first (required). Older versions built aicontained-base plus one aicontained-<tool> image per tool; remove them to free the space (image prune skips tagged images):
podman images --format '{{.Repository}}' | grep '^localhost/aicontained-' | xargs -r podman rmiFor container or wslc, use that engine's own rmi/image delete.
The project was renamed to aicontained. Do these steps before running any tool, so your logins carry over:
mv ~/.cli-tools ~/.aicontained # Windows: rename %USERPROFILE%\.cli-tools to .aicontained
aicontained install # re-point the tool links at the new binary
aicontained build # images are renamed too, so rebuild them (required)
rm ~/.local/bin/cli-tools # Windows: delete cli-tools.exe from %LOCALAPPDATA%\Programs\bin (older installs) or %USERPROFILE%\.local\bin
podman images --format '{{.Repository}}' | grep '^localhost/cli-tools-' | xargs -r podman rmi # old imagesFor container or wslc, remove the old cli-tools-* images with that engine's own rmi/image delete.
If you already ran a tool after upgrading, ~/.aicontained exists and mv would nest the old folder inside it; merge the folders by hand instead.
MIT - see LICENSE.