name: 事故通信 描述: 用于事故通信的Slack集成。在搜索事故频道上下文、发布状态更新或查找问题讨论时使用。 允许工具: Bash(python *)
事故通信
认证
重要: 凭据由代理层自动注入。请勿检查环境变量中的 SLACK_BOT_TOKEN - 它不可见。直接运行脚本;认证透明处理。
为什么Slack上下文重要
在深入技术调查之前:
- 其他人见过这个吗? 搜索相关讨论
- 已经尝试了什么? 检查事故线程历史
- 谁在处理它? 查找活动响应者
- 影响是什么? 查找客户报告
可用脚本
所有脚本位于 .claude/skills/incident-comms/scripts/
search_messages.py - 跨频道搜索
注意: 需要Slack 用户令牌 (xoxu-*),不是机器人令牌。机器人令牌无法使用搜索API。
python .claude/skills/incident-comms/scripts/search_messages.py --query 搜索查询 [--count N]
# 示例:
python .claude/skills/incident-comms/scripts/search_messages.py --query "error timeout"
python .claude/skills/incident-comms/scripts/search_messages.py --query "in:#incidents api error"
python .claude/skills/incident-comms/scripts/search_messages.py --query "from:@oncall database" --count 30
get_channel_history.py - 读取频道消息
python .claude/skills/incident-comms/scripts/get_channel_history.py --channel 频道ID [--limit N]
# 示例:
python .claude/skills/incident-comms/scripts/get_channel_history.py --channel C123ABC456
python .claude/skills/incident-comms/scripts/get_channel_history.py --channel C123ABC456 --limit 100
post_message.py - 发布状态更新
python .claude/skills/incident-comms/scripts/post_message.py --channel 频道ID --text 消息 [--thread 线程TS]
# 示例:
python .claude/skills/incident-comms/scripts/post_message.py --channel C123ABC456 --text "调查更新:找到根本原因"
python .claude/skills/incident-comms/scripts/post_message.py --channel C123ABC456 --text "回滚完成" --thread 1705320123.456789
Slack搜索运算符
| 运算符 | 示例 | 目的 |
|---|---|---|
in:#channel |
in:#incidents |
搜索特定频道 |
from:@user |
from:@jane |
来自用户的消息 |
has:reaction |
has::eyes: |
有反应的消息 |
after:date |
after:2024-01-15 |
在日期之后 |
before:date |
before:2024-01-16 |
在日期之前 |
常见工作流
1. 为新事故收集上下文
# 步骤1:搜索类似问题
python search_messages.py --query "api timeout in:#incidents"
# 步骤2:检查事故频道的近期活动
python get_channel_history.py --channel C_INCIDENTS --limit 50
# 步骤3:读取特定线程
python get_thread_replies.py --channel C_INCIDENTS --thread 1705320123.456789
2. 查找已尝试的操作
# 搜索在此事故期间采取的行动
python search_messages.py --query "in:#incident-123 (restart OR rollback OR revert OR tried)"
3. 检查客户影响
# 搜索支持/客户频道
python search_messages.py --query "in:#support error OR issue"
4. 发布调查摘要
python post_message.py --channel C_INCIDENTS --thread 1705320123.456789 --text ":clipboard: *调查摘要*
*时间线:*
• 14:00 - 警报开始触发
• 14:05 - 调查开始
• 14:15 - 确定根本原因
• 14:20 - 部署修复
*根本原因:*
由于未关闭连接导致的连接池耗尽。
*解决方案:*
回滚到 v2.3.4,在 v2.3.5 中部署修复。"
快速命令参考
| 目标 | 命令 |
|---|---|
| 搜索消息 | search_messages.py --query "error" |
| 频道历史 | get_channel_history.py --channel C123ABC |
| 发布更新 | post_message.py --channel C123ABC --text "更新" |
| 回复线程 | post_message.py --channel C123ABC --text "..." --thread TS |
状态更新模板
调查开始:
:mag: *调查开始*
调查中: [症状简要描述]
初步发现: [截至目前找到的内容]
当前假设: [可能的问题]
将在15分钟内更新。
确定根本原因:
:bulb: *确定根本原因*
原因: [清晰解释]
影响: [受影响内容]
缓解措施: [正在采取的修复措施]
预计解决时间: [时间估计]
已解决:
:white_check_mark: *事故已解决*
根本原因: [简要摘要]
解决方案: [修复措施]
持续时间: [事故持续时间]
后续步骤: [下一步、事后分析时间]
最佳实践
搜索
- 具体化:使用频道过滤器(
in:#channel)减少噪音 - 使用运算符:结合
from:、after:、has:提高精度 - 检查多个频道:事故可能在 #support、#engineering 等频道讨论
发布更新
- 使用线程:将更新保留在事故线程中,而不是主频道
- 简洁明了:忙碌的响应者快速扫描更新
- 包括下一步:始终说明接下来发生什么
查找频道ID
- 频道ID类似
C123ABC456 - 从频道设置或右键单击 → “复制链接” 获取
避免的反模式
- ❌ 在阅读前发布 - 检查已讨论内容
- ❌ 在线程顶部发帖 - 在线程内回复,而不是频道
- ❌ 模糊更新 - “正在处理” 不提供信息
- ❌ 缺少时间戳 - 包括事件发生时间