‹ 首页

worktrunk

@jjmartres · 收录于 1 周前

Use this skill when the user asks about Worktrunk (wt), git worktree management, running parallel AI agents with worktrees, setting up wt hooks, configuring wt.toml, using `wt switch`, `wt list`, `wt merge`, `wt remove`, `wt step`, LLM commit messages, or integrating Worktrunk with your AI agent. Also trigger when the user wants to run multiple AI agent sessions in parallel across isolated git branches, or automate dev server / database / dependency setup per worktree. Always use this skill for any question involving the `wt` CLI, worktree lifecycle automation, or the worktrunk plugin.

适合你,如果经常需要在多个 git 分支间切换并保持独立开发环境

/ 下载安装
worktrunk.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add jjmartres/ai-coding-agents/worktrunk
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- jjmartres/ai-coding-agents/worktrunk
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify jjmartres/ai-coding-agents/worktrunk
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
36GitHub stars
~1.5K最小装载
~2.9K含声明引用
~2.9K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 9a75b8f

Worktrunk Skill

Worktrunk (wt) is a CLI for git worktree management designed to run AI agents (like Claude Code) in parallel across isolated branches. Think of it as making git worktree as easy as git branch.

Quick Reference

| Task | Command | | ------------------------------- | ----------------------------------- | | Create worktree + switch | wt switch --create feat | | Create worktree + launch Claude | wt switch --create feat -x claude | | List all worktrees | wt list | | Merge & clean up | wt merge main | | Remove current worktree | wt remove | | Commit staged changes | wt step commit |

Installation
# macOS/Linux (recommended)
brew install worktrunk && wt config shell install

# Cargo
cargo install worktrunk && wt config shell install

# Windows
winget install max-sixty.worktrunk
git-wt config shell install

Shell integration (wt config shell install) is required so that wt switch can actually change the shell's directory.

Core Workflow
1. Create and Switch
wt switch --create feature-auth         # New branch + worktree
wt switch --create feature-auth -x claude  # + launch Claude in it
wt switch existing-branch               # Switch to existing worktree
wt switch -                             # Previous worktree

Worktrees are placed at ../repo.branch-name by default (configurable).

2. Inspect Status
wt list                    # All worktrees with status, commits, CI
wt list --full --branches  # Include remote branches without worktrees
wt list --format=json      # Machine-readable output

Key indicators in wt list:

  • @ = current worktree
  • + / - = staged / unstaged changes
  • / = ahead / behind remote
  • / = ahead / behind default branch
  • 🤖 = Claude is working (Claude Code plugin)
  • 💬 = Claude waiting for input
3. Parallel Agents Pattern
wt switch -x claude -c feature-a -- 'Add user authentication'
wt switch -x claude -c feature-b -- 'Fix the pagination bug'
wt switch -x claude -c feature-c -- 'Write tests for the API'

-x / --execute runs a command after switching; arguments after -- are passed to it.

4. Merge or Clean Up

PR workflow:

wt step commit              # Commit staged changes with optional LLM message
gh pr create                # Open PR
wt remove                   # After PR merged

Local merge (squash + rebase + fast-forward):

wt merge main
# Commits, rebases onto main, fast-forward merges, removes worktree
Hooks

Hooks automate worktree lifecycle events. Define in .config/wt.toml (project) or ~/.config/worktrunk/config.toml (user/global).

See references/hooks.md for the full hook reference, template variables, and common patterns (dev servers, databases, cold-start elimination).

Hook Types at a Glance

| Hook | When | Blocking | | ------------- | ------------------- | ---------------------- | | post-create | After creation | Yes (blocks --execute) | | post-start | After creation | No (background) | | post-switch | Every switch | No | | pre-commit | Before merge commit | Yes | | pre-merge | Before merge | Yes | | post-merge | After merge | Yes | | pre-remove | Before removal | Yes | | post-remove | After removal | No |

Essential Hook Patterns

Eliminate cold starts (copy deps/caches/env from main):

[post-start]
copy = "wt step copy-ignored"

Dev server per worktree (deterministic port from branch name):

[post-start]
server = "npm run dev -- --port {{ branch | hash_port }}"
[pre-remove]
server = "lsof -ti :{{ branch | hash_port }} -sTCP:LISTEN | xargs kill 2>/dev/null || true"

Local CI gate (run tests before merge):

[pre-merge]
test = "npm test"
build = "npm run build"
Template Variables & Filters

In hook commands (Jinja2 syntax):

| Variable | Value | | ---------------------- | -------------------------------- | | {{ branch }} | Branch name | | {{ repo }} | Repository directory name | | {{ worktree_path }} | Absolute path to this worktree | | {{ default_branch }} | Default branch name | | {{ target }} | Target branch (merge hooks only) |

| Filter | Example | Output | | ------------- | ----------------------------- | ----------------------- | | sanitize | {{ branch \| sanitize }} | / and \- | | sanitize_db | {{ branch \| sanitize_db }} | DB-safe identifier | | hash_port | {{ branch \| hash_port }} | Stable port 10000-19999 |

LLM Commit Messages

Generate commit messages from diffs:

wt step commit              # Commit staged changes, generate message
wt step commit --all        # Stage all + commit

Configure in ~/.config/worktrunk/config.toml:

[commit.generation]
model = "claude-opus-4-5"   # or any supported model
provider = "anthropic"
Claude Code Integration

Install the plugin for activity tracking (🤖 / 💬 in wt list) and configuration skill:

claude plugin marketplace add max-sixty/worktrunk
claude plugin install worktrunk@worktrunk

Add to ~/.claude/settings.json for statusline:

{
  "statusLine": {
    "type": "command",
    "command": "wt list statusline --format=claude-code"
  }
}
Zellij Integration

Spawn agent handoffs directly into Zellij panes (great with your existing Zellij setup):

zellij run -- wt switch --create fix-auth -x claude -- \
  'Fix the session timeout bug in auth module'

Or use hooks for a full multi-pane layout per worktree:

# .config/wt.toml
[post-create]
zellij = """
zellij action new-tab --name {{ branch | sanitize }}
zellij action new-pane -- claude
"""
Common Commands for devops Work

For microservice's repos, a typical .config/wt.toml:

[post-create]
env = "cp {{ primary_worktree_path }}/.env.local .env.local 2>/dev/null || true"

[post-start]
copy = "wt step copy-ignored"

[pre-merge]
lint = "make lint"
test = "make test"

[post-merge]
notify = "echo '✓ Merged {{ branch }} → {{ target }}'"
Further Reference
  • references/hooks.md — Complete hook documentation with all patterns
  • references/commands.md — Full command reference (switch, list, merge, remove, step, config)
  • Official docs: https://worktrunk.dev
  • Claude Code integration: https://worktrunk.dev/claude-code/
  • Tips & patterns: https://worktrunk.dev/tips-patterns/
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。