원클릭으로
git-worktree-prepare
Create or reuse a dedicated git worktree for a branch using a deterministic path layout
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Create or reuse a dedicated git worktree for a branch using a deterministic path layout
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Find a git branch by Linear ticket ID prefix (e.g., STU-15)
Create and maintain implementation progress documentation for a feature branch
Find the worktree path for a branch and create/reuse it when missing
Resolve a properly named git branch from a Linear ticket ID following the convention {type}/{ticket-id}-short-description
Push the current branch to the remote repository with upstream tracking
Fetch unresolved review threads and PR comments for the pull request tied to the resolved target branch
| name | git-worktree-prepare |
| description | Create or reuse a dedicated git worktree for a branch using a deterministic path layout |
Create (or reuse) a dedicated worktree for a target branch so multiple agents can work in parallel without branch checkout conflicts.
status as a shell variable name (read-only in zsh). Use worktree_state instead.Worktree root is always:
{repo-root}/.opencode/.bbq-worktrees
Worktree path for a branch:
{repo-root}/.opencode/.bbq-worktrees/{branch-name-with-slashes-replaced-by-dashes}
Example:
repo root: /Users/me/projects/my-repo
branch: feat/STU-15-user-authentication
worktree: /Users/me/projects/my-repo/.opencode/.bbq-worktrees/feat-STU-15-user-authentication
branch (required): target branch name, for example feat/STU-15-user-authenticationResolve repository context:
git rev-parse --show-toplevel
Resolve default branch from remote HEAD (do not hardcode main):
git symbolic-ref refs/remotes/origin/HEAD
Parse to origin/<default-branch>.
Fallback strategy if remote HEAD is unavailable:
main if it existsmaster if it existsCheck whether this branch is already attached to any worktree:
branch="{branch}"
existing_path=""
current_path=""
while IFS= read -r line; do
case "$line" in
"worktree "*)
current_path="${line#worktree }"
;;
"branch refs/heads/"*)
current_branch="${line#branch refs/heads/}"
if [ "$current_branch" = "$branch" ]; then
existing_path="$current_path"
break
fi
;;
esac
done < <(git worktree list --porcelain)
If found, return that path with worktree state reused and stop.
Build deterministic worktree path:
repo_root from git rev-parse --show-toplevelworktree_root="$repo_root/.opencode/.bbq-worktrees"/ with - in branch name for directory nameExample extraction flow:
repo_root="$(git rev-parse --show-toplevel)"
worktree_root="$repo_root/.opencode/.bbq-worktrees"
branch_slug="${branch//\//-}"
worktree_path="$worktree_root/$branch_slug"
Add the worktree:
git worktree add "{worktree-path}" "{branch}"
git worktree add --track -b "{branch}" "{worktree-path}" "origin/{branch}"
git worktree add -b "{branch}" "{worktree-path}" "origin/{default-branch}"
Verify:
git -C "{worktree-path}" branch --show-current
Sync local-only files/directories from the source checkout:
"{repo-root}/.opencode/worktree-local-files"ln -s) so updates in source are reflected everywherecp -R) if symlink is not possiblesource_root="$(git rev-parse --show-toplevel)"
worktree_path="{worktree-path}"
sync_list="$source_root/.opencode/worktree-local-files"
linked_count=0
copied_count=0
if [ -f "$sync_list" ]; then
while IFS= read -r rel || [ -n "$rel" ]; do
case "$rel" in
""|\#*) continue ;;
esac
src="$source_root/$rel"
dst="$worktree_path/$rel"
if [ ! -e "$src" ] || [ -e "$dst" ]; then
continue
fi
mkdir -p "$(dirname "$dst")"
if ln -s "$src" "$dst" 2>/dev/null; then
linked_count=$((linked_count + 1))
else
cp -R "$src" "$dst"
copied_count=$((copied_count + 1))
fi
done < "$sync_list"
fi
Return:
Branch: <branch>
Worktree: <absolute-path>
Worktree state: <created|reused>
Default base: origin/<default-branch>
Local files linked: <count>
Local files copied: <count>
git checkout -b in the current working tree when parallel work is expected..opencode/worktree-local-files limited to local-only files (for example .env*).init.sh auto-discovers common .env* files and appends exact repo-relative paths to this list.