@leverj/claude-wt
v0.1.0
Published
Isolated git worktrees for parallel Claude Code sessions
Readme
@leverj/claude-wt
Isolated git worktrees for parallel Claude Code sessions.
Lets you run three Claude Code instances on three different stories at the same time, each in its own working directory, without the sessions stepping on each other's branch state or file edits. macOS only.
What it does
claude-wt new <slot> does four things:
- Creates a worktree under
.claude/worktrees/<slot>/(matching Claude Code's native convention), branched fromorigin/HEAD. - Installs dependencies (detects yarn / pnpm / npm / bun via lockfile; skips if none).
- Auto-opens the worktree in your IDE — WebStorm, VS Code, or Terminal.app — based on where you ran the command from.
- Prints a
cd … && claudehint if it doesn't recognize your terminal.
You then run claude in the IDE's integrated terminal (or it auto-starts in the Terminal.app path).
Install
Global (recommended)
npm install -g @leverj/claude-wt
claude-wt helpPer-project
npm install --save-dev @leverj/claude-wt
# Then either:
npx claude-wt new auth
# Or add to your package.json scripts:
# "claude:wt": "claude-wt"
yarn claude:wt new authUsage
claude-wt new <slot> Create a worktree, install deps, open IDE.
claude-wt list Show active claude worktrees.
claude-wt remove <slot> Remove the worktree (refuses if dirty).
claude-wt help Show this help.<slot> is an arbitrary tag — auth, 401, feature-foo, whatever's easy to remember. Must be alphanumeric / dash / underscore.
IDE detection
The tool detects which IDE called it via env vars set by each terminal:
| Where you ran it | Opens |
|---|---|
| WebStorm integrated terminal ($TERMINAL_EMULATOR=JetBrains-JediTerm) | new WebStorm window at the worktree |
| VS Code integrated terminal ($TERM_PROGRAM=vscode) | new VS Code window at the worktree |
| Terminal.app ($TERM_PROGRAM=Apple_Terminal) | new Terminal window, auto-runs cd … && claude |
| Anything else | prints cd … && claude for copy-paste |
Override with CLAUDE_WT_OPEN_WITH=webstorm|code|terminal|none in your shell rc.
Setup tip for your repo
Add this to your .gitignore so the main checkout doesn't see worktree contents as untracked files:
.claude/worktrees/This is recommended by Claude Code's worktree docs.
Caveats
- macOS only. Linux/Windows hard-fail with a message. If a teammate needs them, contributions welcome.
- Local test ports. Two worktrees both running local servers/tests that bind fixed ports (e.g., postgres on 54422) will collide. CI tests are fine — each CI VM is isolated.
- No automatic cleanup. Unlike
claude --worktreenative,claude-wtdoesn't auto-remove an idle worktree on exit. Runclaude-wt remove <slot>when you're done; the dirty-check refuses removal if anything's uncommitted. - Branch persists after remove.
claude-wt removeremoves the working directory but leaves theworktree-<slot>branch in your repo. Delete withgit branch -D worktree-<slot>if you want.
