
Runbook Writer
- 14 installs
- 79 repo stars
- Updated May 6, 2026
- testany-io/testany-agent-skills
Helps with ai & agent building tasks.
About
runbook-writer is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- runbook-writer
- AI & Agent Building
- AI-coding skill
Runbook Writer by the numbers
- 14 all-time installs (skills.sh)
- Ranked #11,296 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/testany-io/testany-agent-skills --skill runbook-writerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 14 |
|---|---|
| repo stars | ★ 79 |
| Last updated | May 6, 2026 |
| Repository | testany-io/testany-agent-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Runbook Writer - 运维手册编写
语言规则:默认跟随用户输入语言;用户显式指定时以用户指定为准;不要因为本SKILL.md是中文而强制输出中文;TRACEABILITY-METADATA的字段名、枚举值、ID、comment markers 始终保持英文。若本 skill 使用模板或派发子任务,继续传递同一个output_language。详见../../references/language-policy.md。
你是运维手册编写的协调者。你的职责是收集上下文、派发 subagent 独立写作、组织审查流程,确保 Runbook 质量达到生产就绪标准。
核心定位
协调者,而非作者。
- ✅ 提取上游文档的关键约束和要求
- ✅ 派发 writer subagent 独立写作
- ✅ 派发 reviewer subagent 独立审查
- ✅ 处理冲突、回答问题、汇总结果
- ❌ 不自己写 Runbook(context 污染风险)
- ❌ 不跳过审查环节
核心原则
| 原则 | 说明 |
|---|---|
| Context 隔离 | Subagent 获得新鲜 context,避免主 session 的假设污染 |
| 完整上下文传递 | Controller 提取完整约束,subagent 不需要自己读文件猜测 |
| 双阶段审查 | Spec compliance 先行,quality 后续,避免浪费精力优化不该存在的内容 |
| 证据驱动 | 所有约束必须来自上游文档,不得凭空推测 |
| 可执行优先 | 每个步骤必须有验证命令,回滚路径必须可操作 |
| 先做 Guardrails trigger check | 若运维要求依赖缺失/过期的项目级规则,先判断是否必须更新 Guardrails |
执行进度清单
执行时使用 TodoWrite 工具跟踪以下进度,完成一项后立即标记为 completed:
□ Phase 0: 基线收集
- 确认上游文档路径(PRD/HLD/LLD/API Contract/Guardrails/Infra)
- 读取所有上游文档
- 提取运维相关约束
- 执行 Guardrails trigger check
□ Phase 1: 上下文准备
- 提取系统边界与依赖
- 提取部署流程要求
- 提取回滚策略约束
- 提取监控 SLO 要求
- 提取故障处理要求
- 识别缺失信息并 AskUserQuestion
□ Phase 2: 派发 Writer Subagent
- 使用 subagents/writer.md 模板
- 提供完整上下文(不让 subagent 读文件)
- 解析 AGENT-RESULT 块判定结果
- 等待 writer 提问(如有 needs_user_input)并回答
□ Phase 3: Spec Compliance Review(最多 2 轮修复)
- 使用 subagents/spec-reviewer.md 模板
- 解析 AGENT-RESULT 块中的 verdict
- 发现问题 → 返回 writer 修复 → 重新审查(最多 2 轮)
- 2 轮后仍有 Critical → 停止,输出遗留问题
- 通过 → 进入 Phase 4
□ Phase 4: Quality Review(最多 2 轮修复)
- 使用 subagents/quality-reviewer.md 模板
- 解析 AGENT-RESULT 块中的 verdict
- 发现 Critical → 返回 writer 修复 → 重新审查(最多 2 轮)
- 2 轮后仍有 Critical → 停止,输出遗留问题
- 通过(含 conditional_pass)→ 输出最终 Runbook
□ Subagent 失败处理(贯穿 Phase 2-4)
- AGENT-RESULT 缺失 → 重试 1 次 → 二次缺失 → 报告用户
- status=needs_input → AskUserQuestion 转达
- status=failed + needs_retry → 重试 1 次
- status=failed + !needs_retry → 报告用户
- 迭代超限 → 输出遗留问题清单
□ Phase 5: 输出与验证
- 按 runbook-template.md 格式输出
- 确认所有章节完整
- 保存文件Phase 0: 基线收集
确认上游文档
必需文档:
- PRD:业务目标、用户场景、成功标准
- HLD:系统架构、技术选型、部署拓扑
- LLD:模块设计、接口定义、数据流
- API Contract:接口规范
- Guardrails:工程规范、发布标准
可选文档:
- Infrastructure 文档:云资源、网络拓扑、安全配置
- 现有 Runbook:参考已有系统的运维手册
如果缺失关键文档:
AskUserQuestion:
questions:
- question: "以下文档缺失,是否继续?"
header: "缺失文档"
multiSelect: false
options:
- label: "提供文档路径后继续"
description: "我会提供缺失文档的路径"
- label: "基于现有文档继续"
description: "运维手册可能不完整,但可以基于现有信息编写"
- label: "暂停,等文档齐全"
description: "暂停 runbook 编写,等上游文档完成"执行 Guardrails trigger check
在进入 Phase 1 前,基于 ../../references/guardrails-trigger-check.md 执行一次 Guardrails trigger check:
no_trigger:继续 Phase 1suggest_guardrails:记录原因、影响域和推荐动作后继续require_guardrails_before_design:停止当前 Runbook 编写,明确建议先运行guardrails-writer
提取运维约束
从上游文档中提取:
1. 系统边界(HLD)
- 服务名称、版本
- 依赖服务(内部/外部)
- 数据存储(数据库、缓存、对象存储)
- 第三方集成
2. 部署要求(HLD/Guardrails)
- 部署环境(K8s/VM/Serverless)
- 资源配置(CPU/内存/磁盘)
- 配置管理(ConfigMap/Secret/环境变量)
- 健康检查端点
3. 回滚策略(HLD/Guardrails)
- 回滚触发条件
- 数据库 migration 回滚方式
- 配置回滚策略
- 流量切换方式
4. 监控 SLO(HLD/Guardrails)
- 关键指标(QPS/延迟/错误率)
- SLO 阈值
- 告警规则
- Dashboard 要求
5. 故障处理(HLD/Guardrails)
- 常见故障场景
- 故障排查步骤
- 应急响应流程
- 值班要求
缺失信息处理:
如果上游文档中这些信息不完整,必须 AskUserQuestion 确认,禁止凭空推测。
Phase 1: 上下文准备
构建 Writer Context
基于 Phase 0 提取的约束,构建完整的上下文摘要:
Context 模板:
## 系统概览
- 系统名称:[从 HLD 提取]
- 系统边界:[从 HLD 提取]
- 依赖服务:[从 HLD 提取]
## 部署约束(来自 HLD/Guardrails)
- 部署环境:[K8s/VM/Serverless]
- 资源配置:[CPU/内存要求]
- 配置管理:[ConfigMap 列表]
- 健康检查:[端点和预期响应]
## 回滚策略(来自 HLD/Guardrails)
- 回滚触发条件:[错误率/延迟阈值]
- 数据库回滚:[migration down 策略]
- 配置回滚:[版本控制方式]
- 流量切换:[蓝绿/金丝雀]
## 监控 SLO(来自 HLD/Guardrails)
- 关键指标:[QPS/P99/错误率]
- SLO 阈值:[具体数值]
- 告警规则:[触发条件]
## 故障场景(来自 HLD/Guardrails)
- 常见故障:[列表]
- 排查步骤:[流程]
## 证据来源
- PRD: [路径]
- HLD: [路径]
- LLD: [路径]
- Guardrails: [路径]
## Guardrails Trigger Check
- Decision: [no_trigger / suggest_guardrails / require_guardrails_before_design]
- Why: [一句话说明原因]
- Impacted domains: [Release / Rollback / Security / Observability ...]
- Guardrails status: [baseline exists / missing domain / outdated / drift]
- Recommended next action: [continue / update guardrails soon / run guardrails-writer first]关键:所有信息必须标注来源,不得凭空添加。
Phase 2: 派发 Writer Subagent
使用 Task 工具派发
Task tool (general-purpose):
description: "Write Runbook for [系统名称]"
prompt: [使用 subagents/writer.md 模板,填充 Phase 1 的 context]Writer 提问处理
Writer subagent 可能问的问题:
- "部署时是否需要停机维护窗口?"
- "回滚失败时的降级策略是什么?"
- "监控告警应该发给哪个团队?"
处理流程: 1. 检查上游文档是否有答案 2. 有 → 提供答案 + 引用位置 3. 没有 → AskUserQuestion 给用户,获得答案后传递给 writer
禁止:让 writer 自己猜测或"先写个占位符"。
接收 Writer 输出
Writer 完成后应提供:
- 完整 Runbook 内容
- 自我审查结果
- 遇到的问题或不确定的地方
Phase 3: Spec Compliance Review
目标
验证 Runbook 是否完整覆盖上游文档的所有要求。
检查项:
- ✅ 是否覆盖了 Phase 1 中提取的所有约束?
- ✅ 部署步骤是否与 HLD 描述的架构一致?
- ✅ 回滚策略是否符合 Guardrails 要求?
- ✅ 监控指标是否覆盖 SLO 要求?
- ✅ 是否有 over-engineering(未被要求的内容)?
派发 Spec Reviewer
Task tool (general-purpose):
description: "Review Runbook spec compliance"
prompt: [使用 subagents/spec-reviewer.md 模板]处理审查结果
如果发现问题:
Spec reviewer 发现:
- 缺失:部署步骤中未包含数据库 migration 验证(HLD 要求)
- 多余:添加了性能测试步骤(上游文档未要求)
→ 返回给 writer subagent 修复
→ 重新派发 spec reviewer
→ 直到通过通过标准:
- ✅ 所有上游要求已覆盖
- ✅ 没有未经要求的额外内容
- ✅ 所有约束都有引用来源
Phase 4: Quality Review
目标
验证 Runbook 的可执行性和完整性。
检查项:
- ✅ 每个部署步骤是否有验证命令?
- ✅ 回滚路径是否清晰可操作?
- ✅ 监控告警配置是否完整?
- ✅ 故障排查步骤是否详细?
- ✅ 是否有模糊或需要人工判断的地方?
派发 Quality Reviewer
Task tool (general-purpose):
description: "Review Runbook quality"
prompt: [使用 subagents/quality-reviewer.md 模板]处理审查结果
Issue 分级:
- Critical:无法执行的步骤、缺失关键信息
- Important:不够清晰、需要人工判断
- Minor:可优化的表述
修复循环:
Quality reviewer 发现 Important issue:
"步骤 3: 验证部署成功" → 没有具体验证命令
→ 返回 writer 修复
→ 重新 quality review
→ 直到所有 Critical/Important 问题解决Phase 5: 输出与验证
最终 Runbook 结构
按照 references/runbook-template.md 输出:
# [系统名称] Runbook
## 1. 系统概览
- 系统边界
- 依赖服务
- 数据存储
## 2. 部署流程
### 2.1 前置检查
- [ ] 检查项 1
- [ ] 检查项 2
### 2.2 部署步骤
**步骤 1: [描述]**命令
**验证**:[预期输出]
### 2.3 部署验证
- 健康检查
- 功能验证
## 3. 回滚流程
### 3.1 回滚触发条件
### 3.2 回滚步骤
### 3.3 回滚验证
## 4. 监控与告警
### 4.1 关键指标
### 4.2 SLO 阈值
### 4.3 告警配置
### 4.4 Dashboard
## 5. 故障处理
### 5.1 常见故障场景
### 5.2 排查流程
### 5.3 应急响应
## 6. 值班手册
### 6.1 值班职责
### 6.2 联系方式
### 6.3 升级路径
## 附录
- 参考文档
- 变更历史保存文件
# 默认路径
docs/runbook/[system-name]-runbook.md
# 如果有 Guardrails 指定路径,遵循 Guardrails红旗警告
禁止行为:
- ❌ 主 agent 自己写 Runbook(context 污染)
- ❌ 跳过 spec compliance review(容易遗漏要求)
- ❌ 跳过 quality review(可执行性无保障)
- ❌ 凭空推测未在上游文档中的约束
- ❌ 让 writer subagent 自己读文件(效率低、易误解)
- ❌ 在审查未通过时直接使用输出
强制要求:
- ✅ Controller 必须提取完整上下文
- ✅ Writer subagent 可以随时提问
- ✅ 必须经过双阶段审查
- ✅ 所有约束必须有上游文档引用
- ✅ 审查发现问题必须修复后重审
与其他 Skill 的关系
上游依赖:
- PRD/HLD/LLD/API Contract/Guardrails:提供运维约束
可能调用的 Sub-skill:
- verification-before-completion(如果有):部署验证步骤的标准
输出给:
- 运维团队:生产环境操作手册
- SRE:故障响应和值班手册
常见问题
Q: Writer subagent 写得太简单怎么办?
A: 在 Phase 1 的 context 中明确要求细节粒度:
## 要求
- 每个部署步骤必须有具体命令
- 每个验证步骤必须有预期输出
- 回滚步骤必须可独立执行Q: 上游文档冲突怎么办?
A: AskUserQuestion 让用户裁决:
AskUserQuestion:
questions:
- question: "HLD 要求蓝绿部署,Guardrails 要求金丝雀,应采用哪种?"
header: "部署策略"
options:
- label: "蓝绿部署(HLD)"
- label: "金丝雀部署(Guardrails)"
- label: "两者结合"Q: Writer 完成后发现缺少关键信息怎么办?
A: 不要让 writer 继续猜,回到 Phase 0 补充文档或 AskUserQuestion。
参考文档
references/runbook-template.md:Runbook 输出模板
<<<<<<< Updated upstream
prompts/writer-prompt.md:Writer subagent prompt 模板prompts/spec-reviewer-prompt.md:Spec reviewer prompt 模板prompts/quality-reviewer-prompt.md:Quality reviewer prompt 模板../../references/guardrails-trigger-check.md:Guardrails 触发检查与分流规则
=======
subagents/writer.md:Writer subagent prompt 模板subagents/spec-reviewer.md:Spec reviewer prompt 模板subagents/quality-reviewer.md:Quality reviewer prompt 模板
>>>>>>> Stashed changes
interface:
display_name: "Runbook Writer"
short_description: "Draft runbooks for services and incidents"
icon_small: "./assets/testany-logo-small.png"
icon_large: "./assets/testany-logo.svg"
default_prompt: "Use $runbook-writer to draft an operations runbook for this service or incident."
Quality Reviewer Prompt Template
Use this template when dispatching a quality reviewer subagent.
Purpose: Verify Runbook is executable, complete, and production-ready
Only dispatch after spec compliance review passes.
Task tool (general-purpose):
description: "Review Runbook quality"
prompt: |
You are reviewing the quality and executability of a Runbook.
**Context:** This Runbook has already passed spec compliance review, meaning
it covers all upstream requirements. Your job is to verify it's well-built
and ready for production use.
## Runbook to Review
[Writer subagent 输出的 Runbook 完整内容]
## Upstream Context (for reference)
[Controller 提供的上下文摘要]
## Guardrails Trigger Check
[Controller 提供的 trigger check 结果;若为 require_guardrails_before_design,不应继续派发本审查]
## Output Language
- Output language: [zh-CN / en]
- Write the quality review in this language.
- Do not fall back to Chinese because this prompt template contains Chinese notes.
- Keep any `TRACEABILITY-METADATA` keys, enum values, IDs, and comment markers in English.
## Your Role
You are a Senior SRE reviewing operational documentation. You need to verify
this Runbook is:
- Executable by on-call engineers unfamiliar with the system
- Complete with no ambiguous steps
- Safe to use in production
- Maintainable over time
- Evaluated in the context of the controller's Guardrails trigger result; `suggest_guardrails` 是治理建议,不等于当前文档自动失败
## Review Checklist
### 1. Deployment Process Quality
**For EACH deployment step, check:**
- [ ] Is the command exact and copy-pasteable?
- [ ] Is expected output specified?
- [ ] Is there a verification command?
- [ ] Is success criteria clear?
- [ ] Can this step be executed independently?
**Red flags:**
- Vague commands: "Run the deployment script" (which script? where? how?)
- Missing verification: "Deploy the service" (how do I know it worked?)
- Ambiguous success: "Check if it's working" (what exactly to check?)
- Assumed knowledge: "Use the standard procedure" (what's standard?)
**Example evaluation:**❌ Bad: "Deploy the new version" Issue: No command, no verification
✅ Good: "Deploy the new version"
kubectl set image deployment/api api=repo/api:v2.0.0Expected: "deployment.apps/api image updated" Verification: kubectl rollout status deployment/api Success: "deployment 'api' successfully rolled out"
### 2. Rollback Process Quality
**Critical requirements:**
- [ ] Can rollback steps execute WITHOUT new version running?
- [ ] Is database migration rollback clear?
- [ ] Is configuration rollback specified?
- [ ] Is rollback verification complete?
- [ ] Are rollback trigger conditions specific?
**Test scenario:** If new version is completely broken (won't start),
can someone follow rollback steps successfully?
**Red flags:**
- Depends on new version: "Use new admin panel to rollback DB"
- Vague conditions: "If something goes wrong, rollback"
- Missing steps: "Rollback database" (HOW?)
### 3. Monitoring & Alerts Quality
**For EACH metric, check:**
- [ ] Is metric name exact (not "check CPU")?
- [ ] Is threshold specific (not "high CPU")?
- [ ] Is query/command provided to check it?
- [ ] Is alert severity defined?
- [ ] Is notification channel specified?
**Red flags:**
- Vague metrics: "Monitor performance"
- Missing queries: "Check error rate" (how? where?)
- No thresholds: "Alert on high latency" (what's high?)
### 4. Failure Handling Quality
**For EACH failure scenario, check:**
- [ ] Are symptoms observable and specific?
- [ ] Are troubleshooting steps actionable?
- [ ] Is root cause identification clear?
- [ ] Is resolution step-by-step?
- [ ] Is escalation criteria defined?
**Test scenario:** Could a junior engineer who just joined the team
follow these steps to diagnose and resolve the issue?
**Red flags:**
- Vague symptoms: "Service is slow"
- No troubleshooting: "Check logs" (which logs? for what?)
- Assumed expertise: "Debug the connection pool"
- No escalation: "Keep trying" (when to give up and escalate?)
### 5. Clarity & Completeness
**Overall document check:**
- [ ] Is contact information complete?
- [ ] Is escalation path clear?
- [ ] Are all referenced documents linked?
- [ ] Is change history maintained?
- [ ] Are acronyms defined?
**Ambiguity check:**
- [ ] No steps require "judgment" without criteria
- [ ] No steps say "if necessary" without defining when
- [ ] No circular references ("see other runbook")
- [ ] No external dependencies not under team's control
### 6. Safety & Risk Management
**Safety checks:**
- [ ] Are destructive operations clearly marked?
- [ ] Are backup/snapshot steps before risky operations?
- [ ] Are rollback points clearly identified?
- [ ] Are maintenance windows mentioned if needed?
**Red flags:**
- Risky operations without warnings
- No backup before data modification
- No rollback checkpoints
- Assumes zero-downtime without verification
## Output Format
### Structure
Quality Review
Strengths
[What's well done? Be specific with examples.]
Issues
Critical (Must Fix Before Production)
[Bugs, safety issues, missing critical steps, impossible-to-execute steps]
Important (Should Fix)
[Ambiguities, missing verification, incomplete troubleshooting]
Minor (Nice to Have)
[Wording improvements, additional examples, formatting]
Recommendations
[Improvements for maintainability, clarity, safety]
Assessment
Production ready? [Yes / With fixes / No]
Reasoning: [Technical assessment in 1-2 sentences]
### Example Output
Quality Review
Strengths
- Clear deployment steps with exact kubectl commands (Section 2.2)
- Comprehensive rollback procedure with verification (Section 3.2)
- Good failure scenario coverage for database connection issues (Section 5.1)
- Health check validation well-defined (Section 2.3)
Issues
Critical (Must Fix Before Production)
1. Rollback depends on new version
- Location: Section 3.2, Step 3
- Issue: "Use new admin panel to verify rollback" - if new version is broken, admin panel won't work
- Impact: Cannot rollback in worst-case scenario
- Fix: Use kubectl/database client directly, not application UI
2. Missing database backup step
- Location: Section 2.2, before Step 5 (database migration)
- Issue: No backup before running migration
- Impact: Cannot recover if migration corrupts data
- Fix: Add explicit backup step with verification before migration
Important (Should Fix)
1. Vague verification in Step 7
- Location: Section 2.2, Step 7
- Issue: "Verify service is healthy" - no specific check
- Fix: Specify exact health check endpoint and expected response
- Example: curl http://api/health should return {"status":"ok"}
2. Monitoring query missing
- Location: Section 4.1, "Error Rate"
- Issue: Says "monitor error rate" but no query provided
- Fix: Add Prometheus query: rate(http_requests_total{status=~"5.."}[5m])
3. Escalation criteria unclear
- Location: Section 5.2, "Database Connection Failure"
- Issue: "Escalate if issue persists" - how long?
- Fix: Specify timeout: "Escalate if not resolved within 15 minutes"
Minor (Nice to Have)
1. Acronyms not defined
- Location: Section 2.1
- Issue: "Check RDS" - RDS not defined
- Fix: First use: "Check RDS (Relational Database Service)"
2. Command formatting
- Location: Various sections
- Issue: Some commands not in code blocks
- Fix: Use ```bash blocks consistently
Recommendations
1. Add pre-flight validation script
- Create a script that checks all prerequisites
- Reduces manual checklist errors
- Makes pre-deployment faster
2. Include rollback testing in staging
- Add section on testing rollback procedure
- Ensures rollback actually works
3. Link to monitoring dashboards
- Add direct links to Grafana/Datadog dashboards
- Faster access during incidents
Assessment
Production ready: With fixes
Reasoning: Core procedures are sound and well-structured, but Critical issues (rollback dependency, missing backup) must be fixed before production use. Important issues should also be addressed to ensure executability.
## Critical Rules
**DO:**
- Test mental execution: Could someone unfamiliar follow this?
- Be specific: file, section, line
- Explain WHY each issue matters (impact)
- Provide concrete fix suggestions
- Categorize by severity
**DON'T:**
- Say "looks good" without testing executability
- Mark nitpicks as Critical
- Give vague feedback ("improve clarity")
- Review spec compliance (already done)
- Avoid giving clear verdict
## Severity Definitions
**Critical:**
- Step is impossible to execute
- Creates safety risk (data loss, downtime)
- Missing essential functionality
- Rollback won't work in worst case
**Important:**
- Step is ambiguous or unclear
- Missing verification
- Incomplete troubleshooting
- Escalation criteria missing
**Minor:**
- Wording improvements
- Formatting inconsistencies
- Nice-to-have additions
- Documentation polish
## Final Check
Before submitting your review:
- [ ] Tested mental execution of all critical paths
- [ ] Provided specific locations for all issues
- [ ] Explained impact of each issue
- [ ] Suggested concrete fixes
- [ ] Clear production-ready verdictSpec Compliance Reviewer Prompt Template
Use this template when dispatching a spec compliance reviewer subagent.
Purpose: Verify Runbook covers all upstream document requirements (nothing more, nothing less)
Task tool (general-purpose):
description: "Review Runbook spec compliance"
prompt: |
You are reviewing whether a Runbook matches upstream document requirements.
## What Was Required (Upstream Documents)
### From PRD
[Controller 提供的 PRD 中的运维相关要求]
### From HLD
[Controller 提供的 HLD 中的部署/架构要求]
### From Guardrails
[Controller 提供的 Guardrails 中的发布标准]
### Complete Context
[Controller 在 Phase 1 准备的完整上下文]
### Guardrails Trigger Check
[Controller 提供的 trigger check 结果;若为 require_guardrails_before_design,不应继续派发本审查]
### Output Language
- Output language: [zh-CN / en]
- Write the review in this language.
- Do not switch back to Chinese because the prompt template contains Chinese annotations.
- Keep any `TRACEABILITY-METADATA` keys, enum values, IDs, and comment markers in English.
## What Writer Produced
[Writer subagent 输出的完整 Runbook]
## CRITICAL: Do Not Trust the Writer's Self-Review
The writer may have:
- Missed requirements from upstream documents
- Added content not requested in upstream documents
- Misinterpreted constraints
- Made assumptions not supported by evidence
**DO NOT:**
- Take their word for completeness
- Accept their interpretation without verification
- Assume they followed all constraints
**DO:**
- Compare Runbook against upstream requirements line by line
- Check for missing requirements
- Check for extra content not requested
- Verify all claims have upstream document citations
- Respect the controller's Guardrails trigger result; `suggest_guardrails` 是治理跟进项,不等于自动判定当前 Runbook 不合规
## Your Job
Review the Runbook and identify:
### Missing Requirements
**Deployment section:**
- [ ] Does it cover all deployment steps from HLD?
- [ ] Are all configuration requirements from Guardrails included?
- [ ] Are health check endpoints from API Contract included?
- [ ] Are resource requirements from HLD specified?
- [ ] Is deployment strategy (blue-green/canary) from Guardrails included?
**Rollback section:**
- [ ] Are rollback trigger conditions from Guardrails included?
- [ ] Is database migration rollback strategy from HLD included?
- [ ] Is configuration rollback from Guardrails included?
- [ ] Are rollback verification steps complete?
**Monitoring section:**
- [ ] Are all SLO metrics from Guardrails included?
- [ ] Are SLO thresholds from HLD included?
- [ ] Are alert rules from Guardrails included?
- [ ] Is dashboard requirement addressed?
**Failure handling section:**
- [ ] Are all failure scenarios from HLD covered?
- [ ] Does each scenario have troubleshooting steps?
- [ ] Are escalation paths defined?
### Extra/Unneeded Content
Check for content that was NOT requested in upstream documents:
- Additional deployment strategies not mentioned in Guardrails
- Monitoring metrics not in SLO requirements
- Failure scenarios not mentioned in HLD
- Tools or processes not specified in upstream documents
### Misinterpretations
Check for:
- Deployment steps that don't match HLD architecture
- Rollback strategy that conflicts with Guardrails
- SLO thresholds different from HLD specifications
- Alert rules not matching Guardrails requirements
## Review Checklist
For EACH section, verify:
### 1. System Overview
- [ ] Architecture matches HLD
- [ ] All dependencies from HLD are listed
- [ ] Data storage matches HLD
### 2. Deployment Process
- [ ] Pre-deployment checks cover Guardrails requirements
- [ ] Deployment steps match HLD deployment strategy
- [ ] Configuration management matches Guardrails
- [ ] Health check uses endpoints from API Contract
- [ ] Verification steps are adequate
### 3. Rollback Process
- [ ] Trigger conditions match Guardrails
- [ ] Database rollback matches HLD strategy
- [ ] Configuration rollback matches Guardrails
- [ ] Rollback verification is complete
### 4. Monitoring & Alerts
- [ ] All SLO metrics from Guardrails are included
- [ ] SLO thresholds match HLD values
- [ ] Alert rules match Guardrails
- [ ] Dashboard requirements addressed
### 5. Failure Handling
- [ ] All failure scenarios from HLD are covered
- [ ] Each scenario has complete troubleshooting steps
- [ ] Escalation paths are defined
- [ ] Resolution steps are clear
### 6. On-Call Guide
- [ ] Responsibilities are defined
- [ ] Contact information is complete
- [ ] Escalation path is clear
## Evidence-Based Review
For EACH claim in the Runbook, verify:
- Is this supported by upstream documents?
- Which document? Which section?
- Is the interpretation correct?
**Example:**Runbook says: "Deploy using blue-green strategy" ✅ Check: HLD Section 4.2 specifies blue-green deployment ✅ Check: Guardrails Section 3 allows blue-green
Runbook says: "Monitor CPU usage > 80%" ❌ Issue: HLD Section 5 specifies 75% threshold, not 80%
## Output Format
### ✅ If Spec Compliant
Spec Compliance Review: PASS
All upstream requirements covered:
- Deployment: ✅ Complete
- Rollback: ✅ Complete
- Monitoring: ✅ Complete
- Failure handling: ✅ Complete
- On-call guide: ✅ Complete
No extra content: ✅ All content traceable to upstream documents
No misinterpretations: ✅ All interpretations correct
Ready for quality review.
### ❌ If Issues Found
Spec Compliance Review: ISSUES FOUND
Missing Requirements
Critical (Must Add)
1. Database migration rollback missing
- Required by: HLD Section 3.4 "Database Migration Strategy"
- Missing: Step-by-step migration rollback procedure
- Impact: Cannot safely rollback if migration fails
2. SLO metric missing: P99 latency
- Required by: Guardrails Section 5.2 "Performance SLO"
- Missing: P99 latency < 500ms monitoring
- Impact: Cannot verify SLO compliance
Important (Should Add)
1. Health check endpoint incomplete
- Required by: API Contract Section 2.3 "/health"
- Missing: Expected response body format
- Impact: Unclear how to verify health
Extra Content (Not Requested)
1. Performance testing steps
- Location: Section 2.3 "Deployment Validation"
- Issue: Performance testing not mentioned in upstream documents
- Recommendation: Remove unless user confirms it's needed
2. Auto-scaling configuration
- Location: Section 4.3 "Monitoring Setup"
- Issue: HLD doesn't specify auto-scaling
- Recommendation: Remove or confirm with upstream documents
Misinterpretations
1. Rollback trigger threshold
- Runbook: "Rollback if error rate > 5%"
- Guardrails: "Rollback if error rate > 1%"
- File: Guardrails Section 3.2
- Impact: Too permissive, violates Guardrails
2. Deployment strategy
- Runbook: "Use rolling deployment"
- HLD: "Use blue-green deployment"
- File: HLD Section 4.2
- Impact: Wrong strategy, doesn't match architecture
Recommendation
Return to writer for fixes. Issues must be resolved before quality review.
Priority order: 1. Fix all Critical missing requirements 2. Fix all Misinterpretations 3. Remove Extra content 4. Add Important missing requirements
## Critical Rules
**DO:**
- Be specific: cite document, section, line
- Distinguish between missing/extra/misinterpreted
- Explain impact of each issue
- Categorize by severity (Critical/Important/Minor)
**DON'T:**
- Say "looks good" without checking every requirement
- Accept close approximations (either matches spec or doesn't)
- Give feedback on code quality (that's next review)
- Be vague ("add more monitoring details")
## Final Check
Before submitting your review, verify:
- [ ] Checked EVERY requirement from upstream context
- [ ] Verified EVERY claim in Runbook has upstream support
- [ ] Provided specific document citations for all issues
- [ ] Categorized issues by severity
- [ ] Clear pass/fail verdictWriter Subagent Prompt Template
Use this template when dispatching a Runbook writer subagent.
Purpose: Write complete, executable Runbook based on upstream constraints
Task tool (general-purpose):
description: "Write Runbook for [系统名称]"
prompt: |
You are writing a production-ready Runbook for [系统名称].
## Your Role
You are a Senior SRE/DevOps Engineer responsible for creating operational documentation
that will be used by on-call engineers during deployments and incidents.
## Context from Upstream Documents
[Controller 提供的完整上下文,包括:]
### 系统概览
- 系统名称:[name]
- 系统边界:[scope]
- 依赖服务:[dependencies]
- 数据存储:[databases, caches, object storage]
### 部署约束(来自 HLD/Guardrails)
- 部署环境:[K8s/VM/Serverless]
- 资源配置:[CPU/memory requirements]
- 配置管理:[ConfigMap/Secret/env vars]
- 健康检查:[endpoints and expected responses]
- 部署策略:[blue-green/canary/rolling]
### 回滚策略(来自 HLD/Guardrails)
- 回滚触发条件:[error rate/latency thresholds]
- 数据库回滚:[migration down strategy]
- 配置回滚:[version control approach]
- 流量切换:[traffic routing method]
### 监控 SLO(来自 HLD/Guardrails)
- 关键指标:[QPS/P99 latency/error rate]
- SLO 阈值:[specific values]
- 告警规则:[trigger conditions]
- Dashboard 要求:[required visualizations]
### 故障场景(来自 HLD/Guardrails)
- 常见故障:[list from HLD]
- 排查步骤:[troubleshooting flow]
- 应急响应:[escalation path]
### 证据来源
- PRD: [path]
- HLD: [path]
- LLD: [path]
- Guardrails: [path]
### Output Language
- Output language: [zh-CN / en]
- Use this language for all human-readable headings, tables, notes, and instructions in the Runbook.
- Do not switch back to Chinese just because the controller prompt or repo templates are written in Chinese.
- Keep `TRACEABILITY-METADATA` keys, enum values, IDs, and comment markers in English if they appear.
## Before You Begin
If you have questions about:
- Any unclear requirements or constraints
- Missing information (e.g., "What's the maintenance window policy?")
- Conflicting information from different documents
- Assumptions you need to make
**Ask them now.** Raise any concerns before starting work.
Do NOT:
- Guess or make assumptions
- Add content not supported by upstream documents
- Skip information because it's "probably not needed"
## Your Job
Write a complete Runbook that covers:
### 1. 系统概览
- System architecture summary (from HLD)
- Service dependencies (internal and external)
- Data storage architecture
### 2. 部署流程
**Pre-deployment checklist:**
- [ ] Verify all prerequisites
- [ ] Check dependency service health
- [ ] Confirm maintenance window (if required)
**Deployment steps:**
For EACH step, provide:
- Clear description
- Exact commands to run
- Expected output/success criteria
- Verification command
**Example format:**步骤 1: 部署新版本镜像
kubectl set image deployment/[name] [container]=[image]:[tag]预期输出:
deployment.apps/[name] image updated验证:
kubectl rollout status deployment/[name]
# 预期:deployment "[name]" successfully rolled out
### 3. 回滚流程
**Rollback trigger conditions:**
- When to rollback (from Guardrails)
- Decision criteria
**Rollback steps:**
- Exact commands for each step
- Database migration rollback (if applicable)
- Configuration rollback
- Verification after rollback
**Critical:** Rollback steps must be executable WITHOUT the new version running.
### 4. 监控与告警
**Key metrics to monitor:**
- List metrics from SLO requirements
- Include query/command to check each metric
**Alert configuration:**
- Alert rules (from Guardrails)
- Thresholds
- Notification channels
**Dashboard:**
- Required visualizations
- Link to dashboard (if exists)
### 5. 故障处理
For EACH common failure scenario (from HLD):
**场景 N: [Description]**
**症状:**
- How to recognize this issue
- Observable symptoms
**排查步骤:**
1. Check [specific metric/log]
2. Verify [specific condition]
3. ...
**解决方案:**
- Step-by-step resolution
- Exact commands
- Verification
**升级条件:**
- When to escalate
- Who to contact
### 6. 值班手册
**On-call responsibilities:**
- What on-call engineer is responsible for
- Response time expectations
**Contact information:**
- Team contacts
- Escalation path
**Runbook maintenance:**
- How to report issues with this runbook
- Update process
## Quality Standards
**Every deployment/rollback step MUST have:**
- ✅ Exact command (not "run the deployment script")
- ✅ Expected output
- ✅ Verification command
- ✅ Success criteria
**Every failure scenario MUST have:**
- ✅ Observable symptoms
- ✅ Step-by-step troubleshooting
- ✅ Clear resolution steps
- ✅ Escalation criteria
**Avoid:**
- ❌ Vague instructions ("check if everything is working")
- ❌ Missing verification steps
- ❌ Assuming knowledge not in this document
- ❌ Adding features not in upstream documents
## Before Reporting Back: Self-Review
Ask yourself:
**Completeness:**
- Did I cover all constraints from the context?
- Are deployment AND rollback both complete?
- Did I include all failure scenarios from HLD?
**Executability:**
- Can someone unfamiliar with this system follow these steps?
- Does every step have verification?
- Are rollback steps independent of the new version?
**Accuracy:**
- Did I only include information from upstream documents?
- Did I cite sources for all constraints?
- Did I avoid adding assumptions?
If you find issues during self-review, fix them now before reporting.
## Output Format
Use the following structure:
[系统名称] Runbook
1. 系统概览
[Content]
2. 部署流程
2.1 前置检查
2.2 部署步骤
2.3 部署验证
3. 回滚流程
3.1 回滚触发条件
3.2 回滚步骤
3.3 回滚验证
4. 监控与告警
4.1 关键指标
4.2 SLO 阈值
4.3 告警配置
4.4 Dashboard
5. 故障处理
[One section per failure scenario]
6. 值班手册
6.1 值班职责
6.2 联系方式
6.3 升级路径
附录
参考文档
- PRD: [path]
- HLD: [path]
- LLD: [path]
- Guardrails: [path]
变更历史
- [Date]: Initial version
## Report Format
When done, report:
- **Status**: Complete / Need clarification
- **Questions** (if any): [List questions that need controller's answer]
- **Runbook content**: [Full markdown]
- **Self-review findings**: [Any concerns or assumptions made]
- **Files referenced**: [List all upstream docs you relied on]Runbook Output Template
This template defines the standard structure for all Runbooks produced by runbook-writer skill.
---
[System Name] Runbook
Version: [version number] Last updated: [Date] Maintenance Team: [Team Name]
---
1. System Overview
1.1 System architecture
System Description: [Brief description of system architecture extracted from HLD]
Service Boundary:
- Core Services: [List]
- Dependent services (internal): [list]
- Dependent services (external): [list]
Data Storage:
- Database: [type, purpose]
- Cache: [type, purpose]
- Object storage: [type, purpose]
1.2 System dependency graph
[Optional: System dependency diagram]1.3 Key configuration
| Configuration items | Location | Description |
|---|---|---|
| [Configuration Name] | [ConfigMap/Secret/File] | [Purpose] |
---
2. Deployment process
2.1 Pre-check
Before starting the deployment, you must confirm:
- [ ] Dependent service health status
# Check command
curl http://[dependency-service]/health
# Expected output: {"status":"ok"}- [ ] Database connection is normal
# Check command
[database-check-command]
# Expected output: [expected-output]- [ ] Maintenance window confirmation (if required)
- Start time: [time]
- End time: [time]
- Notification channel: [Notified]
- [ ] Backup confirmation
# Database backup
[backup-command]
# Verify backup
[verify-backup-command]2.2 Deployment steps
Step 1: [Step Name]
#Execute command
[command]Expected Output:
[expected output]verify:
# Verify command
[verification-command]
# expected results
[expected-result]If it fails: [troubleshooting steps]
---
Step 2: [Next Step]
[Repeat above format]
---
2.3 Deployment verification
After completing all deployment steps, perform the following verifications:
- [ ] Health check passed
curl http://[service]/health
# Expected: {"status":"ok", "version":"[new-version]"}- [ ] Core Function Verification
# Function verification command
[functional-test-command]
# expected results
[expected-result]- [ ] Monitoring indicators are normal
- QPS: [expected-range]
- P99 delay: < [threshold]
- Error rate: < [threshold]
# Query monitoring indicators
[monitoring-query]- [ ] No exception in the log
# View recent logs
kubectl logs -f deployment/[name] --tail=100
# Check if there is ERROR/FATALVerification pass standard:
- ✅ All inspection items passed
- ✅ Monitoring indicators are within the normal range
- ✅ No serious log errors
If validation fails → Perform rollback process (see Section 3)
---
3. Rollback process
3.1 Rollback trigger conditions
Immediate rollback conditions:
- Error rate > [threshold]% (for [duration] minutes)
- P99 delay > [threshold]ms (for [duration] minutes)
- Core functionality is unavailable
- Serious security vulnerabilities discovered
Decision Process:
Abnormal indicators detected
↓
Lasts longer than threshold time?
↓ Yes
Rollback now3.2 Rollback steps
⚠️ The rollback step must be executable in case the new version completely fails
---
Step 1: Stop new version traffic
# Switch traffic to the old version
[traffic-switch-command]verify:
# Confirm that the traffic has been switched
[verify-command]
# Expectation: 100% traffic to the old version---
Step 2: Roll back app version
# Roll back to the previous version
[rollback-command]Expected Output:
[expected-output]verify:
# Confirm that the version has been rolled back
[verify-version-command]
# Expected: [old-version]---
Step 3: Rollback database migration (if any)
# Execute migration down
[migration-rollback-command]verify:
# Check database schema version
[check-schema-version]
# Expected: [old-schema-version]---
Step 4: Rollback configuration (if any)
# Restore old configuration
[config-rollback-command]verify:
# Confirm that the configuration has been restored
[verify-config-command]---
3.3 Rollback verification
After the rollback is complete, you must verify:
- [ ] Service Health
curl http://[service]/health
# Expected: {"status":"ok", "version":"[old-version]"}- [ ] Core functions are normal
[functional-test-command]- [ ] Monitoring indicator recovery
- Error rate < [normal-threshold]%
- P99 delay < [normal-threshold]ms
- [ ] User Impact Assessment
- Number of users affected: [Evaluation]
- Data consistency: [check]
Rollback success criteria:
- ✅ All verification passed
- ✅ Indicators returned to pre-deployment levels
- ✅ No new errors or warnings
---
4. Monitoring and Alarming
4.1 Key Indicators
| Metrics | SLO Thresholds | Query Commands/Query |
|---|---|---|
| QPS | [min-max] | [monitoring-query] |
| P99 delay | < [threshold]ms | [monitoring-query] |
| Error rate | < [threshold]% | [monitoring-query] |
| CPU usage | < [threshold]% | [monitoring-query] |
| Memory usage | < [threshold]% | [monitoring-query] |
4.2 SLO definition
Availability SLO:
- Target: [percentage]% uptime
- Measurement period: [period]
- Error budget: [error-budget]
Performance SLO:
- P99 delay: < [threshold]ms
- P95 delay: < [threshold]ms
- Error rate: < [threshold]%
4.3 Alarm configuration
Critical Alert:
1. [Alarm name]
- Trigger condition: [condition]
- Duration: [duration]
- Notification channel: [channel]
- Response SLA: [time]
Warning warning:
1. [Alarm name]
- Trigger condition: [condition]
- Duration: [duration]
- Notification channel: [channel]
4.4 Dashboard
Main Monitoring Dashboard:
- URL: [dashboard-url]
- Contains panels:
- QPS & Latency
- Error rate trends
- Resource usage
- Depend on service status
---
5. Troubleshooting
5.1 [Fault Scenario 1: Scenario Name]
symptom:
- [Observable Phenomenon 1]
- [Observable Phenomenon 2]
- Abnormal related indicators: [metric] > [threshold]
Troubleshooting steps:
1. Confirm the scope of symptoms
# Check the affected range
[check-command]2. Check log
# View error log
kubectl logs deployment/[name] | grep ERROR3. Check dependent services
# Check upstream service status
[check-dependency-command]Root cause analysis:
- Possible cause 1: [description]
- Verification method: [how-to-verify]
- Possible cause 2: [description]
- Verification method: [how-to-verify]
Solution:
Option 1: [Description]
#Execute command
[fix-command]Verification Fix:
# Verify command
[verify-command]
# Expected results: [expected]If not resolved → Try option 2 or upgrade
Upgrade Conditions:
- No solution after trying all solutions
- more than [time] minutes
- Expanded scope of influence
Upgrade object: [Team/Personnel]
---
5.2 [Fault Scenario 2: Scenario Name]
[Repeat above format]
---
5.N General troubleshooting process
Alarms/abnormalities found
↓
Identify symptoms and extent of effects
↓
Check monitoring indicators + logs
↓
Identify root causes (match known scenarios)
↓
Implement corresponding solutions
↓
Verify the fix takes effect
↓
Record accident report---
6. Duty Manual
6.1 Responsibilities on duty
on-call engineers are responsible for:
- Respond to Critical alerts (SLA: [time])
- Respond to Warning alarms (SLA: [time])
- Perform planned maintenance operations
- Document incidents and solutions
- Update runbook
Not responsible:
- Non-emergency feature development
- Long-term architecture optimization
- Services from other teams
6.2 Contact information
| Role | Contact | Response Time |
|---|---|---|
| On-call Engineer | [contact] | 15 minutes |
| Team Lead | [contact] | 30 minutes |
| [Other Key Roles] | [contact] | [time] |
Depends on Team:
| Team | Service | Contact Information |
|---|---|---|
| [Team name] | [Service name] | [contact] |
6.3 Upgrade path
Level 1: On-call Engineer
↓ Unresolved for 15 minutes
Level 2: Senior Engineer / Team Lead
↓ Unresolved for 30 minutes or P0 failure
Level 3: Engineering Manager / CTOUpgrade trigger conditions:
- Time exceeds SLA
- Expansion of impact of failure
- Requires collaboration from other teams
- Requires architecture-level decisions
6.4 Accident records
Each failure must be recorded:
- Time: [start] - [end]
- Impact: [users/services affected]
- Root cause: [root cause]
- Solution: [what fixed it]
- Improvement measures: [prevention]
Record location: [incident-tracker-url]
6.5 Runbook Maintenance
How to report a runbook issue:
- [Reporting Channel]
- [Responsible Person]
Update Process: 1. Found that the runbook is wrong or out of date 2. Create Issue/Ticket 3. Submit update PR 4. Review + Merge 5. Update version number and date
---
Appendix
A. Reference documentation
| Documentation | Path/URL | Description |
|---|---|---|
| PRD | [path] | Product Requirements |
| HLD | [path] | High Level Design |
| LLD | [path] | low-level design |
| API Contract | [path] | Interface Contract |
| Guardrails | [path] | Engineering Specifications |
| Infrastructure Doc | [path] | Infrastructure |
B. Change History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0.0 | [date] | Initial version | [author] |
C. Quick check of commonly used commands
# Check service status
[command]
# View log
[command]
# Restart the service
[command]
# View monitoring
[command]D. Fault decision tree
Alarm trigger
↓
Is it a Critical alarm?
↓ Yes
Immediate response (15 minutes)
↓
Check symptom matching scenarios
↓
Implement corresponding solutions
↓
Verify fix
↓
record accident---
End of document
Runbook Output Template
This template defines the standard structure for all Runbooks produced by runbook-writer skill.
---
[系统名称] Runbook
版本: [版本号] 最后更新: [日期] 维护团队: [团队名称]
---
1. 系统概览
1.1 系统架构
系统描述: [从 HLD 提取的系统架构简要说明]
服务边界:
- 核心服务:[列表]
- 依赖服务(内部):[列表]
- 依赖服务(外部):[列表]
数据存储:
- 数据库:[类型、用途]
- 缓存:[类型、用途]
- 对象存储:[类型、用途]
1.2 系统依赖图
[可选:系统依赖关系图]1.3 关键配置
| 配置项 | 位置 | 说明 |
|---|---|---|
| [配置名] | [ConfigMap/Secret/文件] | [用途] |
---
2. 部署流程
2.1 前置检查
在开始部署前,必须确认:
- [ ] 依赖服务健康状态
# 检查命令
curl http://[dependency-service]/health
# 预期输出:{"status":"ok"}- [ ] 数据库连接正常
# 检查命令
[database-check-command]
# 预期输出:[expected-output]- [ ] 维护窗口确认(如需要)
- 开始时间:[时间]
- 结束时间:[时间]
- 通知渠道:[已通知]
- [ ] 备份确认
# 数据库备份
[backup-command]
# 验证备份
[verify-backup-command]2.2 部署步骤
步骤 1: [步骤名称]
# 执行命令
[command]预期输出:
[expected output]验证:
# 验证命令
[verification-command]
# 预期结果
[expected-result]如果失败:[troubleshooting steps]
---
步骤 2: [下一步骤]
[重复上述格式]
---
2.3 部署验证
完成所有部署步骤后,执行以下验证:
- [ ] 健康检查通过
curl http://[service]/health
# 预期:{"status":"ok", "version":"[new-version]"}- [ ] 核心功能验证
# 功能验证命令
[functional-test-command]
# 预期结果
[expected-result]- [ ] 监控指标正常
- QPS: [expected-range]
- P99 延迟: < [threshold]
- 错误率: < [threshold]
# 查询监控指标
[monitoring-query]- [ ] 日志无异常
# 查看最近日志
kubectl logs -f deployment/[name] --tail=100
# 检查是否有 ERROR/FATAL验证通过标准:
- ✅ 所有检查项通过
- ✅ 监控指标在正常范围
- ✅ 无严重日志错误
如果验证失败 → 执行回滚流程(见第 3 节)
---
3. 回滚流程
3.1 回滚触发条件
立即回滚条件:
- 错误率 > [threshold]%(持续 [duration] 分钟)
- P99 延迟 > [threshold]ms(持续 [duration] 分钟)
- 核心功能不可用
- 严重安全漏洞发现
决策流程:
检测到异常指标
↓
持续超过阈值时间?
↓ Yes
立即回滚3.2 回滚步骤
⚠️ 回滚步骤必须可以在新版本完全失败的情况下执行
---
步骤 1: 停止新版本流量
# 切换流量到旧版本
[traffic-switch-command]验证:
# 确认流量已切换
[verify-command]
# 预期:流量 100% 到旧版本---
步骤 2: 回滚应用版本
# 回滚到上一版本
[rollback-command]预期输出:
[expected-output]验证:
# 确认版本已回滚
[verify-version-command]
# 预期:[old-version]---
步骤 3: 回滚数据库 Migration(如有)
# 执行 migration down
[migration-rollback-command]验证:
# 检查数据库 schema 版本
[check-schema-version]
# 预期:[old-schema-version]---
步骤 4: 回滚配置(如有)
# 恢复旧配置
[config-rollback-command]验证:
# 确认配置已恢复
[verify-config-command]---
3.3 回滚验证
回滚完成后,必须验证:
- [ ] 服务健康
curl http://[service]/health
# 预期:{"status":"ok", "version":"[old-version]"}- [ ] 核心功能正常
[functional-test-command]- [ ] 监控指标恢复
- 错误率 < [normal-threshold]%
- P99 延迟 < [normal-threshold]ms
- [ ] 用户影响评估
- 受影响用户数:[评估]
- 数据一致性:[检查]
回滚成功标准:
- ✅ 所有验证通过
- ✅ 指标恢复到部署前水平
- ✅ 无新的错误或告警
---
4. 监控与告警
4.1 关键指标
| 指标 | SLO 阈值 | 查询命令/Query |
|---|---|---|
| QPS | [min-max] | [monitoring-query] |
| P99 延迟 | < [threshold]ms | [monitoring-query] |
| 错误率 | < [threshold]% | [monitoring-query] |
| CPU 使用率 | < [threshold]% | [monitoring-query] |
| 内存使用率 | < [threshold]% | [monitoring-query] |
4.2 SLO 定义
可用性 SLO:
- 目标:[percentage]% uptime
- 测量周期:[period]
- 错误预算:[error-budget]
性能 SLO:
- P99 延迟:< [threshold]ms
- P95 延迟:< [threshold]ms
- 错误率:< [threshold]%
4.3 告警配置
Critical 告警:
1. [告警名称]
- 触发条件:[condition]
- 持续时间:[duration]
- 通知渠道:[channel]
- 响应 SLA:[time]
Warning 告警:
1. [告警名称]
- 触发条件:[condition]
- 持续时间:[duration]
- 通知渠道:[channel]
4.4 Dashboard
主监控 Dashboard:
- URL: [dashboard-url]
- 包含面板:
- QPS & 延迟
- 错误率趋势
- 资源使用率
- 依赖服务状态
---
5. 故障处理
5.1 [故障场景 1:场景名称]
症状:
- [可观察的现象 1]
- [可观察的现象 2]
- 相关指标异常:[metric] > [threshold]
排查步骤:
1. 确认症状范围
# 检查受影响范围
[check-command]2. 检查日志
# 查看错误日志
kubectl logs deployment/[name] | grep ERROR3. 检查依赖服务
# 检查上游服务状态
[check-dependency-command]根因分析:
- 可能原因 1:[description]
- 验证方法:[how-to-verify]
- 可能原因 2:[description]
- 验证方法:[how-to-verify]
解决方案:
方案 1: [描述]
# 执行命令
[fix-command]验证修复:
# 验证命令
[verify-command]
# 预期结果:[expected]如果未解决 → 尝试方案 2 或升级
升级条件:
- 尝试所有方案后仍未解决
- 超过 [time] 分钟
- 影响范围扩大
升级对象:[团队/人员]
---
5.2 [故障场景 2:场景名称]
[重复上述格式]
---
5.N 通用故障处理流程
发现告警/异常
↓
确认症状和影响范围
↓
检查监控指标 + 日志
↓
识别根因(匹配已知场景)
↓
执行对应解决方案
↓
验证修复生效
↓
记录事故报告---
6. 值班手册
6.1 值班职责
on-call 工程师负责:
- 响应 Critical 告警(SLA: [time])
- 响应 Warning 告警(SLA: [time])
- 执行计划内维护操作
- 记录事故和解决方案
- 更新 Runbook
不负责:
- 非紧急功能开发
- 长期架构优化
- 其他团队的服务
6.2 联系方式
| 角色 | 联系方式 | 响应时间 |
|---|---|---|
| On-call 工程师 | [contact] | 15 分钟 |
| Team Lead | [contact] | 30 分钟 |
| [其他关键角色] | [contact] | [time] |
依赖团队:
| 团队 | 服务 | 联系方式 |
|---|---|---|
| [团队名] | [服务名] | [contact] |
6.3 升级路径
Level 1: On-call Engineer
↓ 15 分钟未解决
Level 2: Senior Engineer / Team Lead
↓ 30 分钟未解决 或 P0 故障
Level 3: Engineering Manager / CTO升级触发条件:
- 时间超过 SLA
- 故障影响扩大
- 需要其他团队协作
- 需要架构级决策
6.4 事故记录
每次故障必须记录:
- 时间:[start] - [end]
- 影响:[users/services affected]
- 根因:[root cause]
- 解决方案:[what fixed it]
- 改进措施:[prevention]
记录位置:[incident-tracker-url]
6.5 Runbook 维护
如何报告 Runbook 问题:
- [报告渠道]
- [负责人]
更新流程: 1. 发现 Runbook 错误或过时 2. 创建 Issue/Ticket 3. 提交更新 PR 4. Review + 合并 5. 更新版本号和日期
---
附录
A. 参考文档
| 文档 | 路径/URL | 说明 |
|---|---|---|
| PRD | [path] | 产品需求 |
| HLD | [path] | 高层设计 |
| LLD | [path] | 低层设计 |
| API Contract | [path] | 接口契约 |
| Guardrails | [path] | 工程规范 |
| Infrastructure Doc | [path] | 基础设施 |
B. 变更历史
| 版本 | 日期 | 变更内容 | 作者 |
|---|---|---|---|
| 1.0.0 | [date] | Initial version | [author] |
C. 常用命令速查
# 查看服务状态
[command]
# 查看日志
[command]
# 重启服务
[command]
# 查看监控
[command]D. 故障决策树
告警触发
↓
是 Critical 告警?
↓ Yes
立即响应(15分钟)
↓
检查症状匹配场景
↓
执行对应解决方案
↓
验证修复
↓
记录事故---
文档结束
Quality Reviewer Prompt Template
Use this template when dispatching a quality reviewer subagent.
Purpose: Verify Runbook is executable, complete, and production-ready
Only dispatch after spec compliance review passes.
Task tool (general-purpose):
description: "Review Runbook quality"
prompt: |
You are reviewing the quality and executability of a Runbook.
**Context:** This Runbook has already passed spec compliance review, meaning
it covers all upstream requirements. Your job is to verify it's well-built
and ready for production use.
## Runbook to Review
[Writer subagent 输出的 Runbook 完整内容]
## Upstream Context (for reference)
[Controller 提供的上下文摘要]
## Your Role
You are a Senior SRE reviewing operational documentation. You need to verify
this Runbook is:
- Executable by on-call engineers unfamiliar with the system
- Complete with no ambiguous steps
- Safe to use in production
- Maintainable over time
## Review Checklist
### 1. Deployment Process Quality
**For EACH deployment step, check:**
- [ ] Is the command exact and copy-pasteable?
- [ ] Is expected output specified?
- [ ] Is there a verification command?
- [ ] Is success criteria clear?
- [ ] Can this step be executed independently?
**Red flags:**
- Vague commands: "Run the deployment script" (which script? where? how?)
- Missing verification: "Deploy the service" (how do I know it worked?)
- Ambiguous success: "Check if it's working" (what exactly to check?)
- Assumed knowledge: "Use the standard procedure" (what's standard?)
**Example evaluation:**❌ Bad: "Deploy the new version" Issue: No command, no verification
✅ Good: "Deploy the new version"
kubectl set image deployment/api api=repo/api:v2.0.0Expected: "deployment.apps/api image updated" Verification: kubectl rollout status deployment/api Success: "deployment 'api' successfully rolled out"
### 2. Rollback Process Quality
**Critical requirements:**
- [ ] Can rollback steps execute WITHOUT new version running?
- [ ] Is database migration rollback clear?
- [ ] Is configuration rollback specified?
- [ ] Is rollback verification complete?
- [ ] Are rollback trigger conditions specific?
**Test scenario:** If new version is completely broken (won't start),
can someone follow rollback steps successfully?
**Red flags:**
- Depends on new version: "Use new admin panel to rollback DB"
- Vague conditions: "If something goes wrong, rollback"
- Missing steps: "Rollback database" (HOW?)
### 3. Monitoring & Alerts Quality
**For EACH metric, check:**
- [ ] Is metric name exact (not "check CPU")?
- [ ] Is threshold specific (not "high CPU")?
- [ ] Is query/command provided to check it?
- [ ] Is alert severity defined?
- [ ] Is notification channel specified?
**Red flags:**
- Vague metrics: "Monitor performance"
- Missing queries: "Check error rate" (how? where?)
- No thresholds: "Alert on high latency" (what's high?)
### 4. Failure Handling Quality
**For EACH failure scenario, check:**
- [ ] Are symptoms observable and specific?
- [ ] Are troubleshooting steps actionable?
- [ ] Is root cause identification clear?
- [ ] Is resolution step-by-step?
- [ ] Is escalation criteria defined?
**Test scenario:** Could a junior engineer who just joined the team
follow these steps to diagnose and resolve the issue?
**Red flags:**
- Vague symptoms: "Service is slow"
- No troubleshooting: "Check logs" (which logs? for what?)
- Assumed expertise: "Debug the connection pool"
- No escalation: "Keep trying" (when to give up and escalate?)
### 5. Clarity & Completeness
**Overall document check:**
- [ ] Is contact information complete?
- [ ] Is escalation path clear?
- [ ] Are all referenced documents linked?
- [ ] Is change history maintained?
- [ ] Are acronyms defined?
**Ambiguity check:**
- [ ] No steps require "judgment" without criteria
- [ ] No steps say "if necessary" without defining when
- [ ] No circular references ("see other runbook")
- [ ] No external dependencies not under team's control
### 6. Safety & Risk Management
**Safety checks:**
- [ ] Are destructive operations clearly marked?
- [ ] Are backup/snapshot steps before risky operations?
- [ ] Are rollback points clearly identified?
- [ ] Are maintenance windows mentioned if needed?
**Red flags:**
- Risky operations without warnings
- No backup before data modification
- No rollback checkpoints
- Assumes zero-downtime without verification
## Output Format
### Structure
Quality Review
Strengths
[What's well done? Be specific with examples.]
Issues
Critical (Must Fix Before Production)
[Bugs, safety issues, missing critical steps, impossible-to-execute steps]
Important (Should Fix)
[Ambiguities, missing verification, incomplete troubleshooting]
Minor (Nice to Have)
[Wording improvements, additional examples, formatting]
Recommendations
[Improvements for maintainability, clarity, safety]
Assessment
Production ready? [Yes / With fixes / No]
Reasoning: [Technical assessment in 1-2 sentences]
### Example Output
Quality Review
Strengths
- Clear deployment steps with exact kubectl commands (Section 2.2)
- Comprehensive rollback procedure with verification (Section 3.2)
- Good failure scenario coverage for database connection issues (Section 5.1)
- Health check validation well-defined (Section 2.3)
Issues
Critical (Must Fix Before Production)
1. Rollback depends on new version
- Location: Section 3.2, Step 3
- Issue: "Use new admin panel to verify rollback" - if new version is broken, admin panel won't work
- Impact: Cannot rollback in worst-case scenario
- Fix: Use kubectl/database client directly, not application UI
2. Missing database backup step
- Location: Section 2.2, before Step 5 (database migration)
- Issue: No backup before running migration
- Impact: Cannot recover if migration corrupts data
- Fix: Add explicit backup step with verification before migration
Important (Should Fix)
1. Vague verification in Step 7
- Location: Section 2.2, Step 7
- Issue: "Verify service is healthy" - no specific check
- Fix: Specify exact health check endpoint and expected response
- Example: curl http://api/health should return {"status":"ok"}
2. Monitoring query missing
- Location: Section 4.1, "Error Rate"
- Issue: Says "monitor error rate" but no query provided
- Fix: Add Prometheus query: rate(http_requests_total{status=~"5.."}[5m])
3. Escalation criteria unclear
- Location: Section 5.2, "Database Connection Failure"
- Issue: "Escalate if issue persists" - how long?
- Fix: Specify timeout: "Escalate if not resolved within 15 minutes"
Minor (Nice to Have)
1. Acronyms not defined
- Location: Section 2.1
- Issue: "Check RDS" - RDS not defined
- Fix: First use: "Check RDS (Relational Database Service)"
2. Command formatting
- Location: Various sections
- Issue: Some commands not in code blocks
- Fix: Use ```bash blocks consistently
Recommendations
1. Add pre-flight validation script
- Create a script that checks all prerequisites
- Reduces manual checklist errors
- Makes pre-deployment faster
2. Include rollback testing in staging
- Add section on testing rollback procedure
- Ensures rollback actually works
3. Link to monitoring dashboards
- Add direct links to Grafana/Datadog dashboards
- Faster access during incidents
Assessment
Production ready: With fixes
Reasoning: Core procedures are sound and well-structured, but Critical issues (rollback dependency, missing backup) must be fixed before production use. Important issues should also be addressed to ensure executability.
## Critical Rules
**DO:**
- Test mental execution: Could someone unfamiliar follow this?
- Be specific: file, section, line
- Explain WHY each issue matters (impact)
- Provide concrete fix suggestions
- Categorize by severity
**DON'T:**
- Say "looks good" without testing executability
- Mark nitpicks as Critical
- Give vague feedback ("improve clarity")
- Review spec compliance (already done)
- Avoid giving clear verdict
## Severity Definitions
**Critical:**
- Step is impossible to execute
- Creates safety risk (data loss, downtime)
- Missing essential functionality
- Rollback won't work in worst case
**Important:**
- Step is ambiguous or unclear
- Missing verification
- Incomplete troubleshooting
- Escalation criteria missing
**Minor:**
- Wording improvements
- Formatting inconsistencies
- Nice-to-have additions
- Documentation polish
## Final Check
Before submitting your review:
- [ ] Tested mental execution of all critical paths
- [ ] Provided specific locations for all issues
- [ ] Explained impact of each issue
- [ ] Suggested concrete fixes
- [ ] Clear production-ready verdict
## Structured Result (MANDATORY)
After your review output, you MUST append the following block at the very end.
See `../../../references/subagent-result-contract.md` for the full specification.
<!-- AGENT-RESULT:BEGIN --> role: quality-reviewer status: success output_files: [] verdict: pass # pass | conditional_pass | fail p0_count: 0 # Critical (must fix before production) p1_count: 0 # Important (should fix) p2_count: 0 # Minor (nice to have) blocking_issues: [] warnings: [] needs_retry: false needs_user_input: false summary: "Quality review: PASS. Runbook is production-ready." <!-- AGENT-RESULT:END -->
`verdict` mapping:
- `pass`: No Critical or Important issues → production ready
- `conditional_pass`: No Critical, has Important → production ready with caveats
- `fail`: Has Critical issues → must fix before productionSpec Compliance Reviewer Prompt Template
Use this template when dispatching a spec compliance reviewer subagent.
Purpose: Verify Runbook covers all upstream document requirements (nothing more, nothing less)
Task tool (general-purpose):
description: "Review Runbook spec compliance"
prompt: |
You are reviewing whether a Runbook matches upstream document requirements.
## What Was Required (Upstream Documents)
### From PRD
[Controller 提供的 PRD 中的运维相关要求]
### From HLD
[Controller 提供的 HLD 中的部署/架构要求]
### From Guardrails
[Controller 提供的 Guardrails 中的发布标准]
### Complete Context
[Controller 在 Phase 1 准备的完整上下文]
## What Writer Produced
[Writer subagent 输出的完整 Runbook]
## CRITICAL: Do Not Trust the Writer's Self-Review
The writer may have:
- Missed requirements from upstream documents
- Added content not requested in upstream documents
- Misinterpreted constraints
- Made assumptions not supported by evidence
**DO NOT:**
- Take their word for completeness
- Accept their interpretation without verification
- Assume they followed all constraints
**DO:**
- Compare Runbook against upstream requirements line by line
- Check for missing requirements
- Check for extra content not requested
- Verify all claims have upstream document citations
## Your Job
Review the Runbook and identify:
### Missing Requirements
**Deployment section:**
- [ ] Does it cover all deployment steps from HLD?
- [ ] Are all configuration requirements from Guardrails included?
- [ ] Are health check endpoints from API Contract included?
- [ ] Are resource requirements from HLD specified?
- [ ] Is deployment strategy (blue-green/canary) from Guardrails included?
**Rollback section:**
- [ ] Are rollback trigger conditions from Guardrails included?
- [ ] Is database migration rollback strategy from HLD included?
- [ ] Is configuration rollback from Guardrails included?
- [ ] Are rollback verification steps complete?
**Monitoring section:**
- [ ] Are all SLO metrics from Guardrails included?
- [ ] Are SLO thresholds from HLD included?
- [ ] Are alert rules from Guardrails included?
- [ ] Is dashboard requirement addressed?
**Failure handling section:**
- [ ] Are all failure scenarios from HLD covered?
- [ ] Does each scenario have troubleshooting steps?
- [ ] Are escalation paths defined?
### Extra/Unneeded Content
Check for content that was NOT requested in upstream documents:
- Additional deployment strategies not mentioned in Guardrails
- Monitoring metrics not in SLO requirements
- Failure scenarios not mentioned in HLD
- Tools or processes not specified in upstream documents
### Misinterpretations
Check for:
- Deployment steps that don't match HLD architecture
- Rollback strategy that conflicts with Guardrails
- SLO thresholds different from HLD specifications
- Alert rules not matching Guardrails requirements
## Review Checklist
For EACH section, verify:
### 1. System Overview
- [ ] Architecture matches HLD
- [ ] All dependencies from HLD are listed
- [ ] Data storage matches HLD
### 2. Deployment Process
- [ ] Pre-deployment checks cover Guardrails requirements
- [ ] Deployment steps match HLD deployment strategy
- [ ] Configuration management matches Guardrails
- [ ] Health check uses endpoints from API Contract
- [ ] Verification steps are adequate
### 3. Rollback Process
- [ ] Trigger conditions match Guardrails
- [ ] Database rollback matches HLD strategy
- [ ] Configuration rollback matches Guardrails
- [ ] Rollback verification is complete
### 4. Monitoring & Alerts
- [ ] All SLO metrics from Guardrails are included
- [ ] SLO thresholds match HLD values
- [ ] Alert rules match Guardrails
- [ ] Dashboard requirements addressed
### 5. Failure Handling
- [ ] All failure scenarios from HLD are covered
- [ ] Each scenario has complete troubleshooting steps
- [ ] Escalation paths are defined
- [ ] Resolution steps are clear
### 6. On-Call Guide
- [ ] Responsibilities are defined
- [ ] Contact information is complete
- [ ] Escalation path is clear
## Evidence-Based Review
For EACH claim in the Runbook, verify:
- Is this supported by upstream documents?
- Which document? Which section?
- Is the interpretation correct?
**Example:**Runbook says: "Deploy using blue-green strategy" ✅ Check: HLD Section 4.2 specifies blue-green deployment ✅ Check: Guardrails Section 3 allows blue-green
Runbook says: "Monitor CPU usage > 80%" ❌ Issue: HLD Section 5 specifies 75% threshold, not 80%
## Output Format
### ✅ If Spec Compliant
Spec Compliance Review: PASS
All upstream requirements covered:
- Deployment: ✅ Complete
- Rollback: ✅ Complete
- Monitoring: ✅ Complete
- Failure handling: ✅ Complete
- On-call guide: ✅ Complete
No extra content: ✅ All content traceable to upstream documents
No misinterpretations: ✅ All interpretations correct
Ready for quality review.
### ❌ If Issues Found
Spec Compliance Review: ISSUES FOUND
Missing Requirements
Critical (Must Add)
1. Database migration rollback missing
- Required by: HLD Section 3.4 "Database Migration Strategy"
- Missing: Step-by-step migration rollback procedure
- Impact: Cannot safely rollback if migration fails
2. SLO metric missing: P99 latency
- Required by: Guardrails Section 5.2 "Performance SLO"
- Missing: P99 latency < 500ms monitoring
- Impact: Cannot verify SLO compliance
Important (Should Add)
1. Health check endpoint incomplete
- Required by: API Contract Section 2.3 "/health"
- Missing: Expected response body format
- Impact: Unclear how to verify health
Extra Content (Not Requested)
1. Performance testing steps
- Location: Section 2.3 "Deployment Validation"
- Issue: Performance testing not mentioned in upstream documents
- Recommendation: Remove unless user confirms it's needed
2. Auto-scaling configuration
- Location: Section 4.3 "Monitoring Setup"
- Issue: HLD doesn't specify auto-scaling
- Recommendation: Remove or confirm with upstream documents
Misinterpretations
1. Rollback trigger threshold
- Runbook: "Rollback if error rate > 5%"
- Guardrails: "Rollback if error rate > 1%"
- File: Guardrails Section 3.2
- Impact: Too permissive, violates Guardrails
2. Deployment strategy
- Runbook: "Use rolling deployment"
- HLD: "Use blue-green deployment"
- File: HLD Section 4.2
- Impact: Wrong strategy, doesn't match architecture
Recommendation
Return to writer for fixes. Issues must be resolved before quality review.
Priority order: 1. Fix all Critical missing requirements 2. Fix all Misinterpretations 3. Remove Extra content 4. Add Important missing requirements
## Critical Rules
**DO:**
- Be specific: cite document, section, line
- Distinguish between missing/extra/misinterpreted
- Explain impact of each issue
- Categorize by severity (Critical/Important/Minor)
**DON'T:**
- Say "looks good" without checking every requirement
- Accept close approximations (either matches spec or doesn't)
- Give feedback on code quality (that's next review)
- Be vague ("add more monitoring details")
## Final Check
Before submitting your review, verify:
- [ ] Checked EVERY requirement from upstream context
- [ ] Verified EVERY claim in Runbook has upstream support
- [ ] Provided specific document citations for all issues
- [ ] Categorized issues by severity
- [ ] Clear pass/fail verdict
## Structured Result (MANDATORY)
After your review output, you MUST append the following block at the very end.
See `../../../references/subagent-result-contract.md` for the full specification.
<!-- AGENT-RESULT:BEGIN --> role: spec-reviewer status: success output_files: [] verdict: pass # pass | fail p0_count: 0 # Critical (missing requirements, safety issues) p1_count: 0 # Important (ambiguities, misinterpretations) p2_count: 0 # Minor (wording, formatting) blocking_issues: [] warnings: [] needs_retry: false needs_user_input: false summary: "Spec compliance review: PASS. All upstream requirements covered." <!-- AGENT-RESULT:END -->
Writer Subagent Prompt Template
Use this template when dispatching a Runbook writer subagent.
Purpose: Write complete, executable Runbook based on upstream constraints
Task tool (general-purpose):
description: "Write Runbook for [系统名称]"
prompt: |
You are writing a production-ready Runbook for [系统名称].
## Your Role
You are a Senior SRE/DevOps Engineer responsible for creating operational documentation
that will be used by on-call engineers during deployments and incidents.
## Context from Upstream Documents
[Controller 提供的完整上下文,包括:]
### 系统概览
- 系统名称:[name]
- 系统边界:[scope]
- 依赖服务:[dependencies]
- 数据存储:[databases, caches, object storage]
### 部署约束(来自 HLD/Guardrails)
- 部署环境:[K8s/VM/Serverless]
- 资源配置:[CPU/memory requirements]
- 配置管理:[ConfigMap/Secret/env vars]
- 健康检查:[endpoints and expected responses]
- 部署策略:[blue-green/canary/rolling]
### 回滚策略(来自 HLD/Guardrails)
- 回滚触发条件:[error rate/latency thresholds]
- 数据库回滚:[migration down strategy]
- 配置回滚:[version control approach]
- 流量切换:[traffic routing method]
### 监控 SLO(来自 HLD/Guardrails)
- 关键指标:[QPS/P99 latency/error rate]
- SLO 阈值:[specific values]
- 告警规则:[trigger conditions]
- Dashboard 要求:[required visualizations]
### 故障场景(来自 HLD/Guardrails)
- 常见故障:[list from HLD]
- 排查步骤:[troubleshooting flow]
- 应急响应:[escalation path]
### 证据来源
- PRD: [path]
- HLD: [path]
- LLD: [path]
- Guardrails: [path]
## Before You Begin
If you have questions about:
- Any unclear requirements or constraints
- Missing information (e.g., "What's the maintenance window policy?")
- Conflicting information from different documents
- Assumptions you need to make
**Ask them now.** Raise any concerns before starting work.
Do NOT:
- Guess or make assumptions
- Add content not supported by upstream documents
- Skip information because it's "probably not needed"
## Your Job
Write a complete Runbook that covers:
### 1. 系统概览
- System architecture summary (from HLD)
- Service dependencies (internal and external)
- Data storage architecture
### 2. 部署流程
**Pre-deployment checklist:**
- [ ] Verify all prerequisites
- [ ] Check dependency service health
- [ ] Confirm maintenance window (if required)
**Deployment steps:**
For EACH step, provide:
- Clear description
- Exact commands to run
- Expected output/success criteria
- Verification command
**Example format:**步骤 1: 部署新版本镜像
kubectl set image deployment/[name] [container]=[image]:[tag]预期输出:
deployment.apps/[name] image updated验证:
kubectl rollout status deployment/[name]
# 预期:deployment "[name]" successfully rolled out
### 3. 回滚流程
**Rollback trigger conditions:**
- When to rollback (from Guardrails)
- Decision criteria
**Rollback steps:**
- Exact commands for each step
- Database migration rollback (if applicable)
- Configuration rollback
- Verification after rollback
**Critical:** Rollback steps must be executable WITHOUT the new version running.
### 4. 监控与告警
**Key metrics to monitor:**
- List metrics from SLO requirements
- Include query/command to check each metric
**Alert configuration:**
- Alert rules (from Guardrails)
- Thresholds
- Notification channels
**Dashboard:**
- Required visualizations
- Link to dashboard (if exists)
### 5. 故障处理
For EACH common failure scenario (from HLD):
**场景 N: [Description]**
**症状:**
- How to recognize this issue
- Observable symptoms
**排查步骤:**
1. Check [specific metric/log]
2. Verify [specific condition]
3. ...
**解决方案:**
- Step-by-step resolution
- Exact commands
- Verification
**升级条件:**
- When to escalate
- Who to contact
### 6. 值班手册
**On-call responsibilities:**
- What on-call engineer is responsible for
- Response time expectations
**Contact information:**
- Team contacts
- Escalation path
**Runbook maintenance:**
- How to report issues with this runbook
- Update process
## Quality Standards
**Every deployment/rollback step MUST have:**
- ✅ Exact command (not "run the deployment script")
- ✅ Expected output
- ✅ Verification command
- ✅ Success criteria
**Every failure scenario MUST have:**
- ✅ Observable symptoms
- ✅ Step-by-step troubleshooting
- ✅ Clear resolution steps
- ✅ Escalation criteria
**Avoid:**
- ❌ Vague instructions ("check if everything is working")
- ❌ Missing verification steps
- ❌ Assuming knowledge not in this document
- ❌ Adding features not in upstream documents
## Before Reporting Back: Self-Review
Ask yourself:
**Completeness:**
- Did I cover all constraints from the context?
- Are deployment AND rollback both complete?
- Did I include all failure scenarios from HLD?
**Executability:**
- Can someone unfamiliar with this system follow these steps?
- Does every step have verification?
- Are rollback steps independent of the new version?
**Accuracy:**
- Did I only include information from upstream documents?
- Did I cite sources for all constraints?
- Did I avoid adding assumptions?
If you find issues during self-review, fix them now before reporting.
## Output Format
Use the following structure:
[系统名称] Runbook
1. 系统概览
[Content]
2. 部署流程
2.1 前置检查
2.2 部署步骤
2.3 部署验证
3. 回滚流程
3.1 回滚触发条件
3.2 回滚步骤
3.3 回滚验证
4. 监控与告警
4.1 关键指标
4.2 SLO 阈值
4.3 告警配置
4.4 Dashboard
5. 故障处理
[One section per failure scenario]
6. 值班手册
6.1 值班职责
6.2 联系方式
6.3 升级路径
附录
参考文档
- PRD: [path]
- HLD: [path]
- LLD: [path]
- Guardrails: [path]
变更历史
- [Date]: Initial version
## Report Format
When done, report:
- **Status**: Complete / Need clarification
- **Questions** (if any): [List questions that need controller's answer]
- **Runbook content**: [Full markdown]
- **Self-review findings**: [Any concerns or assumptions made]
- **Files referenced**: [List all upstream docs you relied on]
## Structured Result (MANDATORY)
After your report, you MUST append the following block at the very end of your output.
See `../../../references/subagent-result-contract.md` for the full specification.
<!-- AGENT-RESULT:BEGIN --> role: writer status: success # success | failed | needs_input | partial output_files: [] # writer 不直接保存文件,由 controller 决定路径 blocking_issues: [] # list questions here if status=needs_input warnings: [] needs_retry: false needs_user_input: false # true if you have questions for the controller summary: "Runbook 内容已生成,覆盖部署/回滚/监控/故障处理。由 controller 保存。" <!-- AGENT-RESULT:END -->
> Note: Writer 将完整 Runbook 内容包含在输出正文中,AGENT-RESULT 块放在最末尾。
> Controller 负责提取正文内容并保存到 `docs/runbook/[system-name]-runbook.md`。