create-worktree
Git worktree を作成し、並行開発用の独立したブランチ環境を構築する。プラットフォーム固有コード開発時に使用。
When & Why to Use This Skill
This Claude skill automates the creation of Git worktrees to facilitate seamless parallel development. It streamlines the setup of independent branch environments by automatically creating dedicated directories, initializing feature branches, and synchronizing essential environment configuration files (such as .env and .envrc), enabling developers to switch between tasks efficiently without disrupting their primary workspace.
Use Cases
- Parallel Feature Development: Manage multiple feature branches or bug fixes simultaneously in separate directories, eliminating the need for frequent git stashing or context switching.
- Platform-Specific Development: Isolate environments for platform-specific code changes, allowing for side-by-side comparison and testing across different build targets.
- Automated Environment Setup: Instantly bootstrap new development environments by automatically copying local configuration and environment variables to the new worktree, ensuring immediate readiness.
| name | create-worktree |
|---|---|
| description | Git worktree を作成し、並行開発用の独立したブランチ環境を構築する。プラットフォーム固有コード開発時に使用。 |
Git Worktree Creator
planモード終了後、feature開発用の独立したworktree環境を自動作成します。
概要
このスキルは以下を自動で実行します:
.worktrees/<feature-name>/ディレクトリにworktreeを作成feature/<feature-name>ブランチを新規作成- 環境変数ファイル(
.env,.envrcなど)を自動コピー
使用方法
基本的な使い方
bash .opencode/skill/create-worktree/scripts/create_worktree.sh <feature-name>
# 例: Issue #42 用の worktree を作成
bash .opencode/skill/create-worktree/scripts/create_worktree.sh issue-42-auth
実行結果
.worktrees/issue-42-auth/ # worktreeディレクトリ
├── .env # ルートからコピー
├── .envrc # ルートからコピー
└── ...(その他のファイル)
コピーされる環境変数ファイル
| ファイル | 説明 |
|---|---|
.env |
ルートレベルの環境変数 |
.envrc |
direnv設定 |
.env.local |
ローカル開発用 |
作業完了後
PR作成とworktree削除を同時に行う(推奨)
pr-and-cleanup スキルを使用すると、PR作成とworktree削除を自動で行えます:
cd .worktrees/<feature-name>
bash ../../.opencode/skill/pr-and-cleanup/scripts/pr_and_cleanup.sh
詳細は pr-and-cleanup スキル を参照してください。
手動でworktreeを削除する場合
git worktree remove .worktrees/<feature-name>
詳細
詳細については REFERENCE.md を参照してください。