Tips & Patterns

Practical recipes for common Worktrunk workflows.

Alias for new worktree + agent

Create a worktree and launch Claude in one command:

alias wsc='wt switch --create --execute=claude'
wsc new-feature  # Creates worktree, runs hooks, launches Claude

Eliminate cold starts

post-create hooks install deps and copy caches. On macOS, use copy-on-write for instant cache cloning:

[post-create]
"cache" = "cp -c -r ../.cache .cache"  # APFS clones (instant, no disk space)
"install" = "npm ci"

See Worktrunk's own .config/wt.toml for a complete example.

Local CI gate

pre-merge hooks run before merging. Failures abort the merge:

[pre-merge]
"lint" = "uv run ruff check"
"test" = "uv run pytest"

This catches issues locally before pushing β€” like having CI run on your machine.

Track agent status

Custom emoji markers show agent state in wt list. The Claude Code plugin sets these automatically:

+ feature-api      ↑  πŸ€–              ↑1      ./repo.feature-api
+ review-ui      ? ↑  πŸ’¬              ↑1      ./repo.review-ui

Set status manually for any workflow:

wt config var set marker "🚧"                   # Current branch
wt config var set marker "βœ…" --branch feature  # Specific branch
git config worktrunk.marker.feature "πŸ’¬"        # Direct git config

See Claude Code Integration for plugin installation.

Monitor CI across branches

wt list --full --branches

Shows PR/CI status for all branches, including those without worktrees. CI indicators are clickable links to the PR page.

JSON API

wt list --format=json

Structured output for dashboards, statuslines, and scripts. See wt list for query examples.

Task runners in hooks

Reference Taskfile/Justfile/Makefile in hooks:

[post-create]
"setup" = "task install"

[pre-merge]
"validate" = "just test lint"

Shortcuts

Special arguments work across all commandsβ€”see wt switch for the full list.

wt switch --create hotfix --base=@       # Branch from current HEAD
wt switch -                              # Switch to previous worktree
wt remove @                              # Remove current worktree

Stacked branches

Branch from current HEAD instead of main:

wt switch --create feature-part2 --base=@

Creates a worktree that builds on the current branch's changes.