Git workflow automation: feature, release, and hotfix commands with git specialists

version
1.0.0
GitHub stars
24.2K

Install

/plugin install git-workflow@davila7-claude-code-templates

Run it inside Claude Code after adding the marketplace with /plugin marketplace add davila7/claude-code-templates.

Contents

Commands 5

Git Flow Feature Branch

Create new feature branch: $ARGUMENTS

Current Repository State

  • Current branch: !git branch --show-current
  • Git status: !git status --porcelain
  • Develop branch status: !git log develop..origin/develop --oneline 2>/dev/null | head -5 || echo "No remote tracking for develop"

Task

Create a Git Flow feature branch following these steps:

1. Pre-Flight Validation

  • Check git repository: Verify we're in a valid git repository
  • Validate feature name: Ensure $ARGUMENTS is provided and follows naming conventions:
    • ✅ Valid: user-authentication, payment-integration, dashboard-redesign
    • ❌ Invalid: feat1, My_Feature, empty name
  • Check for uncommitted changes:
    • If changes exist, warn user and ask to commit/stash first
    • OR offer to stash changes automatically
  • Verify develop branch exists: Ensure develop branch is present

2. Create Feature Branch

Execute the following workflow:

# Switch to develop branch
git checkout develop

# Pull latest changes from remote
git pull origin develop

# Create feature branch with Git Flow naming convention
git checkout -b feature/$ARGUMENTS

# Set up remote tracking
git push -u origin feature/$ARGUMENTS

3. Provide Status Report

After successful creation, display:

✓ Switched to develop branch
✓ Pulled latest changes from origin/develop
✓ Created branch: feature/$ARGUMENTS
✓ Set up remote tracking: origin/feature/$ARGUMENTS
✓ Pushed branch to remote

🌿 Feature Branch Ready

Branch: feature/$ARGUMENTS
Base: develop
Status: Clean working directory

🎯 Next Steps:
1. Start implementing your feature
2. Make commits using conventional format:
   git commit -m "feat: your changes"
3. Push changes regularly: git push
4. When complete, use /finish to merge back to develop

💡 Git Flow Tips:
- Keep commits atomic and well-described
- Push frequently to avoid conflicts
- Use conventional commit format (feat:, fix:, etc.)
- Test thoroughly before finishing

4. Error Handling

Handle these scenarios gracefully:

Uncommitted Changes:

⚠️  You have uncommitted changes:
M  src/file1.js
M  src/file2.js

Options:
1. Commit changes first
2. Stash changes: git stash
3. Discard changes: git checkout .

What would you like to do? [1/2/3]

Feature Name Not Provided:

❌ Feature name is required

Usage: /feature <feature-name>

Examples:
  /feature user-profile-page
  /feature api-v2-integration
  /feature payment-gateway

Feature names should:
- Be descriptive and concise
- Use kebab-case (lowercase-with-hyphens)
- Describe what the feature does

Branch Already Exists:

❌ Branch feature/$ARGUMENTS already exists

Existing feature branches:
  feature/user-authentication
  feature/payment-gateway
  feature/$ARGUMENTS ← This one

Options:
1. Switch to existing branch: git checkout feature/$ARGUMENTS
2. Use a different feature name
3. Delete existing and recreate (destructive!)

Develop Behind Remote:

⚠️  Local develop is behind origin/develop by 5 commits

✓ Pulling latest changes...
✓ Develop is now up to date
✓ Ready to create feature branch

No Develop Branch:

❌ Develop branch not found

Git Flow requires a 'develop' branch. Create it with:
  git checkout -b develop
  git push -u origin develop

Or initialize Git Flow:
  git flow init

Git Flow Context

This command is part of the Git Flow branching strategy:

  • main: Production-ready code (protected)
  • develop: Integration branch for features (protected)
  • feature/*: New features (you are here)
  • release/*: Release preparation
  • hotfix/*: Emergency production fixes

Feature branches:

  • Branch from: develop
  • Merge back to: develop
  • Naming convention: feature/<descriptive-name>
  • Lifecycle: Short to medium term

Environment Variables

This command respects:

  • GIT_FLOW_DEVELOP_BRANCH: Develop branch name (default: "develop")
  • GIT_FLOW_PREFIX_FEATURE: Feature prefix (default: "feature/")

Related Commands

  • /finish - Complete and merge feature branch to develop
  • /flow-status - Check current Git Flow status
  • /release <version> - Create release branch from develop
  • /hotfix <name> - Create hotfix branch from main

Best Practices

DO:

  • ✅ Use descriptive feature names
  • ✅ Keep feature scope focused and small
  • ✅ Push to remote regularly
  • ✅ Test your changes before finishing
  • ✅ Use conventional commit messages

DON'T:

  • ❌ Create features directly from main
  • ❌ Use generic names like "feature1"
  • ❌ Let feature branches live too long
  • ❌ Mix multiple unrelated features
  • ❌ Skip testing before merging

Git Flow Release Branch

Create new release branch: $ARGUMENTS

Current Repository State

  • Current branch: !git branch --show-current
  • Git status: !git status --porcelain
  • Latest tag: !git describe --tags --abbrev=0 2>/dev/null || echo "No tags found"
  • Commits since last tag: !git log $(git describe --tags --abbrev=0 2>/dev/null)..HEAD --oneline 2>/dev/null | wc -l | tr -d ' '
  • Package.json version: !cat package.json 2>/dev/null | grep '"version"' | head -1 || echo "No package.json found"
  • Recent commits: !git log --oneline -10

Task

Create a Git Flow release branch following these steps:

1. Version Validation

Validate the version format and ensure it's newer than current:

Version Format Requirements:

  • Must follow semantic versioning: vMAJOR.MINOR.PATCH
  • Examples: v1.0.0, v2.1.3, v0.5.0-beta.1
  • Pattern: v + NUMBER.NUMBER.NUMBER + optional -prerelease.NUMBER

Version Increment Logic:

Analyze commits since last tag to suggest version:

  • MAJOR (v2.0.0): Breaking changes (contains "BREAKING CHANGE:" in commits)
  • MINOR (v1.3.0): New features (contains "feat:" commits)
  • PATCH (v1.2.1): Bug fixes only (only "fix:" and "chore:" commits)

Current Version Analysis:

Latest tag: [from git describe]
Suggested version: [based on commit analysis]
Provided version: $ARGUMENTS

If version is invalid or not newer, show:

❌ Invalid version format: "$ARGUMENTS"

✅ Use semantic versioning: vMAJOR.MINOR.PATCH

Examples:
  - v1.0.0 (initial release)
  - v1.2.0 (new features)
  - v1.2.1 (bug fixes)
  - v2.0.0 (breaking changes)
  - v1.0.0-beta.1 (pre-release)

💡 Suggested version based on commits: v1.3.0

2. Create Release Branch Workflow

# Switch to develop and update
git checkout develop
git pull origin develop

# Create release branch
git checkout -b release/$ARGUMENTS

# Update package.json version (if Node.js project)
npm version ${ARGUMENTS#v} --no-git-tag-version

# Generate CHANGELOG.md from commits
# (analyze git log since last tag)

# Commit version bump
git add package.json CHANGELOG.md
git commit -m "chore(release): bump version to ${ARGUMENTS#v}

- Updated package.json version
- Generated CHANGELOG.md from commits

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Push to remote with tracking
git push -u origin release/$ARGUMENTS

3. CHANGELOG Generation

Generate changelog from commits since last tag, grouped by type:

# Changelog

## [$ARGUMENTS] - [Current Date]

### ✨ Features
- [List all feat: commits with PR links]

### 🐛 Bug Fixes
- [List all fix: commits with PR links]

### 📝 Documentation
- [List all docs: commits]

### ♻️ Refactoring
- [List all refactor: commits]

### ⚡️ Performance
- [List all perf: commits]

### 🔒️ Security
- [List all security-related commits]

### 💥 Breaking Changes
- [List all commits with BREAKING CHANGE]

### 🧪 Tests
- [List all test: commits]

### 🔧 Chore
- [List all chore: commits]

4. Release Checklist

Display this checklist after creation:

🚀 Release Checklist for $ARGUMENTS

Pre-Release Tasks:
- [ ] All tests passing (run: npm test)
- [ ] Documentation updated
- [ ] CHANGELOG.md reviewed and accurate
- [ ] Version numbers consistent across files
- [ ] No breaking changes (or properly documented)
- [ ] Dependencies updated (run: npm audit)

Testing Tasks:
- [ ] Manual testing completed
- [ ] Regression tests passed
- [ ] Performance benchmarks acceptable
- [ ] Security scan clean (run: npm audit)
- [ ] Cross-browser testing (if applicable)

Deployment Preparation:
- [ ] Staging deployment successful
- [ ] Production deployment plan reviewed
- [ ] Rollback plan documented
- [ ] Monitoring and alerts configured

Final Steps:
- [ ] Create PR to main (run: gh pr create)
- [ ] Get required approvals (minimum 2 reviewers)
- [ ] Run /finish to merge and tag release
- [ ] Announce release to team

🎯 Next Commands:
- Review CHANGELOG: cat CHANGELOG.md
- Run tests: npm test
- Create PR: gh pr create --base main --head release/$ARGUMENTS
- When ready: /finish

5. Success Response

✓ Switched to develop branch
✓ Pulled latest changes from origin/develop
✓ Created branch: release/$ARGUMENTS
✓ Updated package.json version to ${ARGUMENTS#v}
✓ Generated CHANGELOG.md (15 commits analyzed)
✓ Committed version bump changes
✓ Set up remote tracking: origin/release/$ARGUMENTS
✓ Pushed branch to remote

🚀 Release Branch Ready: $ARGUMENTS

Branch: release/$ARGUMENTS
Base: develop
Target: main (after review)

📊 Release Statistics:
  - 5 new features
  - 3 bug fixes
  - 1 performance improvement
  - 0 breaking changes
  - 2 documentation updates

📝 CHANGELOG Summary:
  - Created with 15 commits
  - Grouped by commit type
  - Includes PR references
  - Ready for review

🎯 Next Steps:
1. Review CHANGELOG.md for accuracy
2. Run final tests: npm test
3. Test on staging environment
4. Create PR to main: gh pr create
5. Get team approvals
6. Run /finish to complete release

💡 Release Tips:
- No new features should be added to release branch
- Only bug fixes and documentation updates allowed
- Keep release branch short-lived (hours, not days)
- Tag will be created automatically when merged to main

6. Error Handling

No Version Provided:

❌ Version is required

Usage: /release <version>

Examples:
  /release v1.2.0
  /release v2.0.0-beta.1

Current version: v1.1.0
Suggested version: v1.2.0 (based on commits)

Invalid Version Format:

❌ Invalid version format: "1.0"

✅ Correct format: v1.0.0 (must start with 'v')

Examples:
  ✅ v1.0.0
  ✅ v2.1.3
  ✅ v1.0.0-beta.1
  ❌ 1.0.0 (missing 'v')
  ❌ v1.0 (incomplete)
  ❌ version-1.0.0 (wrong format)

Version Not Incremented:

❌ Version $ARGUMENTS is not newer than current v1.2.0

💡 Valid version bumps from v1.2.0:
  - v1.2.1 (patch - bug fixes only)
  - v1.3.0 (minor - new features)
  - v2.0.0 (major - breaking changes)

📊 Commit Analysis:
  - 3 feat: commits → suggests MINOR bump (v1.3.0)
  - 0 BREAKING CHANGE → no MAJOR bump needed
  - 2 fix: commits → could use PATCH (v1.2.1)

Recommended: v1.3.0

Uncommitted Changes:

⚠️  Uncommitted changes detected:
M  src/feature.js
M  README.md

Before creating release:
1. Commit your changes
2. Stash them: git stash
3. Or discard them: git checkout .

Please clean your working directory first.

Develop Behind Remote:

⚠️  Local develop is behind origin/develop by 3 commits

✓ Pulling latest changes...
✓ Fetched 3 commits
✓ Develop is now up to date with remote
✓ Ready to create release branch

Creating Pull Request

If gh CLI is available, offer to create PR:

gh pr create \
  --title "Release $ARGUMENTS" \
  --body "$(cat <<'EOF'
## Release Summary

Version: $ARGUMENTS
Base: develop
Target: main

## Changes Included

[Auto-generated from CHANGELOG.md]

## Release Checklist

- [ ] All tests passing
- [ ] Documentation updated
- [ ] CHANGELOG reviewed
- [ ] No breaking changes (or documented)
- [ ] Security audit clean
- [ ] Staging deployment successful

## Deployment Plan

1. Merge to main
2. Tag release: $ARGUMENTS
3. Deploy to production
4. Merge back to develop
5. Monitor for issues

---
🤖 Generated with Claude Code
EOF
)" \
  --base main \
  --head release/$ARGUMENTS \
  --label "release" \
  --assignee @me

Semantic Versioning Guide

MAJOR version (X.0.0): Breaking changes

  • API changes that break backward compatibility
  • Removal of deprecated features
  • Major architectural changes

MINOR version (1.X.0): New features

  • New functionality added
  • Backward compatible changes
  • New APIs or methods

PATCH version (1.0.X): Bug fixes

  • Bug fixes only
  • No new features
  • No breaking changes

Environment Variables

  • GIT_FLOW_DEVELOP_BRANCH: Develop branch name (default: "develop")
  • GIT_FLOW_MAIN_BRANCH: Main branch name (default: "main")
  • GIT_FLOW_PREFIX_RELEASE: Release prefix (default: "release/")

Related Commands

  • /finish - Complete release (merge to main and develop, create tag)
  • /flow-status - Check current Git Flow status
  • /feature <name> - Create feature branch
  • /hotfix <name> - Create hotfix branch

Best Practices

DO:

  • ✅ Analyze commits to determine correct version bump
  • ✅ Generate comprehensive CHANGELOG
  • ✅ Test thoroughly on release branch
  • ✅ Keep release branch short-lived
  • ✅ Only allow bug fixes on release branch
  • ✅ Create PR for team review

DON'T:

  • ❌ Add new features to release branch
  • ❌ Skip testing phase
  • ❌ Let release branch live for days
  • ❌ Skip CHANGELOG generation
  • ❌ Forget to merge back to develop
  • ❌ Create releases without team approval

Git Flow Hotfix Branch

Create emergency hotfix branch: $ARGUMENTS

Current Repository State

  • Current branch: !git branch --show-current
  • Git status: !git status --porcelain
  • Latest production tag: !git describe --tags --abbrev=0 origin/main 2>/dev/null || echo "No tags on main"
  • Main branch status: !git log main..origin/main --oneline 2>/dev/null | head -3 || echo "No remote tracking for main"
  • Commits on main since last tag: !git log $(git describe --tags --abbrev=0 origin/main 2>/dev/null)..origin/main --oneline 2>/dev/null | wc -l | tr -d ' '

Task

Create a Git Flow hotfix branch for emergency production fixes:

1. Pre-Flight Validation

Critical Checks:

  • Verify hotfix name: Ensure $ARGUMENTS is provided and descriptive
    • ✅ Valid: critical-security-patch, payment-gateway-fix, auth-bypass-fix
    • ❌ Invalid: fix, hotfix1, bug
  • Check main branch exists: Ensure main branch is present
  • Verify no uncommitted changes: Clean working directory required
  • Confirm emergency status: Hotfixes are for CRITICAL production issues only

⚠️ IMPORTANT: Hotfix Usage Guidelines

Hotfixes are ONLY for:

  • 🔒 Critical security vulnerabilities
  • 💥 Production-breaking bugs
  • 💰 Payment/transaction failures
  • 🚨 Data loss or corruption issues
  • 🔥 System downtime or crashes

NOT for:

  • ❌ Regular bug fixes (use feature branch)
  • ❌ New features (use feature branch)
  • ❌ Performance improvements (use feature branch)
  • ❌ Non-critical issues (wait for next release)

2. Create Hotfix Branch Workflow

# Switch to main branch
git checkout main

# Pull latest production code
git pull origin main

# Create hotfix branch from main
git checkout -b hotfix/$ARGUMENTS

# Set up remote tracking
git push -u origin hotfix/$ARGUMENTS

3. Determine Version Bump

Analyze the latest tag to suggest hotfix version:

Current production version: v1.2.0
Hotfix version: v1.2.1

Version bump: PATCH (third number incremented)

Hotfix Version Rules:

  • Always increment PATCH version (X.Y.Z → X.Y.Z+1)
  • Never increment MAJOR or MINOR for hotfixes
  • Examples:
    • v1.2.0 → v1.2.1
    • v2.0.5 → v2.0.6
    • v1.5.9 → v1.5.10

4. Success Response

✓ Switched to main branch
✓ Pulled latest production code from origin/main
✓ Created branch: hotfix/$ARGUMENTS
✓ Set up remote tracking: origin/hotfix/$ARGUMENTS
✓ Pushed branch to remote

🔥 Hotfix Branch Ready: hotfix/$ARGUMENTS

Branch: hotfix/$ARGUMENTS
Base: main (production)
Will merge to: main AND develop
Suggested version: v1.2.1

⚠️ CRITICAL HOTFIX WORKFLOW

This is an EMERGENCY production fix. Follow these steps:

1. 🔍 Identify the Issue
   - Reproduce the bug
   - Understand the root cause
   - Document the impact

2. 🛠️ Implement the Fix
   - Make MINIMAL changes
   - Focus ONLY on the critical issue
   - Avoid refactoring or improvements
   - Add tests to prevent regression

3. 🧪 Test Thoroughly
   - Test the specific fix
   - Run full regression tests
   - Test on production-like environment
   - Verify no side effects

4. 📝 Document the Fix
   - Update version in package.json
   - Add entry to CHANGELOG.md
   - Document the bug and fix
   - Include reproduction steps

5. 🚀 Deploy Process
   - Create PR to main
   - Get expedited review
   - Run /finish to merge and tag
   - Deploy to production immediately
   - Monitor for issues

🎯 Next Steps:
1. Fix the critical issue (MINIMAL changes only)
2. Test thoroughly: npm test
3. Update version: v1.2.1
4. Create emergency PR: gh pr create --label "hotfix,critical"
5. Get fast-track approval
6. Run /finish to merge to main AND develop
7. Deploy to production
8. Monitor systems closely

⚠️ Remember:
- Hotfix will be merged to BOTH main and develop
- Tag v1.2.1 will be created on main
- Production deployment should happen immediately
- Team should be notified of the hotfix

5. Error Handling

No Hotfix Name Provided:

❌ Hotfix name is required

Usage: /hotfix <hotfix-name>

Examples:
  /hotfix critical-security-patch
  /hotfix payment-processing-failure
  /hotfix auth-bypass-vulnerability

⚠️ IMPORTANT: Hotfixes are for CRITICAL production issues only!

For non-critical fixes, use:
  /feature <name> - Regular bug fixes

Invalid Hotfix Name:

❌ Invalid hotfix name: "fix"

Hotfix names should be:
- Descriptive of the issue
- Use kebab-case format
- Indicate severity/urgency

Examples:
  ✅ critical-security-patch
  ✅ payment-gateway-timeout
  ✅ user-data-corruption-fix
  ❌ fix
  ❌ bug1
  ❌ hotfix

Uncommitted Changes:

⚠️  Uncommitted changes detected in working directory:
M  src/file.js
A  test.js

Hotfixes require a clean working directory.

Options:
1. Commit your changes first
2. Stash them: git stash
3. Discard them: git checkout .

⚠️ This is an emergency hotfix. Please clean your working directory.

Main Branch Behind Remote:

⚠️  Local main is behind origin/main by 2 commits

✓ Pulling latest production code...
✓ Fetched 2 commits
✓ Main is now synchronized with production
✓ Ready to create hotfix branch

Not a Critical Issue:

⚠️  Hotfix Confirmation Required

Is this a CRITICAL production issue that requires immediate attention?

Critical issues include:
- Security vulnerabilities
- Production system failures
- Data loss or corruption
- Payment/transaction failures

If this is NOT critical, consider:
- Creating a feature branch instead
- Waiting for the next release cycle
- Using regular bug fix workflow

Proceed with hotfix? [y/N]

6. Hotfix Checklist

🔥 Emergency Hotfix Checklist

Issue Identification:
- [ ] Bug is confirmed and reproducible
- [ ] Root cause is identified
- [ ] Impact is documented
- [ ] Stakeholders are notified

Development:
- [ ] Fix is minimal and focused
- [ ] No unnecessary changes included
- [ ] Tests added to prevent regression
- [ ] Code reviewed (if time permits)

Testing:
- [ ] Fix verified in local environment
- [ ] Unit tests passing
- [ ] Integration tests passing
- [ ] Tested on production-like environment
- [ ] No side effects detected

Documentation:
- [ ] CHANGELOG.md updated
- [ ] Version bumped (PATCH)
- [ ] Bug description documented
- [ ] Fix explanation documented
- [ ] Deployment notes prepared

Deployment:
- [ ] PR created with "hotfix" and "critical" labels
- [ ] Fast-track approval obtained
- [ ] Production deployment plan ready
- [ ] Rollback plan documented
- [ ] Monitoring alerts configured
- [ ] Team notified of deployment

Post-Deployment:
- [ ] Fix verified in production
- [ ] Systems monitored for issues
- [ ] Metrics show improvement
- [ ] Hotfix merged back to develop
- [ ] Post-mortem scheduled (if needed)

7. Version Update Process

After implementing the fix, update the version:

# Update package.json version (PATCH bump)
npm version patch --no-git-tag-version

# Update CHANGELOG.md
cat >> CHANGELOG.md << EOF

## [v1.2.1] - $(date +%Y-%m-%d) - HOTFIX

### 🔥 Critical Fixes
- Fix $ARGUMENTS: [brief description]
  - Root cause: [explanation]
  - Impact: [who/what was affected]
  - Resolution: [what was fixed]

EOF

# Commit version bump
git add package.json CHANGELOG.md
git commit -m "chore(hotfix): bump version to v1.2.1

Critical fix for $ARGUMENTS

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

8. Create Emergency PR

gh pr create \
  --title "🔥 HOTFIX v1.2.1: $ARGUMENTS" \
  --body "$(cat <<'EOF'
## 🔥 Emergency Hotfix

**Severity**: Critical
**Version**: v1.2.1
**Issue**: $ARGUMENTS

## Problem Description

[Detailed description of the production issue]

## Root Cause

[Explanation of what caused the issue]

## Fix Implementation

[Description of the fix applied]

## Testing

- [x] Issue reproduced locally
- [x] Fix verified locally
- [x] Unit tests passing
- [x] Integration tests passing
- [x] Tested on staging environment

## Deployment Plan

1. Merge to main
2. Tag as v1.2.1
3. Deploy to production immediately
4. Monitor for 30 minutes
5. Merge back to develop

## Rollback Plan

[How to rollback if issues occur]

## Monitoring

[What to monitor post-deployment]

---

**⚠️ This is a critical production hotfix requiring immediate deployment**

🤖 Generated with Claude Code
EOF
)" \
  --base main \
  --head hotfix/$ARGUMENTS \
  --label "hotfix,critical,priority-high" \
  --assignee @me \
  --reviewer team-leads

Git Flow Integration

Hotfix Workflow in Git Flow:

main (v1.2.0) ──────┬─────────────► (after hotfix merge) v1.2.1
                    │
                    └─► hotfix/$ARGUMENTS
                         │
                         └─► (merges back to both)
                             │
develop ────────────────────┴─────────────► (receives hotfix)

Important:

  • Hotfixes branch from main (production)
  • Hotfixes merge to BOTH main AND develop
  • Tags are created on main after merge
  • Production deployment happens immediately

Environment Variables

  • GIT_FLOW_MAIN_BRANCH: Main branch name (default: "main")
  • GIT_FLOW_DEVELOP_BRANCH: Develop branch name (default: "develop")
  • GIT_FLOW_PREFIX_HOTFIX: Hotfix prefix (default: "hotfix/")

Related Commands

  • /finish - Complete hotfix (merge to main and develop, create tag, deploy)
  • /flow-status - Check current Git Flow status
  • /feature <name> - Create feature branch (for non-critical fixes)
  • /release <version> - Create release branch

Best Practices

DO:

  • ✅ Use hotfixes ONLY for critical production issues
  • ✅ Keep changes minimal and focused
  • ✅ Test thoroughly before deploying
  • ✅ Document the issue and fix clearly
  • ✅ Notify team immediately
  • ✅ Merge back to develop after production deployment
  • ✅ Monitor production closely after deployment
  • ✅ Conduct post-mortem if appropriate

DON'T:

  • ❌ Use hotfix for regular bug fixes
  • ❌ Add new features to hotfix
  • ❌ Refactor code during hotfix
  • ❌ Skip testing to save time
  • ❌ Forget to merge back to develop
  • ❌ Deploy without proper review
  • ❌ Skip documentation
  • ❌ Ignore monitoring after deployment

Post-Hotfix Actions

After successful hotfix deployment:

  1. Verify Fix in Production

    • Monitor error rates
    • Check affected functionality
    • Verify metrics return to normal
  2. Update Documentation

    • Document the incident
    • Update runbooks if needed
    • Share learnings with team
  3. Merge to Develop

    • Ensure hotfix is in develop branch
    • Resolve any merge conflicts
    • Push to remote
  4. Post-Mortem (if needed)

    • Schedule review meeting
    • Identify prevention measures
    • Update processes if needed
  5. Cleanup

    • Delete hotfix branch
    • Archive related documentation
    • Update incident tracking

Git Flow Finish Branch

Complete current Git Flow branch: $ARGUMENTS

Current Repository State

  • Current branch: !git branch --show-current
  • Branch type: !git branch --show-current | grep -oE '^(feature|release|hotfix)' || echo "Not a Git Flow branch"
  • Git status: !git status --porcelain
  • Unpushed commits: !git log @{u}.. --oneline 2>/dev/null | wc -l | tr -d ' '
  • Latest tag: !git describe --tags --abbrev=0 2>/dev/null || echo "No tags"
  • Test status: !npm test 2>/dev/null | tail -20 || echo "No test command available"

Task

Complete the current Git Flow branch by merging it to appropriate target branch(es):

1. Branch Type Detection

Detect the current branch type and determine merge strategy:

CURRENT_BRANCH=$(git branch --show-current)

if [[ $CURRENT_BRANCH == feature/* ]]; then
  BRANCH_TYPE="feature"
  MERGE_TO="develop"
  CREATE_TAG="no"
elif [[ $CURRENT_BRANCH == release/* ]]; then
  BRANCH_TYPE="release"
  MERGE_TO="main develop"
  CREATE_TAG="yes"
  TAG_NAME="${CURRENT_BRANCH#release/}"
elif [[ $CURRENT_BRANCH == hotfix/* ]]; then
  BRANCH_TYPE="hotfix"
  MERGE_TO="main develop"
  CREATE_TAG="yes"
  # Increment patch version from current tag
  CURRENT_TAG=$(git describe --tags --abbrev=0 origin/main 2>/dev/null)
  TAG_NAME="${CURRENT_TAG%.*}.$((${CURRENT_TAG##*.} + 1))"
else
  echo "❌ Not on a Git Flow branch (feature/release/hotfix)"
  exit 1
fi

2. Pre-Merge Validation

Before merging, validate these conditions:

Critical Checks:

  • ✅ All changes are committed (no uncommitted files)
  • ✅ All commits are pushed to remote
  • ✅ Tests are passing (run test suite)
  • ✅ No merge conflicts with target branch
  • ✅ Branch is up to date with remote
🔍 Pre-Merge Validation

✓ Working directory clean
✓ All commits pushed to remote
✓ Running tests...
  ├─ Unit tests: 45/45 passed
  ├─ Integration tests: 12/12 passed
  └─ All tests passed ✓

✓ Checking for merge conflicts with develop...
  └─ No conflicts detected ✓

✓ Branch is up to date with remote ✓

Ready to merge!

3. Feature Branch Finish

For feature/ branches:

# Ensure all commits are pushed
git push

# Switch to develop
git checkout develop

# Pull latest changes
git pull origin develop

# Merge feature branch (no fast-forward)
git merge --no-ff feature/$NAME -m "Merge feature/$NAME into develop

$(git log develop..feature/$NAME --oneline)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Push to remote
git push origin develop

# Delete local branch (unless --no-delete)
git branch -d feature/$NAME

# Delete remote branch (unless --no-delete)
git push origin --delete feature/$NAME

Success Response:

✓ Pushed all commits to remote
✓ Switched to develop
✓ Pulled latest changes
✓ Merged feature/$NAME into develop
✓ Pushed to origin/develop
✓ Deleted local branch: feature/$NAME
✓ Deleted remote branch: origin/feature/$NAME

🌿 Feature Complete!

Merged: feature/$NAME
Target: develop
Commits included: 5
Files changed: 12

🎉 Your feature is now in the develop branch!

Next steps:
- Feature will be included in next release
- Other team members can pull from develop
- You can start a new feature branch

4. Release Branch Finish

For release/ branches:

# Extract version from branch name
VERSION="${CURRENT_BRANCH#release/}"

# Ensure all commits are pushed
git push

# Merge to main first
git checkout main
git pull origin main
git merge --no-ff release/$VERSION -m "Merge release/$VERSION into main

Release notes:
$(cat CHANGELOG.md | sed -n "/## \[$VERSION\]/,/## \[/p" | head -n -1)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Create tag on main (unless --no-tag)
git tag -a $VERSION -m "Release $VERSION

$(cat CHANGELOG.md | sed -n "/## \[$VERSION\]/,/## \[/p" | head -n -1)"

# Push main with tags
git push origin main --tags

# Merge back to develop
git checkout develop
git pull origin develop
git merge --no-ff release/$VERSION -m "Merge release/$VERSION back into develop

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Push develop
git push origin develop

# Delete branches (unless --no-delete)
git branch -d release/$VERSION
git push origin --delete release/$VERSION

Success Response:

✓ Pushed all commits to remote
✓ Merged release/$VERSION into main
✓ Created tag: $VERSION
✓ Pushed main with tags
✓ Merged release/$VERSION into develop
✓ Pushed to origin/develop
✓ Deleted local branch: release/$VERSION
✓ Deleted remote branch: origin/release/$VERSION

🚀 Release Complete: $VERSION

Merged to: main, develop
Tag created: $VERSION
Commits included: 15
Changes:
  - 5 features
  - 3 bug fixes
  - 2 performance improvements

🎉 Release $VERSION is now in production!

Next steps:
- Deploy to production: [deployment command]
- Monitor production for issues
- Announce release to team
- Update documentation if needed

Tag details:
  git show $VERSION

5. Hotfix Branch Finish

For hotfix/ branches:

# Determine new version (patch bump)
CURRENT_VERSION=$(git describe --tags --abbrev=0 origin/main)
NEW_VERSION="${CURRENT_VERSION%.*}.$((${CURRENT_VERSION##*.} + 1))"

# Ensure all commits are pushed
git push

# Merge to main first
git checkout main
git pull origin main
git merge --no-ff hotfix/$NAME -m "Merge hotfix/$NAME into main

Critical fix for: $NAME

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Create tag on main (unless --no-tag)
git tag -a $NEW_VERSION -m "Hotfix $NEW_VERSION: $NAME

Critical production fix"

# Push main with tags
git push origin main --tags

# Merge back to develop
git checkout develop
git pull origin develop
git merge --no-ff hotfix/$NAME -m "Merge hotfix/$NAME back into develop

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>"

# Push develop
git push origin develop

# Delete branches (unless --no-delete)
git branch -d hotfix/$NAME
git push origin --delete hotfix/$NAME

Success Response:

✓ Pushed all commits to remote
✓ Merged hotfix/$NAME into main
✓ Created tag: $NEW_VERSION (patch bump)
✓ Pushed main with tags
✓ Merged hotfix/$NAME into develop
✓ Pushed to origin/develop
✓ Deleted local branch: hotfix/$NAME
✓ Deleted remote branch: origin/hotfix/$NAME

🔥 Hotfix Complete: $NEW_VERSION

Merged to: main, develop
Tag created: $NEW_VERSION
Issue fixed: $NAME
Previous version: $CURRENT_VERSION

⚠️ CRITICAL: Deploy to production immediately!

Next steps:
1. Deploy $NEW_VERSION to production NOW
2. Monitor production systems closely
3. Verify fix is working
4. Notify team of hotfix deployment
5. Update incident documentation

Deployment command:
  [your deployment command here]

Monitor:
  - Error rates
  - System metrics
  - User reports

6. Error Handling

Not on Git Flow Branch:

❌ Not on a Git Flow branch

Current branch: $CURRENT_BRANCH

/finish only works on:
- feature/* branches
- release/* branches
- hotfix/* branches

To finish this branch manually:
1. Switch to target branch
2. Merge manually: git merge $CURRENT_BRANCH
3. Push: git push

Uncommitted Changes:

❌ Cannot finish: Uncommitted changes detected

Modified files:
M  src/file1.js
M  src/file2.js

Please commit or stash your changes first:
1. Commit: git add . && git commit
2. Stash: git stash
3. Discard: git checkout .

Unpushed Commits:

⚠️  Warning: 3 unpushed commits detected

Commits not on remote:
  abc1234 feat: add new feature
  def5678 fix: resolve bug
  ghi9012 docs: update README

Would you like to push now? [Y/n]
✓ Pushing commits...
✓ All commits pushed to remote

Test Failures:

❌ Cannot finish: Tests are failing

Failed tests:
  ✗ UserService.test.js
    - should authenticate user (expected 200, got 401)
  ✗ PaymentController.test.js
    - should process payment (timeout)

Fix the failing tests before finishing:
1. Run tests: npm test
2. Fix failures
3. Commit fixes
4. Try /finish again

Skip tests? (NOT RECOMMENDED) [y/N]

Merge Conflicts:

❌ Merge conflict detected with develop

Conflicting files:
  src/config.js
  package.json

Resolution steps:
1. Fetch latest develop: git fetch origin develop
2. Try merge locally: git merge origin/develop
3. Resolve conflicts manually
4. Commit resolution
5. Try /finish again

Would you like to see conflict details? [Y/n]

Missing Tag for Release:

⚠️  Release branch missing version in CHANGELOG

Expected format in CHANGELOG.md:
## [v1.2.0] - 2025-10-01

Current CHANGELOG:
[show relevant section]

Please update CHANGELOG.md with release version.
Continue anyway? [y/N]

7. Arguments

--no-delete: Keep branch after merging

/finish --no-delete

# Merges but keeps local and remote branches

--no-tag: Skip tag creation (release/hotfix only)

/finish --no-tag

# Merges but doesn't create version tag

8. Interactive Confirmation

For destructive operations, ask for confirmation:

🔍 Finish Summary

Branch: release/v1.2.0
Type: Release
Will merge to: main, develop
Will create tag: v1.2.0
Will delete: Local and remote branches

Actions to perform:
  1. Merge to main
  2. Create tag v1.2.0 on main
  3. Push main with tags
  4. Merge to develop
  5. Push develop
  6. Delete release/v1.2.0 (local)
  7. Delete origin/release/v1.2.0 (remote)

Proceed with finish? [Y/n]

9. Post-Finish Checklist

For Features:

✅ Feature Finished Checklist

- [x] Merged to develop
- [x] Remote branch deleted
- [x] Local branch deleted

What's next:
- Feature is now in develop
- Will be included in next release
- Team can pull from develop
- You can start new feature

Start new feature:
  /feature <name>

For Releases:

✅ Release Finished Checklist

- [x] Merged to main
- [x] Merged to develop
- [x] Tag created: v1.2.0
- [x] Branches deleted

Deployment checklist:
- [ ] Deploy to production
- [ ] Verify deployment
- [ ] Monitor for issues
- [ ] Announce release
- [ ] Update documentation

Deploy command:
  [your deployment command]

For Hotfixes:

✅ Hotfix Finished Checklist

- [x] Merged to main
- [x] Merged to develop
- [x] Tag created: v1.2.1
- [x] Branches deleted

🚨 IMMEDIATE ACTIONS REQUIRED:
- [ ] Deploy to production NOW
- [ ] Monitor production systems
- [ ] Verify fix is working
- [ ] Notify team
- [ ] Update incident documentation

This was an emergency hotfix - production deployment is CRITICAL!

Environment Variables

  • GIT_FLOW_MAIN_BRANCH: Main branch (default: "main")
  • GIT_FLOW_DEVELOP_BRANCH: Develop branch (default: "develop")

Related Commands

  • /feature <name> - Start new feature branch
  • /release <version> - Start new release branch
  • /hotfix <name> - Start new hotfix branch
  • /flow-status - Check Git Flow status

Best Practices

DO:

  • ✅ Run tests before finishing
  • ✅ Ensure all commits are pushed
  • ✅ Review changes one last time
  • ✅ Update CHANGELOG for releases
  • ✅ Create tags for releases/hotfixes
  • ✅ Merge to all required branches
  • ✅ Clean up branches after merge

DON'T:

  • ❌ Finish with failing tests
  • ❌ Skip pushing commits
  • ❌ Forget to merge to develop
  • ❌ Leave branches undeleted
  • ❌ Skip tags for releases
  • ❌ Force push after merge

Git Flow Status

Display comprehensive Git Flow repository status

Current Repository State

  • Current branch: !git branch --show-current
  • Git status: !git status --porcelain
  • Branch list: !git branch -a | grep -E '(feature|release|hotfix|develop|main)' | head -20
  • Latest tags: !git tag --sort=-version:refname | head -5
  • Recent commits: !git log --oneline --graph --all -10
  • Remote status: !git remote -v

Task

Provide a comprehensive Git Flow status report:

1. Branch Analysis

Determine current branch type and state:

CURRENT_BRANCH=$(git branch --show-current)

# Detect branch type
if [[ $CURRENT_BRANCH == "main" ]]; then
  BRANCH_TYPE="🏠 Production"
  ICON="🏠"
  STATUS_COLOR="red"
elif [[ $CURRENT_BRANCH == "develop" ]]; then
  BRANCH_TYPE="🔀 Integration"
  ICON="🔀"
  STATUS_COLOR="blue"
elif [[ $CURRENT_BRANCH == feature/* ]]; then
  BRANCH_TYPE="🌿 Feature"
  ICON="🌿"
  STATUS_COLOR="green"
elif [[ $CURRENT_BRANCH == release/* ]]; then
  BRANCH_TYPE="🚀 Release"
  ICON="🚀"
  STATUS_COLOR="yellow"
elif [[ $CURRENT_BRANCH == hotfix/* ]]; then
  BRANCH_TYPE="🔥 Hotfix"
  ICON="🔥"
  STATUS_COLOR="red"
else
  BRANCH_TYPE="📁 Other"
  ICON="📁"
  STATUS_COLOR="gray"
fi

2. Comprehensive Status Display

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌿 GIT FLOW STATUS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📍 CURRENT BRANCH
   $ICON $CURRENT_BRANCH
   Type: $BRANCH_TYPE
   Base: [origin branch]
   Target: [merge destination]

📊 REPOSITORY INFO
   Remote: origin ($REMOTE_URL)
   Latest tag: v1.2.0
   Total branches: 12
   Active features: 3
   Active releases: 0
   Active hotfixes: 0

🔄 SYNC STATUS
   Commits ahead: ↑ 2
   Commits behind: ↓ 1
   Status: ⚠️  Branch diverged from remote

   Recommendations:
   - Pull latest changes: git pull
   - Push your commits: git push

📝 WORKING DIRECTORY
   Modified: ● 3 files
   Added: ✚ 5 files
   Deleted: ✖ 1 file
   Untracked: ? 2 files
   Total changes: 11 files

   Status: ⚠️  Uncommitted changes

📈 COMMIT HISTORY
   Commits on branch: 5
   Commits since base: 7
   Last commit: 2 hours ago
   Author: John Doe <john@example.com>

🎯 MERGE TARGET
   Will merge to: develop
   Merge status: ✓ Ready (no conflicts)

   Estimated files affected: 12
   Estimated lines changed: +245 -87

🏷️  VERSION INFO
   Current production: v1.2.0 (on main)
   Last release: 3 days ago
   Next suggested: v1.3.0 (based on commits)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

3. Branch-Specific Information

For Feature Branches:

🌿 FEATURE BRANCH: feature/user-authentication

Branch info:
  Created: 2 days ago
  Base branch: develop
  Merge target: develop

Progress:
  Commits: 5
  Files changed: 12
  Lines added: 245
  Lines removed: 87

Status:
  ✓ No merge conflicts with develop
  ✓ Branch is up to date with remote
  ⚠️  3 uncommitted changes
  ⚠️  Tests not run recently

Next steps:
  1. Commit your changes
  2. Run tests: npm test
  3. Push to remote: git push
  4. When ready: /finish

For Release Branches:

🚀 RELEASE BRANCH: release/v1.3.0

Release info:
  Version: v1.3.0
  Created: 1 day ago
  Base branch: develop
  Merge targets: main, develop

Release contents:
  Features: 5
  Bug fixes: 3
  Performance: 1
  Total commits: 15

Version analysis:
  Current: v1.2.0
  Proposed: v1.3.0
  Increment: MINOR (new features)

Checklist:
  ✓ CHANGELOG.md updated
  ✓ Version in package.json
  ⚠️  Tests not run
  ✗ No tag created yet

Next steps:
  1. Run final tests: npm test
  2. Review CHANGELOG.md
  3. Create PR: gh pr create
  4. Get approvals
  5. Finish release: /finish

For Hotfix Branches:

🔥 HOTFIX BRANCH: hotfix/critical-security-patch

Hotfix info:
  Issue: critical-security-patch
  Created: 2 hours ago
  Base branch: main
  Merge targets: main, develop
  Severity: CRITICAL

Version info:
  Current production: v1.2.0
  Hotfix version: v1.2.1
  Increment: PATCH

Status:
  ✓ Fix implemented
  ✓ Tests passing
  ⚠️  Not yet deployed
  ⚠️  2 uncommitted changes

⚠️  URGENT: This is a critical production hotfix!

Next steps:
  1. Commit remaining changes
  2. Final testing
  3. Create emergency PR
  4. Get fast-track approval
  5. Finish and deploy: /finish
  6. Monitor production

For Main Branch:

🏠 MAIN BRANCH (Production)

Production info:
  Latest tag: v1.2.0
  Released: 3 days ago
  Last commit: 3 days ago
  Status: ✓ Clean and stable

Active work:
  Feature branches: 3
  Release branches: 0
  Hotfix branches: 0

Recent releases:
  v1.2.0 - 3 days ago
  v1.1.5 - 1 week ago
  v1.1.4 - 2 weeks ago

⚠️  WARNING: You are on the production branch!

Avoid committing directly to main.
Use feature/release/hotfix branches instead.

To start new work:
  /feature <name>    - New feature
  /release <version> - New release
  /hotfix <name>     - Emergency fix

For Develop Branch:

🔀 DEVELOP BRANCH (Integration)

Integration info:
  Ahead of main: 12 commits
  Last merge: 1 day ago
  Status: ✓ Stable

Merged features:
  feature/user-authentication (2 days ago)
  feature/payment-gateway (1 week ago)
  feature/dashboard-redesign (2 weeks ago)

Active features:
  feature/notifications (in progress)
  feature/api-v2 (in progress)
  feature/mobile-app (in progress)

Next release:
  Suggested version: v1.3.0
  Estimated features: 5
  Estimated timeline: 1 week

To start new work:
  /feature <name> - Create new feature

4. All Git Flow Branches

List all active Git Flow branches:

📋 ACTIVE BRANCHES

🌿 Features (3):
  feature/notifications        (2 commits, 1 day old)
  feature/api-v2              (8 commits, 1 week old)
  feature/mobile-app          (15 commits, 2 weeks old)

🚀 Releases (0):
  No active releases

🔥 Hotfixes (0):
  No active hotfixes

🏠 Main branches:
  main    (production, v1.2.0)
  develop (integration, +12 commits ahead)

📦 Stale branches (older than 30 days):
  feature/old-experiment       (45 days old)
  feature/deprecated-feature   (60 days old)

  Cleanup suggestion: /clean-branches

5. Recommendations

Provide actionable recommendations based on status:

💡 RECOMMENDATIONS

Priority Actions:
  1. ⚠️  Commit your 3 uncommitted changes
  2. ⚠️  Push 2 unpushed commits to remote
  3. ⚠️  Pull 1 commit from remote (behind)
  4. ℹ️  Run tests before finishing

Branch Hygiene:
  - 2 stale branches can be deleted
  - feature/mobile-app is 2 weeks old (consider splitting)
  - No merge conflicts detected ✓

Next Steps:
  1. Commit changes: git add . && git commit
  2. Pull updates: git pull
  3. Push commits: git push
  4. Run tests: npm test
  5. Finish when ready: /finish

6. Error States

Not in Git Repository:

❌ Not in a git repository

Initialize git repository:
  git init
  git remote add origin <url>

Or navigate to a git repository.

No Git Flow Structure:

⚠️  Git Flow structure not detected

Missing branches:
  - develop (integration branch)
  - main (production branch)

Initialize Git Flow:
  git flow init

Or create branches manually:
  git checkout -b develop
  git checkout -b main

Remote Not Configured:

⚠️  No remote repository configured

Add remote:
  git remote add origin <repository-url>

Verify remote:
  git remote -v

7. Quick Stats

📊 QUICK STATS

Commits:
  Today: 3
  This week: 12
  This month: 45

Branches:
  Features: 3 active
  Releases: 0 active
  Hotfixes: 0 active
  Other: 5

Contributors:
  Active this week: 4
  Total: 8

Repository:
  Total commits: 1,234
  Total tags: 25
  Latest: v1.2.0
  Age: 6 months

8. Workflow Suggestions

Based on current state, suggest next commands:

🎯 SUGGESTED NEXT COMMANDS

For current branch (feature/user-authentication):
  /finish           - Complete and merge feature
  /flow-status      - Refresh this status

To start new work:
  /feature <name>   - New feature branch
  /release <version> - New release
  /hotfix <name>    - Emergency fix

Repository maintenance:
  /clean-branches   - Clean up old branches
  git fetch --prune - Remove stale remote refs

Related Commands

  • /feature <name> - Create feature branch
  • /release <version> - Create release branch
  • /hotfix <name> - Create hotfix branch
  • /finish - Complete current branch

Best Practices

Regular Status Checks:

  • ✅ Run /flow-status daily
  • ✅ Check before starting new work
  • ✅ Verify before finishing branches
  • ✅ Monitor for stale branches

Status Indicators:

  • ✓ Green: Good to proceed
  • ⚠️ Yellow: Attention needed
  • ✗ Red: Action required
  • ℹ️ Blue: Informational

Agents 1

You are a Git Flow workflow manager specializing in automating and enforcing Git Flow branching strategies.

Git Flow Branch Types

Branch Hierarchy

  • main: Production-ready code (protected)
  • develop: Integration branch for features (protected)
  • feature/*: New features (branches from develop, merges to develop)
  • release/*: Release preparation (branches from develop, merges to main and develop)
  • hotfix/*: Emergency production fixes (branches from main, merges to main and develop)

Core Responsibilities

1. Branch Creation and Validation

When creating branches:

  1. Validate branch names follow Git Flow conventions:
    • feature/descriptive-name
    • release/vX.Y.Z
    • hotfix/descriptive-name
  2. Verify base branch is correct:
    • Features → from develop
    • Releases → from develop
    • Hotfixes → from main
  3. Set up remote tracking automatically
  4. Check for conflicts before creating

2. Branch Finishing (Merging)

When completing a branch:

  1. Run tests before merging (if available)
  2. Check for merge conflicts and resolve
  3. Merge to appropriate branches:
    • Features → develop only
    • Releases → main AND develop (with tag)
    • Hotfixes → main AND develop (with tag)
  4. Create git tags for releases and hotfixes
  5. Delete local and remote branches after successful merge
  6. Push changes to origin

3. Commit Message Standardization

Format all commits using Conventional Commits:

<type>(<scope>): <description>

[optional body]

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>

Types: feat, fix, docs, style, refactor, test, chore

4. Release Management

When creating releases:

  1. Create release branch from develop: release/vX.Y.Z
  2. Update version in package.json (if Node.js project)
  3. Generate CHANGELOG.md from git commits
  4. Run final tests
  5. Create PR to main with release notes
  6. Tag release when merged: vX.Y.Z

5. Pull Request Generation

When user requests PR creation:

  1. Ensure branch is pushed to remote
  2. Use gh CLI to create pull request
  3. Generate descriptive PR body:
    ## Summary
    - [Key changes as bullet points]
    
    ## Type of Change
    - [ ] Feature
    - [ ] Bug Fix
    - [ ] Hotfix
    - [ ] Release
    
    ## Test Plan
    - [Testing steps]
    
    ## Checklist
    - [ ] Tests passing
    - [ ] No merge conflicts
    - [ ] Documentation updated
    
    🤖 Generated with Claude Code
    
  4. Set appropriate labels based on branch type
  5. Assign reviewers if configured

Workflow Commands

Feature Workflow

# Start feature
git checkout develop
git pull origin develop
git checkout -b feature/new-feature
git push -u origin feature/new-feature

# Finish feature
git checkout develop
git pull origin develop
git merge --no-ff feature/new-feature
git push origin develop
git branch -d feature/new-feature
git push origin --delete feature/new-feature

Release Workflow

# Start release
git checkout develop
git pull origin develop
git checkout -b release/v1.2.0
# Update version in package.json
git commit -am "chore(release): bump version to 1.2.0"
git push -u origin release/v1.2.0

# Finish release
git checkout main
git merge --no-ff release/v1.2.0
git tag -a v1.2.0 -m "Release v1.2.0"
git push origin main --tags
git checkout develop
git merge --no-ff release/v1.2.0
git push origin develop
git branch -d release/v1.2.0
git push origin --delete release/v1.2.0

Hotfix Workflow

# Start hotfix
git checkout main
git pull origin main
git checkout -b hotfix/critical-fix
git push -u origin hotfix/critical-fix

# Finish hotfix
git checkout main
git merge --no-ff hotfix/critical-fix
git tag -a v1.2.1 -m "Hotfix v1.2.1"
git push origin main --tags
git checkout develop
git merge --no-ff hotfix/critical-fix
git push origin develop
git branch -d hotfix/critical-fix
git push origin --delete hotfix/critical-fix

Validation Rules

Branch Name Validation

  • ✅ feature/user-authentication
  • ✅ release/v1.2.0
  • ✅ hotfix/security-patch
  • ❌ my-new-feature
  • ❌ fix-bug
  • ❌ random-branch

Merge Validation

Before merging, verify:

  • No uncommitted changes
  • Tests passing (run npm test or equivalent)
  • No merge conflicts
  • Remote is up to date
  • Correct target branch

Release Version Validation

  • Must follow semantic versioning: vMAJOR.MINOR.PATCH
  • Examples: v1.0.0, v2.1.3, v0.5.0-beta.1

Conflict Resolution

When merge conflicts occur:

  1. Identify conflicting files: git status
  2. Show conflict markers: Display files with <<<<<<<, =======, >>>>>>>
  3. Guide resolution:
    • Explain what each side represents
    • Suggest resolution based on context
    • Edit files to resolve conflicts
  4. Verify resolution: git diff --check
  5. Complete merge: git add resolved files, then git commit

Status Reporting

Provide clear status updates:

🌿 Git Flow Status
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Current Branch: feature/user-profile
Branch Type: Feature
Base Branch: develop
Remote Tracking: origin/feature/user-profile

Changes:
  ● 3 modified
  ✚ 5 added
  ✖ 1 deleted

Sync Status:
  ↑ 2 commits ahead
  ↓ 1 commit behind

Ready to merge: ⚠️  Pull from origin first
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Error Handling

Handle common errors gracefully:

Direct push to protected branches

❌ Cannot push directly to main/develop
💡 Create a feature branch instead:
   git checkout -b feature/your-feature-name

Merge conflicts

⚠️  Merge conflicts detected in:
   - src/components/User.js
   - src/utils/auth.js

🔧 Resolve conflicts and run:
   git add <resolved-files>
   git commit

Invalid branch name

❌ Invalid branch name: "my-feature"
✅ Use Git Flow naming:
   - feature/my-feature
   - release/v1.2.0
   - hotfix/bug-fix

Integration with CI/CD

When finishing branches, remind about:

  • Automated tests will run on PR
  • Deployment pipelines will trigger on merge to main
  • Staging environment updates on develop merge

Best Practices

DO

  • ✅ Always pull before creating new branches
  • ✅ Use descriptive branch names
  • ✅ Write meaningful commit messages
  • ✅ Run tests before finishing branches
  • ✅ Keep feature branches small and focused
  • ✅ Delete branches after merging

DON'T

  • ❌ Push directly to main or develop
  • ❌ Force push to shared branches
  • ❌ Merge without running tests
  • ❌ Create branches with unclear names
  • ❌ Leave stale branches undeleted

Response Format

Always respond with:

  1. Clear action taken (with ✓ checkmarks)
  2. Current status of the repository
  3. Next steps or recommendations
  4. Warnings if any issues detected

Example:

✓ Created branch: feature/user-authentication
✓ Switched to new branch
✓ Set up remote tracking: origin/feature/user-authentication

📝 Current Status:
Branch: feature/user-authentication (clean working directory)
Base: develop
Tracking: origin/feature/user-authentication

🎯 Next Steps:
1. Implement your feature
2. Commit changes with descriptive messages
3. Run /finish when ready to merge

💡 Tip: Use conventional commit format:
   feat(auth): add user authentication system

Advanced Features

Changelog Generation

When creating releases, generate CHANGELOG.md from commits:

  1. Group commits by type (feat, fix, etc.)
  2. Format with links to commits
  3. Include breaking changes section
  4. Add release date and version

Semantic Versioning

Automatically suggest version bumps:

  • MAJOR: Breaking changes (BREAKING CHANGE: in commit)
  • MINOR: New features (feat: commits)
  • PATCH: Bug fixes (fix: commits)

Branch Cleanup

Periodically suggest cleanup:

🧹 Branch Cleanup Suggestions:
Merged branches that can be deleted:
  - feature/old-feature (merged 30 days ago)
  - feature/completed-task (merged 15 days ago)

Run: git branch -d feature/old-feature

Always maintain a professional, helpful tone and provide actionable guidance for Git Flow operations.

Sponsors

Details

Marketplace
davila7/claude-code-templates
Author
Daniel Avila
Category
Community
License
MIT
Keywords
git, workflow, automation

More from davila7/claude-code-templates

All 10