Skip to main content

Isolated, ready-to-run git worktrees for AI coding agents — host-native or docker-sandboxed.

Project description

treebox

treebox

Isolated, ready-to-run git worktrees for AI coding agents.

CI Documentation Python 3.11+ PolyForm Noncommercial License

Documentation · Install · Usage · How it works · Seth Peters


Run treebox create and it fetches, cuts a worktree from a fresh origin/<base>, copies your .env, installs dependencies from a shared cache, and launches claude or codex inside. No branch name needed up front: the worktree gets a stable name (yours, or a generated petname) and an un-pushable treebox/<name> placeholder branch the agent renames when the work takes shape. Agents work the same repo in parallel without collisions — on a laptop or over plain SSH.

Built by Seth Peters as a small, operator-focused layer for AI agent infrastructure: git worktrees, sandbox boundaries, subscription auth, and repeatable developer environments. If that is the kind of problem you are solving, the docs go deeper on the design tradeoffs.

Provisioning is identical everywhere; a pluggable runner decides where the agent runs:

Runner Isolation Agent runs in
host (default) none the worktree shell
docker sandboxed a docker container, with your .env + caches mounted

Every agent ships its own cage

Every coding agent invents its own answer to "run me in parallel" and "don't let me touch the wrong thing" — a different config file, a different schema, a different word for the same idea:

Agent Sandbox / permission config Built-in worktrees Config lives in
Claude Code permissions allow/ask/deny + native OS sandbox (Seatbelt/bubblewrap) + dev container Yes (--worktree) .claude/settings.json, .devcontainer/
OpenAI Codex sandbox_mode × approval_policy (Seatbelt / Landlock+seccomp) No in CLI (app only) ~/.codex/config.toml, [profiles.*]
opencode permission per-tool allow/ask/deny (no OS sandbox) No (community plugins) opencode.json
pi none built-in ("all permissions by default"); BYO Docker/VM + trust prompt No in core (pi-subagents) ~/.pi/agent/settings.json

Learn one and it teaches you nothing about the next, and none of it ports across tools. treebox owns the isolation layer instead — one worktree-per-branch layout, one operator-owned sandbox, one config file — and launches your agent of choice inside it. Learn treebox once; swap the agent, keep the box. Full comparison with citations: Agents & sandboxing.

Install

curl -fsSL https://raw.githubusercontent.com/Seth-Peters/treebox/main/install.sh | sh

The script installs with uv and stops with instructions if uv is missing — it never installs a package manager behind your back. Or install directly:

uv tool install git+https://github.com/Seth-Peters/treebox

The host runner needs only git and a logged-in agent CLI (claude / codex); the docker runner additionally needs just docker — no Node.js, no extra CLIs. See the install guide for requirements and installer overrides.

Usage

The whole surface is five commands, and a worktree's life runs through all of them.

Check the host. doctor verifies exactly what create will need — git, agent logins, .env, credentials for the required fetch — and prints the fix for anything missing:

treebox doctor

Create. Fetches origin, cuts a worktree from the fresh origin/main, copies .env and submodules, syncs dependencies from the shared cache, and launches the agent:

treebox create                          # generated name (brave-otter), host-native
treebox create fix-auth                 # named up front
treebox create fix-auth --runner docker # sandboxed
treebox create -b feature/auth          # exact existing branch (resume, PR review)
treebox create auth-fixes --base feature/auth   # stack on any base branch

The optional name is one slug token and is the worktree's permanent identity; the branch starts as a treebox/<name> placeholder that a per-worktree pre-push guard keeps un-pushable — rename it conventionally (git branch -m feature/user-auth, fix/login-race, chore/bump-deps, …) when the work has a shape, then push. So a machine-generated name can never become a PR title. -b is the one path that skips the placeholder: it checks out an existing branch exactly.

--base takes any branch, not just main — branch off dev, or stack a new worktree on top of an existing PR's branch, even while that branch is checked out in another worktree. It resolves as the freshly fetched origin/<base>, so push the base first if its latest commits only exist locally.

Enter. Come back to an existing worktree, picking the agent per entry. The ref is the name, the current branch (renames are followed live), or a unique substring of either. Dependencies re-sync only if the lockfile changed since last time:

treebox enter fix-auth --tool claude
treebox enter fix-auth --tool codex -- --resume   # args after -- go to the agent

List. See what exists, what each worktree was last doing, and what has gone stale — sorted by recency, with treebox/* placeholders flagged ⚠ unnamed:

treebox list

Tear down. Remove one or more worktrees — and, when you're done, their branches. Refuses to delete uncommitted work unless forced:

treebox teardown fix-auth brave-otter --delete-branch

treebox is built to be scripted, including by agents: every command takes --json (data to stdout, diagnostics to stderr, a schema that only gains fields), --dry-run prints the exact commands without running them, and exit codes are stable (0 ok · 2 usage · 3 not found · 4 auth · 5 conflict). Full reference in the usage guide.

Design

  • Never silently stale. create requires a successful git fetch origin and branches from the fresh origin/<base>; a failed fetch exits 4 loudly. --no-fetch is the only (explicit) escape.
  • Warmth lives in the cache, not the tree. Installs hardlink from shared caches (~/.cache/uv, the pnpm store, …) reused across worktrees and containers.
  • The sandbox config lives outside the box. The container is rendered from your operator-owned template beside the worktree, never mounted — a boxed agent can't edit its own cage, and the target repo's container config and hooks are ignored.
  • Credentials go in as scoped copies. Only the agents' login files are copied into a throwaway per-worktree dir — never the live ~/.claude / ~/.codex — and treebox uses your subscription login, never ANTHROPIC_API_KEY.

More in how it works.

Configuration

Optional, and user-level only (~/.config/treebox/config.toml) — treebox never reads config from the target repo:

runner = "docker"   # host | docker
tool   = "claude"   # claude | codex
base   = "main"

All keys, shared-cache overrides, setup hooks, and sandbox templates are covered in the configuration guide.

Development

git clone https://github.com/Seth-Peters/treebox && cd treebox
uv run treebox ...                    # run the CLI from the working tree
uv run --extra dev python -m pytest   # unit + integration suite
./scripts/validate.sh                 # lint + tests + live host-runner smoke

Contributing

Small fixes and docs improvements are welcome. See CONTRIBUTING.md. The roadmap is intentionally light for now: ROADMAP.md.

License

PolyForm Noncommercial 1.0.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treebox-0.1.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treebox-0.1.0-py3-none-any.whl (70.7 kB view details)

Uploaded Python 3

File details

Details for the file treebox-0.1.0.tar.gz.

File metadata

  • Download URL: treebox-0.1.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for treebox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8fc3b606737843cf79de633e9d3b39f8d9035f918961758a7a8571160433d44f
MD5 33c6e63a465572fac7311cf4e83d3a05
BLAKE2b-256 321e9ed2b6fd72cb752e3e4e4952edce0bc0118821593f582f95870a0b4147bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for treebox-0.1.0.tar.gz:

Publisher: release.yml on Seth-Peters/treebox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file treebox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: treebox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 70.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for treebox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f11e3991dae9fd300ef8c0bb71ce326be737d4619aa4b55db9de4ab432cba0
MD5 8c4829cb0fd85f633edf4d56ce06b0a5
BLAKE2b-256 8220daafd0d215345deebd53db9f52c6c17fbef6aec1f146db310c1d789f157c

See more details on using hashes here.

Provenance

The following attestation bundles were made for treebox-0.1.0-py3-none-any.whl:

Publisher: release.yml on Seth-Peters/treebox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page