create-worktree
Creates a git worktree for parallel feature development. Use after planning to prepare an isolated development environment with all necessary environment files.
When & Why to Use This Skill
The Git Worktree Creator skill streamlines parallel feature development by automating the setup of isolated development environments. It leverages Git's worktree functionality to create dedicated directories for new branches, automatically synchronizing essential environment variables (.env, .envrc) and executing setup scripts. This eliminates the friction of context switching, stashing changes, or manual environment configuration, allowing developers to maintain multiple active workstreams efficiently.
Use Cases
- Parallel Feature Development: Work on multiple independent features simultaneously in separate directories without the need to stash or commit unfinished work when switching branches.
- Urgent Hotfix Handling: Quickly spin up a clean, isolated environment to address critical production bugs while keeping your primary feature development workspace untouched.
- Automated Environment Bootstrapping: Instantly provision new workspaces with all necessary configuration files and dependencies pre-configured through automated copying of environment variables and 'make setup' execution.
- Code Review and Testing: Create a temporary, isolated worktree to pull and test a colleague's branch without disrupting your own local development state.
| name | create-worktree |
|---|---|
| description | Creates a git worktree for parallel feature development. Use after planning to prepare an isolated development environment with all necessary environment files. |
| allowed-tools | Bash(git:*), Bash(mkdir:*), Bash(cp:*), Bash(chmod:*), Bash(bash:*), Bash(make:*) |
Git Worktree Creator
planモード終了後、feature開発用の独立したworktree環境を自動作成します。
概要
このSkillは以下を自動で実行します:
.worktrees/<feature-name>/ディレクトリにworktreeを作成feature/<feature-name>ブランチを新規作成- 環境変数ファイル(
.env,.envrcなど)を自動コピー make setupで開発環境をセットアップ
使用方法
基本的な使い方
# スクリプトを実行
bash .claude/skills/create-worktree/scripts/create_worktree.sh <feature-name>
# 例: user-auth 機能を開発する場合
bash .claude/skills/create-worktree/scripts/create_worktree.sh user-auth
実行結果
.worktrees/user-auth/ # worktreeディレクトリ
├── .env # ルートからコピー
├── .envrc # ルートからコピー
├── modules/
│ ├── frontend/.env* # frontendの環境変数
│ ├── backend/.env # backendの環境変数
│ └── agent/.env # agentの環境変数(あれば)
└── ...(その他のファイル)
コピーされる環境変数ファイル
- ルート:
.env,.envrc - frontend:
.env,.env.local,.env.dev,.env.prd,.env.test - backend:
.env - agent:
.env(存在する場合)
作業完了後
PR作成とworktree削除を同時に行う(推奨)
pr-and-cleanup スキルを使用すると、PR作成とworktree削除を自動で行えます:
cd .worktrees/<feature-name>
bash ../../.claude/skills/pr-and-cleanup/scripts/pr_and_cleanup.sh
詳細は pr-and-cleanup スキル を参照してください。
手動でworktreeを削除する場合
git worktree remove .worktrees/<feature-name>
詳細
詳細については REFERENCE.md を参照してください。