worktree-ghostty — Claude Code hook: three-panel Ghostty layout
Splits Ghostty into three panes when a worktree is created: Claude on the left, lazygit and yazi on the right. macOS only.
npx claude-code-templates@latest --hook development-tools/worktree-ghosttyWhat worktree-ghostty does
The hook listens for WorktreeCreate and WorktreeRemove and runs .claude/hooks/worktree-ghostty.sh. A new worktree brings up a Ghostty window with Claude in the left pane, lazygit in the upper right and yazi in the lower right. The worktree itself lands next to the repository, at ../worktrees/<repo>/<name>/, and removal triggers cleanup.
Four things must be in place first: jq, the Ghostty terminal, lazygit and yazi. Ghostty also needs two keybindings, super+d for new_split:right and super+shift+d for new_split:down. The script splits the window through those shortcuts, so with different bindings the layout falls apart.
On anything other than macOS this won't do much. The WorktreeCreate command gets 30 seconds and WorktreeRemove gets 15, which is enough to open the panes and tidy up.
What it helps with
- keep lazygit and yazi visible next to a Claude session
- park worktrees in a sibling folder instead of inside the repository
- switch between git and file browsing while several branches are open
- clean up automatically when a worktree goes away
- get the same pane arrangement every time a branch starts
Example prompts for the agent
- Create a worktree for
feature/loginand bring up the Ghostty layout - Start this task in a new worktree with lazygit and yazi beside it
- Remove the
feature/loginworktree and clean up after it
How to install worktree-ghostty
1claude-code-templates
npx claude-code-templates@latest --hook development-tools/worktree-ghostty2Manually: put the files in place
.claude/settings.jsonThe hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json
Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command
Questions about worktree-ghostty
How do I install worktree-ghostty in Claude Code?
Run npx claude-code-templates@latest --hook development-tools/worktree-ghostty. The hook configuration is written to .claude/settings.json.
What does worktree-ghostty do?
It splits Ghostty into three panes on worktree creation: Claude, lazygit and yazi. Removing the worktree closes the layout and clears the folder.
What are the requirements for worktree-ghostty?
macOS, Ghostty, jq, lazygit and yazi. Ghostty must map super+d to new_split:right and super+shift+d to new_split:down.
Source text
worktree-ghostty.json · MIT
{
"description": "Worktree Ghostty Layout. Opens a 3-panel Ghostty layout when creating worktrees: Claude Code (left) | lazygit (top-right) / yazi (bottom-right). Creates worktrees in a sibling directory (../worktrees/<repo>/<name>/) and cleans up on removal. macOS only. Requires: jq, Ghostty terminal, lazygit, yazi. Ghostty keybindings required: super+d = new_split:right, super+shift+d = new_split:down.",
"hooks": {
"WorktreeCreate": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/worktree-ghostty.sh",
"timeout": 30
}
]
}
],
"WorktreeRemove": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/worktree-ghostty.sh",
"timeout": 15
}
]
}
]
}
}
© davila7 · MIT · davila7/claude-code-templates