worktrunk
Worktrunk provides guidance for the `wt` CLI tool, which manages git worktrees with integrated hooks and configuration. Use this skill when configuring user settings in `~/.config/worktrunk/config.toml`, editing project hooks in `.config/wt.toml`, setting up LLM-based commit message generation, debugging hook execution, or troubleshooting Worktrunk behavior and shell integration issues.
git clone --depth 1 https://github.com/max-sixty/worktrunk /tmp/worktrunk && cp -r /tmp/worktrunk/skills/worktrunk ~/.claude/skills/worktrunkSKILL.md
# Worktrunk
Help users work with Worktrunk, a CLI tool for managing git worktrees.
## Available Documentation
Reference files are synced from [worktrunk.dev](https://worktrunk.dev) documentation:
- **reference/config.md**: User and project configuration (LLM, hooks, command defaults)
- **reference/hook.md**: Hook types, timing, and execution order
- **reference/switch.md**, **merge.md**, **list.md**, etc.: Command documentation
- **reference/extending.md**: Aliases, multi-step pipelines, custom subcommands, and template-expansion gotchas (two-pass `{% raw %}` deferral, for-each recipes)
- **reference/llm-commits.md**: LLM commit message generation
- **reference/tips-patterns.md**: Practical recipes — aliases, per-branch variables, dev server per worktree, parallel agent patterns
- **reference/shell-integration.md**: Shell integration debugging
- **reference/troubleshooting.md**: Troubleshooting for LLM and hooks (Claude-specific)
For command-specific options, run `wt <command> --help`. For configuration, follow the workflows below.
## Two Types of Configuration
Worktrunk uses two separate config files with different scopes and behaviors:
### User Config (`~/.config/worktrunk/config.toml`)
- **Scope**: Personal preferences for the individual developer
- **Location**: `~/.config/worktrunk/config.toml` (never checked into git)
- **Contains**: LLM integration, worktree path templates, command settings, user hooks, approved commands
- **Permission model**: Always propose changes and get consent before editing
- **See**: `reference/config.md` for detailed guidance
### Project Config (`.config/wt.toml`)
- **Scope**: Team-wide automation shared by all developers
- **Location**: `<repo>/.config/wt.toml` (checked into git)
- **Contains**: Hooks for worktree lifecycle (pre-start, pre-merge, etc.)
- **Permission model**: Proactive (create directly, changes are reversible via git)
- **See**: `reference/hook.md` for detailed guidance
## Determining Which Config to Use
When a user asks for configuration help, determine which type based on:
**User config indicators**:
- "set up LLM" or "configure commit generation"
- "change where worktrees are created"
- "customize commit message templates"
- Affects only their environment
**Project config indicators**:
- "set up hooks for this project"
- "automate npm install"
- "run tests before merge"
- Affects the entire team
**Both configs may be needed**: For example, setting up commit message generation requires user config, but automating quality checks requires project config.
## Core Workflows
### Setting Up Commit Message Generation (User Config)
Most common request. See `reference/llm-commits.md` for supported tools and exact command syntax.
1. **Detect available tools**
```bash
which claude codex llm aichat 2>/dev/null
```
2. **If none installed, recommend Claude Code** (already available in Claude Code sessions)
3. **Propose config change** — Get the exact command from `reference/llm-commits.md`
```toml
[commit.generation]
command = "..." # see reference/llm-commits.md for tool-specific commands
```
Ask: "Should I add this to your config?"
4. **After approval, apply**
- Check if config exists: `wt config show`
- If not, guide through `wt config create`
- Read, modify, write preserving structure
5. **Suggest testing**
```bash
wt step commit --show-prompt | head # verify prompt builds
wt merge # in a repo with uncommitted changes
```
### Setting Up Project Hooks (Project Config)
Common request for workflow automation. Follow discovery process:
1. **Detect project type**
```bash
ls package.json Cargo.toml pyproject.toml
```
2. **Identify available commands**
- For npm: Read `package.json` scripts
- For Rust: Common cargo commands
- For Python: Check pyproject.toml
3. **Design appropriate hooks** (10 hook types: 5 events × pre/post — see `reference/hook.md`)
- Dependencies (fast, must complete) → `pre-start`
- Tests/linting (must pass) → `pre-commit` or `pre-merge`
- Long builds, dev servers → `post-start`
- Setup before branch resolution → `pre-switch`
- Terminal/IDE updates → `post-switch`
- After-commit triggers (CI, notifications) → `post-commit`
- Deployment → `post-merge`
- Cleanup before removal → `pre-remove`
- Cleanup after removal (stop servers, remove containers) → `post-remove`
4. **Validate commands work**
```bash
npm run lint # verify exists
which cargo # verify tool exists
```
5. **Create `.config/wt.toml`**
```toml
# Install dependencies when creating worktrees
pre-start = "npm install"
# Validate code quality before committing
[pre-commit]
lint = "npm run lint"
typecheck = "npm run typecheck"
# Run tests before merging
pre-merge = "npm test"
```
6. **Add comments explaining choices**
7. **Suggest testing**
```bash
wt switch --create test-hooks
```
**See `reference/hook.md` for complete details.**
### Adding Hooks to Existing Config
When users want to add automation to an existing project:
1. **Read existing config**: `cat .config/wt.toml`
2. **Determine hook type** - When should this run? (10 types: 5 events × pre/post)
- Creating worktree (blocking) → `pre-start`
- Creating worktree (background) → `post-start`
- Before/after a switch → `pre-switch` / `post-switch`
- Before committing → `pre-commit`
- After committing (CI, notifications) → `post-commit`
- Before merging → `pre-merge`
- After merging → `post-merge`
- Before/after removal → `pre-remove` / `post-remove`
3. **Handle format conversion if needed**
Single command to a pipeline of dependent steps:
```toml
# Before
pre-start = "npm install"
# After (adding db:migrate, which needs install to finish first)
[[pre-start]]
install = "npm install"
[[pre-start]]
migrate = "npm run db:migrate"
```
For independent commands, a named table runs them coWorktrunk release workflow. Use when user asks to "do a release", "release a new version", "cut a release", or wants to publish a new version to crates.io and GitHub.
Worktrunk-specific guidance for tend CI workflows. Adds codecov polling, Rust test commands, labels, and review criteria on top of the generic tend-* skills. Use when operating in CI.
CLI output formatting standards for worktrunk. Load before editing any code that calls warning_message, hint_message, error_message, info_message, eprintln, or println, or that produces strings the user will see (CLI help, progress UI, snapshot text). Documents ANSI color nesting rules, message patterns, and output system architecture.
Create a new worktrunk worktree (optionally in another repo) and switch this session's working directory into it. The branch name is optional — one is picked from the task when omitted. Use when launching a session that should work in its own worktree (e.g. `/wt-switch-create -- <task>`, `/wt-switch-create my-branch -- <task>`, or `/wt-switch-create my-branch ~/workspace/other-repo -- <task>`), or mid-session to move work into a fresh branch.