github-pr-workflowlisted
Install: claude install-skill Jessinra/Lorekeeper
# GitHub Pull Request Workflow
Complete guide for managing the PR lifecycle. Each section shows the `gh` way first, then the `git` + `curl` fallback for machines without `gh`.
## Diverged Branch Recovery
When `git pull` fails with "divergent branches" (local commits + remote commits both exist):
```bash
# Check what diverged
git log --oneline origin/main..HEAD # local-only commits
git log --oneline HEAD..origin/main # remote-only commits
# Stash any uncommitted changes first
git add -A && git stash
# Rebase local commits on top of remote (cleaner than merge)
git pull --rebase
# Restore stashed changes
git stash pop
```
Prefer `--rebase` over `--no-rebase` — keeps history linear. If stash pop conflicts, resolve manually.
## Prerequisites
- Authenticated with GitHub (see `github-auth` skill)
- Inside a git repository with a GitHub remote
### Quick Auth Detection
```bash
# Determine which method to use throughout this workflow
if command -v gh &>/dev/null && gh auth status &>/dev/null; then
AUTH="gh"
else
AUTH="git"
# Ensure we have a token for API calls
if [ -z "$GITHUB_TOKEN" ]; then
if [ -f ~/.hermes/.env ] && grep -q "^GITHUB_TOKEN=" ~/.hermes/.env; then
GITHUB_TOKEN=$(grep "^GITHUB_TOKEN=" ~/.hermes/.env | head -1 | cut -d= -f2 | tr -d '\n\r')
elif grep -q "github.com" ~/.git-credentials 2>/dev/null; then
GITHUB_TOKEN=$(grep "github.com" ~/.git-credentials 2>/dev/null | head -1 | sed 's|https://[^:]*:\([^@]*\)@.*|\1|')
fi
fi