worktree-guide
Interactive guide for parallel development with Ghostty, git worktrees, and Lazygit. Use when setting up multi-task workflows or learning the worktree system.
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit davila7/claude-code-templates/cli-tool/components/skills/development/worktree-guide .claude/skills/worktree-guideOr install it for every project:
npx degit davila7/claude-code-templates/cli-tool/components/skills/development/worktree-guide ~/.claude/skills/worktree-guideFile content
Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source β
--- name: worktree-guide description: Interactive guide for parallel development with Ghostty, git worktrees, and Lazygit. Use when setting up multi-task workflows or learning the worktree system. license: MIT metadata: author: claude-code-templates version: "1.0" --- Guide the user through parallel development workflows using Ghostty terminal panels, git worktrees, and Lazygit. This is both a teaching experience and a practical reference. --- ## Preflight Before starting, detect the user's environment: ```bash git rev-parse --is-inside-work-tree 2>&1 && echo "GIT_OK" || echo "NOT_GIT" ``` **If not a git repo:** > This isn't a git repository. Navigate to a git project first, then come back to `/worktree-guide`. Check if we're in a worktree or main repo: ```bash git worktree list pwd ``` Note the context for later guidance. --- ## Phase 1: Welcome & Context Detection Display based on environment: **If in main repo:** ``` ## Worktree Parallel Development Guide Welcome! I'll guide you through setting up and using parallel worktrees for multi-task development. βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Ghostty Terminal β β ββββββββββββββββββββββββ¬βββββββββββββββββββββββ β β β β β β β β Claude (Task 1) β Claude (Task 2) β β β β claude/login-page β claude/fix-auth-bug β β β β β β β β ββββββββββββββββββββββββ΄βββββββββββββββββββββββ€ β β β Lazygit (monitoring) β β β βββββββββββββββββββββββββββββββββββββββββββββββ β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ **Your workflow:** 1. Create worktrees β `/worktree-init` 2. Open Ghostty panels β `Cmd+D` / `Cmd+Shift+D` 3. Run Claude in each panel β `cd <worktree> && claude` 4. Deliver when done β `/worktree-deliver` 5. Clean up β `/worktree-cleanup` What would you like to do? ``` Use AskUserQuestion: - "Learn the full workflow" β Start from Phase 2 - "Just show keybindings" β Jump to Quick Reference - "Create worktrees now" β Suggest `/worktree-init` - "Something else" β Ask what they need **If already in a worktree:** ``` ## Worktree Status You're already inside a worktree! Let me check your status. ``` Then run the equivalent of `/worktree-check` and provide contextual guidance. --- ## Phase 2: Ghostty Essentials **EXPLAIN:** ``` ## Ghostty Panel Management Ghostty's panel system is perfect for parallel development. Here are the essential keybindings: ``` **SHOW:** ``` βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β GHOSTTY KEYBINDINGS β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β SPLITTING β β βββββββββ β β Cmd+D Split panel to the right β β Cmd+Shift+D Split panel below β β β β NAVIGATION β β βββββββββ β β Cmd+Alt+β/β/β/β Move focus between panels β β Cmd+[/] Cycle through panels β β β β SIZING β β βββββββββ β β Cmd+Shift+E Equalize all panel sizes β β Cmd+Shift+F Toggle zoom (fullscreen current panel) β β β β CLOSING β β βββββββββ β β Cmd+W Close current panel β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ **Pro tip:** Use Cmd+Shift+F to zoom into a panel when you need focus, then press it again to return to the multi-panel view. ``` **PAUSE** - "Ready to learn about Lazygit? (Or skip to workflow)" --- ## Phase 3: Lazygit Essentials **EXPLAIN:** ``` ## Lazygit for Monitoring Worktrees Lazygit gives you a visual overview of all your worktrees and their changes. Run it from your main repo to monitor everything. ``` **SHOW:** ``` βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β LAZYGIT KEYBINDINGS β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β WORKTREES (navigate to Worktrees panel) β β βββββββββ β β w Switch to worktree panel (or create new) β β Enter Switch to selected worktree β β n Create new worktree β β d Delete worktree (with confirmation) β β β β FILES & STAGING β β βββββββββ β β Space Stage/unstage file β β a Stage all files β β Enter View file diff (with Delta highlighting) β β β β COMMITS β β βββββββββ β β c Commit staged changes β β C Commit with editor β β A Amend last commit β β β β SYNC β β βββββββββ β β P Push β β p Pull β β f Fetch β β β β GENERAL β β βββββββββ β β ? Help (context-sensitive) β β q Quit / go back β β Tab Switch panels β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ **Monitoring workflow:** 1. Open lazygit in the main repo (or a dedicated Ghostty panel) 2. Press `w` to see all worktrees 3. Use Enter to dive into any worktree's changes 4. Press `q` to go back to the worktree list ``` **PAUSE** - "Ready for the full workflow walkthrough?" --- ## Phase 4: Complete Workflow (Guided) **EXPLAIN:** ``` ## Full Parallel Development Workflow Let me walk you through the complete cycle. We'll go step by step. ``` ### Step 4.1: Create Worktrees **EXPLAIN:** ``` ### Step 1: Create Worktrees First, define the tasks you want to work on in parallel. The `/worktree-init` command creates a worktree for each task. ``` **DO:** Show example command: ``` Example usage: /worktree-init add user authentication | fix login bug | improve dashboard performance This creates: βββ ../worktrees/<repo>/claude-add-user-authentication/ βββ ../worktrees/<repo>/claude-fix-login-bug/ βββ ../worktrees/<repo>/claude-improve-dashboard-performance/ ``` ### Step 4.2: Open Ghostty Panels **EXPLAIN:** ``` ### Step 2: Open Ghostty Panels Now split your terminal into panelsβone for each task, plus optionally one for Lazygit monitoring. ``` **DO:** ``` 1. Press Cmd+D to split right (first worktree) 2. Press Cmd+D again (second worktree) 3. Optionally press Cmd+Shift+D on any panel for Lazygit below Resulting layout: ββββββββββββ¬βββββββββββ¬βββββββββββ β Task 1 β Task 2 β Task 3 β β claude β claude β claude β ββββββββββββ΄βββββββββββ΄βββββββββββ€ β lazygit β ββββββββββββββββββββββββββββββββββ ``` ### Step 4.3: Work in Each Panel **EXPLAIN:** ``` ### Step 3: Work Independently In each panel: 1. cd to the worktree path (from the commands output) 2. Run `claude` to start a Claude session 3. Use `/worktree-check` anytime to verify which task you're working on 4. Work normallyβClaude doesn't know about other panels ``` ### Step 4.4: Deliver Completed Work **EXPLAIN:** ``` ### Step 4: Deliver When Done When you finish a task in any panel, use `/worktree-deliver` to: 1. Review your changes 2. Create a commit 3. Push to remote 4. Create a pull request ``` ### Step 4.5: Clean Up **EXPLAIN:** ``` ### Step 5: Clean Up After Merging After your PRs are merged on GitHub: 1. Go back to the main repo (not a worktree) 2. Run `/worktree-cleanup --all` 3. It removes merged worktrees and branches ``` --- ## Phase 5: Troubleshooting **SHOW:** ``` ## Troubleshooting ### "I'm not sure which worktree I'm in" Run `/worktree-check` β it shows your branch, task, and status. Alternatively: $ git branch --show-current # Shows claude/<name> $ pwd # Shows the worktree path --- ### "I have uncommitted changes and want to switch tasks" **Option 1:** Commit work-in-progress $ git add . && git commit -m "wip: progress on feature" **Option 2:** Stash changes (temporary) $ git stash push -m "wip: parking changes" Then in the other panel, continue working. Come back later with: $ git stash pop --- ### "I accidentally started working in the wrong worktree" 1. Stash your changes: `git stash push -m "work done in wrong place"` 2. Navigate to the correct worktree 3. Apply the stash: `git stash pop` --- ### "My worktree has merge conflicts" 1. Run `git fetch origin` to get latest 2. Run `git rebase origin/main` (or merge if you prefer) 3. Resolve conflicts in your editor 4. `git add .` then `git rebase --continue` --- ### "I want to abandon a worktree" From the main repo: $ git worktree remove ../worktrees/repo/claude-<name> --force $ git branch -D claude/<name> Note: Force is needed if there are uncommitted changes. --- ### "/worktree-deliver failed on push" Usually means the remote branch doesn't exist yet or there's a conflict. Try: $ git push -u origin HEAD If there's a conflict with remote, pull first: $ git pull --rebase origin claude/<name> --- ### "The worktree path doesn't exist anymore" The worktree was probably deleted manually. Clean up the git state: $ git worktree prune ``` --- ## Phase 6: Quick Reference Card **SHOW:** ``` βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β WORKTREE QUICK REFERENCE β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β COMMANDS β β βββββββββ β β /worktree-init <task1> | <task2> Create worktrees for parallel tasks β β /worktree-check Show current worktree status & task β β /worktree-deliver Commit, push, and create PR β β /worktree-cleanup --all Remove merged worktrees and branches β β /worktree-cleanup --dry-run Preview what would be cleaned up β β β β GHOSTTY β β βββββββββ β β Cmd+D Split right β Cmd+Shift+E Equalize panels β β Cmd+Shift+D Split down β Cmd+Shift+F Zoom toggle β β Cmd+Alt+Arrows Navigate β Cmd+W Close panel β β β β LAZYGIT β β βββββββββ β β w Worktrees panel β Space Stage/unstage β β Enter View diff β c Commit β β P Push β ? Help β β β β GIT (manual) β β βββββββββ β β git worktree list List all worktrees β β git worktree add -b claude/name path Create worktree manually β β git worktree remove path Remove a worktree β β git worktree prune Clean up stale worktree refs β β β β WORKFLOW β β βββββββββ β β 1. /worktree-init tasks... Create worktrees β β 2. Cmd+D (split panels) Open Ghostty panels β β 3. cd <path> && claude Start Claude in each β β 4. /worktree-deliver PR when done β β 5. /worktree-cleanup Clean up after merge β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ``` --- ## Guardrails - **Never execute destructive commands** without confirmation (worktree remove, branch delete) - **Always verify location** before suggesting worktree operations - **If user seems lost**, offer `/worktree-check` first - **Never force-delete** branches that aren't merged - **Don't assume tools are installed** β check for lazygit availability if suggesting it - **Respect user's pace** β don't rush through sections if they want to practice - **Keep the reference card available** β offer to show it whenever relevant