$npx -y skills add jezweb/claude-skills --skill git-workflowGuided git workflows: prepare PRs, clean up branches, resolve merge conflicts, handle monorepo tags, squash-and-merge patterns. Use when asked to prepare a PR, clean branches, resolve conflicts, or tag a release.
| 1 | # Git Workflow |
| 2 | |
| 3 | Guided workflows for common git operations that benefit from structured steps. |
| 4 | |
| 5 | ## PR Preparation |
| 6 | |
| 7 | When preparing a pull request: |
| 8 | |
| 9 | 1. **Gather context** |
| 10 | - `git log main..HEAD --oneline` — list all commits on the branch |
| 11 | - `git diff main...HEAD --stat` — see all changed files |
| 12 | - `git status` — check for uncommitted work |
| 13 | |
| 14 | 2. **Draft PR content** |
| 15 | - Title: under 70 chars, describes the change (not the branch name) |
| 16 | - Body: summarise the "why", list key changes, add test plan |
| 17 | - Use the commit history to write the summary — don't rely on memory |
| 18 | |
| 19 | 3. **Push and create** |
| 20 | ```bash |
| 21 | git push -u origin HEAD |
| 22 | gh pr create --title "..." --body "$(cat <<'EOF' |
| 23 | ## Summary |
| 24 | - ... |
| 25 | |
| 26 | ## Test plan |
| 27 | - [ ] ... |
| 28 | |
| 29 | 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 30 | EOF |
| 31 | )" |
| 32 | ``` |
| 33 | |
| 34 | 4. **Verify** — `gh pr view --web` to open in browser |
| 35 | |
| 36 | ## Branch Cleanup |
| 37 | |
| 38 | Clean up merged branches safely: |
| 39 | |
| 40 | 1. **Switch to main and pull latest** |
| 41 | ```bash |
| 42 | git checkout main && git pull |
| 43 | ``` |
| 44 | |
| 45 | 2. **List merged branches** (excludes main/master/develop) |
| 46 | ```bash |
| 47 | git branch --merged main | grep -vE '^\*|main|master|develop' |
| 48 | ``` |
| 49 | |
| 50 | 3. **Delete local merged branches** |
| 51 | ```bash |
| 52 | git branch --merged main | grep -vE '^\*|main|master|develop' | xargs -r git branch -d |
| 53 | ``` |
| 54 | |
| 55 | 4. **Prune remote tracking refs** |
| 56 | ```bash |
| 57 | git fetch --prune |
| 58 | ``` |
| 59 | |
| 60 | 5. **List remote branches with no local tracking** (optional) |
| 61 | ```bash |
| 62 | git branch -r --merged origin/main | grep -vE 'main|master|develop|HEAD' |
| 63 | ``` |
| 64 | |
| 65 | ## Merge Conflict Resolution |
| 66 | |
| 67 | When a PR has conflicts: |
| 68 | |
| 69 | 1. **Assess the conflict scope** |
| 70 | ```bash |
| 71 | git fetch origin |
| 72 | git merge origin/main --no-commit --no-ff |
| 73 | git diff --name-only --diff-filter=U # List conflicted files |
| 74 | ``` |
| 75 | |
| 76 | 2. **For each conflicted file**, read the file and resolve: |
| 77 | - Keep both changes if they're in different areas |
| 78 | - If architecturally incompatible, prefer the main branch's approach and re-apply the PR's intent on top |
| 79 | |
| 80 | 3. **If rebase is cleaner** (few commits, no shared history): |
| 81 | ```bash |
| 82 | git rebase origin/main |
| 83 | # Resolve conflicts per commit, then: |
| 84 | git rebase --continue |
| 85 | ``` |
| 86 | |
| 87 | 4. **If rebase is messy** (many conflicts, architectural divergence): |
| 88 | - Abort: `git rebase --abort` or `git merge --abort` |
| 89 | - Extract useful code: `git show origin/branch:path/to/file > /tmp/extracted.txt` |
| 90 | - Apply changes manually to main |
| 91 | - Close original PR with explanation |
| 92 | |
| 93 | 5. **Verify** — run tests, check the diff looks right |
| 94 | |
| 95 | ## Monorepo Release Tags |
| 96 | |
| 97 | In monorepos, scope tags to the package: |
| 98 | |
| 99 | ```bash |
| 100 | # ❌ Ambiguous in monorepos |
| 101 | git tag v2.1.0 |
| 102 | |
| 103 | # ✅ Scoped to package |
| 104 | git tag contextbricks-v2.1.0 |
| 105 | git push origin contextbricks-v2.1.0 |
| 106 | ``` |
| 107 | |
| 108 | Pattern: `{package-name}-v{semver}` |
| 109 | |
| 110 | ## .gitignore-First Init |
| 111 | |
| 112 | When creating a new repo, always create `.gitignore` BEFORE the first `git add`: |
| 113 | |
| 114 | ```bash |
| 115 | cat > .gitignore << 'EOF' |
| 116 | node_modules/ |
| 117 | .wrangler/ |
| 118 | dist/ |
| 119 | .dev.vars |
| 120 | *.log |
| 121 | .DS_Store |
| 122 | .env |
| 123 | .env.local |
| 124 | EOF |
| 125 | |
| 126 | git init && git add . && git commit -m "Initial commit" |
| 127 | ``` |
| 128 | |
| 129 | **If node_modules is already tracked:** |
| 130 | ```bash |
| 131 | git rm -r --cached node_modules/ |
| 132 | git commit -m "Remove node_modules from tracking" |
| 133 | ``` |
| 134 | |
| 135 | ## Private Repo License Audit |
| 136 | |
| 137 | Before publishing or sharing a private repo: |
| 138 | |
| 139 | ```bash |
| 140 | gh repo view --json visibility -q '.visibility' |
| 141 | ``` |
| 142 | |
| 143 | If `PRIVATE`, ensure: |
| 144 | - `LICENSE` contains proprietary notice (not MIT/Apache) |
| 145 | - `package.json` has `"license": "UNLICENSED"` and `"private": true` |
| 146 | - No `CONTRIBUTING.md` or "contributions welcome" in README |