https://github.com/wbnns/cw
Git worktree manager for running multiple Claude Code instances in parallel
https://github.com/wbnns/cw
anthropic claude claude-ai claude-code
Last synced: 20 days ago
JSON representation
Git worktree manager for running multiple Claude Code instances in parallel
- Host: GitHub
- URL: https://github.com/wbnns/cw
- Owner: wbnns
- License: mit
- Created: 2026-02-05T11:57:26.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-17T20:22:59.000Z (4 months ago)
- Last Synced: 2026-02-18T01:28:02.715Z (4 months ago)
- Topics: anthropic, claude, claude-ai, claude-code
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cw
Git worktree manager for running multiple Claude Code instances in parallel.
## Installation
Clone or download this repository anywhere on your system, then install with pipx:
```bash
git clone https://github.com/wbnns/claude-worktrees ~/claude-worktrees
pipx install ~/claude-worktrees
```
After installation, the `cw` command is available globally.
## Quick Start
```bash
# Navigate to any git repository
cd your-repo
# Create a worktree and launch Claude Code
cw
```
That's it. Running `cw` with no arguments:
1. Auto-initializes config and git hooks (first run only)
2. Creates a new branch named `wbnns/`
3. Creates a worktree in `~/cw//`
4. Symlinks dependency directories from the main repo
5. Launches Claude Code in the new worktree
## Commands
### `cw` (no arguments)
Create a new worktree with auto-generated name and launch Claude Code.
### `cw new [branch]`
Create a worktree with a specific branch name.
```bash
cw new feature/auth # Create new branch + worktree
cw new --from existing-branch existing-branch # Use existing branch
cw new --no-claude # Don't launch Claude Code
cw new --no-deps # Skip dependency symlinking
```
### `cw list`
List all managed worktrees with status, PR info, and disk usage.
### `cw cleanup`
Remove worktrees for merged branches.
```bash
cw cleanup # Interactive
cw cleanup --dry-run # Preview what would be removed
cw cleanup --force # Remove without prompting
```
### `cw remove `
Remove a specific worktree.
### `cw open `
Launch Claude Code in an existing worktree.
### `cw init`
Manually initialize config and git hooks. This runs automatically on first `cw` use, so you typically don't need this.
## Dependency Sharing
To avoid reinstalling dependencies for each worktree, `cw` symlinks common dependency directories from your main repo:
- **JavaScript/Node:** `node_modules`, `.pnpm-store`, `.yarn/cache`
- **Ruby/Rails:** `vendor/bundle`, `.bundle`
- **Python/Django:** `.venv`, `venv`, `env`
- **PHP:** `vendor`
- **Go:** `vendor`
- **Elixir:** `deps`
- **iOS/macOS:** `Pods`
- **Java/Kotlin:** `.gradle`
All worktrees share the same dependencies, saving disk space and install time.
## Dotfiles
`cw` also symlinks common environment dotfiles so your config is available in each worktree:
- `.env`
- `.env.local`
- `.env.development`
- `.env.development.local`
- `.env.test`
- `.env.test.local`
## Configuration
Optional config at `~/.claude-worktrees.toml`:
```toml
[global]
worktree_base = "~/cw"
auto_cleanup = true
[deps]
strategy = "symlink" # symlink | copy | custom
# post_create_hook = "bundle install" # for custom strategy
[github]
check_pr_status = true # Check PR merge status via gh CLI
```
### Dependency Strategies
- **symlink** (default): Symlinks deps from main repo. Fast, saves space.
- **copy**: Copy-on-write copies (macOS). Independent but space-efficient.
- **custom**: Run your own command via `post_create_hook`.
## Automatic Cleanup
Running `cw` automatically:
1. Pulls latest changes from remote (if configured)
2. Runs cleanup on every invocation (and also via the `post-merge` git hook)
Worktrees are cleaned up when:
- **A PR exists for the branch** - opened, merged, or closed; detected via `gh` CLI
- **Branch merged locally** - detected via `git branch --merged`
- **Older than 1 day** - with no open PR (for repos without GitHub)
The worktree you're currently inside is always skipped, and worktrees with
uncommitted changes are skipped in auto mode.
## Directory Structure
```
~/cw/
└── my-project/
├── wbnns-1738789200/
├── wbnns-1738789500/
└── feature-auth/
```
## Requirements
- Python 3.10+
- Git
- Claude Code CLI (`claude`)
- `gh` CLI (optional, for PR status checking)