Manages git worktrees for parallel workflows, providing tools for creating, listing, locking, merging, and cleaning up worktrees with agent coordination and conflict resolution capabilities.
treehouse-worktree 🌲
A cross-platform git worktree manager designed for parallel AI agent workflows. Supports both CLI and MCP (Model Context Protocol) interfaces.
Why Treehouse?
When multiple AI agents need to work on the same repository simultaneously, git worktrees provide isolated working directories without the overhead of multiple clones. Treehouse simplifies worktree management with:
Agent coordination - Lock worktrees to prevent conflicts between agents
Automatic setup - Run install commands when creating worktrees
MCP support - Integrate with AI tools via Model Context Protocol
Cursor compatibility - Works with
.cursor/worktrees.jsonconfig format
Quick Start
Installation
CLI Commands
Basic Operations
Agent Coordination
Completing Work
Conflict Resolution
Maintenance
Configuration
Create treehouse.json in your repository root (or use .cursor/worktrees.json for Cursor compatibility):
Configuration Options
Option | Description | Default |
| Directory for worktrees (relative or absolute) |
|
| Default branch for merges ( |
|
| How long locks last before auto-expiring |
|
| Commands to run after creating a worktree |
|
| Unix-specific setup commands | - |
| Windows-specific setup commands | - |
| Enable automatic cleanup |
|
| Remove worktrees older than N days |
|
| Max total size of worktrees |
|
Setup Commands
Setup commands support:
Comments: Lines starting with
#are skippedEnvironment Variables:
ROOT_WORKTREE_PATHenvironment variable contains main repo pathScript files: Point to external scripts instead of inline commands
Example using the environment variable:
MCP Integration
Treehouse includes an MCP server for integration with AI tools like Claude.
Setup
Add to your MCP configuration:
Or with npx:
Available MCP Tools
Tool | Description |
| Initialize configuration |
| List all worktrees |
| Create a new worktree |
| Get worktree status |
| Complete work on a worktree |
| Remove a worktree |
| Lock a worktree for an agent |
| Unlock a worktree |
| Check for merge conflicts |
| Resolve conflicts |
| Abort a merge |
| Prune orphaned entries |
| Clean old worktrees |
Multi-Agent Workflow Example
Programmatic Usage
Config File Search Order
Treehouse looks for configuration in this order:
.cursor/worktrees.jsonin current worktreetreehouse.jsonin current worktree.cursor/worktrees.jsonin repo roottreehouse.jsonin repo root
Requirements
Node.js 18+
Git 2.5+ (worktree support)
Troubleshooting
Common Issues
"Git is not available"
Solution: Install git and ensure it's in your PATH
Verify with:
git --versionTreehouse requires git 2.5 or higher
"Not in a git repository"
Solution: Run
git initfirst, or navigate to an existing git repositoryCheck with:
git status
"Worktree already exists"
Solution: Choose a different name or remove the existing worktree first
List worktrees with:
treehouse listRemove with:
treehouse remove <name>
"Worktree has uncommitted changes"
Solution: Commit or stash changes before removing/completing the worktree
Use
--forceflag to remove anyway (caution: will lose changes)
Setup commands fail on Windows
Solution: Use platform-specific setup commands
Set
setup-worktree-windowsin your configEnsure PowerShell or cmd commands are properly formatted
Lock expired but worktree still shows as locked
Solution: Manually unlock with
treehouse unlock <name>Locks auto-expire based on
lockExpiryMinutesconfig
Metadata out of sync with actual worktrees
Solution: Run
treehouse pruneto clean up orphaned entriesThis syncs metadata with actual git worktrees
Getting Help
Check the GitHub Issues
Read the Contributing Guide
Review the Changelog for recent changes
License
MIT