Manage worktrees without managing worktrees.
treehouse
Manage worktrees without managing worktrees.
Are you still only working on one task at a time? Are you manually juggling between a few clones of the same repo?
Or... are you starting a new worktree for every agent session, losing all your installed dependencies and build cache each time, and wondering why your agents are slow?
Treehouse helps you manage a pool of reusable, isolated worktrees so each of your agents gets its own environment instantly — no cloning, no conflicts, no coordination overhead.
treehouse puts you into a clean worktree with zero hassel.$ cd myproject # start in your repo as usual
$ treehouse # get a worktree and drop into a subshell
Entered worktree at ~/.treehouse/myproject-a1b2c3/1/myproject. Type 'exit' to return.
# You're now in an isolated worktree.
# Run your AI agent, make changes, do whatever you need.
$ exit # exit the subshell when you're done
Terminated lingering processes: opencode (pid 12345)
Worktree returned to pool.macOS / Linux
curl -fsSL https://kunchenguid.github.io/treehouse/install.sh | shWindows (PowerShell)
irm https://kunchenguid.github.io/treehouse/install.ps1 | iexNix
nix run github:kunchenguid/treehouse
# or pin a specific release tag:
nix run github:kunchenguid/treehouse/v2.3.0Install into your Nix profile:
nix profile add github:kunchenguid/treehouseOr add to your flake inputs:
treehouse = {
url = "github:kunchenguid/treehouse";
inputs.nixpkgs.follows = "nixpkgs";
};The flake exposes #default and #treehouse package outputs, plus apps for nix run.
Go
go install github.com/kunchenguid/treehouse@latestFrom source
git clone https://github.com/kunchenguid/treehouse.git
cd treehouse
make installTreehouse manages a pool of git worktrees per repository, stored under the configured treehouse root.
The default treehouse root is ~/.treehouse/.
You can instead keep the pool inside the project with --root ., so it lives next to the code and is removed with the project.
…base_branch in treehouse.toml, or pass treehouse get --base , to cut worktrees from a branch other than the repository default. Opt-in; unset keeps today's inference. Worktrees stay in detached HEAD — this selects the commit they start at, it does not create or check out a branch.treehouse get --unique-leaf (or set unique_leaf in treehouse.toml) to name new slots - instead of ``, so tooling that derives per-checkout identity from the directory name tells the slots apart. Opt-in; off keeps today's layout, and existing worktrees are never moved.worktree_path in treehouse.toml, or pass treehouse get --worktree-path '', to place new worktrees somewhere a tool requires instead of {pool}/{slot}/{repo}. Opt-in, and creation-only: worktrees already in the pool keep their recorded paths. See Worktree path.treehouse, treehouse get, and treehouse enter start $SHELL as an interactive login shell when it resolves to bash, fish, or zsh. Other shells, fallback shells, and Windows use their default invocation. A regular executable that is merely named like a supported shell but does not accept -i -l (for example a wrapper script at /opt/tools/bash) is an accepted limitation: the resolved basename is the contract, and PATH-identity probing would reject genuine second installs of the same shell.get, destroy, and prune lifecycle work is running.treehouse get --lease reserves a worktree as a persistent home without keeping a process inside it. Each acquisition gets an immutable random lease identity, and the lease is recorded in treehouse's own state. The worktree is never handed out by a later get and never removed by prune until you release it with treehouse return. Unlike process-based in-use detection, a lease survives with zero processes running inside the worktree..worktreeinclude file for the default selection, or pass get --include-file for a personal manifest. Selected local files are copied from the main checkout on each acquire. See Seeding gitignored files.git status output.treehouse prune removes only idle managed worktrees whose HEAD is already merged into the default branch and whose working tree is clean.
treehouse prune --all applies the same safety checks across every managed pool under the user-level treehouse root.
Backing-repository-missing orphans are reported by default; --prune-orphans includes them as unverified prune candidates, and --yes is required before deletion.
It is a dry run unless you pass --yes.treehouse get prunes stale git worktree bookkeeping (e.g. left behind by a crashed or forcibly removed worktree) before adding a new worktree, so a prunable registration never wedges the pool with a "missing but already registered worktree" error.| Command | Description |
|---|---|
treehouse |
Get a worktree and open a subshell (alias for get) |
treehouse get |
Acquire a worktree from the pool |
treehouse get --lease |
Durably lease a worktree without a subshell; print its path |
treehouse lease |
Durably lease an existing pool worktree in place, without touching its files or git state |
treehouse enter |
Open a subshell in an existing worktree by name (the number from status), even if it is in use; pool state is left untouched |
treehouse status |
Show pool status (highlights leased and current worktrees) |
treehouse return [path] |
Release any lease and return a worktree only after verifying foreign processes stopped |
treehouse prune |
Dry-run removal of stale idle worktrees in the current repo pool |
treehouse prune --all |
Dry-run removal of stale idle worktrees across every managed pool |
treehouse destroy |
Dry-run removal of one worktree (safe by default; --yes to execute) |
treehouse destroy --all |
Dry-run removal of every disposable worktree in that pool |
treehouse init |
Create a default treehouse.toml config file |
treehouse update |
Update treehouse to the latest version |
| Command | Flag | Description |
|---|---|---|
get |
--lease |
Durably lease the worktree without opening a subshell; print only its path to stdout |
get |
--lease-holder |
Optional label recorded as the lease holder (defaults to $TREEHOUSE_LEASE_HOLDER) |
get |
--json |
Print path, lease_id, lease_holder, leased_at, and base_branch as JSON (requires --lease) |
get |
--base |
Branch to cut this worktree from, overriding base_branch in config |
get |
--include-file |
Replace committed .worktreeinclude for this acquisition with the supplied manifest |
get |
--unique-leaf |
Name a newly created worktree directory - instead of ``, overriding unique_leaf in config |
get |
--worktree-path |
Template for a newly created worktree's directory, overriding worktree_path in config |
lease |
--lease-holder |
Optional label recorded as the lease holder (defaults to $TREEHOUSE_LEASE_HOLDER) |
lease |
--json |
Print path, lease_id, lease_holder, leased_at, and base_branch as JSON (base_branch is best-effort: empty when the slot records no explicit base and its own worktree cannot resolve a default) |
enter |
--print-path |
Print only the worktree's absolute path to stdout instead of opening a subshell (for cd "$(treehouse enter --print-path 1)") |
status |
--json |
Print worktree status and lease metadata as JSON |
return |
--force |
Clean, reset, and return without prompting |
return |
--if-lease-id |
Return only if the current lease has the expected per-acquisition identity |
return |
--if-lease-holder |
Return only if the current lease has the expected holder |
prune |
--yes |
Delete listed prune candidates instead of doing a dry run |
prune |
--all |
Sweep every managed pool under the user-level treehouse root |
prune |
--global |
Alias for --all |
prune |
--prune-orphans |
Include backing-repository-missing orphans in prune candidates |
prune |
--verbose, -v |
Show detailed skip diagnostics |
destroy |
--all |
Remove all worktrees in the named pool (requires a pool path) |
destroy |
--yes |
Execute the removal instead of doing a dry run |
destroy |
--include-unlanded |
Also remove dirty, unmerged, or unverified worktrees (irreversible data loss) |
destroy |
--include-in-use |
Also remove worktrees with a running process or owner reservation (processes are terminated cleanly first) |
destroy |
--include-leased |
Also remove a leased worktree; only when the exact path is named, never via --all |
Commit a .worktreeinclude file to seed selected gitignored files from the main checkout into each acquired Git worktree or jj workspace. This is useful for local configuration or generated files that every worktree needs but Git should not track. By default, only the committed file at the worktree's HEAD is used; a dirty or untracked .worktreeinclude in the main checkout is ignored, and a missing committed file is a no-op.
Manifests use .gitignore pattern syntax. A file must be ignored by the repository and selected by the manifest; tracked files and unignored untracked files are never copied. Use ! to exclude a broader match:
.env*
!.env.local
local-config/For a personal selection that does not need to be committed, pass an explicit manifest:
treehouse get --include-file ./personal.include
treehouse get --lease --include-file ./personal.includeThe supplied manifest replaces, rather than extends, committed .worktreeinclude for this acquisition, on both new and r
No open issues yet, or sync has not completed.