claudegoodies
Command

worktree

From rtk-ai

Git Worktree Setup for RTK (Rust project)

Install

/worktree

Facts

Repository
rtk-ai/rtk
Status
Actively maintained
Last commit
Model
haiku

Source preview

The instructions Claude Code reads when this command runs.

# Git Worktree Setup

Create isolated git worktrees with instant feedback and background Rust verification.

**Performance**: ~1s setup + background `cargo check` (non-blocking)

## Usage

```bash
/worktree feature/new-filter       # Creates worktree + background cargo check
/worktree fix/typo --fast          # Skip cargo check (instant)
/worktree feature/big-refactor --check  # Wait for cargo check (blocking)
```

**Branch naming**: Always use `category/description` with a slash.

- `feature/new-filter` -> branch: `feature/new-filter`, dir: `.worktrees/feature-new-filter`
- `fix/bug-name` -> branch: `fix/bug-name`, dir: `.worktrees/fix-bug-name`

## Implementation

Execute this **single bash script** with branch name from `$ARGUMENTS`:

```bash
#!/bin/bash
set -euo pipefail

trap 'kill $(jobs -p) 2>/dev/null || true' EXIT

# Resolve main repo root (works from worktree too)
GIT_COMMON_DIR="$(git rev-parse --git-common-dir 2>/dev/null)"
if [ -z "$GIT_COMMON_DIR" ]; then
  echo "Not in a git repository"
  exit 1
fi
REPO_ROOT="$(cd "$GIT_COMMON_DIR/.." && pwd)"

# Parse flags
RAW_ARGS="$ARGUMENTS"
BRANCH_NAME="$RAW_ARGS"
SKIP_CHECK=false
BLOCKING_CHECK=false

if [[ "$RAW_ARGS" == *"--fast"* ]]; then
  SKIP_CHECK=true
  BRANCH_NAME="${BRANCH_NAME// --fast/}"
fi
if [[ "$RAW_ARGS" == *"--check"* ]]; then
  BLOCKING_CHECK=true
  BRANCH_NAME="${BRANCH_NAME// --check/}"
fi

# Validate b
View full source on GitHub →

Other slash commands