来源:https://academy.claude.com/courses/ai-native-sdlc-playbook/closing-the-loop-on-metrics 读这篇之前:02 intent.md、10 PR 审查、11 hooks、12 CI/CD 回滚 不确定:ZH 是 Clint 译官方英文课体,不是 Anthropic 中文。
本课词汇
| English | 中文 | 怎么记 |
|---|---|---|
| control band | 控制带 | 指标允许的波动。越界触发 |
| sigma / σ | 标准差档 | 1σ 只记日志,2σ 只读诊断,3σ 可开 PR 或跑预先批准的 runbook |
| bands.yaml | 档位配置 | 进版本库的确定性检测,不经过模型 |
| Claude Tag | Claude 标签 | 公开 beta,Slack 里 Claude 以自己身份进频道 |
| Western Electric | 控制图规则 | 抓慢漂和尖刺 |
| headless | 无头 | 没人启动也能开始和结束 |
对照正文
EN Where every earlier stage needs a person to start it, Stage 6 shifts the focus to autonomous running of Claude to close the loop. For example, a continuously running monitoring agent could, off the back of a bug ticket being raised, create an intent.md, and flow through the requirements, plan, build, test, and review phases. Stage 6: Maintain runs headless, with an independent confidence gate between stages, a deterministic check or an adversarial reviewing agent, deciding whether the previous stage’s output continues or is escalated to a human.
ZH 前面每阶段都要人来启动。Stage 6 把重心转到 Claude 自主跑、把环闭合。例如一个持续跑的监控 agent,可以在开了缺陷工单之后写出 intent.md,再流过需求、计划、构建、测试、审查。Stage 6: Maintain 无头跑,阶段之间有独立的信心闸:确定性检查或对抗性审查 agent,决定上一阶段的产出继续走还是升级给人。
什么变了 / What changes
EN | Traditional | AI-native |
| --- | --- |
| Maintenance is a reactive phase. All tickets or incidents wait on a person to act on them and restart the process. An alert fires at 3 a.m. and can be missed, a ticket can sit in the backlog until someone picks it up, and post-mortem actions may not reach the codebase at all if another fire starts first. | A trigger such as a control-band breach, a ticket, a channel message, or a schedule invokes Claude without a person in the path. Claude diagnoses, acts only through gated routes, and writes what it finds as intent.md, which then goes through the stages described above. People triage and review that work, and no longer have to start it. |
ZH | 传统 | AI-native |
| --- | --- |
| 维护是被动阶段。工单或事故都等人来动手、重开流程。凌晨 3 点告警可能被错过,工单可能在 backlog 里坐到有人捡,复盘动作可能根本到不了代码库——如果另一场火先烧起来。 | 控制带越界、工单、频道消息或日程这类触发,不经过人就调用 Claude。Claude 诊断,只走有闸的路径动手,并把发现写成 intent.md,再按上面的阶段走。人分流和审查这些活,不必再启动它们。 |
EN A deterministic script watches production and invokes Claude when a control band is breached. Monitoring of a breach is a helpful example of the pattern for the loop running autonomously, while the Claude Tag (public beta) section at the end of the stage covers work arriving through different channels.
ZH 确定性脚本盯生产,控制带越界时调用 Claude。越界监控是环自主跑的一个好例子;本阶段末的 Claude Tag(公开 beta)一节则讲活从别的渠道进来。
怎么起步 / Getting started
EN - Prerequisites: intent.md, which gives the loop a structured output to restart. Claude-accelerated PR reviews, hooks as an action boundary, and a rollback path for CI/CD (which the highest autonomy tier invokes).
- Infrastructure: A metrics store the detection script can query (Prometheus, the CI system’s API, or equivalents), read access to the repository, a way to run Claude Code non-interactively in CI, or the Agent SDK for a service that receives webhooks.
ZH 先决条件:intent.md,给环一份结构化输出好重开。Claude 加速的 PR 审查、hooks 当动作边界、以及 CI/CD 的回滚路径(最高自主档会调用)。
- 基础设施:检测脚本能查的指标库(Prometheus、CI 系统的 API,或等价物),仓库读权限,CI 里非交互跑 Claude Code 的办法,或收 webhook 的 Agent SDK 服务。
怎么做 / How to execute it
EN 1. The service owner or platform engineer picks one metric with a stable rolling baseline, such as CI test failure rate, post-deploy 5xx rate, or PR cycle time.
2. They write the detection script, typically mean and standard deviation over a rolling window with rules (Western Electric or similar) so the bands catch slow drift as well as spikes. The script is version controlled and unit tested, and detection stays entirely deterministic, with no model involved.
3. Response tiers are defined in version-controlled config (bands.yaml below). At 1σ the script only logs, at 2σ it invokes Claude read-only to diagnose, and at 3σ Claude may act, though only by opening a PR into the review gate or triggering a pre-approved runbook.
4. The trigger layer can be a scheduled workflow in GitHub or GitLab, a webhook from the existing monitoring stack, or a cron job inside the network. Claude runs stateless, either as a non-interactive step on a CI runner or as an Agent SDK service in a sandboxed container, and the CI/CD play covers the deployment and model-access options. Because the run is stateless and non-interactive, a loop can begin and end without anyone starting it.
5. The agent writes its diagnosis as intent.md in the Stage 1: Plan format, covering the anomaly and its evidence, a proposed outcome, the affected systems, and any open questions. From there the finding goes through the pipeline like anything else.
6. The service owner or on-call engineer triages the queue, routing product-facing findings to the product owner. Fix now, schedule, or dismiss. Dismissals tune the bands and help to reduce noise.
7. When a fix ships, add an eval for the incident (the continuous evals play) to ensure that such issues are protected against going forwards.
ZH 1. 服务主人或平台工程师挑一个有稳定滚动基线的指标,例如 CI 测试失败率、发布后 5xx 率、或 PR 周期时间。
2. 写检测脚本,通常是滚动窗口上的均值和标准差,加规则(Western Electric 或类似),让控制带既能抓慢漂也能抓尖刺。脚本进版本库并做单元测试,检测完全确定性,不经过模型。
3. 响应档写在进版本库的配置里(下面的 bands.yaml)。1σ 只记日志,2σ 只读调用 Claude 做诊断,3σ Claude 可以动手,但只限开 PR 进审查闸,或触发预先批准的 runbook。
4. 触发层可以是 GitHub/GitLab 的定时工作流、现有监控栈的 webhook、或网内 cron。Claude 无状态跑:CI runner 上的非交互步骤,或沙箱容器里的 Agent SDK 服务;部署和模型访问选项见 CI/CD 打法。因为这次跑无状态、非交互,环可以在没人启动的情况下开始和结束。
5. Agent 把诊断写成 Stage 1: Plan 格式的 intent.md:异常和证据、拟议结果、受影响系统、未决问题。从那里,发现像别的东西一样走流水线。
6. 服务主人或值班工程师分流队列,把面向产品的发现转给产品负责人。现在修、排期、或驳回。驳回用来调控制带、降噪。
7. 修复上船后,为这起事故加一条 eval(持续 eval 打法),保证往后有防护。
长什么样 / What it looks like
EN For example, a bands.yaml monitoring CI test failure rate:
ZH 例如一份盯 CI 测试失败率的 bands.yaml:
metric: ci_test_failure_rate
baseline: rolling_30d
rules: western_electric
tiers:
1sigma: { action: log }
2sigma: { action: diagnose,
tools: "Read,Grep,Bash(gh run view *)" }
3sigma: { action: propose,
routes: [pull_request, runbook:rollback-deploy] }
ZH 官方示例,保持英文。
治理 / Governance considerations
EN The tier boundaries are enforced from version-controlled config, with permissions and managed settings denying production access. Invocations, findings, and triage decisions are logged with a timestamp. A service owner triages and approves findings, resulting changes go through the normal PR review gate, and the runbooks the agent may trigger were approved in advance.
ZH 档位边界由进版本库的配置强制,权限和托管设置拒绝生产访问。调用、发现、分流决定带时间戳记下。服务主人分流并批准发现,结果改动走正常 PR 审查闸;agent 可触发的 runbook 事先批准过。
怎么衡量 / How to measure it
EN - Leading indicator: Time from band breach to an intent.md in the triage queue, against the old time from incident to post-mortem action. The detection script’s log has the breach timestamp and tier of incident.
- Lagging indicator: The share of findings that become merged fixes (triage queue against actual PR history), and repeat incidents of the same class, which should fall as the fixes add cases to the eval suite.
ZH 领先指标:从控制带越界到分流队列里出现 intent.md 的时间,对照旧的从事故到复盘动作的时间。检测脚本日志有越界时间戳和事故档位。
- 滞后指标:发现变成已合并修复的占比(分流队列对实际 PR 历史),以及同一类重复事故——修复把用例加进 eval 套件后应变少。
例子 / Examples
EN - When the CI test failure rate breaches 3σ, the agent quarantines the flaky test or opens a revert PR, and the review gate decides.
- When the post-deploy 5xx rate breaches 3σ with a deployment in the window, the agent triggers the existing rollback pipeline.
- When PR cycle time trips a drift rule, the agent writes a report for engineering leadership, which shows the harness works for process metrics as well as production ones.
ZH - CI 测试失败率越 3σ,agent 隔离脆弱测试或开还原 PR,审查闸决定。
- 发布后 5xx 率越 3σ 且窗口内有部署,agent 触发已有回滚流水线。
- PR 周期时间触发漂规则,agent 给工程领导写报告,说明这套 harness 对过程指标和生产指标都管用。
用 Claude Tag 值班 / Claude on call with Claude Tag
EN Incidents can also arrive via other means such as workplace communication apps, like Slack or Microsoft Teams. Incidents can look like a 10 p.m. Slack message for an urgent fix on an incident channel and can now be actioned immediately. Claude Tag (public beta currently available in Slack) makes Claude a member of those channels under its own identity, so each new incident gets a first responder and the response itself becomes part of the loop and memory for future incidents.
ZH 事故也可以从别的地方进来,例如职场通讯应用,如 Slack 或 Microsoft Teams。事故可以长得像晚上 10 点事故频道里一条要紧急修的 Slack 消息,现在能立刻动手。Claude Tag(公开 beta,目前在 Slack)让 Claude 以自己的身份成为这些频道的成员,于是每起新事故都有第一响应者,响应本身也成为环和未来事故记忆的一部分。
EN The conversation and institutional knowledge stay in the channel, with anyone in the channel able to guide and action the response. Any team member can test hypotheses, explore new options, and investigate in real time with the channel history adding to the auditability. Through access to MCP, Claude verifies the metric is back at baseline and confirms it in the thread, and writes the post-mortem to a version-controlled lessons file that future investigations can read.
ZH 对话和组织知识留在频道里,频道里任何人都能指路和动手。任何成员都可以测假设、探新选项、实时调查,频道历史增加可审计性。经 MCP,Claude 核实指标回到基线并在线程里确认,再把复盘写进进版本库的 lessons 文件,供以后的调查读。
EN Incidents are not the only work Claude Tag picks up. Tagged on a ticket over MCP or asked in the channel, Claude triages the work the same way. A small, well-bounded fix arrives as a PR through the review gate, and anything larger is written up as intent.md for Stage 1: Plan, at which point the loop starts feeding itself.
ZH 事故不是 Claude Tag 接的唯一活。在工单上经 MCP 被点名,或在频道里被问,Claude 用同样方式分流。小而边界清楚的修复以 PR 进审查闸;更大的写成 intent.md 给 Stage 1: Plan,于是环开始自己喂自己。
读完能记住的三句话
EN A deterministic script watches the metric. The model is not in the detector. ZH 确定性脚本盯指标。检测器里没有模型。
EN A 3σ breach may open a PR or run a pre-approved runbook. It does not skip the human gate. ZH 3σ 越界可以开 PR 或跑预先批准的 runbook。它不跳过人闸。
EN The finding is written as intent.md, so the loop feeds itself.
ZH 发现写成 intent.md,环自己喂自己。