Skip to content

Commit aeebea7

Browse files
dev-ankitclaude
andauthored
Create git worktree manager CLI tool (#6)
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 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fd1c8aa commit aeebea7

20 files changed

Lines changed: 3096 additions & 8 deletions

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ jobs:
1414
tool:
1515
- locust-compare
1616
- config-utils
17+
- wt-worktree
18+
# Just test for 3.12
19+
# uncomment if you want to test for all versions
20+
# python-version: ["3.10", "3.11", "3.12"]
21+
python-version: ["3.12"]
1722
fail-fast: false
1823
steps:
1924
- uses: actions/checkout@v4
2025

21-
- name: Set up Python 3.12
26+
- name: Set up Python ${{ matrix.python-version }}
2227
uses: actions/setup-python@v5
2328
with:
24-
python-version: 3.12
29+
python-version: ${{ matrix.python-version }}
2530

26-
- name: Install and test ${{ matrix.tool }}
31+
- name: Install and test ${{ matrix.tool }} (Python ${{ matrix.python-version }})
2732
working-directory: tools/${{ matrix.tool }}
2833
run: |
2934
python -m pip install --upgrade pip

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ A collection of small, independent Python utilities. Each tool is self-contained
88
|------|-------------|
99
| [locust-compare](tools/locust-compare/) | Compare performance metrics between two Locust runs |
1010
| [config-utils](tools/config-utils/) | CLI tool for capturing environment variables and Django settings |
11+
| [wt-worktree](tools/wt-worktree/) | Git worktree manager for parallel development workflows |
1112

1213
## Installation
1314

@@ -22,23 +23,29 @@ uv tool install 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=
2223

2324
# Install config-utils
2425
uv tool install 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/config-utils'
26+
27+
# Install wt-worktree
28+
uv tool install 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/wt-worktree'
2529
```
2630

2731
After installation, you can run from anywhere:
2832
```bash
2933
locust-compare <base_dir> <current_dir>
3034
config-utils capture-env
35+
wt init
3136
```
3237

3338
To update to the latest from GitHub:
3439

3540
```bash
3641
uv tool upgrade locust-compare
3742
uv tool upgrade config-utils
43+
uv tool upgrade wt-worktree
3844

3945
# Or force reinstall:
4046
uv tool install --force 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/locust-compare'
4147
uv tool install --force 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/config-utils'
48+
uv tool install --force 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/wt-worktree'
4249

4350
# To see installed tools:
4451
uv tool list
@@ -58,6 +65,9 @@ uvx --from 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools
5865

5966
# Run config-utils
6067
uvx --from 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/config-utils' config-utils capture-env
68+
69+
# Run wt
70+
uvx --from 'git+https://github.com/dev-ankit/python-tools.git#subdirectory=tools/wt-worktree' wt init
6171
```
6272

6373
Option 3: Clone and run locally:
@@ -72,20 +82,27 @@ uvx --from . <tool-name> [args]
7282

7383
```
7484
python-tools/
75-
├── README.md
85+
├── README.md
7686
├── LICENSE # MIT License (shared)
7787
├── .github/
7888
│ └── workflows/
7989
└── tools/
80-
├── locust-compare/ # Locust performance comparison tool
90+
├── locust-compare/ # Locust performance comparison tool
8191
│ ├── compare_runs.py
8292
│ ├── pyproject.toml
8393
│ ├── README.md
8494
│ └── tests/
85-
└── config-utils/ # CLI tool for capturing environment variables and Django settings
86-
├── cli.py
95+
├── config-utils/ # CLI tool for capturing environment variables and Django settings
96+
│ ├── cli.py
97+
│ ├── pyproject.toml
98+
│ └── README.md
99+
└── wt-worktree/ # Git worktree manager for parallel development
100+
├── wt/
101+
├── tests/
87102
├── pyproject.toml
88-
└── README.md
103+
├── README.md
104+
├── PRD.md
105+
└── notes.md
89106
```
90107

91108
## Adding a New Tool

tools/wt-worktree/PRD.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# `wt` - Git Worktree Manager - Product Requirements Document
2+
3+
## Overview
4+
5+
`wt` is a CLI tool that simplifies git worktree management for parallel development workflows. It enables multiple agents or developers to work on separate features simultaneously with an intuitive interface and shell integration.
6+
7+
## Stories and Tasks
8+
9+
### Story 1: Core Infrastructure ✅
10+
**As a developer, I want the basic project structure and core git operations, so that I can build features on top**
11+
12+
- [x] Task 1.1: Set up project structure with pyproject.toml
13+
- [x] Task 1.2: Implement git operations module (git.py)
14+
- [x] Task 1.3: Implement configuration management (config.py)
15+
- [x] Task 1.4: Implement core worktree operations (worktree.py)
16+
- [x] Task 1.5: Add tests for core modules
17+
18+
### Story 2: Basic Commands ✅
19+
**As a user, I want to initialize and manage worktrees, so that I can work on multiple features**
20+
21+
- [x] Task 2.1: Implement `wt init` command
22+
- [x] Task 2.2: Implement `wt switch` command (existing worktrees)
23+
- [x] Task 2.3: Implement `wt switch -c` (create new worktrees)
24+
- [x] Task 2.4: Implement `wt list` command
25+
- [x] Task 2.5: Add tests for basic commands
26+
27+
### Story 3: Worktree Management Commands ✅
28+
**As a user, I want to compare, delete, and check status of worktrees**
29+
30+
- [x] Task 3.1: Implement `wt diff` command
31+
- [x] Task 3.2: Implement `wt delete` command with prompts
32+
- [x] Task 3.3: Implement `wt status` command
33+
- [x] Task 3.4: Add tests for management commands
34+
35+
### Story 4: Advanced Features ✅
36+
**As a user, I want to run commands in worktrees and clean up merged branches**
37+
38+
- [x] Task 4.1: Implement `wt run` command
39+
- [x] Task 4.2: Implement `wt clean` command
40+
- [x] Task 4.3: Implement `wt config` command
41+
- [x] Task 4.4: Add tests for advanced features
42+
43+
### Story 5: Shell Integration ✅
44+
**As a user, I want seamless shell integration, so that I can navigate worktrees easily**
45+
46+
- [x] Task 5.1: Implement `wt shell-init` command
47+
- [x] Task 5.2: Generate bash/zsh shell wrapper
48+
- [x] Task 5.3: Generate fish shell wrapper
49+
- [x] Task 5.4: Add --shell-helper flag for cd support
50+
- [x] Task 5.5: Test shell integration
51+
52+
### Story 6: User Experience ✅
53+
**As a user, I want helpful prompts and error messages**
54+
55+
- [x] Task 6.1: Implement user prompts module (prompts.py)
56+
- [x] Task 6.2: Add comprehensive error messages
57+
- [x] Task 6.3: Add progress indicators
58+
- [x] Task 6.4: Handle edge cases (spaces in paths, special characters)
59+
60+
### Story 7: Documentation and Testing ✅
61+
**As a developer, I want comprehensive documentation and tests**
62+
63+
- [x] Task 7.1: Write comprehensive test suite
64+
- [x] Task 7.2: Create README.md with usage examples
65+
- [x] Task 7.3: Create notes.md documenting implementation decisions
66+
- [x] Task 7.4: Update root README.md
67+
- [x] Task 7.5: End-to-end testing
68+
69+
## Success Criteria
70+
71+
1. All commands work as specified in the spec
72+
2. Test coverage > 80%
73+
3. Shell integration works in bash, zsh, and fish
74+
4. Error messages are clear and actionable
75+
5. Configuration system works with both local and global configs
76+
6. Tool handles edge cases gracefully (uncommitted changes, conflicts, etc.)
77+
78+
## Technical Requirements
79+
80+
- Python 3.10+
81+
- Click for CLI framework
82+
- Subprocess-based git operations (no gitpython dependency for simplicity)
83+
- TOML configuration files
84+
- Shell wrappers for cd integration
85+
86+
## Non-Goals (Future Considerations)
87+
88+
- `wt clone` - Clone with pre-configuration
89+
- `wt sync` - Pull/rebase all worktrees
90+
- `wt exec` - Run command across all worktrees
91+
- Worktree templates
92+
- Agent tracking
93+
- Locking mechanism

0 commit comments

Comments
 (0)