worktrees
1
总安装量
1
周安装量
#52487
全站排名
安装命令
npx skills add https://github.com/srstomp/pokayokay --skill worktrees
Agent 安装分布
mcpjam
1
claude-code
1
junie
1
windsurf
1
crush
1
Skill 文档
Worktrees Skill
Guide for managing git worktrees in pokayokay.
When Worktrees Are Created
| Task Type | Default | Override |
|---|---|---|
| feature | Worktree | –in-place |
| bug | Worktree | –in-place |
| spike | Worktree | –in-place |
| chore | In-place | –worktree |
| docs | In-place | –worktree |
| test | Inherits | explicit flag |
Story-Based Reuse
Tasks within the same story share a worktree:
Story 12: User Authentication
âââ Task 42: Login form â .worktrees/story-12-user-auth/
âââ Task 43: Session handling â .worktrees/story-12-user-auth/ (reused)
âââ Task 44: Logout button â .worktrees/story-12-user-auth/ (reused)
Benefits:
- Related changes stay together
- No merge conflicts between related tasks
- Single PR for entire story
- Cleaner git history
Worktree Lifecycle
âââââââââââââââ
â Task starts â
ââââââââ¬âââââââ
â
â¼
ââââââââââââââââââââ NO ââââââââââââââââ
â Needs worktree? ââââââââââââââºâ Work in-placeâ
ââââââââ¬ââââââââââââ ââââââââââââââââ
â YES
â¼
ââââââââââââââââââââ YES ââââââââââââââââ
â Story worktree ââââââââââââââºâ Reuse it â
â exists? â ââââââââââââââââ
ââââââââ¬ââââââââââââ
â NO
â¼
ââââââââââââââââââââ
â Create worktree â
â Install deps â
ââââââââ¬ââââââââââââ
â
â¼
ââââââââââââââââââââ
â Work on task â
ââââââââ¬ââââââââââââ
â
â¼
ââââââââââââââââââââ
â Task complete â
ââââââââ¬ââââââââââââ
â
â¼
ââââââââââââââââââââ YES ââââââââââââââââ
â Part of story? ââââââââââââââºâ Continue to â
â â â next task â
ââââââââ¬ââââââââââââ ââââââââââââââââ
â NO (or story done)
â¼
ââââââââââââââââââââ
â Completion promptâ
â merge/PR/keep/ â
â discard â
ââââââââââââââââââââ
Directory Structure
project/
âââ .worktrees/ # All worktrees (auto-ignored)
â âââ story-12-user-auth/
â â âââ src/
â â âââ tests/
â â âââ ...
â âââ task-51-email/
âââ .gitignore # Contains ".worktrees/"
âââ src/ # Main worktree
Completion Options
Merge to Default Branch
Direct merge, good for:
- Small features
- Bug fixes
- Team doesn’t require PRs
git checkout main
git merge --no-ff story-12-user-auth
git worktree remove .worktrees/story-12-user-auth
git branch -d story-12-user-auth
Create Pull Request
Pushes branch, creates PR via gh CLI:
- Requires review
- CI/CD validation
- Keeps worktree for iterations
git push -u origin story-12-user-auth
gh pr create --title "feat: user authentication" --body "..."
Keep Worktree
No action, useful when:
- Work is incomplete
- Waiting for external input
- Planning to continue later
Discard Work
Force removes all changes:
- Failed experiment
- Requirements changed
- Duplicate work
git worktree remove --force .worktrees/story-12-user-auth
git branch -D story-12-user-auth
Dependency Installation
On worktree creation, dependencies auto-install:
| Lockfile | Command |
|---|---|
| bun.lockb | bun install |
| pnpm-lock.yaml | pnpm install |
| yarn.lock | yarn install |
| package-lock.json | npm install |
| Cargo.toml | cargo build |
| go.mod | go mod download |
| pyproject.toml | poetry install |
| requirements.txt | pip install -r requirements.txt |
| Gemfile | bundle install |
Monorepos: All detected languages are installed.
Troubleshooting
“Worktree already exists”
Another worktree uses this branch:
git worktree list # Find which worktree
“Permission denied”
Worktree might be locked:
rm .git/worktrees/<name>/locked
Dependency install fails
Options:
- Retry with different flags (–legacy-peer-deps)
- Skip and install manually
- Abort and investigate
Merge conflicts
If merging fails:
git checkout main
git merge story-12-user-auth
# Resolve conflicts
git add .
git commit
git worktree remove .worktrees/story-12-user-auth