kunchenguid/treehouse
Manage worktrees without managing worktrees.
What it solves
Treehouse manages a pool of reusable, isolated Git worktrees. This prevents the need to manually juggle multiple clones of the same repository or start a fresh worktree for every AI agent session, which often leads to slow performance due to the loss of installed dependencies and build caches.
How it works
Treehouse maintains a pool of worktrees (by default in ~/.treehouse/) for each repository. When a user or agent requests a worktree via treehouse get, the tool scans for an available one (not leased, not in-use, and not dirty). If found, it resets the worktree to the latest default branch; otherwise, it creates a new one in detached HEAD mode.
Once the user exits the subshell or releases a lease, Treehouse terminates lingering processes and returns the worktree to the pool for future reuse, preserving its environment.
Who it’s for
Developers and AI agent operators who need multiple isolated environments for the same project without the overhead of repeated cloning or environment setup.
Highlights
- Reusable Environments: Preserves dependencies and build caches across sessions.
- Durable Leases: Allows non-interactive acquisition of a worktree as a persistent home via
treehouse get --lease. - Conflict-Free: Automatically detects in-use worktrees to prevent agents from interfering with each other.
- Safe Pruning: Includes safety checks to ensure only merged, clean, and idle worktrees are deleted.
- Lifecycle Hooks: Supports
post_createandpre_destroyhooks in the user-level configuration to automate setup and teardown.