Skip navigation
I replaced Claude Code’s default --worktree command with a custom one built around Ghostty, Lazygit…
0:00 / 0:24

I replaced Claude Code’s default --worktree command with a custom one built around Ghostty, Lazygit…

Daniel San

@dani_avila734K followers

Visit on X
572 likesDownloadOriginal post

67,005 views

I replaced Claude Code’s default --worktree command with a custom one built around Ghostty, Lazygit, and Yazi. By default, Claude Code creates worktrees inside the .claude/worktrees folder within the same project. That means if you spin up 3 worktrees, you end up with 3 complete copies of your project nested inside your main project. It makes the project structure messy and difficult to manage. So I built a hook that: - Overrides the default --worktree command - Creates each branch in a sibling directory: ../worktrees/branch-name - Automatically opens Ghostty panes - Launches Lazygit and Yazi already positioned in the correct branch directory Install it with: npx claude-code-templates@latest --hook=development-tools/worktree-ghostty --yes Now each branch lives where it should, outside the main project, and your terminal environment is ready instantly.

27 Comments

Comments from the original post on X (Twitter)

  • Lawrence Chen's profile picture

    @lawrencecchen

    nice! can you also optionally support workspaces+panes in with cmux cli?

    4 likes

  • Roderik's profile picture

    @roderik

    how do you do the ghostty panes? did not know you could script those

    1 like

  • Jon Zeolla's profile picture

    @JonZeolla

    You can do similar without the third party dep with a bash function like this

    1 like

  • Robogator's profile picture

    @Robogator_adm

    This is such a clean upgrade to Claude Code worktrees, love how you turned chaos into a focused branch playground 🚀

  • Jelmer Borst's profile picture

    @japborst

    Or... Just use @conductor_build

  • Ben Kruger's profile picture

    @benkruger

    Good luck with your permissions with a sibling! When inside the same repo you inherit the repo permissions

  • Pere's profile picture

    @pmontp19

    Love it!

  • Alvaro's profile picture

    @alvaro__data

    I love your customization tools for ghostty and Claude Code, thanks for sharing! Do you use an IDE on top, or only the terminal?

  • Doug Lance's profile picture

    @Douglance

    tmux bro

  • Donny Li's profile picture

    @DonnyLi2001

    Great workflow tweak. Keeping worktrees outside the repo is cleaner for fs watchers and usually cuts IDE index churn when multiple branches are open.

  • yrzhe.top's profile picture

    @yrzhe_top

    Nested worktrees inside the project dir = accidental complexity tax. Solving it at the hook layer with adjacent dirs is a small spatial shift, big cognitive payoff. Bookmarked.

  • Vish's profile picture

    @rv_RAJvishnu

    moving worktrees to sibling directories is one of those fixes that seems small until you realize how much cognitive overhead messy project nesting adds. having lazygit and yazi ready in the right context on launch is a nice touch too. most people underestimate how much time they lose just navigating to the right place before they can start working

  • SweatSpots 🏃🏼‍♂️'s profile picture

    @sweatspots_com

    It's indeed a better DX than the default one! I didn't know that you can hook and overwrite the commands. How did you do that magic?

  • Life Of Rick's profile picture

    @Life_of_rick

    the sibling directory move is underrated. I've seen agents step on each other's files mid-task and it's chaos. isolation isn't just cleaner — it's the difference between reliable output and silent corruption nobody catches until production.

  • Sam Cui's profile picture

    @samcmkt

    Nicely done! I also found hooks to be the ideal solution to parallel subagents. Furthermore, you can use context injection to avoid information repetition. Check it out here:

  • Shreyans Bhansali's profile picture

    @askcodi

    bro turned worktrees into a spa day for branches

  • Tyson George's profile picture

    @TysonGeorge

    This is awesome. If you want the editor part too, I made lazyide — lazygit-style TUI IDE made to run right next to Claude Code.

  • Sizero's profile picture

    @Sizero

    What's your ghostty setup? Looks amazing!

  • Morgan's profile picture

    @morganlinton

    Super interesting Daniel, I need to try this.

  • Himanshu Kumar's profile picture

    @codewithimanshu

    @dani_avila7, Dani, custom worktrees offer better project organization.