git-worktree

Git worktreeを使用した並行作業管理。実装開始時にworktreeを作成し、完了時に削除する。

⭐4stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

When & Why to Use This Skill

This Claude skill streamlines parallel development workflows by managing Git worktrees through the 'gwq' utility. It enables developers to work on multiple branches simultaneously in isolated directories, eliminating the need for frequent stashing or context switching. The skill automates the entire lifecycle of a worktree—from creation and dependency installation to execution and final cleanup—ensuring a clean and organized workspace for complex software engineering tasks.

Use Cases

  • Scenario 1: Handling urgent hotfixes while working on a long-term feature branch without interrupting the current coding state or losing uncommitted changes.
  • Scenario 2: Running time-consuming test suites or build processes in one worktree while simultaneously continuing development or code refactoring in another.
  • Scenario 3: Performing local code reviews and testing of multiple Pull Requests side-by-side in dedicated environments to ensure integration quality.
  • Scenario 4: Managing micro-implementations where each task requires a fresh environment and specific dependency versions without affecting the main repository root.
namegit-worktree
descriptionGit worktreeを使用した並行作業管理。実装開始時にworktreeを作成し、完了時に削除する。

Git Worktree Management (gwq)

軽微な修正以外の実装作業は、gwqを使ってworktreeで作業する。

0. 前提条件

1. Worktree 作成

1.1 既存worktree確認

gwq list

1.2 新規ブランチでworktree作成(推奨)

# 新規ブランチ + worktree を作成
gwq add -b feature/xxx

# 作成後、worktreeに移動
cd $(gwq get feature/xxx)

1.3 現在のブランチでworktree作成

gwq add
cd $(gwq get <branch-name>)

1.4 依存関係インストール

# lock fileを検出してインストール
if [ -f "bun.lockb" ]; then
    bun install
elif [ -f "pnpm-lock.yaml" ]; then
    pnpm install
fi

2. 作業中

2.1 worktree内でコマンド実行

# cdなしでworktree内でコマンド実行
gwq exec feature/xxx -- bun test
gwq exec feature/xxx -- bun run lint
gwq exec feature/xxx -- bun run tsc

2.2 変更状態確認

gwq status

2.3 注意事項

  • worktree内で作業を継続する
  • コミット・プッシュは通常通り実行可能
  • 各Bashコマンドは worktree ディレクトリ内で実行する

3. 作業完了後

3.1 削除前確認

ユーザーに以下を確認する:

  • 「worktree作業が完了しました。削除してよろしいですか?」
# 変更状態を確認
gwq status

3.2 削除実行

# 元のリポジトリに移動してから削除
cd <original-repo-path>

# worktree + ブランチを削除(推奨)
gwq remove -b feature/xxx

# worktree のみ削除(ブランチは残す)
gwq remove feature/xxx

3.3 強制削除(未コミット変更がある場合)

ユーザー確認必須:

gwq remove -f feature/xxx

4. トラブルシューティング

不要なworktree参照を削除

gwq prune

全worktree一覧確認

gwq list