Skip to main content
hook

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.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --hook development-tools/worktree-ghostty
Open on GitHub

What 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/login and bring up the Ghostty layout
  • Start this task in a new worktree with lazygit and yazi beside it
  • Remove the feature/login worktree and clean up after it

How to install worktree-ghostty

1claude-code-templates

npx claude-code-templates@latest --hook development-tools/worktree-ghostty

2Manually: put the files in place

.claude/settings.json

The 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

Similar hooks

All hooks for Agent setup: memory, context, orchestration →

From the same set495

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor