name: git-worktree description: 該 skill 用於建立 git worktree
git-worktree
規則
- 使用以下 Bash 取得當前 branch
BASE_BRANCH=$(git branch --show-current)
- worktree 命名規則
wt-${openspec proposal name}-{date}
- 透過以下方式建立 worktree
BASE_BRANCH=$(git branch --show-current)
WT_BRANCH=wt-${openspec proposal name}-{date}
git worktree add worktrees/$WT_BRANCH -b "$WT_BRANCH" "$BASE_BRANCH"
- 建立完成後需要同步將 claude/settings.local.json 一並複製到 worktree
worktree 命名規則
錯誤處理:
- 使用既有 branch,但確保 reset 到正確的基礎分支
- 避免指向舊的 commit 而缺少必要檔案(如 openspec 資料夾)
worktree structure:
main-repo/
├── .git/
└── worktrees/
├── wt-add-auth-system-20260110/
├── wt-refactor-api-20260111/
└── wt-update-docs-20260113/