Files
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 line
12 KiB
JSON

{"content": "---\nallowed-tools: Bash(git:*), Read, Edit, Write\nargument-hint: <hotfix-name>\ndescription: Create a new Git Flow hotfix branch from main for emergency production fixes\n---\n\n# Git Flow Hotfix Branch\n\nCreate emergency hotfix branch: **$ARGUMENTS**\n\n## Current Repository State\n\n- Current branch: !`git branch --show-current`\n- Git status: !`git status --porcelain`\n- Latest production tag: !`git describe --tags --abbrev=0 origin/main 2>/dev/null || echo \"No tags on main\"`\n- Main branch status: !`git log main..origin/main --oneline 2>/dev/null | head -3 || echo \"No remote tracking for main\"`\n- 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 ' '`\n\n## Task\n\nCreate a Git Flow hotfix branch for emergency production fixes:\n\n### 1. Pre-Flight Validation\n\n**Critical Checks:**\n- **Verify hotfix name**: Ensure `$ARGUMENTS` is provided and descriptive\n - ✅ Valid: `critical-security-patch`, `payment-gateway-fix`, `auth-bypass-fix`\n - ❌ Invalid: `fix`, `hotfix1`, `bug`\n- **Check main branch exists**: Ensure `main` branch is present\n- **Verify no uncommitted changes**: Clean working directory required\n- **Confirm emergency status**: Hotfixes are for CRITICAL production issues only\n\n**⚠️ IMPORTANT: Hotfix Usage Guidelines**\n\nHotfixes are ONLY for:\n- 🔒 Critical security vulnerabilities\n- 💥 Production-breaking bugs\n- 💰 Payment/transaction failures\n- 🚨 Data loss or corruption issues\n- 🔥 System downtime or crashes\n\nNOT for:\n- ❌ Regular bug fixes (use feature branch)\n- ❌ New features (use feature branch)\n- ❌ Performance improvements (use feature branch)\n- ❌ Non-critical issues (wait for next release)\n\n### 2. Create Hotfix Branch Workflow\n\n```bash\n# Switch to main branch\ngit checkout main\n\n# Pull latest production code\ngit pull origin main\n\n# Create hotfix branch from main\ngit checkout -b hotfix/$ARGUMENTS\n\n# Set up remote tracking\ngit push -u origin hotfix/$ARGUMENTS\n```\n\n### 3. Determine Version Bump\n\nAnalyze the latest tag to suggest hotfix version:\n\n```\nCurrent production version: v1.2.0\nHotfix version: v1.2.1\n\nVersion bump: PATCH (third number incremented)\n```\n\n**Hotfix Version Rules:**\n- Always increment PATCH version (X.Y.Z → X.Y.Z+1)\n- Never increment MAJOR or MINOR for hotfixes\n- Examples:\n - v1.2.0 → v1.2.1\n - v2.0.5 → v2.0.6\n - v1.5.9 → v1.5.10\n\n### 4. Success Response\n\n```\n✓ Switched to main branch\n✓ Pulled latest production code from origin/main\n✓ Created branch: hotfix/$ARGUMENTS\n✓ Set up remote tracking: origin/hotfix/$ARGUMENTS\n✓ Pushed branch to remote\n\n🔥 Hotfix Branch Ready: hotfix/$ARGUMENTS\n\nBranch: hotfix/$ARGUMENTS\nBase: main (production)\nWill merge to: main AND develop\nSuggested version: v1.2.1\n\n⚠️ CRITICAL HOTFIX WORKFLOW\n\nThis is an EMERGENCY production fix. Follow these steps:\n\n1. 🔍 Identify the Issue\n - Reproduce the bug\n - Understand the root cause\n - Document the impact\n\n2. 🛠️ Implement the Fix\n - Make MINIMAL changes\n - Focus ONLY on the critical issue\n - Avoid refactoring or improvements\n - Add tests to prevent regression\n\n3. 🧪 Test Thoroughly\n - Test the specific fix\n - Run full regression tests\n - Test on production-like environment\n - Verify no side effects\n\n4. 📝 Document the Fix\n - Update version in package.json\n - Add entry to CHANGELOG.md\n - Document the bug and fix\n - Include reproduction steps\n\n5. 🚀 Deploy Process\n - Create PR to main\n - Get expedited review\n - Run /finish to merge and tag\n - Deploy to production immediately\n - Monitor for issues\n\n🎯 Next Steps:\n1. Fix the critical issue (MINIMAL changes only)\n2. Test thoroughly: npm test\n3. Update version: v1.2.1\n4. Create emergency PR: gh pr create --label \"hotfix,critical\"\n5. Get fast-track approval\n6. Run /finish to merge to main AND develop\n7. Deploy to production\n8. Monitor systems closely\n\n⚠️ Remember:\n- Hotfix will be merged to BOTH main and develop\n- Tag v1.2.1 will be created on main\n- Production deployment should happen immediately\n- Team should be notified of the hotfix\n```\n\n### 5. Error Handling\n\n**No Hotfix Name Provided:**\n```\n❌ Hotfix name is required\n\nUsage: /hotfix <hotfix-name>\n\nExamples:\n /hotfix critical-security-patch\n /hotfix payment-processing-failure\n /hotfix auth-bypass-vulnerability\n\n⚠️ IMPORTANT: Hotfixes are for CRITICAL production issues only!\n\nFor non-critical fixes, use:\n /feature <name> - Regular bug fixes\n```\n\n**Invalid Hotfix Name:**\n```\n❌ Invalid hotfix name: \"fix\"\n\nHotfix names should be:\n- Descriptive of the issue\n- Use kebab-case format\n- Indicate severity/urgency\n\nExamples:\n ✅ critical-security-patch\n ✅ payment-gateway-timeout\n ✅ user-data-corruption-fix\n ❌ fix\n ❌ bug1\n ❌ hotfix\n```\n\n**Uncommitted Changes:**\n```\n⚠️ Uncommitted changes detected in working directory:\nM src/file.js\nA test.js\n\nHotfixes require a clean working directory.\n\nOptions:\n1. Commit your changes first\n2. Stash them: git stash\n3. Discard them: git checkout .\n\n⚠️ This is an emergency hotfix. Please clean your working directory.\n```\n\n**Main Branch Behind Remote:**\n```\n⚠️ Local main is behind origin/main by 2 commits\n\n✓ Pulling latest production code...\n✓ Fetched 2 commits\n✓ Main is now synchronized with production\n✓ Ready to create hotfix branch\n```\n\n**Not a Critical Issue:**\n```\n⚠️ Hotfix Confirmation Required\n\nIs this a CRITICAL production issue that requires immediate attention?\n\nCritical issues include:\n- Security vulnerabilities\n- Production system failures\n- Data loss or corruption\n- Payment/transaction failures\n\nIf this is NOT critical, consider:\n- Creating a feature branch instead\n- Waiting for the next release cycle\n- Using regular bug fix workflow\n\nProceed with hotfix? [y/N]\n```\n\n### 6. Hotfix Checklist\n\n```\n🔥 Emergency Hotfix Checklist\n\nIssue Identification:\n- [ ] Bug is confirmed and reproducible\n- [ ] Root cause is identified\n- [ ] Impact is documented\n- [ ] Stakeholders are notified\n\nDevelopment:\n- [ ] Fix is minimal and focused\n- [ ] No unnecessary changes included\n- [ ] Tests added to prevent regression\n- [ ] Code reviewed (if time permits)\n\nTesting:\n- [ ] Fix verified in local environment\n- [ ] Unit tests passing\n- [ ] Integration tests passing\n- [ ] Tested on production-like environment\n- [ ] No side effects detected\n\nDocumentation:\n- [ ] CHANGELOG.md updated\n- [ ] Version bumped (PATCH)\n- [ ] Bug description documented\n- [ ] Fix explanation documented\n- [ ] Deployment notes prepared\n\nDeployment:\n- [ ] PR created with \"hotfix\" and \"critical\" labels\n- [ ] Fast-track approval obtained\n- [ ] Production deployment plan ready\n- [ ] Rollback plan documented\n- [ ] Monitoring alerts configured\n- [ ] Team notified of deployment\n\nPost-Deployment:\n- [ ] Fix verified in production\n- [ ] Systems monitored for issues\n- [ ] Metrics show improvement\n- [ ] Hotfix merged back to develop\n- [ ] Post-mortem scheduled (if needed)\n```\n\n### 7. Version Update Process\n\nAfter implementing the fix, update the version:\n\n```bash\n# Update package.json version (PATCH bump)\nnpm version patch --no-git-tag-version\n\n# Update CHANGELOG.md\ncat >> CHANGELOG.md << EOF\n\n## [v1.2.1] - $(date +%Y-%m-%d) - HOTFIX\n\n### 🔥 Critical Fixes\n- Fix $ARGUMENTS: [brief description]\n - Root cause: [explanation]\n - Impact: [who/what was affected]\n - Resolution: [what was fixed]\n\nEOF\n\n# Commit version bump\ngit add package.json CHANGELOG.md\ngit commit -m \"chore(hotfix): bump version to v1.2.1\n\nCritical fix for $ARGUMENTS\n\n🤖 Generated with Claude Code\nCo-Authored-By: Claude <noreply@anthropic.com>\"\n```\n\n### 8. Create Emergency PR\n\n```bash\ngh pr create \\\n --title \"🔥 HOTFIX v1.2.1: $ARGUMENTS\" \\\n --body \"$(cat <<'EOF'\n## 🔥 Emergency Hotfix\n\n**Severity**: Critical\n**Version**: v1.2.1\n**Issue**: $ARGUMENTS\n\n## Problem Description\n\n[Detailed description of the production issue]\n\n## Root Cause\n\n[Explanation of what caused the issue]\n\n## Fix Implementation\n\n[Description of the fix applied]\n\n## Testing\n\n- [x] Issue reproduced locally\n- [x] Fix verified locally\n- [x] Unit tests passing\n- [x] Integration tests passing\n- [x] Tested on staging environment\n\n## Deployment Plan\n\n1. Merge to main\n2. Tag as v1.2.1\n3. Deploy to production immediately\n4. Monitor for 30 minutes\n5. Merge back to develop\n\n## Rollback Plan\n\n[How to rollback if issues occur]\n\n## Monitoring\n\n[What to monitor post-deployment]\n\n---\n\n**⚠️ This is a critical production hotfix requiring immediate deployment**\n\n🤖 Generated with Claude Code\nEOF\n)\" \\\n --base main \\\n --head hotfix/$ARGUMENTS \\\n --label \"hotfix,critical,priority-high\" \\\n --assignee @me \\\n --reviewer team-leads\n```\n\n## Git Flow Integration\n\n**Hotfix Workflow in Git Flow:**\n\n```\nmain (v1.2.0) ──────┬─────────────► (after hotfix merge) v1.2.1\n │\n └─► hotfix/$ARGUMENTS\n │\n └─► (merges back to both)\n │\ndevelop ────────────────────┴─────────────► (receives hotfix)\n```\n\n**Important:**\n- Hotfixes branch from `main` (production)\n- Hotfixes merge to BOTH `main` AND `develop`\n- Tags are created on `main` after merge\n- Production deployment happens immediately\n\n## Environment Variables\n\n- `GIT_FLOW_MAIN_BRANCH`: Main branch name (default: \"main\")\n- `GIT_FLOW_DEVELOP_BRANCH`: Develop branch name (default: \"develop\")\n- `GIT_FLOW_PREFIX_HOTFIX`: Hotfix prefix (default: \"hotfix/\")\n\n## Related Commands\n\n- `/finish` - Complete hotfix (merge to main and develop, create tag, deploy)\n- `/flow-status` - Check current Git Flow status\n- `/feature <name>` - Create feature branch (for non-critical fixes)\n- `/release <version>` - Create release branch\n\n## Best Practices\n\n**DO:**\n- ✅ Use hotfixes ONLY for critical production issues\n- ✅ Keep changes minimal and focused\n- ✅ Test thoroughly before deploying\n- ✅ Document the issue and fix clearly\n- ✅ Notify team immediately\n- ✅ Merge back to develop after production deployment\n- ✅ Monitor production closely after deployment\n- ✅ Conduct post-mortem if appropriate\n\n**DON'T:**\n- ❌ Use hotfix for regular bug fixes\n- ❌ Add new features to hotfix\n- ❌ Refactor code during hotfix\n- ❌ Skip testing to save time\n- ❌ Forget to merge back to develop\n- ❌ Deploy without proper review\n- ❌ Skip documentation\n- ❌ Ignore monitoring after deployment\n\n## Post-Hotfix Actions\n\nAfter successful hotfix deployment:\n\n1. **Verify Fix in Production**\n - Monitor error rates\n - Check affected functionality\n - Verify metrics return to normal\n\n2. **Update Documentation**\n - Document the incident\n - Update runbooks if needed\n - Share learnings with team\n\n3. **Merge to Develop**\n - Ensure hotfix is in develop branch\n - Resolve any merge conflicts\n - Push to remote\n\n4. **Post-Mortem (if needed)**\n - Schedule review meeting\n - Identify prevention measures\n - Update processes if needed\n\n5. **Cleanup**\n - Delete hotfix branch\n - Archive related documentation\n - Update incident tracking\n"}