git-workflow
Git workflows for branching, committing, and creating PRs. Use when working with Git operations, creating commits, or opening pull requests.
When & Why to Use This Skill
This Claude skill provides a comprehensive framework for Git workflows, covering branching strategies, structured commit messages, and pull request management. It helps development teams maintain repository hygiene, improve code review efficiency, and ensure consistent version control practices across the project lifecycle.
Use Cases
- Standardizing Branch Management: Generate branch names using specific prefixes like feature/, bugfix/, or hotfix/ to ensure a clean and organized repository structure.
- Structured Commit Authoring: Create professional commit messages using standardized verbs and formats, making project history easier to navigate and audit.
- Streamlined Pull Request Workflows: Facilitate the creation of detailed PRs with checklists and size guidelines to ensure code quality and faster peer reviews.
- Advanced History Management: Perform interactive rebasing and fixup operations to maintain a clean, linear commit history before merging changes into the main branch.
| name | git-workflow |
|---|---|
| description | Git workflows for branching, committing, and creating PRs. Use when working with Git operations, creating commits, or opening pull requests. |
Git Workflow Skill
When to Use
- Creating new branches
- Writing commit messages
- Creating pull requests
- Resolving merge conflicts
- Managing branch history
Branch Creation
Format
<branch_type>/<branch_name>
Common Branch Types
| Type | Use For |
|---|---|
feature/ |
New functionality |
bugfix/ |
Bug fixes |
hotfix/ |
Critical production fixes |
enhancement/ |
Improvements |
docs/ |
Documentation |
Process
# 1. Ensure you're on main branch
git checkout master
git pull origin master
# 2. Create feature branch
git checkout -b feature/user-authentication
# 3. Work on changes...
# 4. Push branch
git push -u origin feature/user-authentication
Commit Messages
Format
[OPTIONAL-REFERENCE] Verb subject description
Allowed Verbs
Add- New functionalityFix- Bug fixesUpdate- Changes to existing codeRemove- Removing code/filesImprove- EnhancementsMigrate- Data migrationsRevert- Reverting changes
Examples
# Simple commit
git commit -m "Add user authentication system"
# With issue reference
git commit -m "[PROJ-123] Fix login error handling"
# Multi-line
git commit -m "Add user profile component
Implements profile editing with avatar upload.
Includes form validation and error states."
Rules
- Verb in PascalCase
- Max 100 characters for header
- No trailing punctuation
- Subject required after verb
Pull Request Creation
Pre-PR Checklist
- Code follows style guidelines
- Tests pass locally
- No console.log statements
- No commented-out code
- Branch is up to date with base
Using GitHub CLI
# Create PR interactively
gh pr create
# Create PR with details
gh pr create \
--title "Add user authentication" \
--body "## Summary
Implements JWT authentication.
## Changes
- Add login endpoint
- Add token refresh
- Add protected routes
## Test Plan
1. Login with valid credentials
2. Verify token stored
3. Access protected route"
# Create draft PR
gh pr create --draft
PR Size Guidelines
- < 400 lines: Ideal, easy to review
- 400-800 lines: Consider splitting
- > 800 lines: Must split into smaller PRs
History Management
Interactive Rebase
# Rebase last 3 commits
git rebase -i HEAD~3
# Actions:
# pick - use commit
# reword - edit message
# squash - combine with previous
# fixup - combine, discard message
# drop - remove commit
Fixup Commits
# Create fixup for specific commit
git commit --fixup <commit-hash>
# Auto-squash when rebasing
git rebase -i --autosquash HEAD~5
Keep Branch Updated
git fetch origin
git rebase origin/master
# Force push if needed (only on feature branches!)
git push --force-with-lease
Checklist for Git Operations
Creating Branch
- Start from updated master/main
- Use correct branch type prefix
- Use kebab-case for branch name
Creating Commit
- Use allowed verb in PascalCase
- Message describes what AND why
- No WIP commits in final PR
Creating PR
- All tests pass
- PR description complete
- Linked to issues if applicable
- Requested reviewers