worktree-plus Hook Setup
Register WorktreeCreate and WorktreeRemove hooks in the appropriate settings.json so that claude -w uses worktree-plus instead of the built-in worktree behavior.
What it does
The setup script detects the install scope and configures hooks accordingly:
- Marketplace install (
~/.claude/plugins/cache/...) → writes to~/.claude/settings.json - Local install (
--plugin-dir) → writes to.claude/settings.local.json
It handles three cases per hook: missing (adds), stale path (updates), already correct (skips). Existing hooks from other plugins are preserved.
Prerequisites
Requires jq for JSON manipulation. If the script fails with "jq: command not found", install it first:
brew install jq # macOS
apt install jq # Linux
Run
bash "${CLAUDE_SKILL_DIR}/../../hooks/scripts/setup-hooks.sh"
After
- Report the script output to the user
- If successful, tell the user to restart Claude Code for changes to take effect
- If the script reported "alongside existing hooks", explain that other plugins' hooks for the same event were preserved
- If the script failed, check that
jqis installed and the settings file path is writable
