GitHub - max-sixty/worktrunk: Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Key Points
- 1Worktrunk is a CLI tool designed to simplify Git worktree management, enabling developers to run multiple AI agents in parallel within isolated working directories.
- 2By streamlining commands for creating, switching, and removing worktrees, the tool eliminates the complexities of manual Git navigation and promotes efficient parallel workflows.
- 3It provides advanced features such as build cache sharing, automated hooks, and AI-generated commit messages to enhance productivity for developers managing multiple concurrent coding tasks.
Worktrunk is a specialized command-line interface (CLI) designed to streamline Git worktree management, specifically optimized for supporting multiple concurrent AI agent workflows. By addressing the verbosity and configuration overhead associated with native Git worktree operations, Worktrunk allows developers to manage 5–10+ parallel development tasks, each isolated within its own working directory to prevent state conflicts.
Core Methodology and Technical Implementation
The tool simplifies Git's native worktree architecture by mapping branch names to predictable directory structures via configurable templates. Unlike standard Git, where users must manually synchronize branches with paths (), Worktrunk abstracts these paths, allowing commands to target branches directly.
Key technical capabilities include:
- State Management and Atomicity: Worktrunk replaces multi-step shell operations with atomic commands. For instance, the
wt switch -c -x [command] [branch]sequence automates:- Branch creation.
- Worktree registration.
- Directory navigation.
- Execution of an external AI agent or setup process.
- Resource Virtualization: To handle the storage overhead of multiple worktrees, Worktrunk implements "copy-on-write" build cache sharing. By leveraging filesystems like APFS, btrfs, and XFS, it enables multiple worktrees to reference the same
target/ornode_modules/directories without redundant disk usage or re-compilation, effectively minimizing the latency of spinning up new environments. - Workflow Automation and Hooks: The CLI utilizes a hook-based architecture that triggers processes on specific lifecycle events such as
create,pre-merge, andpost-merge. This allows for per-worktree customization, such as thehash_porttemplate filter which algorithmically assigns unique development server ports to each worktree, preventing collision in parallel testing environments. - Integrated Intelligence: Worktrunk natively integrates with LLM-based tools to perform post-processing tasks, such as generating commit messages based on local diffs or providing AI-summarized status reports for the
wt list --fullcommand, which displays CI status, PR links, and progress telemetry alongside standard Git metadata.
CLI Operational Logic
The tool redefines the Git workflow primitives through a refined mapping layer:
| Task | Git Native Execution | Worktrunk CLI Logic |
| :--- | :--- | :--- |
| Worktree Switch | cd ../repo.name | wt switch [branch] |
| Lifecycle Cleanup | git worktree remove + git branch -d | wt remove |
| Merge/Sync | Manual rebase/squash/cleanup | wt merge [target_branch] |
By providing a shell integration (), the CLI modifies the user's environment to enable context-switching capabilities that standard Git does not offer, effectively treating worktrees as first-class, ephemeral entities rather than static directory configurations. This architecture allows AI agents to maintain high-context, long-running tasks in parallel with minimal operational friction.