/github-issue-worktree:github-issue-worktreefrom github-issue-worktree
Manages an isolated git worktree per GitHub issue. Registers branches with gh issue develop, then creates, lists, and removes worktrees using git cow. Useful when working on multiple GitHub issues simultaneously.
Ships in github-issue-worktree. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill covers the issue workflow. The git-worktrees skill owns the worktree. Read that skill and follow it. Call git cow only. A new worktree goes in ~/.worktrees/<project>/. If git cow list already has the branch under <project>/.claude/worktrees, use that path.
gh (GitHub CLI) is installed and on PATHgh auth login is done for the correct GitHub host/accountorigin) points to the repository that holds the issues and PRsCheck:
gh auth status
gh repo view
gh issue list --limit 1
A worktree is an extra working directory attached to the same repository. Each worktree has its own checked-out branch, so you can work on several branches at once without stashing or committing unfinished work.
┌─────────────────────────────────────────────────────────────────┐
│ GIT WORKTREE WORKFLOW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. START WORK │
│ ├── Comment on issue: "## 🚀 Starting Work" + plan │
│ ├── Register branch link: gh issue develop {id} │
│ ├── Create worktree from linked branch │
│ └── Work in new directory │
│ │
│ 2. DEVELOPMENT │
│ ├── Implement solution in worktree │
│ ├── Commit changes │
│ └── Push to remote branch │
│ │
│ 3. SUBMIT WORK │
│ ├── Create Pull Request (from feature → main) │
│ ├── Link PR to issue │
│ └── Comment: "## ✅ Task Completed" + summary │
│ │
│ 4. CLEANUP (after merge) │
│ ├── Update labels: status:in-progress → status:done │
│ └── git cow remove --warm, from the main checkout │
│ │
└─────────────────────────────────────────────────────────────────┘
Set these names first and use them in all commands:
PROJECT_NAME: directory name of the main checkoutWORKTREE_ROOT: ~/.worktrees/<project-name>/BRANCH_NAME: gh-task-{issueId}-{shortTitle}shortTitle: issue title slug (lowercase, spaces and special characters replaced with -)WORKTREE_PATH: ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}Compute them before you create a worktree. This works when the current directory is already a worktree:
common=$(git rev-parse --path-format=absolute --git-common-dir)
PROJECT_NAME=$(basename "$(dirname "$common")")
WORKTREE_ROOT="$HOME/.worktrees/$PROJECT_NAME"
BRANCH_NAME="gh-task-{issueId}-{shortTitle}"
WORKTREE_PATH="$WORKTREE_ROOT/$BRANCH_NAME"
Before you start, post your plan as a comment on the issue:
gh issue comment {issueId} --body "## 🚀 Starting Work
**Plan:**
1. Step 1 description
2. Step 2 description
3. Step 3 description
**Estimated Time:** X hours
**Worktree:** ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}"
# Make sure you are in the project directory and on the intended base branch.
# Branch naming format: gh-task-{issueId}-{shortTitle}
gh issue develop {issueId} \
--base main \
--name gh-task-{issueId}-{shortTitle}
git cow add ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle} gh-task-{issueId}-{shortTitle}
cd ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}
The branch already exists, so the path comes first. Follow the git-worktrees skill for that command.
Do not use gh issue develop --checkout with worktrees. Git checks out a branch in only one worktree at a time.
Do all development in the new worktree directory:
# You're now in ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}
# Make your changes, edit files, create new ones
# Stage and commit as you work
git add .
git commit -m "feat: descriptive commit message"
# Push the branch to remote
git push -u origin gh-task-{issueId}-{shortTitle}
# Create PR from current branch to main
gh pr create \
--base main \
--head gh-task-{issueId}-{shortTitle} \
--title "feat: {descriptive title referencing shortTitle}" \
--body "## Summary
Brief description of changes.
## Changes
- Change 1
- Change 2
- Change 3
## Related
Closes #{issueId}"
Two options:
Closes #{issueId} or Fixes #{issueId} in the PR bodyRelated to #{issueId}, and link it in the GitHub UI sidebar if neededAfter you create the PR, post a completion comment on the issue:
gh issue comment {issueId} --body "## ✅ Task Completed
**Summary:**
Brief description of what was done.
**Pull Request:** {pr-url}
**Changes:**
- Change 1
- Change 2
- Change 3"
# Remove in-progress label, add done label
gh issue edit {issueId} \
--remove-label "status:in-progress" \
--add-label "status:done"
From the main checkout, follow the git-worktrees skill:
git cow remove --warm ~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}
This removes the worktree. It also deletes the branch if the branch is merged.
git cow list
git cow add ~/.worktrees/<project-name>/gh-task-{id} gh-task-{id}
git cow remove --warm ~/.worktrees/<project-name>/gh-task-{id}
gh issue develop {id} --base main --name gh-task-{id}
git cow add ~/.worktrees/<project-name>/gh-task-{id} gh-task-{id}
~/.worktrees/<project-name>/gh-task-{issueId}-{shortTitle}gh-task-{issueId}-{shortTitle}The default directory is ~/.worktrees/<project-name>/. Follow the git-worktrees skill for the path. An existing Claude Code worktree under <project>/.claude/worktrees stays there.
common=$(git rev-parse --path-format=absolute --git-common-dir)
PROJECT_NAME=$(basename "$(dirname "$common")")
WORKTREE_ROOT="$HOME/.worktrees/$PROJECT_NAME"
For issue #42 "Add user authentication":
~/.worktrees/my-repo/gh-task-42-add-user-authgh-task-42-add-user-auth| Do | Don't |
|---|---|
| Register linked branch, then create worktree | Work directly in main repo for isolated tasks |
| Use descriptive branch names | Use generic names like fix, feature |
| Commit regularly in the worktree | Wait until the end to commit |
| Clean up after PR merge | Leave orphaned worktrees |
| Run tests before pushing | Push untested code |
| Link PR to issue | Forget to reference the issue |
| Keep worktrees in a dedicated root directory | Mix worktrees into tracked project paths |
| Ensure local worktree root is gitignored | Commit worktree directories by accident |
git cow list
Reuse the path it prints for that branch.
git cow add ~/.worktrees/<project-name>/gh-task-{id} gh-task-{id}
gh issue develop {id} --name gh-task-{id}
#!/bin/bash
# Complete workflow automation template
set -euo pipefail
ISSUE_ID="${1:-}"
if [ -z "$ISSUE_ID" ]; then
echo "Usage: $0 <issue-id>"
exit 1
fi
# Pull issue title and sanitize into slug (lowercase, a-z0-9- only)
ISSUE_TITLE=$(gh issue view "$ISSUE_ID" --json title -q .title)
BRANCH_SLUG=$(echo "$ISSUE_TITLE" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//; s/-{2,}/-/g' \
| cut -c1-30)
BRANCH_NAME="gh-task-${ISSUE_ID}-${BRANCH_SLUG}"
# Configurable defaults
BASE_BRANCH="${BASE_BRANCH:-main}"
common=$(git rev-parse --path-format=absolute --git-common-dir)
REPO_NAME=$(basename "$(dirname "$common")")
WORKTREE_ROOT="${WORKTREE_ROOT:-$HOME/.worktrees/$REPO_NAME}"
WORKTREE_PATH="$WORKTREE_ROOT/$BRANCH_NAME"
# If the branch is already checked out, reuse that path
EXISTING_BRANCH_PATH=$(git cow list | awk -F '\t' -v b="$BRANCH_NAME" '$2==b {print $1; exit}')
if [ -n "$EXISTING_BRANCH_PATH" ]; then
echo "ℹ️ Branch $BRANCH_NAME is already checked out at:"
echo " $EXISTING_BRANCH_PATH"
echo " Reuse it with: cd $EXISTING_BRANCH_PATH"
exit 0
fi
if [ -e "$WORKTREE_PATH" ]; then
echo "Path already exists: $WORKTREE_PATH"
exit 1
fi
# 1. Comment on issue
echo "📋 Commenting on issue #${ISSUE_ID}..."
gh issue comment "$ISSUE_ID" --body "## 🚀 Starting Work
**Plan:**
1. Analyze requirements
2. Implement solution
3. Test and verify
4. Create PR
**Worktree:** ${WORKTREE_PATH}"
# 2. Register linked branch in GitHub
echo "🔗 Registering branch link..."
gh issue develop "$ISSUE_ID" --base "$BASE_BRANCH" --name "$BRANCH_NAME"
# Optional verification that GitHub recognizes branch linkage
echo "🔍 Verifying linked branches..."
gh issue develop --list "$ISSUE_ID"
# 3. Create local worktree from linked branch
echo "🔧 Creating worktree..."
git cow add "$WORKTREE_PATH" "$BRANCH_NAME"
echo "✅ Worktree created at: $WORKTREE_PATH"
echo "📁 Navigate with: cd $WORKTREE_PATH"
echo ""
echo "Next steps:"
echo " 1. cd $WORKTREE_PATH"
echo " 2. Make your changes"
echo " 3. git add . && git commit -m \"feat: ...\""
echo " 4. git push -u origin $BRANCH_NAME"
echo " 5. gh pr create --base $BASE_BRANCH --fill"
echo " 6. Use 'Related to #${ISSUE_ID}' (relation only) or 'Closes #${ISSUE_ID}' (auto-close)"
Use this checklist for each task:
gh issue develop {id} --base main --name gh-task-{id}-{title}git cow add ~/.worktrees/<project-name>/gh-task-{id}-{title} gh-task-{id}-{title}Closes #{issueId} (auto-close) or Related to #{issueId} (relation only)status:in-progress, add status:donegit cow remove --warm on the worktree pathWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub gabrielkoerich/skills --plugin github-issue-worktree