$npx -y skills add jackspace/ClaudeSkillz --skill claude-git-branchingExpert Git workflow management for Claude Code sessions with branch naming conventions, push retry logic, conflict resolution, and PR automation specifically designed for AI-assisted development workflows.
| 1 | # Claude Git Branching |
| 2 | |
| 3 | Master Git workflows optimized for Claude Code development sessions with intelligent branching, retry logic, and automated PR creation. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | This skill provides battle-tested Git workflows specifically designed for Claude Code sessions, including: |
| 8 | - Claude-specific branch naming conventions |
| 9 | - Automatic push retry with exponential backoff |
| 10 | - Multi-repository coordination |
| 11 | - Conflict-free collaboration patterns |
| 12 | - Automated PR creation and management |
| 13 | |
| 14 | ## When to Use |
| 15 | |
| 16 | Use this skill when: |
| 17 | - Starting a new Claude Code development session |
| 18 | - Managing multiple feature branches across sessions |
| 19 | - Dealing with intermittent network issues during push |
| 20 | - Creating PRs from Claude-generated code |
| 21 | - Coordinating work across multiple repositories |
| 22 | - Following team Git conventions for AI-assisted development |
| 23 | - Handling merge conflicts in long-running sessions |
| 24 | |
| 25 | ## Branch Naming Conventions |
| 26 | |
| 27 | ### Claude Code Standard Format |
| 28 | |
| 29 | ```bash |
| 30 | # Standard format |
| 31 | claude/[feature-name]-[session-id] |
| 32 | |
| 33 | # Examples |
| 34 | claude/harvest-claude-skills-01MtCwKhDQhWyZCgwfkhdVG5 |
| 35 | claude/fix-auth-bug-01NAB2cDE3FgHiJ4KlM5NoPq |
| 36 | claude/add-api-endpoints-01PQRsT6UvWxY7ZaBcD8EfGh |
| 37 | ``` |
| 38 | |
| 39 | **Format requirements:** |
| 40 | - **Prefix**: Must start with `claude/` |
| 41 | - **Feature name**: Kebab-case description of work |
| 42 | - **Session ID**: Unique identifier for the session |
| 43 | - **Maximum length**: 100 characters recommended |
| 44 | |
| 45 | **Why this format?** |
| 46 | - ✅ Clear AI-assisted development marker |
| 47 | - ✅ Prevents conflicts with human developer branches |
| 48 | - ✅ Traceable to specific session |
| 49 | - ✅ Easy to filter and manage |
| 50 | - ✅ Works with GitHub access controls (required for push) |
| 51 | |
| 52 | ### Alternative Formats |
| 53 | |
| 54 | ```bash |
| 55 | # Team-based |
| 56 | claude/[team]/[feature]-[session-id] |
| 57 | claude/backend/api-optimization-01ABC |
| 58 | |
| 59 | # Priority-based |
| 60 | claude/[priority]/[feature]-[session-id] |
| 61 | claude/urgent/security-patch-01DEF |
| 62 | |
| 63 | # Issue-based |
| 64 | claude/issue-[number]-[session-id] |
| 65 | claude/issue-1234-01GHI |
| 66 | ``` |
| 67 | |
| 68 | ## Branch Creation Workflow |
| 69 | |
| 70 | ### Step 1: Check Current State |
| 71 | |
| 72 | ```bash |
| 73 | # Verify current branch |
| 74 | git branch --show-current |
| 75 | |
| 76 | # Check status |
| 77 | git status |
| 78 | |
| 79 | # View recent branches |
| 80 | git branch -a | grep "claude/" | head -10 |
| 81 | ``` |
| 82 | |
| 83 | ### Step 2: Create Feature Branch |
| 84 | |
| 85 | ```bash |
| 86 | # From main/master |
| 87 | git checkout main |
| 88 | git pull origin main |
| 89 | |
| 90 | # Create Claude branch |
| 91 | FEATURE="add-user-authentication" |
| 92 | SESSION_ID="01MtCwKhDQhWyZCgwfkhdVG5" |
| 93 | BRANCH="claude/${FEATURE}-${SESSION_ID}" |
| 94 | |
| 95 | git checkout -b "$BRANCH" |
| 96 | echo "Created branch: $BRANCH" |
| 97 | ``` |
| 98 | |
| 99 | ### Step 3: Verify Branch Name |
| 100 | |
| 101 | ```bash |
| 102 | # Ensure proper format |
| 103 | CURRENT_BRANCH=$(git branch --show-current) |
| 104 | |
| 105 | if [[ ! "$CURRENT_BRANCH" =~ ^claude/.+-[0-9A-Za-z]{20,}$ ]]; then |
| 106 | echo "⚠️ Warning: Branch name doesn't match Claude format" |
| 107 | echo "Expected: claude/[feature-name]-[session-id]" |
| 108 | echo "Got: $CURRENT_BRANCH" |
| 109 | fi |
| 110 | ``` |
| 111 | |
| 112 | ## Push with Retry Logic |
| 113 | |
| 114 | ### Standard Push Pattern |
| 115 | |
| 116 | ```bash |
| 117 | #!/bin/bash |
| 118 | # push-with-retry.sh - Push with exponential backoff |
| 119 | |
| 120 | BRANCH=$(git branch --show-current) |
| 121 | MAX_RETRIES=4 |
| 122 | RETRY_COUNT=0 |
| 123 | DELAYS=(2 4 8 16) # Exponential backoff in seconds |
| 124 | |
| 125 | echo "Pushing branch: $BRANCH" |
| 126 | |
| 127 | while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do |
| 128 | if git push -u origin "$BRANCH"; then |
| 129 | echo "✓ Successfully pushed to origin/$BRANCH" |
| 130 | exit 0 |
| 131 | else |
| 132 | EXIT_CODE=$? |
| 133 | RETRY_COUNT=$((RETRY_COUNT + 1)) |
| 134 | |
| 135 | # Check if it's a 403 error (branch name issue) |
| 136 | if git push -u origin "$BRANCH" 2>&1 | grep -q "403"; then |
| 137 | echo "✗ Push failed with 403 - Check branch naming convention" |
| 138 | echo "Branch must start with 'claude/' and end with session ID" |
| 139 | exit 1 |
| 140 | fi |
| 141 | |
| 142 | if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then |
| 143 | DELAY=${DELAYS[$RETRY_COUNT-1]} |
| 144 | echo "⚠️ Push failed (attempt $RETRY_COUNT/$MAX_RETRIES)" |
| 145 | echo "Retrying in ${DELAY}s..." |
| 146 | sleep $DELAY |
| 147 | fi |
| 148 | fi |
| 149 | done |
| 150 | |
| 151 | echo "✗ Push failed after $MAX_RETRIES attempts" |
| 152 | exit 1 |
| 153 | ``` |
| 154 | |
| 155 | **Usage:** |
| 156 | ```bash |
| 157 | chmod +x push-with-retry.sh |
| 158 | ./push-with-retry.sh |
| 159 | ``` |
| 160 | |
| 161 | ### Inline Retry Pattern |
| 162 | |
| 163 | ```bash |
| 164 | # Quick inline version |
| 165 | for i in {1..4}; do |
| 166 | if git push -u origin $(git branch --show-current); then |
| 167 | echo "✓ Pushed successfully" |
| 168 | break |
| 169 | else |
| 170 | [ $i -lt 4 ] && echo "Retry $i/4..." && sleep $((2**i)) |
| 171 | fi |
| 172 | done |
| 173 | ``` |
| 174 | |
| 175 | ## Commit Best Practices |
| 176 | |
| 177 | ### Atomic Commits |
| 178 | |
| 179 | ```bash |
| 180 | # Make focused, atomic commits |
| 181 | git add src/auth/login.ts |
| 182 | git commit -m "feat: Add JWT-based login authentication" |
| 183 | |
| 184 | git add src/auth/middleware.ts |
| 185 | git commit -m "feat: Add auth middleware for protected routes" |
| 186 | |
| 187 | git add tests/auth.test.ts |
| 188 | git commit -m "test: Add authentication test suite" |
| 189 | ``` |
| 190 | |
| 191 | ### Commit Message Format |
| 192 | |
| 193 | ```bash |
| 194 | # Format: <type> |