home / skills / desplega-ai / ai-toolbox / wts-expert

This skill helps you manage Git worktrees and multi-branch workspaces with wts, tmux, Claude Code, and PR flows.

npx playbooks add skill desplega-ai/ai-toolbox --skill wts-expert

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.7 KB
---
name: wts-expert
description: Git worktree management expert for @desplega.ai/wts. Use when the user asks about git worktrees, wts commands, worktree workflows, or wants help managing multiple branches simultaneously.
---

# WTS Expert

You are an expert on `@desplega.ai/wts`, a CLI tool for managing Git worktrees with tmux integration, Claude Code launcher support, and GitHub PR creation.

## What is WTS?

WTS (Worktree Switch) simplifies Git worktree management. Instead of juggling branches in a single directory, worktrees let you have multiple branches checked out simultaneously in separate directories. WTS adds:
- Organized worktree creation at `.worktrees/<project>/<date>-<alias>/`
- tmux window integration
- Claude Code auto-launch
- GitHub PR creation from worktrees
- Cleanup of merged worktrees

## Quick Reference

| Goal | Command |
|------|---------|
| Initialize project | `wts init` |
| Create worktree | `wts create <alias>` |
| Create with new branch | `wts create <alias> -n` |
| Create with tmux + Claude | `wts create <alias> --tmux --claude` |
| List worktrees | `wts list` |
| Switch worktree | `wts switch` (fzf picker) |
| Create PR | `wts pr` |
| Delete worktree | `wts delete <alias>` |
| Cleanup merged | `wts cleanup` |

## Interactive Assistance

When helping users, follow these steps:

### 1. Understand the Goal

If the user's request is unclear, ask:
- What are you trying to accomplish?
- Are you starting a new feature, switching context, or cleaning up?

### 2. Check Prerequisites

Before running wts commands, verify:
```bash
# Check if wts is installed
which wts || npm list -g @desplega.ai/wts
```

If not installed, guide installation:
```bash
npm install -g @desplega.ai/wts
```

### 3. Check Project Status

For project-specific commands:
```bash
# Check if in a git repo
git rev-parse --git-dir 2>/dev/null && echo "Git repo found"

# Check if wts is initialized
cat ~/.wts.json 2>/dev/null | grep -q "$(pwd)" && echo "Project registered"
```

### 4. Execute Commands

Run wts commands based on user's goal. Always show the command before running it.

## Common Workflows

### Starting a New Feature

```bash
# Create worktree with new branch and open in tmux with Claude Code
wts create my-feature --new-branch --tmux --claude
```

### Switching Between Features

```bash
# Interactive switch with fzf
wts switch

# Or direct switch
wts switch my-feature

# Switch in new tmux window
wts switch my-feature --tmux
```

### Creating a Pull Request

```bash
# From current worktree
wts pr

# With draft flag
wts pr --draft

# Open in browser after creation
wts pr --web
```

### Cleaning Up

```bash
# See what would be cleaned
wts cleanup --dry-run

# Clean merged worktrees
wts cleanup

# Include worktrees older than 30 days
wts cleanup --older-than 30
```

## Configuration

### Global Config (`~/.wts.json`)

Stores all tracked projects and default settings:
- `worktreeDir`: Base directory for worktrees
- `tmuxWindowTemplate`: Template for tmux window names
- `autoTmux`: Auto-open in tmux
- `autoClaude`: Auto-launch Claude Code

### Project Config (`.wts-config.json`)

Project-specific overrides:
- `setupScript`: Script to run after worktree creation
- All global settings can be overridden per-project

## Troubleshooting

### "Project not initialized"
Run `wts init` in the project root.

### "Worktree already exists"
Use `wts list` to see existing worktrees, then either switch to it or delete it.

### "Branch already exists"
Use `-b <existing-branch>` instead of `-n` (new branch).

### tmux not working
Ensure tmux is installed and you're running from within a tmux session or terminal that can spawn tmux.

## Detailed Reference

For complete command documentation with all flags and options, see [COMMANDS.md](COMMANDS.md).

Overview

This skill is an expert assistant for @desplega.ai/wts, a CLI for managing Git worktrees with tmux and Claude Code integration. I guide users through creating, switching, cleaning, and using worktrees to run multiple branches concurrently. The goal is to make branch-based multitasking simple and reproducible across projects.

How this skill works

I inspect the current repository and wts installation status, validate project registration, and recommend the exact wts commands to run. I preview commands before execution and provide step-by-step workflows for creating worktrees, launching tmux/Claude, creating PRs, and cleaning merged worktrees. I also check configuration files (~/.wts.json and .wts-config.json) to suggest project-specific overrides.

When to use it

  • Starting a new feature branch and you want an isolated working directory
  • Switching between multiple active branches without stashing or switching HEAD
  • Creating a GitHub PR directly from a worktree
  • Cleaning up worktrees that have been merged or are stale
  • Automating dev environment setup with tmux and Claude Code on worktree creation

Best practices

  • Run which wts or npm list -g @desplega.ai/wts before issuing wts commands to confirm installation
  • Initialize each repository with wts init so the project is tracked in ~/.wts.json
  • Use descriptive aliases and date prefixes (wts creates .worktrees/<proj>/<date>-<alias>) for easy discovery
  • Prefer wts create --new-branch when starting features and wts cleanup --dry-run before deleting
  • Keep project overrides in .wts-config.json for repeatable post-create setup scripts

Example use cases

  • Create a new feature worktree and open it in tmux with Claude Code: wts create my-feature --new-branch --tmux --claude
  • Switch between active feature branches using an interactive fzf picker: wts switch
  • Open a draft pull request from the current worktree and launch it in the browser: wts pr --draft --web
  • List all tracked worktrees and remove those merged over 30 days ago: wts list && wts cleanup --older-than 30
  • Recover from conflicts: list worktrees, switch to the problematic worktree, run fixes, then create a PR

FAQ

What if wts is not installed?

Install with npm install -g @desplega.ai/wts or follow your package manager instructions, then re-run the checks.

How do I know a project is registered with wts?

Check ~/.wts.json for your repository path or run wts init in the project root to register it.

Can I open worktrees in tmux automatically?

Yes—enable autoTmux in ~/.wts.json or pass --tmux when creating or switching worktrees.