Worktree Init

Create parallel worktrees for multi-task development with Ghostty panels

Commandgit workflowMIT1 source files

Before you use this component

This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.

Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.

Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.

Source publisher
Claude Code Templates
Creator supplied by source
Not listed in source
Pinned source version
a344359459263d73d8948651c789244093c02e4e
License evidence
LICENSE

Source preview

cli-tool/components/commands/git-workflow/worktree-init.md

---
allowed-tools: Bash(git:*), Bash(mkdir:*), Bash(ls:*), Bash(cat:*), Bash(basename:*), Bash(pwd:*), Bash(sed:*)
argument-hint: task 1 | task 2 | task 3
description: Create parallel worktrees for multi-task development with Ghostty panels
---

# Worktree Parallel Init

Create multiple git worktrees for parallel development: $ARGUMENTS

## Instructions

You are setting up parallel worktrees so the user can work on multiple tasks simultaneously in separate Ghostty terminal panels, each running its own Claude instance.

### Step 1: Validate Environment

1. Check this is a git repository: `git rev-parse --is-inside-work-tree`
2. Get the repo name: `basename $(git rev-parse --show-toplevel)`
3. Get the main branch name (check for `main` or `master`): `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'` — if that fails, default to `main`
4. Ensure working tree is clean: `git status --porcelain`. If dirty, warn the user and ask if they want to continue.
5. Fetch latest: `git fetch origin`

### Step 2: Parse Tasks

Parse tasks from `$ARGUMENTS`. Tasks are separated by `|` (pipe character).

If `$ARGUMENTS` is empty, use AskUserQuestion to ask the user to describe their tasks (they can provide multiple separated by `|`).

For each task description:
- Trim whitespace
- Generate a kebab-case branch name: `claude/<kebab-case-task>` (max 50 chars, alphanumeric and hyphens only)
- Generate a worktree directory path: `../worktrees/<repo-name>/claude-<kebab-case-task>`

### Step 3: Create Worktrees

For each task:

1. Create the parent directory if needed: `mkdir -p ../worktrees/<repo-name>`
2. Create the worktree:
   ```bash
   git worktree add -b claude/<name> ../worktrees/<repo-name>/claude-<name> origin/<main-branch>
   ```
3. Write a `.worktree-task.md` file inside the new worktree with this content:
   ```markdown
   # Worktree Task

   **Branch:** claude/<name>
   **Task:** <original task description>
   **Created:** <ISO date>
   **Source repo:** <path to main repo>
   ```

### Step 4: Check for Dependencies

If a `package.json` exists in the repo root, note that each worktree may need `npm install` (or the appropriate package manager).

Check for:
- `package-lock.json` → npm install
- `yarn.lock` → yarn install
- `pnpm-lock.yaml` → pnpm install
- `bun.lockb` → bun install

### Step 5: Output Summary

Display a clear summary table:

```
| # | Task | Branch | Path |
|---|------|--------|------|
| 1 | ... | claude/... | ../worktrees/repo/claude-... |
```

Then display ready-to-copy commands for Ghostty panels. For each worktree:

```
# Panel <N>: <task description>
cd <absolute-path-to-worktree> && claude
```

If dependencies were detected, add a note:
```
# Note: Run <package-manager> install in each worktree before starting
```

Finally, remind the user:
- Open a new Ghostty panel with `Cmd+D` (split right) or `Cmd+Shift+D` (split down)
- When done with a task, use `/worktree-deliver` to commit, push, and create a PR
- After merging all PRs, use `/worktree-cleanup --all` from the main repo

Preview capped at 60,000 characters. Download the bundle for every original file and notice.

Read the redistribution license
MIT License

Copyright (c) 2025 Daniel (San) Ávila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Bundle SHA-256: 07799fb6517712818a242cff6cfa53446d88c868c88bf9221731f040d7074c79. Files are served as downloads and are never executed by this page.