Grepedia
WO

Worktrunk

A Git worktree manager designed to optimize parallel AI agent workflows by automating branch environment setup, cleanup, and task integration.

Score1
About

Worktrunk is a command-line interface developed by Max Sixty designed to streamline git worktree management, specifically for users running multiple AI agent workflows in parallel. Git's native worktree functionality allows developers to maintain multiple working directories for different branches, preventing code changes from interfering with one another. However, native commands are often verbose and repetitive. Worktrunk simplifies this by addressing worktrees by branch name, with directory paths computed from configurable templates. This enables developers to easily create, list, switch, and remove worktrees with minimal manual input, making managing parallel development environments efficient and less prone to errors. It is built to support scenarios where an engineer might need to manage 5 to 10+ tasks simultaneously.

Worktrunk enables developers to handle complex workflows through three core commands that mirror the simplicity of branching, while providing advanced automation through a powerful hook system and workflow-specific utilities. The tool excels at managing the complexity of parallel state, allowing for isolated dev servers, databases, and dependencies for each active branch. By integrating with AI agent workflows, such as Claude Code, Worktrunk provides a foundation where agents can operate in isolated directories without collision, using specialized automation to handle commits, merges, and cleaning up environments upon completion.

Some of the key features are:

  • Git Worktree Management: Simplified commands for creating, listing, switching, and removing worktrees that eliminate repetitive path handling.
  • Workflow Automation Hooks: Robust support for custom shell scripts that run on specific events like creation, pre-merge, post-merge, and removal.
  • Interactive Picker: A built-in terminal UI to browse worktrees with live previews of diffs, commit logs, and status updates.
  • LLM Commit Message Generation: Automates the creation of commit messages by sending diffs to configured LLM CLIs.
  • Dependency and Cache Sharing: Includes utilities to copy gitignored files like node_modules or build caches between worktrees to eliminate cold starts.
  • Parallel Process Tethering: Ensures processes like dev servers are automatically terminated when their associated worktree is removed.
  • Per-Branch Variable State: Stores configuration state for individual branches to facilitate isolated database connections and unique environment setups.
  • PR and MR Shortcuts: Direct checkout of pull requests or merge requests by ID using specialized syntax.

Worktrunk is used by executing standard CLI commands that handle the underlying Git operations automatically. Users define configuration files, such as ~/.config/worktrunk/config.toml for user-wide settings and .config/wt.toml for project-specific configurations, to define custom templates, hook behaviors, and alias commands. When a worktree is created, the system triggers designated hooks that can perform setup tasks like installing dependencies or initializing containers, allowing the developer or AI agent to begin work immediately in a fully provisioned environment. Once the task is complete, Worktrunk can squash changes, rebase onto the main branch, merge, and clean up the worktree and branch in one operation.

Some common use cases include:

  • Parallel Agent Workflows: Running multiple AI coding agents in separate worktrees to work on distinct feature branches simultaneously without environment pollution.
  • Rapid Feature Branching: Quickly creating new, clean worktrees for urgent hotfixes or small experimental tasks.
  • Isolated Local Environments: Maintaining individual database and dev server instances for different branches using port hashing to prevent collisions.
  • Streamlined Pull Request Reviews: Jumping directly into an existing PR's branch for testing or modifications without manual setup steps.
  • Squash and Merge Automation: Consolidating branch history into clean, single-commit merges before deleting the ephemeral worktree.