Lazyworktree
repository·main·Indexed 42 days ago
https://github.com/chmouel/lazyworktreeA terminal-based Git worktree manager and workspace orchestration tool built with Go and the Bubble Tea framework. It provides a keyboard-first TUI for managing worktrees with integrated CI/CD and Forge (GitHub/GitLab) visibility, PR-driven creation, and shell integration helpers for Bash, Zsh, and Fish to enable rapid directory jumping.
What's inside Lazyworktree
- LazyWorktree is a terminal-based Git worktree manager optimized for speed, context, and focus. It provides a keyboard-first interface to manage Git worktrees, specifically designed to handle large repositories efficiently by using a Go-based implementation powered by the Bubble Tea framework.
Overview of LazyWorktree features
mainLazyWorktree is a terminal-based Git worktree management tool designed to create, switch, and remove worktrees without leaving your editor context. It provides a keyboard-first UX for managing multiple simultaneous checkouts of the same repository.
Core Capabilities
- Worktree Management: Create, rename, remove, absorb, and prune worktrees. Switch between them without the churn of traditional branch checkouts.
- Development Workflow: Perform Git operations (stage, unstage, commit, diff) in-terminal. View CI checks and logs from GitHub/GitLab. Open PR/MR links directly.
- Container Integration: Run commands inside OCI containers (Docker/Podman) with automatic worktree mounting for isolated, reproducible builds.
- Customisation: Configure settings globally, per repository, or via CLI overrides. Add custom command bindings for shell, tmux, or zellij.
Access built-in workflows via the Command Palette
mainThe command palette surfaces several categories of built-in workflows:
- Worktree actions:
create,delete,rename,set icon,set colour,absorb,prune, andsync. - Commit flow: Search for
Open commit screento open the staged commit modal. - Git operations: Access
lazygit,cherry-pick, anddiff viewing. - Navigation and pane controls:
focus pane,toggle zoom, andswitch layout. - Settings: Perform
theme selectionwith live preview.
- Worktree actions:
Understand multiplexer (tmux/zellij) behavior
mainWhen using multiplexers like
tmuxorzellij, be aware of the following:- Session Name Sanitisation: Session names are sanitised to remove invalid characters. If your worktree path contains special characters, the resulting session name may differ from the path.
- Existing Session Behavior: Controlled by the
on_existsconfiguration:attach: (Default) Attach to the existing session.replace: Close the existing session and create a new one.ignore: Do nothing.
- CLI
execLimitations: Thenew-tabcommand is not supported in CLIexecmode because it requires a running multiplexer session (available only in the TUI). Useshellorcommandtypes for CLI-based commands.
Understand the `.wt` file Trust Model (TOFU)
mainLazyWorktree uses a Trust On First Use (TOFU) model for executing
.wtfiles. Key implications include:trust_mode: never: This setting blocks all.wtcommand execution. Init and terminate hooks will never run.- File Modifications: In
tofumode, any change to a.wtfile (including whitespace) changes its hash. This invalidates the stored trust and triggers a re-approval prompt to prevent silent execution of modified commands. - Storage: Trust decisions are stored per-file in
~/.local/share/lazyworktree/trusted.json, keyed by the file content hash. Deleting this file resets all trust decisions. - Team Workflows: Trust decisions are local. If a team modifies a
.wtfile, every developer will be prompted to re-approve the new hash independently.
Understand branch name sanitization and suggestions
mainLazyworktree applies specific rules to ensure branch names are Git-compatible and safe for directory names:
Sanitization Rules:
- Special characters are converted to hyphens (
-). - Leading and trailing hyphens are removed.
- Consecutive hyphens are collapsed into a single hyphen.
- Length is capped at 50 characters for manual names and 100 characters for automatically generated names.
Suggested Names: If you do not provide an explicit name when creating a worktree, the tool pre-fills the prompt with a random
adjective-nounsuggestion (e.g.,scrupulous-stable,heedful-foxglove). These are generated from a pool of over 58,000 pairings and are guaranteed to be lowercase ASCII without punctuation.- Special characters are converted to hyphens (
Understand LazyWorktree configuration precedence
mainLazyWorktree uses a layered configuration model. If a setting is defined in multiple places, the source with the highest precedence wins. The order from highest to lowest precedence is:
- CLI overrides: Using the
--configflag. - Git local configuration: Settings stored in the current repository via
git config --local. - Git global configuration: Settings stored globally via
git config --global. - YAML file: The primary configuration file located at
~/.config/lazyworktree/config.yaml. - Built-in defaults: The fallback values used if no other configuration is provided.
- CLI overrides: Using the
Note on 'new-tab' command in CLI mode
mainThenew-tabcommand type is not supported when usinglazyworktree execfrom the CLI. This command requires an active multiplexer session (liketmuxorzellij) which is only accessible when the TUI is running. To run commands via CLI, useshellorcommandtypes instead.Understand the LazyWorktree interface layout
mainThe TUI is organized into six distinct panes. You can focus a specific pane by pressing its corresponding number key (
1through6).Pane Key Content Worktree List 1All Git worktrees with branch, note markers, and status indicators Status / CI 2PR/MR info, CI check results, divergence status, and notes preview Git Status 3Changed files in the selected worktree (collapsible tree view) Commit Log 4Commit history for the selected branch Notes 5Per-worktree notes (visible only when a note exists) Agent Sessions 6Open Claude, Codex, Copilot, and pi sessions attached to the selected worktree Note on Agent Sessions: Agent Sessions is the final pane in the
Tabcycle when visible. By default, it shows only live agent processes. PressAwithin the pane to include offline history, or press6to reveal historical matches when nothing is currently open.Configure LazyWorktree using layered configuration
mainLazyWorktree uses a layered configuration model. Settings are applied in the following order of precedence (later stages override earlier ones):
- Built-in defaults: Provided by
DefaultConfig(). - YAML configuration: Loaded from the standard config location or an explicit file provided via the
--configflag. - Git global config: Settings defined via
git config --global lw.*. - Git local config: Settings defined via
git config --local lw.*for the current repository. - Runtime CLI overrides: Flags passed during execution via
bootstrap.
Note: There is no
LAZYWORKTREE_*environment variable configuration cascade. Repository lifecycle hooks are loaded from.wtfiles rather than a repo-local YAML app config.- Built-in defaults: Provided by
Configure Worktree Notes storage
mainLazyworktree allows you to persist notes for your worktrees. You can choose between two storage modes via
worktree_note_type:onejson(default): All notes are stored in a single shared JSON file defined byworktree_notes_path. This is ideal for cross-system synchronization as keys are relative to the repo/worktree.splitted: Each worktree gets its own individual markdown file. In this mode,worktree_notes_pathacts as a template using the following variables:$REPO_OWNER$REPO_REPONAME$WORKTREE_NAME
worktree_note_type: "splitted" worktree_notes_path: "~/notes/$REPO_OWNER/$REPO_REPONAME/$WORKTREE_NAME/note.md"Understand the positioning and use cases of lazyworktree
mainlazyworktree is a human-first workspace orchestration tool rather than a simple Git worktree manager. It is designed for developers who want deep repository context, integrated development workspace orchestration, and high visibility into Forge (GitHub/GitLab) and CI status.
Core Design Philosophy
It follows a DWIM (Do What I Mean) approach to automate complex workflows:
- PR-driven creation: Creating a worktree from a Pull Request automatically fetches the code, tracks the branch, and names the directory.
- Feature completion (absorb): The
absorbworkflow assumes a feature is complete and handles merging/rebasing safely. - Session attachment: Opening a terminal automatically attaches to a per-worktree session.
When to use lazyworktree
- You need deep repository awareness and lifecycle operations (e.g., renaming worktrees, cross-worktree cherry-picking, or absorbing worktrees).
- You want visibility into PR/MR status and CI checks directly within your workspace.
- You prefer a workspace-style UI (TUI) and deep terminal orchestration (tmux/Zellij).
When NOT to use lazyworktree
- Headless or CI workflows: Use tools like
wtmorwtpfor deterministic automation. - Heavy shell scripting: Use
gtrornewtfor better scripting ergonomics. - AI-native/Agent workflows: Use
worktrunkorkoshoif your primary workflow is parallel agent orchestration.