Files
max-sixty__worktrunk/plugins/worktrunk/README.md
Maximilian Roos 11129d3811 fix(plugin): fail worktree hooks before side effects; document path args (#3060)
Hardens the plugin's worktree-lifecycle hooks against malformed
payloads, and documents two things they rely on.

**Hooks** (`plugins/worktrunk/hooks/hooks.json`): in the pipeline form,
`jq -r .name | xargs … wt switch --create {} …` runs `wt` with whatever
jq printed — so a payload missing `.name` minted a real branch named
`null`, and `set -o pipefail` could only report the failure after the
side effect (verified under `/bin/sh`). Both hooks now validate the
field in a command substitution before `wt` runs (`name=$(jq -er .name)
|| exit 1; …`), which fails with nothing created and stays
whitespace-safe via quoted variables. The `bash -c` wrapper remains —
hook commands must parse under fish/zsh/bash and fish rejects
`name=$(…)` — but `set -o pipefail` is gone: the only remaining pipe
ends in `jq -er .path`, whose exit is the pipeline's. Exercised under
`sh -c` against the shipped JSON: missing field → exit 1, no branch;
fresh create → path on stdout, exit 0; existing branch → wt's real
error, nonzero; remove by path → removed.

**Docs**: `wt remove`'s positional also accepts worktree paths
(`resolve_worktree_arg` tries branches first, then paths) and the
`WorktreeRemove` hook passes a path — the help line now reads "Branch
name or worktree path". The plugin README lists `jq` as a hook
dependency, and the skill's branch-naming step asks for names consistent
with the repo's existing worktrees.

> _This was written by Claude Code on behalf of max_

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 00:33:58 -07:00

1.9 KiB

Worktrunk Plugin for Claude Code

Git worktree management CLI integration with activity tracking.

Requires the wt CLI (worktrunk.dev) and jq (used by the worktree-lifecycle hooks).

Features

  1. Configuration skill — Guides LLM-powered commit message setup, project hooks (pre-start, pre-merge), and worktree path customization
  2. Activity tracking — Shows which branches have active Claude sessions via indicators in wt list
  3. /wt-switch-create command — Creates a worktrunk worktree and moves the current Claude session into it

Examples

Activity tracking across worktrees

The plugin installs Claude Code hooks that track session activity per branch. When a prompt is submitted, the hook sets 🤖 on that branch. When Claude finishes and waits for input, it switches to 💬. When the session ends, the marker clears.

These markers appear in wt list output, making it easy to see which worktrees have active Claude sessions — useful when running multiple instances in parallel.

Set up LLM commit message generation

The configuration skill guides through configuring an AI tool (Claude Code, Codex, llm, or aichat) and adding [commit.generation] to the user config so wt merge can auto-generate commit messages.

Add pre-start hooks to run npm install automatically

The skill configures .config/wt.toml with project hooks. Pre-start hooks run when creating worktrees, pre-merge hooks validate before merging.

Start work in a fresh worktree

/wt-switch-create fix-auth Investigate the 5-minute session timeout creates a fix-auth worktree in worktrunk's normal sibling layout (<repo>.fix-auth/), switches the session into it, and starts the task there. The branch name is optional (/wt-switch-create -- <task>). The worktree persists after the session — merge or remove it with wt merge / wt remove like any other.