Skip to content
Development
Command

/hotfix

Create a new Git Flow hotfix branch from main for emergency production fixes

From plugin
claude-code-templates
30k200 skills200 agents200 commands2 MCP
Install
$ npx -y skills add davila7/claude-code-templates --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/hotfix

Context preview

What this command does when you run it.

Create a new Git Flow hotfix branch from main for emergency production fixes

Command definition

hotfix.md
allowed-tools: Bash(git:*), Read, Edit, Write
argument-hint: <hotfix-name>
description: Create a new Git Flow hotfix branch from main for emergency production fixes

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
- [
Read more
Ships withclaude-code-templates

Ready-to-use configurations for Anthropic's Claude Code. A comprehensive collection of AI agents, custom commands, settings, hooks, external integrations (MCPs), and project templates to enhance your development workflow.

Get the whole plugin, auto-invoked
Stats
30,155
Stars
18
Views
3,377
Forks
Active
Maintenance
Python
Language
MIT
License
28m ago
Last commit
1y ago
Created

Repo: davila7/claude-code-templates