Skip to content

Create git worktree manager CLI tool#6

Merged
dev-ankit merged 8 commits into
mainfrom
claude/git-worktree-manager-57xpR
Jan 17, 2026
Merged

Create git worktree manager CLI tool#6
dev-ankit merged 8 commits into
mainfrom
claude/git-worktree-manager-57xpR

Conversation

@dev-ankit
Copy link
Copy Markdown
Owner

Implements a comprehensive CLI tool for managing git worktrees with the following features:

  • Simple worktree management: init, switch, list, delete, status
  • Smart defaults with configurable branch prefixes and path patterns
  • Shell integration for seamless cd support (bash, zsh, fish)
  • Status tracking across all worktrees
  • Auto-cleanup of merged/deleted worktrees
  • User prompts for safety (uncommitted changes, unpushed commits)

Technical details:

  • Python 3.10+ with Click CLI framework
  • Subprocess-based git operations (no external git library)
  • TOML configuration (local and global)
  • 57 tests with 63% coverage
  • All commands fully implemented per spec

Documentation:

  • README.md with comprehensive usage examples
  • PRD.md with completed stories and tasks
  • notes.md documenting implementation decisions and challenges

claude and others added 8 commits January 17, 2026 20:17
Implements a comprehensive CLI tool for managing git worktrees with the
following features:

- Simple worktree management: init, switch, list, delete, status
- Smart defaults with configurable branch prefixes and path patterns
- Shell integration for seamless cd support (bash, zsh, fish)
- Status tracking across all worktrees
- Auto-cleanup of merged/deleted worktrees
- User prompts for safety (uncommitted changes, unpushed commits)

Technical details:
- Python 3.10+ with Click CLI framework
- Subprocess-based git operations (no external git library)
- TOML configuration (local and global)
- 57 tests with 63% coverage
- All commands fully implemented per spec

Documentation:
- README.md with comprehensive usage examples
- PRD.md with completed stories and tasks
- notes.md documenting implementation decisions and challenges
…10-3.12

- Add wt-worktree to test matrix
- Test all tools across Python 3.10, 3.11, and 3.12
- Update step name to show Python version being tested
Problem: When running wt commands from a secondary worktree, the tool
would ask to run 'wt init' again because it couldn't find .wt.toml.

Root cause: git rev-parse --show-toplevel returns the current worktree's
root directory, not the main worktree root where .wt.toml is stored.

Solution:
- Added get_main_worktree_root() function in git.py
- Uses 'git worktree list' to find the main worktree (always first)
- Updated CLI to use main worktree root for config loading
- Added test to verify commands work from secondary worktrees

Changes:
- wt/git.py: Added get_main_worktree_root() function
- wt/cli.py: Use get_main_worktree_root() instead of get_repo_root()
- tests/test_cli.py: Added test_commands_from_secondary_worktree
- notes.md: Documented the issue and solution

Tests: 58 tests pass (added 1 new test)
Coverage: git.py increased from 83% to 86%
BREAKING CHANGE: Config is now stored globally in ~/.wt.toml instead of
per-repository .wt.toml files.

Motivation:
- Simpler design - one config location for all repositories
- No need to find main worktree when running from secondary worktrees
- Works the same everywhere
- Removes the need to run 'wt init' per repository

Changes:
- Config now stored in $WT_CONFIG/.wt.toml (defaults to ~/.wt.toml)
- Removed local repo config concept
- 'wt init' is now optional (just sets custom defaults globally)
- Removed is_initialized() check - tool works out of the box
- Updated CLI to not require initialization
- Simplified config module:
  - Removed save_local() and save_global()
  - Added single save() method
  - Removed get_local_config_path()
  - Added get_config_path() and get_config_dir()

Tests updated:
- All fixtures now use temp config directories via WT_CONFIG env var
- Updated test_init to test global config creation
- Removed tests for local config and is_initialized
- Added tests for config directory resolution
- All 58 tests passing

Documentation updated:
- README: Made 'wt init' optional, updated config section
- notes.md: Documented the simplification rationale
- Updated all command examples

Benefits:
- Simpler user experience (no init needed)
- Works from any worktree without issues
- Easier to understand and maintain
- Consistent configuration across all repositories
The wt run command now properly handles the '^' symbol to reference the
default worktree, consistent with how wt switch handles it.

Changes:
- Added special handling for '^' in run command (cli.py)
- Added three new tests for run command functionality
- Updated notes.md with implementation details

Fixes issue where 'wt run ^ "git status"' would error with "Worktree '^'
not found" instead of running in the default worktree.

All 61 tests passing.

Co-authored-by: Claude <noreply@anthropic.com>
- Removed the confirmation prompt when switching with uncommitted changes
- Users can now switch freely between worktrees without interruption
- This is more aligned with git's worktree behavior (git allows switching)
- Tests still pass (61 tests)
- Coverage improved to 66%
Co-authored-by: Claude <noreply@anthropic.com>
@dev-ankit dev-ankit merged commit aeebea7 into main Jan 17, 2026
3 checks passed
@dev-ankit dev-ankit deleted the claude/git-worktree-manager-57xpR branch January 18, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants