ワンクリックで
using-git-worktrees
Use when starting feature work that needs isolation from the current workspace
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when starting feature work that needs isolation from the current workspace
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when reviewing a spec or task graph for completeness before implementation
Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging in, or automating browser actions
Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, logging in, or automating browser actions
Use when decomposing a spec, design, or feature description into a task dependency graph with self-evaluating acceptance criteria
Use when doing creative product, feature, component, functionality, or behavior design work
Use when infrastructure or features are built but before declaring done -- verifies work is wired into the system and actively used
| name | using-git-worktrees |
| description | Use when starting feature work that needs isolation from the current workspace |
Git worktrees create isolated workspaces sharing the same repository. Work on multiple branches simultaneously without switching.
Core principle: Systematic directory selection + safety verification = reliable isolation.
Check existing directories:
ls -d .worktrees 2>/dev/null || ls -d worktrees 2>/dev/null
If found: use it. If both exist, .worktrees wins.
Check AGENTS.md for worktree directory preference.
Ask the user if nothing found.
For project-local directories, verify the directory is gitignored:
git check-ignore -q .worktrees 2>/dev/null
If NOT ignored: Add to .gitignore and commit before proceeding.
project=$(basename "$(git rev-parse --show-toplevel)")
git worktree add .worktrees/$BRANCH_NAME -b $BRANCH_NAME
cd .worktrees/$BRANCH_NAME
main_root=$(git rev-parse --show-toplevel)
for env in .env .env.local .env.test; do
[ -f "$main_root/$env" ] && cp "$main_root/$env" .
done
# Go
if [ -f go.mod ]; then go mod download; fi
# Python
if [ -f pyproject.toml ]; then uv sync; fi
# Node
if [ -f package.json ]; then npm install; fi
go test ./... # Go
uv run pytest # Python
If tests fail: report failures, ask whether to proceed.
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>
Removing a worktree while the shell cwd is inside it permanently kills the Bash tool — every subsequent command returns exit code 1 with no output. This is a known Codex bug (GitHub #9190) with no recovery except session restart.
Mandatory sequence:
# 1. ALWAYS cd to project root FIRST
cd "$(git rev-parse --show-toplevel)"
# 2. THEN remove the worktree
git worktree remove .worktrees/$BRANCH_NAME
# 3. Verify bash still works
echo "bash ok"
Rules:
&&, ;)worktree_guard.py) will block dangerous removals, but don't rely on it — follow the sequence aboveIf bash dies anyway: The session is unrecoverable. Use /clear or restart Codex.
| Situation | Action |
|---|---|
.worktrees/ exists | Use it (verify ignored) |
worktrees/ exists | Use it (verify ignored) |
| Neither exists | Check AGENTS.md → ask user |
| Directory not ignored | Add to .gitignore + commit |
| Tests fail at baseline | Report + ask |
| Removing a worktree | cd to project root first, then remove |
git worktree remove without first cd to project root