Procedure
Parse $ARGUMENTS to determine the subcommand and arguments.
new <branch-name> [base-branch]
- •Extract branch name from arguments. If a second argument is provided, use it as the base branch (default:
main). - •Sanitize the branch name to a kebab-case slug by replacing
/with-and lowercasing. - •Run the following using Bash:
bash
bash scripts/claude-wt.sh new <branch-name> [base-branch]
- •Report the worktree path and suggest:
- •Open a new terminal
- •
cd ../worktrees/crm-<slug> && claude
list
- •Run using Bash:
bash
bash scripts/claude-wt.sh list
- •Format the output as a readable table showing path, branch, and HEAD commit.
clean
- •Inform the user this will check for merged worktrees and prompt for removal.
- •Run using Bash (this is interactive, requires user confirmation):
bash
bash scripts/claude-wt.sh clean
- •Report which worktrees were removed.
remove <name>
- •Extract the worktree name from arguments.
- •Run using Bash:
bash
bash scripts/claude-wt.sh remove <name>
- •Report whether the worktree and branch were removed.
No arguments or help
Display available commands:
- •
/worktree new feat/contact-import— Create worktree + branch, install deps, suggests launching Claude - •
/worktree list— Show active worktrees with branch and status - •
/worktree clean— Remove merged worktrees (interactive) - •
/worktree remove <name>— Remove a specific worktree
Important
- •Worktrees are created in
../worktrees/crm-<branch-slug>/(sibling to the main repo) - •
.env.localis automatically copied from the main repo if it exists - •
npm installis run automatically in the new worktree - •Each worktree can have its own independent Claude Code session