hotfix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hotfix Workflow

热修复工作流

For urgent production fixes. Minimal change, fast turnaround.
用于紧急生产环境修复。最小改动、快速周转。

1. Sync main

1. 同步主分支

git checkout main && git pull
git checkout main && git pull

2. Create worktree and branch

2. 创建工作树和分支

git worktree add .claude/worktrees/hotfix-<name> -b hotfix/<description>
cd .claude/worktrees/hotfix-<name>
All work happens in the worktree — main stays clean.
git worktree add .claude/worktrees/hotfix-<name> -b hotfix/<description>
cd .claude/worktrees/hotfix-<name>
所有工作都在工作树中进行——主分支保持干净。

3. Identify and fix

3. 定位并修复问题

  • Read the error carefully — stack trace, logs, error message
  • Make the smallest possible change that fixes the issue
  • No refactoring, no cleanup, no "while I'm here" improvements
  • 仔细阅读错误信息——堆栈跟踪、日志、错误提示
  • 做出能解决问题的最小改动
  • 不重构、不清理、不做“顺手改进”

4. Test

4. 测试

  • Write a regression test for the bug
  • Run full test suite — must pass with zero failures
  • If test infrastructure doesn't cover this path, manually verify and document how
  • 为该bug编写回归测试
  • 运行完整测试套件——必须零失败通过
  • 如果测试基础设施未覆盖该路径,手动验证并记录验证方式

5. Create PR

5. 创建PR

  • Commit with message: what broke, why, and what the fix does
  • Push and create PR via
    gh pr create
  • Mark PR as urgent in the description
  • Wait for CI/CD checks to complete:
    gh pr checks <number> --watch
  • If checks fail, fix the issues and push again — do not notify the user until all checks are green
  • Once all checks pass, return the PR URL and ask the user to review
  • DO NOT merge — wait for explicit approval
  • 提交信息需说明:哪里出问题、原因是什么、修复内容是什么
  • 推送并通过
    gh pr create
    创建PR
  • 在描述中标记PR为紧急
  • 等待CI/CD检查完成:
    gh pr checks <number> --watch
  • 如果检查失败,修复问题后重新推送——在所有检查通过前不要通知用户
  • 所有检查通过后,返回PR链接并请求用户审核
  • 请勿合并——等待明确的审批

6. Merge (only when approved)

6. 合并(仅在获批后)

  • gh pr merge <number> --merge
  • Clean up worktree:
    cd <project-root> && git worktree remove .claude/worktrees/hotfix-<name>
  • git checkout main && git pull && git branch -d hotfix/<description>
  • Consider whether a release is needed immediately
  • gh pr merge <number> --merge
  • 清理工作树:
    cd <project-root> && git worktree remove .claude/worktrees/hotfix-<name>
  • git checkout main && git pull && git branch -d hotfix/<description>
  • 考虑是否需要立即发布版本

Rules

规则

  • Scope discipline — fix ONLY the bug, nothing else
  • Never merge without explicit approval
  • Never push directly to main
  • Always write a regression test
  • If the fix is complex (>20 lines changed), switch to
    /fix-bug
    workflow instead
  • 范围约束——仅修复bug,不做其他改动
  • 未经明确审批绝不合并
  • 绝不直接推送到主分支
  • 始终编写回归测试
  • 如果修复复杂(改动超过20行),请切换到
    /fix-bug
    工作流