| name | worktree-manager |
| description | Create, list, switch to, rename, delete, and manage notes for git worktrees using lazyworktree CLI |
Worktree Management
Manage git worktrees for the current repository using the lazyworktree CLI.
Current Worktrees
!lazyworktree list --json
Current Working Directory
!pwd
Current Branch
!git branch --show-current
Available Operations
Create a Worktree
From the current branch (new feature work):
lazyworktree create --silent
lazyworktree create --silent my-feature-name
lazyworktree create --silent --with-change my-feature-name
lazyworktree create --silent --from-branch main my-feature-name
From a GitHub/GitLab PR:
lazyworktree create --silent --from-pr 42
lazyworktree create --silent --from-pr 42 --no-workspace
From a GitHub/GitLab issue:
lazyworktree create --silent --from-issue 123
lazyworktree create --silent --from-issue 123 --from-branch main
lazyworktree create --silent --from-issue 123 --no-workspace
Auto-generate worktree name from branch:
lazyworktree create --silent --generate
Run a command after creation:
lazyworktree create --silent --from-branch main my-feature --exec "npm install"
All create commands print the created worktree path to stdout on success.
List Worktrees
lazyworktree list --json
lazyworktree list --pristine
lazyworktree list --main
lazyworktree list
Alias: lazyworktree ls is equivalent to lazyworktree list.
JSON fields: path, name, branch, is_main, dirty, ahead, behind, unpushed, last_active.
Run Commands in a Worktree
Use exec to run commands in a specific worktree without changing directory:
lazyworktree exec -w my-feature-name "make build"
lazyworktree exec -w /path/to/worktree "make build"
cd /path/to/my-feature && lazyworktree exec "git status"
lazyworktree exec -w my-feature-name "go test ./..."
lazyworktree exec -w my-feature-name --key t
Note: --key and a command argument are mutually exclusive.
Rename a Worktree
lazyworktree rename --silent new-name
lazyworktree rename --silent my-feature-name new-name
Worktree Notes
lazyworktree note show
lazyworktree note show my-feature-name
lazyworktree note edit my-feature-name
lazyworktree note edit my-feature-name --input notes.md
echo "my note" | lazyworktree note edit my-feature-name --input -
Delete a Worktree
lazyworktree delete --silent my-feature-name
lazyworktree delete --silent --no-branch my-feature-name
cd /path/to/worktree && lazyworktree delete --silent
Workflow Instructions
When the user asks to create a worktree:
- Determine the source: current branch, a specific branch, a PR number, or an issue number
- Run the appropriate
lazyworktree create --silent command
- Capture the output path
- Report the created worktree path to the user
- If the user wants to work in it immediately, use
lazyworktree exec -w <name> for subsequent commands
When the user asks to switch to a worktree:
- Run
lazyworktree list --json to find available worktrees
- Identify the target by name, branch, or path
- For running commands in the target worktree, use:
lazyworktree exec -w <name> "<command>"
- Tell the user they can switch their shell with:
cd <path>
When the user asks to list worktrees:
- Run
lazyworktree list --json and present the results
- Highlight dirty worktrees, ahead/behind status, and last active times
When the user asks to rename a worktree:
- Run
lazyworktree list --json to identify the worktree
- Run
lazyworktree rename --silent <old-name> <new-name>
- Report the new name to the user
When the user asks to view or edit worktree notes:
- To view:
lazyworktree note show <name> (omit name to use cwd)
- To set from a string:
echo "content" | lazyworktree note edit <name> --input -
- To set from a file:
lazyworktree note edit <name> --input path/to/file
When the user asks to delete a worktree:
- Run
lazyworktree list --json to show current worktrees
- Confirm which worktree to delete
- Run
lazyworktree delete --silent <name>
Important Notes
- The
--silent flag suppresses progress messages to stderr; stdout still contains the result path
- Worktree names are automatically sanitised (special characters replaced with hyphens)
- The main worktree cannot be deleted
- Use
exec -w to run commands in a worktree without changing your shell's working directory
- If the user says "switch to" or "work in" a worktree, prefer using
exec -w for running commands there and inform the user of the path for manual cd