关于 incident-response
用于系统化处理生产事故的流程指南,面向负责排查、缓解和沟通的工程与运维团队。内容涵盖严重级别、处置步骤、恢复验证及事后复盘。
主要功能
- 01按影响划分事故级别
- 02检查监控与近期部署
- 03提供回滚和流量缓解选项
- 04安排内部与外部沟通
- 05验证修复并编写事后复盘
适用场景
- 01评估线上故障的严重程度
- 02通过回滚或功能标记缓解故障
- 03向团队和受影响用户同步进展
- 04事故结束后撰写无责复盘
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ spencerpauly/ awesome-cursor-skills --skill incident-response安装后在 Claude Code 中输入/incident-response确认已加载。
详细介绍
事故响应
系统地处理生产事故。
严重级别
| 级别 | 定义 | 响应时间 | 示例 |
|---|---|---|---|
| SEV1 | 服务中断,所有用户均受影响 | 立即 | 数据库崩溃、DNS 故障、身份验证不可用 |
| SEV2 | 主要功能故障,许多用户受影响 | < 30 分钟 | 支付失败、搜索不可用 |
| SEV3 | 次要功能故障,但有替代方案 | < 4 小时 | 导出按钮故障、仪表盘缓慢 |
| SEV4 | 外观问题或影响较小的问题 | 下一个工作日 | UI 中的拼写错误、轻微样式问题 |
事故处理流程
1. 检测与分类(前 5 分钟)
- 确认已知悉事故——“我正在查看这个问题”
- 确定严重级别
- 检查监控仪表盘(错误率、延迟、状态页)
- 检查最近的部署:
git log --oneline -10——最近是否有部署?
2. 缓解(接下来 15-30 分钟)
目标是先止损,而不是找出根本原因。
快速缓解措施:
- 回滚:
git revert <commit> && deploy——如果问题由部署引起,这是最快的选择 - 功能开关:禁用故障功能
- 扩容:如果是容量问题,则增加实例
- 故障转移:如果主服务不可用,则切换到备用服务
- 阻止流量:对特定的恶意流量进行速率限制或拦截
3. 沟通
内部:
- 创建事故频道(
#incident-2026-04-10) - 每隔 15-30 分钟发布状态更新
- 分配角色:事故指挥官、沟通负责人、工程师
外部:
- 更新状态页
- 如果中断持续时间较长,则向受影响的用户发送邮件/通知
- 诚实说明:“X 出现问题。我们已找到原因,正在修复。”
4. 解决
- 部署修复
- 在生产环境中验证修复有效(检查指标,而不只是确认没有错误)
- 发布总结并关闭事故频道
5. 事后复盘(48 小时内)
撰写无责备的事后复盘:
# Incident: Payments failing for Stripe webhook
**Date:** 2026-04-10
**Duration:** 45 minutes (14:30 — 15:15 UTC)
**Severity:** SEV2
**Impact:** ~200 users unable to complete purchases
## Timeline
- 14:30 — Alert fires: payment success rate drops to 20%
- 14:35 — On-call engineer acknowledges, begins investigation
- 14:40 — Identified: Stripe webhook endpoint returning 500
- 14:45 — Root cause: migration added NOT NULL column without default
- 14:50 — Fix deployed: added default value to migration
- 15:00 — Payment success rate recovering
- 15:15 — Metrics back to normal, incident closed
## Root Cause
Database migration #47 added a `currency` column with NOT NULL
but no DEFAULT value. Existing rows were fine (backfilled), but
new webhook events failed because the insert didn't include `currency`.
## What Went Well
- Alert fired within 5 minutes of the issue starting
- Rollback was considered but the fix was faster
## What Went Wrong
- Migration wasn't tested with live webhook payloads
- No staging test for the webhook flow
## Action Items
- [ ] Add webhook integration test to CI (@alice, due 2026-04-17)
- [ ] Require DEFAULT for all new NOT NULL columns in migration review (@bob)
- [ ] Add runbook for payment failures (@charlie, due 2026-04-14)
提示
- 先回滚,再调查——速度比优雅更重要
- 最近一次部署最有可能是问题根源
- 事后复盘不要追究责任——应着重改进流程
- 为常见故障模式维护操作手册
- 在真实事故发生前,通过演练日练习事故响应
评论
支持 Markdown