Claude
Skills
Sign in
โ† Back

git-workflow-skills

Included with Lifetime
$97 forever

Provides standardized Git workflows, commit message conventions, branching strategies, and collaboration patterns for all agents performing Git operations. Use when creating commits, choosing branching strategies, creating PRs, performing git operations (merge vs rebase), or handling git collaboration workflows.

Generalscripts

What this skill does


# Git Workflow Skills

## Overview

This skill provides comprehensive Git workflow guidance for agents performing version control operations. It covers commit message conventions (Conventional Commits), branching strategies (GitHub Flow, Git Flow, Trunk-based), PR best practices, git operation patterns (merge vs rebase vs squash), collaboration workflows, and security considerations.

Use this skill whenever performing git operations to ensure consistency, maintainability, and professional quality across all projects.

## Core Principles

1. **Clarity Over Cleverness**: Commit messages and branch names should be immediately understandable
2. **Atomic Commits**: One logical change per commit (enables easy revert, clear history)
3. **Safety First**: Never commit secrets, avoid force push to protected branches
4. **Team Consistency**: Follow project conventions, communicate through commits and PRs
5. **History Matters**: Clean, readable history is a project asset

## Commit Message Conventions

### Conventional Commits Format

Follow the Conventional Commits specification for all commit messages:

```
<type>(<scope>): <subject>

<body>

<footer>
```

**Components**:
- **type** (required): feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert
- **scope** (optional): Component/module affected (e.g., auth, api, ui, database)
- **subject** (required): Brief description (50 chars max, imperative mood, no period)
- **body** (optional): Detailed explanation (wrap at 72 chars)
- **footer** (optional): Breaking changes, issue references

### Commit Types

**feat**: New feature for the user
```
feat(auth): add OAuth2 login support

Implement OAuth2 authentication flow with Google and GitHub providers.
Includes token refresh mechanism and session management.

Closes #142
```

**fix**: Bug fix for the user
```
fix(api): prevent race condition in user creation

Add database transaction lock to prevent duplicate user records
when multiple requests arrive simultaneously.

Fixes #238
```

**docs**: Documentation changes only
```
docs(readme): add installation instructions for Windows

Include troubleshooting section for common Windows-specific issues.
```

**style**: Code formatting, missing semicolons, whitespace (no logic change)
```
style(components): format with prettier, remove trailing whitespace
```

**refactor**: Code change that neither fixes bug nor adds feature
```
refactor(database): extract query builder into separate class

Improve code organization and testability by separating query
construction from execution logic.
```

**test**: Adding or updating tests
```
test(auth): add integration tests for OAuth flow
```

**chore**: Maintenance tasks, dependency updates, build configuration
```
chore(deps): upgrade React from 18.2.0 to 18.3.0
```

**perf**: Performance improvement
```
perf(api): add database indexes for user queries

Reduce user lookup time from 250ms to 15ms by indexing email column.
```

**ci**: CI/CD configuration changes
```
ci(github): add automated deployment to staging environment
```

**build**: Build system or external dependency changes
```
build(webpack): optimize bundle size with code splitting
```

**revert**: Reverts a previous commit
```
revert: feat(auth): add OAuth2 login support

This reverts commit a1b2c3d4. OAuth implementation needs rework
due to security concerns identified in code review.
```

### Breaking Changes

Indicate breaking changes with `!` after type/scope and in footer:

```
feat(api)!: change user endpoint response format

BREAKING CHANGE: User API now returns `userId` instead of `id`.
Clients must update to use new field name.

Migration guide: https://docs.example.com/migration-v2
```

### Good vs Bad Commit Messages

**โŒ Bad Examples**:
```
Update files
Fix bug
WIP
asdf
Changed some stuff
Fixed it
```

**โœ… Good Examples**:
```
feat(search): add fuzzy matching for product queries
fix(checkout): calculate tax correctly for international orders
docs(api): update authentication examples
refactor(utils): extract date formatting into helper function
```

### Multi-line Commit Messages

Use multi-line messages for non-trivial changes:

```
feat(notifications): implement real-time notification system

Add WebSocket-based notification delivery for user actions.
Includes:
- WebSocket server with connection pooling
- Client-side notification queue with retry logic
- Notification preferences UI
- Email fallback for offline users

Performance: Handles 10k concurrent connections with <100ms latency.

Closes #156, #187
```

### Integration with Claude Code

When agents create commits, always:
1. Analyze `git diff` to understand changes
2. Determine appropriate type (feat, fix, docs, etc.)
3. Identify scope from files changed
4. Write clear subject line (imperative mood)
5. Add body for non-trivial changes explaining "why"
6. Include Claude Code footer:
   ```
   ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code)

   Co-Authored-By: Claude <[email protected]>
   ```

## Branching Strategies

### Strategy Selection Guide

**Choose GitHub Flow** (recommended for most projects):
- โœ… Continuous deployment
- โœ… Small to medium teams
- โœ… Web applications
- โœ… Simple release process

**Choose Git Flow**:
- โœ… Scheduled releases
- โœ… Multiple production versions
- โœ… Enterprise software
- โœ… Complex release management

**Choose Trunk-based Development**:
- โœ… Very frequent deployments
- โœ… Strong CI/CD pipeline
- โœ… Experienced team
- โœ… Feature flags in place

### GitHub Flow (Recommended)

**Branches**:
- `main`: Always deployable, protected
- `feature/*`: Short-lived feature branches

**Workflow**:
1. Create feature branch from `main`: `feature/add-user-search`
2. Commit changes with conventional commits
3. Push to remote and create PR
4. Code review and CI checks
5. Merge to `main` (squash or merge commit)
6. Deploy `main` to production
7. Delete feature branch

**Branch naming**:
```
feature/add-oauth-login
feature/user-profile-page
bugfix/fix-login-redirect
hotfix/patch-security-vulnerability
docs/update-api-documentation
```

**Example workflow**:
```bash
# Start feature
git checkout main
git pull origin main
git checkout -b feature/add-search-filter

# Work on feature
git add src/components/SearchFilter.tsx
git commit -m "feat(search): add category filter to search UI"

# Push and create PR
git push -u origin feature/add-search-filter
gh pr create --title "Add category filter to search" --body "..."

# After PR approval
# Merge via GitHub UI (squash recommended)
# Delete branch
git checkout main
git pull origin main
git branch -d feature/add-search-filter
```

### Git Flow

**Branches**:
- `main`: Production releases only
- `develop`: Integration branch
- `feature/*`: Feature development
- `release/*`: Release preparation
- `hotfix/*`: Production hotfixes

**Workflow**:
1. Feature: Branch from `develop`, merge back to `develop`
2. Release: Branch from `develop`, merge to `main` and `develop`
3. Hotfix: Branch from `main`, merge to `main` and `develop`

**Use when**: Managing multiple release versions, scheduled releases, complex projects

**Example**:
```bash
# Feature development
git checkout develop
git checkout -b feature/payment-integration
# ... work ...
git checkout develop
git merge --no-ff feature/payment-integration

# Release
git checkout -b release/1.2.0 develop
# ... version bump, changelog ...
git checkout main
git merge --no-ff release/1.2.0
git tag -a v1.2.0
git checkout develop
git merge --no-ff release/1.2.0
```

### Trunk-based Development

**Branches**:
- `main`: The trunk, always deployable
- `feature/*`: Very short-lived (< 1 day)

**Workflow**:
1. Create small feature branch
2. Commit frequently
3. Merge to `main` within hours/1 day
4. Use feature flags for incomplete features
5. Deploy `main` frequently (multiple times per day)

**Requirements**:
- Strong automated testing
- Feature flag system
- Mature CI/CD pipeline
- Team discipline

## PR/MR Best Practices

### PR Title 

Related in General