The AI-Native SDLC playbook
Code is no longer the bottleneck
代码不再是瓶颈
Organizations have started using AI to write code at a speed unthinkable one year ago, yet the processes around the code haven't changed at the same pace.
各组织已经开始使用 AI 编写代码,其速度在一年前还难以想象,然而围绕代码的流程却没有以同样的速度演进。
Many engineering teams still have the same approval gates, reviews, handoffs, and policies, stalling productivity gains made by using agentic coding solutions like Claude Code.
许多工程团队仍然保留着相同的审批关卡、审查、交接和策略,阻碍了使用 Claude Code 等智能体编程解决方案所带来的生产力提升。
The software development lifecycle (SDLC) is the process that takes software from idea to production. Most organizations run some version of the same six stages, covering planning, design, building, testing, deploying, and maintaining software. Traditionally, each stage is a discrete phase owned by a different role. Product managers write requirements, technical architects turn them into designs, engineers build the designs, QA teams at regulated enterprises verify it, releases teams ship it, and operations monitors what is running. Work moves between the phases through documents, tickets, and sign-offs.
软件开发生命周期(SDLC)是将软件从创意推向生产的过程。大多数组织都在运行相同六个阶段的某种版本,涵盖软件的规划、设计、构建、测试、部署和维护。传统上,每个阶段都是由不同角色负责的独立阶段。产品经理编写需求,技术架构师将其转化为设计,工程师构建这些设计,受监管企业的 QA 团队对其进行验证,发布团队将其交付,运维团队监控运行状态。工作通过文档、工单和签字在各阶段之间流转。
The traditional software development lifecycle (SDLC) is process-heavy to ensure accountability and control at each step. However, the traditional SDLC was designed to maximize efficiency in an era where the most time-consuming and expensive stage was writing and implementing code, which is no longer the case. PRDs, estimation rituals, and product security reviews all existed to force alignment during what could be weeks, months, or quarters of development work.
传统的软件开发生命周期(SDLC)流程繁重,以确保每个步骤的责任和控制。然而,传统 SDLC 的设计是为了在编写和实现代码这一最耗时、最昂贵的阶段实现效率最大化,但如今情况已不再如此。PRD、估算仪式和产品安全审查的存在,都是为了在可能长达数周、数月或数季度的开发工作期间强制达成一致。
The traditional SDLC also features controls that assume every step is performed by humans. The organizations generating the most value have rebuilt their process around what agentic AI can now do, while ensuring that humans stay in the loop. In this guide, we walk through several of our Applied AI team's best practices for integrating Claude internally across each stage of the SDLC to accelerate development and make processes run faster, inspired by working with our customers.
传统 SDLC 的控制措施还假设每一步都由人类执行。创造最大价值的组织已经围绕智能体 AI(agentic AI)目前能做的事情重建了流程,同时确保人类保持在闭环中。在本指南中,我们将介绍应用 AI 团队(Applied AI team)在 SDLC 各个阶段内部集成 Claude 的一些最佳实践,这些实践借鉴了我们与客户合作的经验,旨在加速开发并使流程运行得更快。
When code is no longer the bottleneck and the build phase runs faster than the traditional SDLC allows for, three things become true:
当代码不再是瓶颈,且构建阶段的运行速度超过了传统 SDLC 所允许的速度时,以下三件事将成为现实:
- The bottleneck moves to the steps to the left and right of the build phase. This is mainly plan, review/test, and deploy, which still run at human speed.
- The controls stop matching reality and become intractable. Reviewing each line by hand made sense when a person had written it, but it can't keep up once agents write most of the diff.
- Governance costs increase because exceptions still route through meetings and committees that meet weekly or monthly.
- 瓶颈转移到构建阶段左右两侧的步骤。这主要是计划、审查/测试和部署,它们仍然以人类速度运行。
- 控制措施不再符合现实并变得难以处理。当由人工编写代码时,逐行手动审查是有意义的,但当智能体编写了大部分差异时,这种方法就无能为力了。
- 治理成本增加,因为异常情况仍然需要通过每周或每月开会的会议和委员会来处理。


Build is no longer the constraint — the human-speed steps around it are. Human-speed stages keep their length while build collapses to hours.
构建不再是约束——周围以人类速度执行的步骤才是。人类速度的阶段保持其长度,而构建则缩减至数小时。
Let's use a security bottleneck as an example. Security teams are sized for human output, so when agents multiply code output, either the review queue builds or code ships under-reviewed. A regulated organization can't accept either outcome, so its security and policy checks have to keep pace with the agents.
让我们以安全瓶颈为例。安全团队的规模是根据人类产出设定的,因此当智能体使代码产出成倍增加时,要么审查队列堆积,要么代码在未充分审查的情况下发布。受监管的组织无法接受这两种结果中的任何一种,因此其安全和策略检查必须与智能体保持同步。
To better realize the productivity gains of and secure agentic AI, the traditional SDLC lifecycle requires the same level of transformation as the implementation phase has undergone.
为了更好地实现智能体 AI 的生产力提升并确保其安全性,传统的 SDLC 生命周期需要进行与实现阶段所经历的同等程度的转型。
What is an AI-native SDLC?
什么是 AI 原生 SDLC?
The AI-native SDLC is a reimagined process that combines the old control objectives with new enforcement. Instead of a linear flow, the process becomes a loop, and AI is embedded at each point. The AI-native SDLC promotes automated handover and triggering of subsequent plays, helping to address the manual and clunky nature of handoff between the phases of the traditional SDLC.
AI 原生 SDLC 是一个重新构想的过程,将旧的控制目标与新的执行方式相结合。该过程不再是线性流转,而是变成了一个循环,AI 被嵌入到每个节点中。AI 原生 SDLC 促进自动交接和触发后续行动方案,有助于解决传统 SDLC 各阶段之间交接的手工和笨重问题。
You'll also hear this shift called the agentic SDLC, the AI SDLC, or simply agentic software development — the labels differ, but they describe the same thing.
你也会听到这种转变被称为智能体 SDLC、AI SDLC 或简称为智能体软件开发——标签各不相同,但描述的是同一回事。


The shifts across the six stages of an AI-native SDLC
AI 原生 SDLC 六个阶段的转变
The table below highlights the ends of the spectrum between traditional SDLC and AI-native SDLC, supported by Claude. Most organizations sit somewhere between the two columns.
下表突出了由 Claude 支持的传统 SDLC 与 AI 原生 SDLC 之间的两极状态。大多数组织都处于两列之间的某个位置。
| Stage | Traditional SDLC | AI-native SDLC |
|---|---|---|
| Plan | Requirements gathered by committee, distilled through workshops and sign-offs, written up by hand | Claude synthesizes pain points straight from the sources and captures them within intent.md which is human readable and machine actionable |
| Design | Spec written by analysts, parsed by designers | Requirements and design compressed into one working session with an agent, guided by standards encoded as skills, versioned in git |
| Build | Tests and code are handwritten and documentation is written after the main development happens | Tests and code are generated by AI and institutional knowledge is maintained as versioned machine-readable CLAUDE.md files and skills |
| Test | QA gates at stage boundaries | Continuous evals woven through implementation |
| Deploy | Humans review every line of code and governance occurs in review cycles, often inconsistently | Layers of agentic review with human review reserved for regulated and critical code. Governance is enforced as the AI acts, with hooks as approval gates |
| Maintain | Humans watch production for bugs | Agents monitor live deployments. Any breached control band is diagnosed and written back into the loop as a new intent.md |
| 阶段 | 传统 SDLC | AI 原生 SDLC |
|---|---|---|
| 规划 | 需求由委员会收集,通过研讨会和签字提炼,手工编写 | Claude 直接从来源合成痛点,并将其捕获在 intent.md 中,该文件人类可读且机器可执行 |
| 设计 | 规格说明由分析师编写,由设计师解析 | 需求和设计被压缩为与智能体进行的一个工作会话,由编码为技能并在 git 中进行版本控制的标准指导 |
| 构建 | 测试和代码均为手写,文档在主要开发完成后编写 | 测试和代码由 AI 生成,机构知识作为版本化的机器可读 CLAUDE.md 文件和技能进行维护 |
| 测试 | 阶段边界的 QA 关卡 | 贯穿实现过程的持续评估 |
| 部署 | 人类审查每一行代码,治理在审查周期中进行,通常不一致 | 多层智能体审查,人工审查仅保留用于受监管和关键代码。治理在 AI 行动时通过作为审批关卡的钩子来强制执行 |
| 维护 | 人类监控生产环境中的错误 | 智能体监控实时部署。任何被突破的控制范围都会被诊断并作为新的 intent.md 写回循环中 |
The thread running through the right-hand column is the committed artifact. Each stage ends by writing one to version control (including intent.md, spec.md, plan.md, the diff and its tests, the PR with its review findings, and the incident record) and the next stage begins by reading it. For the early stages, .md files are the predominant artifact because a product owner and an agent can both read and act on the same file. From Build onward, the artifact is code and its records. The chain of commits is also the audit trail: who asked for what, what the agent produced, and who approved it.
贯穿右列的线索是提交的产出物。每个阶段都以向版本控制写入一个产出物(包括 intent.md、spec.md、plan.md、差异及其测试、带有审查发现的 PR 以及事件记录)结束,而下一阶段则以读取该产出物开始。在早期阶段,.md 文件是主要的产出物,因为产品所有者和智能体都可以读取并基于同一文件采取行动。从构建阶段开始,产出物变为代码及其记录。提交链也是审计追踪:谁要求了什么,智能体生产了什么,以及谁批准了它。
Humans remain accountable for every decision that requires judgment. In the agentic SDLC world, the human attention shifts along with the artifacts that must be reviewed.
人类仍然对每一个需要判断的决策负责。在智能体 SDLC 的世界里,人类的注意力随着必须审查的产出物而转移。
Every stage commits an artifact the next stage can read. Together, the intent, the spec, the plan, the diff and the review findings are the audit trail.
每个阶段都会提交一个下一阶段可读取的产出物。意图、规格说明、计划、差异和审查发现共同构成了审计追踪。
Plays
行动方案
The plays are the core of the playbook and are grouped into six non-linear stages (Plan, Design, Build, Test, Deploy, Maintain), which together cover the complete lifecycle.
行动方案是剧本的核心,被分为六个非线性阶段(规划、设计、构建、测试、部署、维护),它们共同涵盖了完整的生命周期。
Each play covers:
每个行动方案涵盖:
- What changes;
- Getting started;
- Concrete steps for implementation;
- Governance considerations; and
- How you measure whether it worked.
- 改变了什么;
- 如何入门;
- 具体的实施步骤;
- 治理考量;以及
- 如何衡量其是否有效。
The steps are modular and organizations may choose to prioritize transforming different stages at different times based on their unique needs. Each play names its dependencies under "Prerequisites," which the dependency graph further illustrates.
这些步骤是模块化的,组织可以根据其独特需求选择在不同时间优先转换不同阶段。每个行动方案在“先决条件”下列出了其依赖项,依赖图进一步说明了这一点。
A stage ends by committing an artifact with the commit initiating the next stage. An accepted intent.md triggers the requirements and design pass, an approved spec.md triggers plan mode, a merged PR triggers the pipeline, and a breached control band in production writes the next intent.md and so the loop continues.
一个阶段以提交一个产出物结束,该提交会启动下一个阶段。被接受的 intent.md 触发需求和设计流程,被批准的 spec.md 触发计划模式,合并的 PR 触发流水线,而生产环境中被突破的控制范围会写入下一个 intent.md,循环由此继续。
First, you prompt each step by hand with the end state being a loop in which each accepted artifact fires the next gate. Human attention concentrates at the gates, reviewing what the agent flagged rather than starting each stage from scratch.
起初,你手动为每个步骤提供提示,最终状态会演变成一个循环,其中每个被接受的产出物都会触发下一个关卡。人类的注意力集中在关卡上,审查智能体标记的内容,而不是从零开始每个阶段。


The plays are listed with stage; the arrows give the order to adopt them in. The two are not the same. Start with any clay play — nothing points into it, so it needs nothing first. For any other play, the arrows pointing into it are the plays to adopt before it.
行动方案按阶段列出;箭头给出了采用它们的顺序。两者并不相同。从任何“规划”行动方案开始——没有任何东西指向它,因此它不需要任何前置条件。对于任何其他行动方案,指向它的箭头表示需要在它之前采用的行动方案。
01
01
Plan
规划
Ideas stop waiting for someone to write them up. Intent is captured once, in the originator's own words, as a version-controlled artifact the next stage can act on.
创意不再等待某人来撰写。意图被一次性捕获,使用发起者自己的话,作为下一阶段可执行的版本控制产出物。
Capture as intent.md
捕获为 intent.md
The intent.md, which kicks off the software development process can enter through different routes. A person has an idea, a ticket is filed, or an incident is surfaced via an alert (see Stage 6: Maintenance).
启动软件开发过程的 intent.md 可以通过不同途径进入。一个人有了一个想法、提交了一个工单,或者通过警报显现了一个事件(见阶段 6:维护)。
When a person has an idea, they brainstorm with Claude and produce a markdown proto-spec. In the traditional SDLC, the same person must then convince a member of the product team to write the idea up with them or on their behalf.
当一个人有了一个想法,他们与 Claude 进行头脑风暴,并生成一个 markdown 原型规格说明。在传统的 SDLC 中,此人随后必须说服产品团队的一名成员与其一起或代表其撰写该想法。
The proto-spec generated by Claude is human readable, version-controlled, and immediately consumable by the next stage. The proto-spec is saved as an intent.md.
Claude 生成的原型规格说明人类可读、受版本控制,并且可立即供下一阶段使用。该原型规格说明被保存为 intent.md。
Regardless of whether the intent originates from an event trigger or an agent, the same steps apply: the product owner reviews and corrects the agent-written intent.md before it is committed.
无论意图是源于事件触发还是智能体,都适用相同的步骤:产品所有者在提交前审查并更正智能体编写的 intent.md。
TraditionalAn idea passes through backlog entries, user stories, story points, and refinement meetings before anyone can act on it. Ownership transfers at each handoff, so what reaches engineering is several steps removed from what the originator meant.
传统:一个创意在任何人采取行动之前,要经历待办事项、用户故事、故事点和细化会议。所有权在每次交接时转移,因此到达工程团队的内容距离发起者的本意已经隔了几个步骤。
AI-nativeThe originator brainstorms with Claude and writes the result down as intent.md, a proto-spec in the originator's own terms. The artifact contains what is wanted, why, and under which constraints. Repeat processes are encoded via skills.
AI 原生:发起者与 Claude 进行头脑风暴,并将结果记录为 intent.md,这是一份用发起者自己的话表述的原型规格说明。该产出物包含想要什么、为什么以及在哪些约束下。重复过程通过技能进行编码。
Getting started
入门指南
Prerequisites
先决条件
None.
无。
Infrastructure
基础设施
Claude access for people who are not engineers (claude.ai or Cowork); an agreed intent.md template; a shared, version-controlled home for intent that the product owner watches. For a single product the simplest home is an intent/ folder in the product repo. This setup keeps the artifact chain next to the code derived from it. A dedicated intent repo is only worth the overhead when intent spans many repositories, and in a monorepo it is a directory. The Stage 3: Build sidebar covers how this home relates to a Jira or requirements tool that already holds the record.
为非工程师人员提供 Claude 访问权限(claude.ai 或 Cowork);一个约定的 intent.md 模板;一个由产品所有者监控的共享、版本控制的意图存放地。对于单一产品,最简单的存放地是产品仓库中的一个 intent/ 文件夹。这种设置将产出物链与其衍生的代码放在一起。只有当意图跨越多个仓库时,专门的意图仓库才值得增加这种开销,而在 monorepo(单体仓库)中,它是一个目录。阶段 3:构建的侧边栏介绍了这个存放地与已经持有记录的 Jira 或需求工具之间的关系。
Setting this up is a one-time task for the platform or engineering team. A technical team member needs to stand up the intent home and decide who can write to it, since many contributors will come from across the organization.
对平台或工程团队来说,这是一次性设置任务。技术团队成员需要搭建意图库,并决定谁有写入权限,因为许多贡献者将来自组织各个部门。
Once the repository exists, contributors without git experience don't need to use git directly. Instead a connector to the version-control system (e.g. GitHub) lets Claude commit markdown files on their behalf from claude.ai or Cowork.
一旦仓库建立完成,没有 git 经验的贡献者无需直接使用 git。相反,通过版本控制系统(例如 GitHub)的连接器,Claude 可以代表他们在 claude.ai 或 Cowork 中提交 markdown 文件。
How to execute it
如何执行
- The originator describes the problem to Claude in their own words. The originator may describe what they cannot do today, who is affected by the idea, what better looks like, or what is out of scope. No formal language is required.
- Brainstorm until the idea is concrete. Claude asks the questions an analyst would ask: scope, users, constraints, and what success looks like.
- Ask Claude to write the result as
intent.mdusing the organization's template, which can be encoded as a skill set up by a technical team member and signed off by a lead. This can cover the problem, proposed outcome, affected users and systems, constraints, and open questions. - The originator corrects anything Claude misunderstood.
- Commit
intent.mdto the shared home. Author and timestamp join the record, and the product owner picks the idea up from there.
- 提出者用自己的话向 Claude 描述问题。提出者可以描述他们现在做不到的事情、受该想法影响的人群、理想的样子,或是范围之外的内容。不需要使用正式语言。
- 进行头脑风暴,直到想法具体化。Claude 会提出分析师会问的问题:范围、用户、限制条件以及成功是什么样的。
- 让 Claude 使用组织的模板将结果写成
intent.md,该模板可以由技术团队成员编写为技能,并由主管签字确认。它可以涵盖问题、提议的结果、受影响的用户和系统、限制条件以及待解决的问题。 - 提出者纠正 Claude 误解的任何内容。
- 将
intent.md提交到共享库。作者和时间戳加入记录,产品负责人从那里接手该想法。
# Intent: claims status self-service
Author: J. Ortiz (claims operations). Status: draft.
## Problem
Customers phone the contact center to ask where their claim is.
Handlers spend roughly a third of call time on status-only queries.
## Proposed outcome
Customers see claim status, next step and expected date in the portal.
## Affected users and systems
Claims handlers, portal team, claims-core API.
## Constraints
No new PII in the portal session. Existing authentication only.
## Open questions
Do third-party loss adjusters need access too?
# Intent: claims status self-service
Author: J. Ortiz (claims operations). Status: draft.
## Problem
Customers phone the contact center to ask where their claim is.
Handlers spend roughly a third of call time on status-only queries.
## Proposed outcome
Customers see claim status, next step and expected date in the portal.
## Affected users and systems
Claims handlers, portal team, claims-core API.
## Constraints
No new PII in the portal session. Existing authentication only.
## Open questions
Do third-party loss adjusters need access too?
Governance considerations
治理考量
The evidence is the committed intent.md, which lists the author, the timestamp and the full revision history. It's logged in the git history of the intent home. The product owner approves, and the accept or reject decision that sends the intent into Stage 2: Design is recorded as the merge or the closing review.
凭证就是已提交的 intent.md,其中列出了作者、时间戳和完整的修订历史。它记录在意图库的 git 历史中。产品负责人进行审批,而将该意图发送到第 2 阶段:设计的接受或拒绝决定,将记录为合并或结束审查。
How to measure it
如何衡量
Leading indicator
领先指标
Time from first conversation to a committed intent.md, read from git history on the intent home, which records author and time stamp. The expectation is to fall from a multi-week elicitation and refinement cycle to hours.
从首次对话到提交 intent.md 的时间,可从意图库的 git 历史记录中读取,该记录包含作者和时间戳。预期是从数周的引导和细化周期缩短至数小时。
Lagging indicator
滞后指标
The survival rate, or the share of intent.md files that the product owner accepts into Stage 2: Design rather than closes. The accept or reject decision is recorded as the merge of the artifact or the closed review. Additionally, the number of changes made to the intent.md that are made after the first spec.md commit for the same change.
存活率,即产品负责人接受进入第 2 阶段:设计而不是关闭的 intent.md 文件所占比例。接受或拒绝的决定记录为工件的合并或审查的关闭。此外,还包括在同一变更的首次 spec.md 提交之后对 intent.md 所做的修改数量。
02
02
Design
设计
Requirements and design collapse into one session. Policy is applied while the spec is written, not discovered in a review weeks later.
需求和设计合并为一个环节。在编写规范时就应用了策略,而不是在数周后的审查中才发现。
Requirements and design
需求与设计
Once approved by the product owner, Claude takes the accepted intent.md and produces a requirements and design spec. This is guided by the organization's skills for brand, security, compliance, and UX.
一旦产品负责人批准,Claude 就会接收已批准的 intent.md 并生成需求和设计规范。这受组织的 skills(品牌、安全、合规和 UX)引导。
The product owner reviews that spec, but doesn't write it. The goal of this process is to create a spec the engineering team can plan against, with flagged areas of concern.
产品负责人审查该规范,但不编写它。此流程的目标是创建一个工程团队可以据此规划的规范,并标记出关注区域。
Front-end work is the clearest example. Once the intent.md is accepted, the product owner mocks the design up in Claude Design (beta) from the intent.md, iterates on the mock, and then exports it to Claude Code to build.
前端工作是最清晰的例子。一旦 intent.md 被接受,产品负责人就会在 Claude Design (beta) 中根据 intent.md 进行设计模型制作,对模型进行迭代,然后将其导出到 Claude Code 进行构建。
TraditionalRequirements and design are separate phases run by separate teams. Analysts formalize the idea into requirements and designers then parse those back into a design. The separation exists for accountability, but it is slow and lossy.
传统方式:需求和设计是由不同团队执行的两个独立阶段。分析师将想法形式化为需求,然后设计人员再将其重新解析为设计。这种分离是为了问责,但速度慢且信息流失大。
AI-nativeBoth phases happen in a single prompted session. Claude takes intent.md and produces a requirements and design spec, constrained by the organization's skills, with areas of concern flagged.
AI 原生方式:两个阶段在一次提示会话中完成。Claude 接收 intent.md 并生成需求和设计规范,受组织的技能约束,并标记出关注区域。
Getting started
开始使用
Prerequisites
前提条件
Write an intent.md file, with brand, security, compliance, and UX policies written as skills.
编写一个 intent.md 文件,并将品牌、安全、合规和 UX 策略编写为技能。
Infrastructure
基础设施
A product owner with Claude access. No engineering skill is required.
一位拥有 Claude 访问权限的产品负责人。不需要工程技能。
How to execute it
如何执行
- The product owner opens a session with the organization's skills available and attaches the
intent.md. - The product owners prompt points at the
intent.md, names the constraints, and demands flagged concerns. Run it by hand at first, then codify it as an organization-level slash command. From there make the acceptance ofintent.mdin the intent home the trigger, with a non-interactive job that fires on the merge, run the pass with the organization's skills loaded, and commitspec.mdas a pull request (the CI/CD play in Stage 5: Deploy covers the plumbing). From that point the product owner's first involvement is the review. - The same product owner reviews the spec against the idea. Does the spec solve the stated problem, and are the open questions from
intent.mdanswered or carried forward? - Work through the flagged concerns first as they are the points an analyst would have escalated. The product owner resolves each one with its policy owner before engineering sees the spec.
- Commit
spec.mdalongsideintent.md. The file pair records what was asked for and what was decided. - The product owner decides whether the spec and intent progress to build, consulting a technical lead for anything the organization classes as higher risk. A human team mate always makes this call, and accepting the spec is what starts the plan mode play in Stage 3: Build.
- 产品负责人开启一个包含组织技能的会话,并附上
intent.md。 - 产品负责人的提示指向
intent.md,指出限制条件,并要求标记关注点。首先手动运行,然后将其编纂为组织级别的斜杠命令。从那时起,将意图库中对intent.md的接受作为触发器,通过一个在合并时触发的非交互式作业,加载组织的技能运行该过程,并将spec.md作为拉取请求提交(第 5 阶段:部署中的 CI/CD 环节涵盖了具体实现)。从那时起,产品负责人的首次介入就是进行审查。 - 同一位产品负责人根据原始想法审查规范。规范是否解决了既定问题?
intent.md中的待解决问题是否已得到解答或延续? - 首先处理标记的关注点,因为它们是分析师本应上报的问题。产品负责人在工程团队看到规范之前,与其策略负责人共同解决每个问题。
- 将
spec.md与intent.md一起提交。这对文件记录了需求内容和决定内容。 - 产品负责人决定规范和意图是否进入构建阶段,对于组织归类为较高风险的任何内容,需咨询技术负责人。这一决定始终由人类团队成员做出,而接受规范即是启动第 3 阶段:构建中的规划模式环节的关键。
What it looks like (the prompt)
它的样子(提示)
Read the attached intent.md and produce a requirements and design spec for integrating it into our existing codebase. Apply the skills available to you so the plan conforms to our brand guidelines, security policies and UX standards. Document the spec fully as spec.md, ready to hand to the engineering team. Describe clearly any areas of concern, especially where you cannot satisfy contradicting policies.
Read the attached intent.md and produce a requirements and design spec for integrating it into our existing codebase. Apply the skills available to you so the plan conforms to our brand guidelines, security policies and UX standards. Document the spec fully as spec.md, ready to hand to the engineering team. Describe clearly any areas of concern, especially where you cannot satisfy contradicting policies.
Governance considerations
治理考量
Instead of being discovered in a review weeks later, the live policy is read and applied while the spec is written. The organization's skills are applied as constraints on the spec. The spec, the prompt that produced it, and the skill versions in force are all logged in version control. The product owner signs off the spec, and routes flagged concerns to the named policy owners.
策略在编写规范时即被读取并应用,而不是在数周后的审查中才发现。组织的技能作为对规范的约束被应用。规范、生成规范的提示以及生效的技能版本均记录在版本控制中。产品负责人签署规范,并将标记的关注点路由给指定的策略负责人。
How to measure it
如何衡量
Leading indicator
领先指标
Elapsed time between the intent.md commit and the spec.md commit for the same change (two git timestamps), compared with the old requirements-plus-design cycle.
同一变更的 intent.md 提交与 spec.md 提交之间的间隔时间(两个 git 时间戳),与旧的需求加设计周期进行比较。
Lagging indicator
滞后指标
Requirements rework after build starts. Count spec.md commits dated after the first plan.md commit for the same change. Git log will give this directly.
构建开始后的需求返工。计算同一变更的首次 plan.md 提交之后日期的 spec.md 提交数量。Git log 将直接提供此数据。
03
03
Build
构建
Nothing is implemented without an accepted plan. Institutional knowledge becomes files the agent reads, and the guardrails run as code rather than as habits.
没有可接受的计划,就不会进行任何实现。机构知识变成了代理可读取的文件,护栏以代码而非习惯的形式运行。
Claude Code plan mode as the default starting point
Claude Code 规划模式作为默认起点
Engineers start Claude Code sessions in plan mode, give Claude the approved spec.md from Stage 2: Design, and let it interview them, iterating on the plan until the engineer is happy with it.
工程师在 plan mode 中启动 Claude Code 会话,将第 2 阶段:设计中批准的 spec.md 提供给 Claude,让它对工程师进行访谈,并不断迭代计划,直到工程师满意为止。
TraditionalAn engineer reads the design and starts writing code. How the change will be made, down to which files and which tests, stays in the engineer's head or at best a ticket comment. Nobody else can review it. The first thing a reviewer sees is the finished diff, and by then rework is slow.
传统方式:工程师阅读设计并开始编写代码。如何进行更改(具体到哪些文件和哪些测试)仍停留在工程师的脑海中,充其量只是工单上的一句评论。没有其他人可以审查它。审查者看到的第一件事就是完成的差异对比,到那时返工已经很慢了。
AI-nativeWork starts with a written plan that Claude produces in plan mode, where it can read the codebase without changing anything. The engineer corrects the plan before code is written, and the approved version is committed as plan.md for later stages to check against.
AI 原生方式:工作从 Claude 在规划模式中生成的书面计划开始,在该模式下,它可以阅读代码库而不进行任何更改。工程师在编写代码之前纠正计划,批准的版本将作为 plan.md 提交,供后续阶段检查。
Getting started
开始使用
Prerequisites
前提条件
The intent artifact (intent.md or spec.md) if one exists, and the CLAUDE.md file helps.
如果存在意图工件(intent.md 或 spec.md),以及 CLAUDE.md 文件会有所帮助。
Infrastructure
基础设施
Claude Code with access to the repository.
具有仓库访问权限的 Claude Code。
How to execute it
如何执行
- The engineer starts the session in plan mode with Claude.
- The engineer gives Claude the
intent.mdand thespec.mdand asks for an implementation plan that names the files that change, the order of the work, and the tests that prove it. - Interrogate the plan by asking what the change could break, which step is most risky, and what other options Claude chose not to do.
- Iterate until an engineer who has never seen the conversation could implement the change from the plan alone.
- Commit the approved plan as
plan.md. The plan joins the audit trail, and the PR review play (Stage 5: Deploy) checks the eventual diff against it. - Accept the plan and let Claude implement. With a solid plan, the implementation is often a single pass.
- When implementation departs from the plan, update
plan.mdin the same commit. Consider using a hook to enforce synchronization between the two.
- 工程师在规划模式中与 Claude 启动会话。
- 工程师将
intent.md和spec.md提供给 Claude,并要求提供一份实现计划,其中包括需要更改的文件、工作顺序以及证明其可行的测试。 - 通过询问该更改可能导致什么破坏、哪一步风险最大,以及 Claude 选择不做的其他选项来质询该计划。
- 不断迭代,直到从未看过该对话的工程师也能仅凭计划实现更改。
- 将批准的计划提交为
plan.md。计划加入审计追踪,PR 审查环节(第 5 阶段:部署)将根据它检查最终的差异对比。 - 接受计划并让 Claude 进行实现。有了可靠的计划,实现通常一次即可完成。
- 当实现偏离计划时,在同一提交中更新
plan.md。考虑使用钩子来强制两者之间的同步。
What it looks like (plan.md)
它的样子(plan.md)
# Plan: claims status self-service (from intent.md 2026-06-02)
## Files that change
portal/src/claims/StatusPanel.tsx (new), claims-api/routes/status.py,
claims-api/tests/test_status.py
## Order of work
1. Add the status endpoint behind existing auth.
2. Panel against the endpoint.
3. Wire into the portal nav.
## Risks
The claims-core API rate-limits at 50 rps; the panel must cache.
## Proof
test_status.py covers the four claim states; screenshot matches the
approved mock.
# Plan: claims status self-service (from intent.md 2026-06-02)
## Files that change
portal/src/claims/StatusPanel.tsx (new), claims-api/routes/status.py,
claims-api/tests/test_status.py
## Order of work
1. Add the status endpoint behind existing auth.
2. Panel against the endpoint.
3. Wire into the portal nav.
## Risks
The claims-core API rate-limits at 50 rps; the panel must cache.
## Proof
test_status.py covers the four claim states; screenshot matches the
approved mock.
Governance considerations
治理考量
Design review happens before any code is generated, when changing course is still a matter of editing a document. Plan mode enforces this itself, since Claude cannot edit files until the engineer accepts the plan. The plan and its revisions are logged along with who accepted it. Routine changes are approved by the engineer, and anything the organization classes as higher risk goes to a tech lead or architect.
设计审查发生在生成任何代码之前,此时改变方向只是编辑文档的问题。规划模式本身强制执行了这一点,因为 Claude 在工程师接受计划之前无法编辑文件。计划及其修订记录以及接受者都会被记录。常规更改由工程师批准,组织归类为较高风险的任何内容则交由技术负责人或架构师处理。
How to measure it
如何衡量
Leading indicator
领先指标
Share of changes that merge from the first implementation pass, and time from plan approval to merged PR with the required data within the PR metadata.
首次实现阶段即合并的更改比例,以及从计划批准到合并 PR 的时间,其中包含 PR 元数据中的所需数据。
Lagging indicator
滞后指标
Rework cycles per change, again from the PR metadata, and how often the merged diff still matches the committed plan.md.
每次更改的返工周期(同样来自 PR 元数据),以及合并的差异对比与已提交的 plan.md 之间的匹配程度。
Claude Code on auto mode
Claude Code 自动模式
Claude Code can also run in auto mode, where the engineer approves the plan and, once happy and iterated upon, Claude applies each change without a per-edit prompt. As the guardrails from the later plays mature (a tuned CLAUDE.md, skills that encode policy, hooks that block unsafe actions, and a test suite Claude can run), auto-accept becomes the default for routine work: a tight spec.md, a small blast radius, and code the tests already cover.
Claude Code 也可以在自动模式下运行,工程师批准计划,一旦满意并经过迭代,Claude 就会应用每次更改而无需每次编辑提示。随着后续环节中护栏的成熟(经过调整的 CLAUDE.md、编码策略的技能、阻止不安全操作的钩子,以及 Claude 可以运行的测试套件),自动接受成为常规工作的默认设置:严密的 spec.md、小的爆炸半径以及测试已覆盖的代码。
The shift is now away from the user watching the agent make the edits and reviewing actions, towards the review of artifacts after longer autonomous sessions. Auto-accept mode further enables parallelism across individuals and the team when used with worktrees and is fundamental to running the SDLC autonomously and closing the loop as described in Stage 6: Maintenance.
现在的转变是,用户不再盯着代理进行编辑和审查操作,而是转向在更长的自主会话之后审查工件。自动接受模式与工作树结合使用时,进一步实现了个人和团队之间的并行工作,并且是自主运行 SDLC 并如第 6 阶段:维护中所述闭环的基础。
Sidebar
侧边栏
Legacy systems and the source of truth
遗留系统与事实来源
Applies to every artifact the process produces.
适用于流程产生的每个工件。
Existing SDLC processes likely already track artifacts, just not in markdown files. Work items may be in Jira, requirements in a tool with regulatory traceability built in, designs in Figma, and change approvals with a change board. Those systems are hard to displace because auditors and regulators already accept them and other teams depend on them, so the AI-native SDLC has to fit around what exists.
现有的 SDLC 流程可能已经在跟踪工件了,只是没有使用 Markdown 文件。工作项可能在 Jira 中,需求在具有内置法规可追溯性功能的工具中,设计在 Figma 中,变更审批在变更控制委员会中。这些系统很难被取代,因为审计人员和监管机构已经接受了它们,而且其他团队也依赖它们,因此 AI 原生的 SDLC 必须与现有系统相融合。
When transitioning to the AI-native SDLC, for every artifact the process produces, name one system as the source of truth, with everything else holding a copy or a link to the original. The configurations below can be set up to have one source of truth, with the choice differing per artifact:
在向 AI 原生 SDLC 过渡时,对于流程产生的每个工件,指定一个系统作为单一事实来源,其他所有内容仅保留副本或指向原始文件的链接。可以通过以下配置来实现单一事实来源,具体选择因工件而异:
The repo as the source of truth. The markdown artifacts are the authoritative record and the legacy system references files within commits. This can be one of the cleanest configurations for engineering-led organizations, as all records live in one tool with one timestamp authority.
仓库作为事实来源。 Markdown 工件是权威记录,遗留系统引用提交中的文件。对于工程主导的组织来说,这可能是最清晰的配置之一,因为所有记录都存在于一个工具中,并具有统一的时间戳权威。
The legacy system as the source of truth. Jira, ServiceNow, or the requirements tool holds the authoritative record and the markdown artifacts are working copies. Claude reads the record at the start of the session and writes the outcome back through an MCP connector in the same session that produced the spec or the plan.
遗留系统作为事实来源。 Jira、ServiceNow 或需求工具持有权威记录,而 Markdown 工件是工作副本。Claude 在会话开始时读取记录,并在生成规范或计划的同一会话中,通过 MCP 连接器将结果写回。
Linkage as the minimum bar. All artifacts note the record ID and all legacy records contain the commit SHA of the markdown file. Linkage is a good place to start when transitioning to the AI-native SDLC, accepting that there are two sources of truth.
链接作为最低门槛。 所有工件都注明记录 ID,所有遗留记录包含 Markdown 文件的提交 SHA。链接是向 AI 原生 SDLC 过渡时的一个良好起点,这需要接受存在两个事实来源的现实。
Both the legacy system and the markdown-first system can coexist, so long as there is a link between the two or one is declared the source of truth.
遗留系统和 Markdown 优先的系统可以共存,只要两者之间存在链接,或者其中一个被指定为事实来源。
The CLAUDE.md
CLAUDE.md
CLAUDE.md gives Claude the context a new joiner would need, covering conventions, commands, architecture, and the mistakes the team sees most often. Knowledge that used to sit in people's heads and on wikis becomes a file the agent reads at the start of every session, maintained by the whole team and iterated on whenever a mistake is made.
CLAUDE.md 为 Claude 提供了新成员所需的上下文,涵盖规范、命令、架构以及团队最常犯的错误。曾经存在于人们头脑中和维基上的知识,现在变成了一个文件,智能体在每次会话开始时都会读取它,由整个团队维护,并在每次犯错时进行迭代。
Getting started
入门指南
Prerequisites
前提条件
None.
无。
Infrastructure
基础设施
A repo, Claude Code installed, and one engineer who knows the codebase well.
一个代码库,已安装的 Claude Code,以及一名非常熟悉该代码库的工程师。
How to execute it
如何执行
- Run
/initin the repo. Claude generates a startingCLAUDE.mdfrom what it finds. - Cut the generated file down to what a new joiner would need on day one. Keep the build, test and lint commands, the conventions that matter, and the things Claude keeps getting wrong.
- Check
CLAUDE.mdinto git at the repo root so the whole team shares one version and changes are reviewed like code. - A working rule helps here. When Claude makes a mistake twice, the correction goes into
CLAUDE.md. - Keep it under a page, because Claude reads all of it at the start of a session and anything stale is taking up context for no benefit.
- 在代码库中运行
/init。Claude 会根据其发现生成一个初始的CLAUDE.md。 - 将生成的文件精简为新成员第一天所需的内容。保留构建、测试和 lint 命令,重要的规范,以及 Claude 总是出错的地方。
- 将
CLAUDE.md提交到代码库根目录的 git 中,以便整个团队共享一个版本,并且像审查代码一样审查更改。 - 这里有一条实用规则:当 Claude 犯两次同样的错误时,将纠正方法写入
CLAUDE.md。 - 将其保持在一页以内,因为 Claude 会在会话开始时读取全部内容,任何过时的内容都会白白占用上下文。
What it looks like (CLAUDE.md)
实际效果 (CLAUDE.md)
# Payments service
## Commands
- Build: make build
- Test: make test (unit), make itest (integration, needs docker)
- Lint: make lint (runs in CI; fix before pushing)
## Conventions
- Java 21, Spring Boot 3. No new Lombok.
- Money is always BigDecimal, never double.
- Every endpoint needs an integration test in src/itest.
## Architecture
- api/ holds REST controllers, core/ holds domain logic,
adapters/ talks to external systems.
- Kafka events are defined in schemas/; never edit generated classes.
## Things Claude gets wrong
- Do not bump dependency versions; the platform team owns them.
- The legacy v1/ package is frozen; changes go in v2/.
# Payments service
## Commands
- Build: make build
- Test: make test (unit), make itest (integration, needs docker)
- Lint: make lint (runs in CI; fix before pushing)
## Conventions
- Java 21, Spring Boot 3. No new Lombok.
- Money is always BigDecimal, never double.
- Every endpoint needs an integration test in src/itest.
## Architecture
- api/ holds REST controllers, core/ holds domain logic,
adapters/ talks to external systems.
- Kafka events are defined in schemas/; never edit generated classes.
## Things Claude gets wrong
- Do not bump dependency versions; the platform team owns them.
- The legacy v1/ package is frozen; changes go in v2/.
Governance considerations
治理考量
CLAUDE.md is version controlled, so the instructions the agent works to are reviewable and auditable. Team conventions are applied through the file, changes to it are logged in git history, and code owners approve those changes in PR review.
CLAUDE.md 是受版本控制的,因此智能体遵循的指令是可审查和可审计的。团队规范通过该文件应用,对其的更改记录在 git 历史中,代码所有者在 PR 审查中批准这些更改。
How to measure it
如何衡量
Leading indicator
领先指标
How often Claude repeats a mistake CLAUDE.md should have caught. The corrections or changes to the CLAUDE.md should be tracked within the git history.
Claude 重复 CLAUDE.md 本应避免的错误的频率。对 CLAUDE.md 的纠正或更改应记录在 git 历史中。
Lagging indicator
滞后指标
Time to first merged PR for a new member of the team from PR history.
从 PR 历史中提取的,团队新成员首次合并 PR 所需的时间。
Skills as institutional knowledge
将技能作为机构知识
Skills are how an organization makes its institutional knowledge operational. The instructions are explicit, version-controlled, applied broadly, and updated centrally when policy changes. The rule of thumb: write a skill for institutional knowledge that must be applied consistently; don't write a skill for components that belong in CLAUDE.md or a prompt.
技能是组织将其机构知识付诸实践的方式。这些指令是明确的、受版本控制的、被广泛应用的,并且当策略发生改变时会进行集中更新。经验法则:对于必须一致应用的机构知识,编写技能;对于属于 CLAUDE.md 或提示词的组件,不要编写技能。
Getting started
入门指南
Prerequisites
前提条件
None required. Having a CLAUDE.md helps, because it keeps the agent's working knowledge in the repo, but a skill does not depend on it.
无要求。拥有 CLAUDE.md 会有所帮助,因为它将智能体的工作知识保留在代码库中,但技能并不依赖于它。
Infrastructure
基础设施
One policy with a named owner and a written source of truth.
一项具有明确所有者和书面事实来源的策略。
How to execute it
如何执行
- Pick one piece of knowledge that is enforced inconsistently today. This could be a security standard, an API design convention, or a brand rule.
- Write it as a skill, a folder containing a
SKILL.mdwhose frontmatter says when it triggers and whose body says what to do. An engineer writes it from the policy owner's source of truth, using Claude to help. - Put the skill in the repo at
.claude/skills/<name>/so it ships with the code, or distribute it organization-wide through a plugin. - Test that the skill triggers. Ask Claude to do the relevant task in different ways and confirm the skill loads each time.
- When the policy changes, change the skill and have the policy owner sign off the change.
- Engineers pick up the new version automatically in their next session.
- 选择一项目前执行不一致的知识。这可以是安全标准、API 设计规范或品牌规则。
- 将其编写为技能,即一个包含
SKILL.md的文件夹,其 frontmatter 说明触发时机,正文说明要做什么。工程师根据策略所有者的事实来源来编写它,并使用 Claude 辅助完成。 - 将技能放入代码库的
.claude/skills/<name>/中,使其随代码一起发布,或者通过插件在整个组织内分发。 - 测试技能是否会触发。以不同方式要求 Claude 执行相关任务,并确认技能每次都会加载。
- 当策略发生改变时,修改技能并让策略所有者批准更改。
- 工程师在下一次会话中会自动获取新版本。
What it looks like (.claude/skills/secure-api-review/SKILL.md)
实际效果 (.claude/skills/secure-api-review/SKILL.md)
---
name: secure-api-review
description: Apply the API security standard. Use whenever creating or
modifying an external-facing endpoint, reviewing API code, or
generating an OpenAPI spec.
---
# Secure API review
When you create or change an API endpoint:
1. Authentication: every endpoint requires the gateway JWT;
no anonymous routes outside /health.
2. Input validation: validate request bodies against the OpenAPI
schema and reject unknown fields.
3. Audit: every state-changing endpoint emits an audit event with
actor, action, entity and timestamp.
4. Data classification: fields tagged pii in the schema must never
appear in logs or error messages.
Run scripts/check-endpoints.sh and include its output in your summary.
---
name: secure-api-review
description: Apply the API security standard. Use whenever creating or
modifying an external-facing endpoint, reviewing API code, or
generating an OpenAPI spec.
---
# Secure API review
When you create or change an API endpoint:
1. Authentication: every endpoint requires the gateway JWT;
no anonymous routes outside /health.
2. Input validation: validate request bodies against the OpenAPI
schema and reject unknown fields.
3. Audit: every state-changing endpoint emits an audit event with
actor, action, entity and timestamp.
4. Data classification: fields tagged pii in the schema must never
appear in logs or error messages.
Run scripts/check-endpoints.sh and include its output in your summary.
Governance considerations
治理考量
A skill is a control, though an advisory one. It makes Claude likely to apply the policy while the code is written, and nothing forces a session to comply with it. A policy that must always hold needs something deterministic behind the skill, such as a hook that blocks the action or a review pass that re-checks the policy at the PR. The skill makes violations rare and the hook makes them close to impossible. Skill invocations are logged in session traces, and the policy owner reviews skill changes like code.
技能是一种控制,尽管是建议性的。它使 Claude 在编写代码时有可能应用策略,但没有任何东西强制会话遵守它。必须始终维持的策略需要在技能背后有确定性的东西,例如阻止该操作的钩子,或者在 PR 处重新检查策略的审查过程。技能使违规行为变得罕见,而钩子使其几乎不可能发生。技能调用记录在会话追踪中,策略所有者像审查代码一样审查技能更改。
How to measure it
如何衡量
Leading indicator
领先指标
Time from the policy owner approving a policy change to the updated skill merging, taken from the PR on the skill folder.
从策略所有者批准策略更改到更新后的技能合并所需的时间,从技能文件夹的 PR 中获取。
Lagging indicator
滞后指标
PR reviews findings that cite the policy, which should fall towards zero once the skill is applying the policy while the code is written. Where the findings don't fall towards zero, either the skill isn't triggering or its text has drifted from the official policy.
引用该策略的 PR 审查发现,一旦技能在编写代码时应用了该策略,这些发现应趋于零。如果发现没有趋于零,要么是技能没有触发,要么是其文本已经偏离了官方策略。
Hooks as build-time guardrails
将钩子作为构建时的护栏
A skill is an advisory control while a hook is the deterministic layer behind it. Most of Claude's actions are file edits and shell commands during implementation, so the build phase is where hooks can end up firing most often.
技能是建议性控制,而钩子是其背后的确定性层。Claude 的大部分操作都是在实现阶段进行文件编辑和执行 shell 命令,因此构建阶段是钩子触发最频繁的阶段。
Build-phase hooks can:
构建阶段的钩子可以:
- Block edits to protected paths such as generated classes or a frozen package;
- Run the formatter and linter after file edits so drift never accumulates;
- Keep credentials out of the diff.
- 阻止编辑受保护路径,例如生成的类或冻结的包;
- 在文件编辑后运行格式化工具和 linter,以防止偏差积累;
- 将凭证排除在差异之外。
Back any skill whose policy has to hold without exception. A hook runs on each action that matches it, so build-phase hooks should be fast and scoped to the file that changed. Heavier checks such as the full test suite belong at the commit or the PR.
为任何策略必须毫无例外维持的技能提供支持。钩子会在与之匹配的每个操作上运行,因此构建阶段的钩子应该快速且仅限于更改的文件。较重的检查(如完整的测试套件)应放在提交或 PR 阶段。
A hook that asks a human for approval belongs with the gates in Stage 5: Deploy, because an approval prompt during the build puts a person back on the critical path of all the sessions running in parallel.
需要人工批准的钩子属于第 5 阶段:部署中的门禁,因为构建期间的批准提示会将人重新置于所有并行运行会话的关键路径上。
Parallel sessions and subagents
并行会话和子智能体
One engineer can drive several streams of work at once.
一名工程师可以同时推进多个工作流。
A parallel session is another full Claude Code instance, working a separate task in its own git worktree. Each independent session knows nothing about the others, and the engineer steering them is the only thing they share.
并行会话是另一个完整的 Claude Code 实例,在独立的 git worktree 中处理单独的任务。每个独立会话对其他会话一无所知,而引导它们的工程师是它们唯一共享的联系。
A subagent runs inside a single session as a scoped helper with its own context window and tool limits and suits jobs that recur in multiple tasks such as verifying the app runs as expected.
子智能体在单个会话内作为一个具有独立上下文窗口和工具限制的范围受限的助手运行,适合在多个任务中重复出现的工作,例如验证应用是否按预期运行。
Parallel sessions raise the number of tasks an engineer can have in flight, while subagents keep each session focused on its own task. The engineer's job is steering and reviewing all of them.
并行会话增加了工程师可以同时进行的任务数量,而子智能体则使每个会话专注于自己的任务。工程师的工作是引导和审查所有这些任务。
TraditionalOne engineer works one task at a time and spends a significant portion of their day or week on builds, tests and reviewers. Switching between tasks while waiting is possible, but the context switch is tiring enough that few people choose to.
传统模式下,一名工程师一次只处理一个任务,并将一天或一周中很大一部分时间花在构建、测试和审查上。在等待时切换任务是可能的,但上下文切换非常令人疲惫,以至于很少有人会选择这样做。
AI-nativeOne engineer runs several Claude sessions at once, each in its own worktree on its own task. Repeated jobs become subagents with their own context and tool limits. The engineer's job shifts to orchestrating, and eventually, to building and monitoring loops.
AI 原生模式下,一名工程师同时运行多个 Claude 会话,每个会话在独立的 worktree 中处理独立的任务。重复的工作变成了具有独立上下文和工具限制的子智能体。工程师的工作转向编排,并最终转向构建和监控循环。
Getting started
入门指南
Prerequisites
前提条件
The CLAUDE.md, since all sessions read the file. The feedback loop (Stage 4: Test) also helps here, because less supervision from the engineer is needed when a session can verify its own work.
CLAUDE.md,因为所有会话都会读取该文件。反馈循环(第 4 阶段:测试)在这里也有帮助,因为当会话能够验证自身工作时,需要的工程师监督就会减少。
Infrastructure
基础设施
A git repository, since isolation comes from worktrees and permission settings tuned so sessions are not waiting on approval prompts for commands the organization considers safe.
一个 git 代码库,因为隔离来自于 worktree 和调整后的权限设置,以确保会话不会因为组织认为安全的命令而等待批准提示。
How to execute it
如何执行
- The engineer splits the work into tasks that touch different files, using the plan from the plan mode play (Stage 3: Build) to see where the work is independent. Tasks that share files run in a single session, one after another.
- Each parallel task gets its own worktree, for example
claude --worktree feature-authin one terminal andclaude --worktree fix-rate-limitin another. A worktree is a separate checkout on its own branch, which stops sessions colliding on files. - Two or three sessions is a sensible starting point. The practical ceiling is how many streams one person can review properly, so add sessions only while review is keeping up.
- Turn repeated jobs into subagents, as defined in markdown files in
.claude/agents/, each with a name, a description of when to use it, and the tools it may touch. Examples include a code simplifier that strips needless complexity after the main agent finishes, a verifier that runs the app and checks behavior, a researcher that explores the codebase and reports back without flooding the main context. Check the definitions into git so the whole team shares them.
- 工程师将工作拆分为涉及不同文件的任务,使用计划模式实践(第 3 阶段:构建)中的计划来确定哪些工作是独立的。共享文件的任务在单个会话中依次运行。
- 每个并行任务都有自己的 worktree,例如在一个终端中运行
claude --worktree feature-auth,在另一个终端中运行claude --worktree fix-rate-limit。worktree 是一个位于独立分支上的独立检出,这可以防止会话在文件上发生冲突。 - 两到三个会话是一个合理的起点。实际的上限是一个人能够妥善审查多少个工作流,因此只有在审查跟得上的情况下才增加会话。
- 将重复的工作转变为子智能体,定义在
.claude/agents/中的 markdown 文件中,每个都有名称、何时使用的描述以及可以使用的工具。示例包括在主智能体完成后去除不必要复杂性的代码简化器、运行应用并检查行为的验证器、探索代码库并汇报而不会淹没主上下文的研究员。将这些定义提交到 git 中,以便整个团队共享它们。
What it looks like (.claude/agents/verifier.md)
它的样子 (.claude/agents/verifier.md)
---
name: verifier
description: Runs the app and checks the change works before the session
reports done
tools: Bash, Read
---
Start the app with make run. Exercise the changed behavior and the two
nearest neighboring flows. Report what you ran, what you saw, and any
behavior that does not match plan.md. Do not fix anything; report only.
---
name: verifier
description: Runs the app and checks the change works before the session
reports done
tools: Bash, Read
---
Start the app with make run. Exercise the changed behavior and the two
nearest neighboring flows. Report what you ran, what you saw, and any
behavior that does not match plan.md. Do not fix anything; report only.
Governance considerations
治理考量
More sessions means more output, so the controls have to come from configuration in the repo. Hooks and permission settings there apply to all sessions, and what a session does is logged and attributed to the engineer who ran it.
更多的会话意味着更多的输出,因此控制必须来自代码仓库中的配置。钩子和权限设置适用于所有会话,会话的操作会被记录并归属于运行它的工程师。
How to measure it
如何衡量它
Leading indicator
先行指标
Concurrent sessions per engineer while review quality holds, counted from the OpenTelemetry export, and the share of the day spent steering rather than waiting.
在审查质量保持的前提下,每位工程师的并发会话数(从 OpenTelemetry 导出中统计),以及一天中用于引导而非等待的时间占比。
Lagging indicator
滞后指标
Changes merged per engineer per week read alongside the rework rate as determined per the PR history.
每位工程师每周合并的变更数,与根据 PR 历史确定的返工率对照查看。
04
04
Test
测试
Every session checks its own work before a human sees it, and the configuration that steers the agent gets regression-tested like the code it writes.
每个会话在人工查看之前会自行检查其工作,驱动代理的配置会像它编写的代码一样进行回归测试。
Give Claude a feedback loop
给 Claude 一个反馈回路
Always give Claude a way to verify its own work, whether tests, a build, or a screenshot diff. A session checks its own work and fixes its own mistakes before an engineer sees them.
始终给 Claude 一种验证自身工作的方式,无论是测试、构建还是截图对比。会话在工程师看到之前会检查自身的工作并修复自身的错误。
The feedback loop should not be confused with a verifier subagent (Stage 3: Build). The feedback loop runs through the whole task as many times as the work. The verifier subagent, on the other hand, is one way to package the final check by running a fresh context window once the session believes the work is done. This way the verdict is not colored by the assumptions that produced the code.
反馈回路不应与验证子代理(阶段 3:构建)混淆。反馈回路会在整个任务中运行与工作相同的次数。而验证子代理则是一种打包最终检查的方式——当会话认为工作完成时,运行一个全新的上下文窗口。这样,判断就不会被产生代码的假设所影响。
TraditionalThe signal that code works arrives late. CI minutes later, a tester days later, production weeks later. With an agent producing the code, a late signal means a person has to check all of its output, and that person becomes the bottleneck.
传统方式代码可用的信号来得较晚。CI 几分钟后,测试人员几天后,生产环境几周后。当由代理生成代码时,迟来的信号意味着一个人需要检查其所有输出,而这个人就成为瓶颈。
AI-nativeThe session is given a way to check its own work before a person sees it. Run the tests, run the build, take the screenshot. Claude iterates until the check passes, so what reaches the engineer has already passed it. Setting the loop up falls to the engineer running the session, and the steps below are written for them.
AI 原生方式会话获得了一种在人工查看之前检查自身工作的方法。运行测试,运行构建,截图。Claude 会迭代直到检查通过,因此到达工程师手中的内容已经通过了检查。设置这个回路是运行会话的工程师的职责,下面的步骤就是为他们编写的。
Getting started
入门指南
Prerequisites
前提条件
None.
无。
Infrastructure
基础设施
A test suite and a build that run locally with one command each. For the UI work, a way for Claude to see the result is crucial, either a browser tool or a screenshot utility wired in via MCP.
一个测试套件和一个构建,各自通过一条命令在本地运行。对于 UI 工作,让 Claude 看到结果的方式至关重要,可以是通过 MCP 接入的浏览器工具或截图工具。
How to execute it
如何执行它
- If checking the work today takes a sequence of commands and some environment knowledge, wrap it in a single target such as "make test" or "npm test" that exits non-zero on failure.
- In the
CLAUDE.md's Commands section, list each command with an example of a healthy output. - State a target and make it quantifiable so Claude can check the work without asking you, for example: "All tests in test_status.py pass," "the screenshot matches the attached mock," or "the endpoint returns 200 with the new field".
- For bug fixes, write the failing test first. Ask Claude to reproduce the bug as a test, run it, and confirm it fails for the reason you expect. Commit that test. Only then ask Claude to make it pass without editing the test, with the test-file hook from the final step enforcing the restriction. A test that existed before the fix, and that the agent couldn't rewrite, is proof the bug is gone.
- For UI work, close the loop with a visual check. Give Claude a browser or screenshot tool, give it the mock, and let it iterate. Implement, screenshot, compare, and adjust. Two or three rounds is normal, and the result should improve with each one.
- Make verification part of "done." Instruction lives in
CLAUDE.md. Run the tests before reporting a task complete, and show the output. - Finally, the loop itself needs protecting, because an agent fixing code must not be able to weaken the check on that code. A hook that blocks edits to test files during a fix task does this. The alternative is to check the diff in review and reject any change that touches a test.
- 如果如今检查工作需要一系列命令和一些环境知识,将其封装在一个单一目标中,例如 "make test" 或 "npm test",在失败时以非零状态退出。
- 在
CLAUDE.md的 Commands 部分,列出每个命令及其正常输出的示例。 - 说明目标并使其可量化,这样 Claude 就能无需询问你而检查工作,例如:"test_status.py 中的所有测试都通过"、"截图与附带的模拟图匹配",或"端点返回 200 并带有新字段"。
- 对于修复 Bug,先编写失败的测试。要求 Claude 将 Bug 重现为测试,运行它,并确认它因为预期原因而失败。提交该测试。然后再要求 Claude 在不编辑测试的情况下使其通过,用最后一步中的测试文件钩子来强制执行这一限制。修复前就已存在且代理无法重写的测试,就是 Bug 已被消除的证明。
- 对于 UI 工作,用视觉检查闭合回路。给 Claude 一个浏览器或截图工具,给它模拟图,让它迭代。实现、截图、比较、调整。两三轮是正常的,结果应该每一轮都有改善。
- 将验证纳入"完成"的一部分。指令位于
CLAUDE.md中。在报告任务完成之前运行测试,并展示输出。 - 最后,回路本身需要保护,因为修复代码的代理绝不能削弱对该代码的检查。一个在修复任务期间阻止编辑测试文件的钩子可以实现这一点。另一种方法是在审查时检查差异,并拒绝任何涉及测试的更改。
What it looks like (CLAUDE.md verification block)
它的样子(CLAUDE.md 验证块)
## Verifying your work
- Build: make build (must finish with "Build succeeded")
- Test: make test (all green; never skip or delete a failing test)
- Lint: make lint (zero warnings)
Run all three before reporting any task complete, and paste the output.
If a test fails, fix the code, not the test.
## Verifying your work
- Build: make build (must finish with "Build succeeded")
- Test: make test (all green; never skip or delete a failing test)
- Lint: make lint (zero warnings)
Run all three before reporting any task complete, and paste the output.
If a test fails, fix the code, not the test.
Governance considerations
治理考量
What is enforced
强制执行的内容
Verification before a task is reported done, and the block on the agent editing test files during a fix, both implemented as hooks where the organization wants them guaranteed.
在报告任务完成之前进行验证,以及在修复期间阻止代理编辑测试文件,两者都作为钩子实现,用于组织希望得到保证的地方。
What the evidence is
证据是什么
The literal output of "make test," the build log, or the screenshot diff that Claude ran and pasted, so the evidence comes from the toolchain.
"make test" 的字面输出、构建日志或 Claude 运行并粘贴的截图对比,因此证据来自工具链。
Where it is logged
记录在哪里
In the session transcript, which the OpenTelemetry export forwards to the organization's observability stack, and in the PR's check run, where the reviewer and any later auditor can both see it.
在会话记录中,OpenTelemetry 导出会将其转发到组织的可观测性技术栈,以及在 PR 的检查运行中,审查者和任何后续审计者都可以看到它。
Who approves
由谁批准
The code owner reviewing the PR, who can concentrate on intent and risk because the mechanical evidence is already attached.
审查 PR 的代码所有者,由于机械性证据已经附上,他们可以专注于意图和风险。
How to measure it
如何衡量它
Leading indicator
先行指标
First-pass CI success rate for agent-written changes, which the CI system already supports.
代理编写变更的首次 CI 成功率,CI 系统已经支持这一指标。
Lagging indicator
滞后指标
Review time per PR (from the PR metadata), which should fall once the tests catch what reviewers used to catch, and the change failure rate from an incident tracker.
每个 PR 的审查时间(来自 PR 元数据),一旦测试捕获了审查者过去捕获的问题,这个时间应该会下降,以及来自事件追踪器的变更失败率。
Continuous evals in CI
CI 中的持续评估
Evals are the AI-native equivalent of stage-gate QA. In practice that means a suite that runs whenever the agent's configuration changes. When a new model is swapped in or a prompt is rewritten, the eval suite says whether the agent still does the work to the same standard.
评估是阶段关卡 QA 的 AI 原生等价物。在实践中,这意味着一个在代理配置变更时运行的套件。当新模型被替换或提示词被重写时,评估套件会说明代理是否仍以相同标准完成工作。
The evals should be seen as a live suite. As models improve, cases that once discriminated stop doing so and new ones must be added that arise from ongoing monitoring.
评估应被视为一个动态套件。随着模型改进,曾经具有区分能力的案例不再如此,必须根据持续监控添加新的案例。
Depending on the use case, some teams may prefer to run these evals offline on a set cadence rather than on every change. The steps below are for continuous evaluations.
根据使用场景,一些团队可能倾向于按固定节奏离线运行这些评估,而非在每次变更时运行。下面的步骤适用于持续评估。
Getting started
入门指南
Prerequisites
前提条件
The CLAUDE.md and feedback loop (Stage 4: Test).
CLAUDE.md 和反馈回路(阶段 4:测试)。
Infrastructure
基础设施
CI that can run Claude Code non-interactively, and an API key with budget for eval runs.
能够非交互式运行 Claude Code 的 CI,以及用于评估运行的、有预算的 API 密钥。
How to execute it
如何执行它
- The platform engineer collects 20 to 50 real tasks from recent work with its expected/accepted outcome.
- Write each task as an eval, meaning the prompt plus the checks that define acceptable (tests pass, lint clean, behavior unchanged, policy followed).
- The suite runs non-interactively in CI on a schedule and on any change to
CLAUDE.md, skills or hooks, since that configuration steers the agent and deserves the regression testing that code gets. - Gate configuration changes on the results. A skill change that drops the pass rate gets reviewed before it merges.
- Each production incident gets an eval, written by the team that owned the incident, and stays in the suite as a regression test.
- 平台工程师从最近的工作中收集 20 到 50 个真实任务及其预期/可接受的结果。
- 将每个任务编写为一个评估,即提示词加上定义可接受的检查(测试通过、lint 无误、行为不变、遵循策略)。
- 套件在 CI 中按计划并在
CLAUDE.md、技能或钩子的任何变更时非交互式运行,因为该配置驱动代理,理应获得与代码相同的回归测试。 - 根据结果对配置变更设关卡。降低通过率的技能变更在合并前需接受审查。
- 每个生产事件都会由拥有该事件的团队编写一个评估,并作为回归测试保留在套件中。
What it looks like (.github/workflows/agent-evals.yml)
它的样子 (.github/workflows/agent-evals.yml)
name: Agent evals
on:
pull_request:
paths: ['CLAUDE.md', '.claude/**']
schedule:
- cron: '0 2 * * *'
jobs:
evals:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install -g @anthropic-ai/claude-code
- name: Run eval suite
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
for eval in evals/*.json; do
claude -p "$(jq -r '.prompt' $eval)" \
--allowedTools "Read,Edit,Bash(make test)" \
--output-format json > result.json
./evals/check.sh "$eval" result.json
done
name: Agent evals
on:
pull_request:
paths: ['CLAUDE.md', '.claude/**']
schedule:
- cron: '0 2 * * *'
jobs:
evals:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install -g @anthropic-ai/claude-code
- name: Run eval suite
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
for eval in evals/*.json; do
claude -p "$(jq -r '.prompt' $eval)" \
--allowedTools "Read,Edit,Bash(make test)" \
--output-format json > result.json
./evals/check.sh "$eval" result.json
done
Governance considerations
治理考量
Evals give QA a gate that keeps up with agent output. The pass-rate threshold is enforced as a merge check, runs are logged so results can be compared over time, and the team that owns the configuration change approves it.
评估为 QA 提供了一个能跟上代理产出的关卡。通过率阈值作为合并检查来强制执行,运行被记录以便随时间比较结果,拥有配置变更的团队对其进行批准。
How to measure it
如何衡量它
Leading indicator
先行指标
The eval pass rate over time, reported by the suite on every run, and how long a production incident takes to become a permanent eval.
随时间变化的评估通过率,由套件在每次运行时报告,以及一个生产事件成为永久评估需要多长时间。
Lagging indicator
滞后指标
Regressions caught in CI compared with regressions found in production derived from the incident tracker.
在 CI 中捕获的回归与来自事件追踪器的生产中发现的回归相对比。
05
05
Deploy
部署
Review runs in both directions, and governance is enforced as the agent acts. The agent does everything up to the production gate and nothing past it.
审查双向运行,治理在代理行动时强制执行。代理执行到生产关卡之前的所有操作,不越过关卡。
AI in the PR review loop
PR 审查回路中的 AI
Claude both gives and receives reviews. It reviews incoming PRs against the organization's policies and addresses review comments on its own PRs. This allows engineers to focus on behavior in their PR review, which boils down to judging intent and risk.
Claude 既给出审查也接受审查。它根据组织策略审查传入的 PR,并处理自己 PR 上的审查评论。这使得工程师能够专注于 PR 审查中的行为,归结为判断意图和风险。
TraditionalReview capacity was planned around human output. A PR waits for a reviewer to read all of it, review quality varies with the reviewer's load, and the author chases while the backlog grows.
传统方式审查能力围绕人工产出规划。PR 等待审查者阅读全部内容,审查质量随审查者负荷而变化,作者在积压增长时不断催促。
AI-nativeAll PRs get an identical set of review passes, with findings ranked by severity. Human attention moves up a level, to whether the change does what the plan intended and whether the risk is acceptable.
AI 原生方式所有 PR 都获得一套相同的审查流程,发现的问题按严重程度排序。人工注意力上移一个层级,关注变更是否实现了计划意图以及风险是否可接受。
Getting started
入门指南
Prerequisites
前提条件
An updated CLAUDE.md file from Stage 3: Build; skills if the review passes enforce written policies, defined subagents.
来自阶段 3:构建的已更新 CLAUDE.md 文件;如果审查流程强制执行书面策略则需技能,已定义的子代理。
Infrastructure
基础设施
A repo with the Claude integration installed, either the managed Code Review (research preview) service enabled by an admin or the claude-code-action running in your own CI, with model calls through AWS Bedrock, Google Vertex or Microsoft Foundry where needed (the CI/CD play covers the deployment options). Branch protection policies that require a code owner's approval are also worthwhile.
一个安装了 Claude 集成的代码仓库,可以是由管理员启用的托管 Code Review(研究预览)服务,或在你自己的 CI 中运行的 claude-code-action,在需要时通过 AWS Bedrock、Google Vertex 或 Microsoft Foundry 进行模型调用(CI/CD 演练涵盖部署选项)。要求代码所有者批准的分支保护策略也值得采用。
How to execute it
如何执行它
- The managed Code Review service is the fastest start. An admin enables it and selects repositories. Run the review in your own CI with the claude-code-action when you need control of the pipeline or want API calls routed through your own cloud agreement (the CI/CD play covers that plumbing).
- The tech lead writes the review policy as
REVIEW.mdat the repo root, divided into the passes the organization cares about: bugs and logical errors; security and vulnerabilities; compliance against the spec (spec.mdfrom the requirements play), the implementation plan (plan.mdfrom the plan mode play) and design principles.REVIEW.mdalso defines what counts as Important as opposed to a Nit, and what to skip. - The tech lead sets the human threshold. Findings do not approve or block a PR on their own, and branch protection still requires approval from a code owner. A platform engineer who wants to gate merges on findings can read the severity counts that the check run publishes as a machine-readable tally.
- When a reviewer or the author tags
@claudeon a review comment, Claude addresses the comment and pushes the fix. The PR thread records both the request and the change. This fix loop runs through the claude-code-action. In the managed service, commenting@claude reviewrequests a fresh review instead. For PRs Claude opened, go further and let Claude babysit the PR to merge. Teams wrap the loop in a custom slash command that sweeps the unresolved review comments and failing checks on the PR, addresses them and pushes the fixes, until the PR is green and waiting only on code owner approval. - Review findings feed back into
CLAUDE.md. When a review flags a mistake for the second time, the correction goes intoCLAUDE.mdas part of that review, and because review readsCLAUDE.mdthe mistake is caught from the next PR onwards. Review also flags when a change has madeCLAUDE.mdoutdated. - Once a month the tech lead tunes the setup by rating findings so the reviewer improves and by capping Nit volume in
REVIEW.md. Generated paths and anything CI already enforces are excluded.
- 托管的 Code Review 服务是最快的起点。管理员启用它并选择仓库。当你需要控制流水线或希望 API 调用通过你自己的云协议路由时,可以在你自己的 CI 中使用 claude-code-action 运行审查(CI/CD 演练涵盖了这些底层机制)。
- 技术主管在仓库根目录下将审查策略编写为
REVIEW.md,分为组织关心的各个检查阶段:错误和逻辑缺陷;安全和漏洞;针对规范(来自需求演练的spec.md)、实施计划(来自计划模式演练的plan.md)和设计原则的合规性。REVIEW.md还定义了什么是 Important(重要问题)而非 Nit(细微问题),以及跳过什么。 - 技术主管设定人工阈值。审查发现本身不会批准或阻止 PR,且分支保护仍需要代码所有者的批准。希望根据审查发现来控制合并的平台工程师,可以读取 check run 发布的严重程度计数,作为机器可读的统计。
- 当审查者或作者在审查评论中标记
@claude时,Claude 会处理评论并推送修复。PR 线程记录了请求和更改。这个修复循环通过 claude-code-action 运行。在托管服务中,评论@claude review则是请求一次新的审查。对于 Claude 开启的 PR,可以更进一步,让 Claude 监管 PR 直到合并。团队将循环封装在一个自定义斜杠命令中,该命令会扫描 PR 上未解决的审查评论和失败的检查,处理它们并推送修复,直到 PR 变绿且仅等待代码所有者的批准。 - 审查发现会反馈到
CLAUDE.md中。当审查第二次标记某个错误时,纠正措施会作为该审查的一部分写入CLAUDE.md,并且由于审查会读取CLAUDE.md,从下一个 PR 开始就会捕获到该错误。当更改导致CLAUDE.md过时,审查也会发出标记。 - 技术主管每月一次通过对发现进行评级来调整设置,以便审查者改进,并通过在
REVIEW.md中限制 Nit 的数量。生成的路径和 CI 已经强制执行的任何内容都被排除在外。
What it looks like (REVIEW.md)
它看起来是什么样 (REVIEW.md)
# Review instructions
## Passes
Run three passes and tag each finding with its pass:
- Bugs: logic errors, broken edge cases, subtle regressions
- Security: injection risks, authentication gaps, PII in logs
- Compliance: the change matches spec.md, plan.md and our design principles
## What Important means here
Reserve Important for findings that would break behavior, leak data
or breach a policy. Style and naming are nits.
## Cap the nits
Report at most five nits per review; summarize the rest as a count.
## Do not report
Generated files under src/gen/ and anything CI already enforces.
# Review instructions
## Passes
Run three passes and tag each finding with its pass:
- Bugs: logic errors, broken edge cases, subtle regressions
- Security: injection risks, authentication gaps, PII in logs
- Compliance: the change matches spec.md, plan.md and our design principles
## What Important means here
Reserve Important for findings that would break behavior, leak data
or breach a policy. Style and naming are nits.
## Cap the nits
Report at most five nits per review; summarize the rest as a count.
## Do not report
Generated files under src/gen/ and anything CI already enforces.
Governance considerations
治理考量
Separation of duties is preserved, because the agent that wrote the code has no way to approve it. The review policy in REVIEW.md is applied to all PRs, and findings, fixes, ratings and approvals are logged in the PR history, so the PR is the audit record. Approval comes from a human through branch protection, informed by the findings.
职责分离得到了保留,因为编写代码的代理无法批准它。REVIEW.md 中的审查策略应用于所有 PR,并且发现、修复、评级和批准都记录在 PR 历史中,因此 PR 就是审计记录。批准来自人类通过分支保护进行的,并受到审查发现的信息支持。
For how these controls compose at production scale, see securing an AI-native SDLC at Anthropic.
有关这些控制如何在生产规模上组合的详细信息,请参阅在 Anthropic 保护 AI 原生 SDLC。
How to measure it
如何衡量它
Leading indicator
领先指标
Time to first review, which should fall to minutes, and the share of review comments resolved without a human touching the branch with data stored directly on Git.
首次审查的时间,这应该降至几分钟,以及在没有人类干预分支的情况下解决的审查评论比例,数据直接存储在 Git 上。
Lagging indicator
滞后指标
Defects and vulnerabilities caught before merge set against those escaping to production, from the PR history and the incident tracker.
合并前捕获的缺陷和漏洞与逃逸到生产环境的缺陷和漏洞的对比,数据来自 PR 历史和事件追踪器。
Hooks as approval gates
作为批准门的 Hooks
The build phase used hooks as guardrails, allowing or blocking actions with no human involved (Stage 3: Build). A hook can also ask, pausing the action until a specific person approves, which is what release gating needs.
构建阶段使用 hooks 作为护栏,在没有人类参与的情况下允许或阻止操作(阶段 3:构建)。Hook 也可以请求,暂停操作直到特定人员批准,这正是发布门控所需要的。
The play sits in Stage 5: Deploy because the release gate is the clearest case, but hooks are not deploy-specific: they run wherever Claude acts. For example, hooks can block edits to migrations and infra without a change ticket during Stage 3: Build, and stop the agent editing test files during a fix task in Stage 4: Test.
本演练位于阶段 5:部署,因为发布门是最清晰的情况,但 hooks 并不是部署特有的:它们在 Claude 行动的任何地方运行。例如,hooks 可以在阶段 3:构建期间阻止在没有变更单的情况下编辑迁移和基础设施,并在阶段 4:测试的修复任务期间停止代理编辑测试文件。
Getting started
入门
Prerequisites
先决条件
None.
无。
Infrastructure
基础设施
A written list of the approvals the change process requires.
变更过程所需批准的书面列表。
How to execute it
如何执行它
- Engineering leadership, with change management and compliance, lists the human approval gates that must survive, such as change management sign-off, release authorization, and edits to protected paths.
- The platform engineer expresses each gate as a hook, a script that runs before Claude acts that can allow, ask, or block.
- Team hooks go in
.claude/settings.jsonin git, and non-negotiable hooks go in managed settings owned by the platform or IT admin, where individual engineers cannot switch them off. - A block should explain itself, so when a hook stops an action the reason and the route to approval appear in Claude's output.
- 工程领导层与变更管理和合规部门一起,列出必须保留的人工批准门,例如变更管理签核、发布授权和对受保护路径的编辑。
- 平台工程师将每个门表达为一个 hook,一个在 Claude 行动之前运行的脚本,可以允许、请求或阻止。
- 团队 hooks 放在 git 中的
.claude/settings.json中,而不可协商的 hooks 放在由平台或 IT 管理员拥有的托管设置中,个人工程师无法关闭它们。 - 阻止应该解释自身原因,因此当 hook 停止操作时,原因和批准途径会出现在 Claude 的输出中。
What it looks like (.claude/settings.json)
它看起来是什么样 (.claude/settings.json)
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/production-gate.sh" }
]
}
]
}
}
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/production-gate.sh" }
]
}
]
}
}
And the gate itself (.claude/hooks/production-gate.sh)
以及门本身 (.claude/hooks/production-gate.sh)
#!/bin/bash
# Production deploys require a named release authorization
cmd=$(jq -r '.tool_input.command' < /dev/stdin)
if [[ "$cmd" == *"deploy"* && "$cmd" == *"production"* ]]; then
if [ -z "$RELEASE_APPROVAL" ]; then
echo "Production deploys need a release authorization." >&2
exit 2 # exit 2 blocks the action; the message goes to Claude
fi
fi
exit 0
#!/bin/bash
# Production deploys require a named release authorization
cmd=$(jq -r '.tool_input.command' < /dev/stdin)
if [[ "$cmd" == *"deploy"* && "$cmd" == *"production"* ]]; then
if [ -z "$RELEASE_APPROVAL" ]; then
echo "Production deploys need a release authorization." >&2
exit 2 # exit 2 blocks the action; the message goes to Claude
fi
fi
exit 0
Governance considerations
治理考量
Hooks are the approval gates. The gate condition is enforced every time, for everyone. Allow and block decisions are logged with a timestamp. The gate also defines what counts as approval, whether that's an approved change ticket or the release manager's sign-off.
Hooks 是批准门。门条件每次都对每个人强制执行。允许和阻止的决定会带有时间戳记录。门还定义了什么算作批准,无论是已批准的变更单还是发布经理的签核。
Worked example
实战案例
Managed settings for a regulated enterprise
受监管企业的托管设置
Deployed by the platform team via MDM or the admin console; engineers cannot edit or override any of it.
由平台团队通过 MDM 或管理控制台部署;工程师无法编辑或覆盖其中的任何内容。
{ "permissions": { "deny": [ "Read(.env*)", "Read(./secrets/**)", "WebFetch", "Bash(curl *)", "Bash(wget *)" ], "allow": [ "Bash(git *)", "Bash(make build)", "Bash(make test)", "Bash(make lint)" ], "disableBypassPermissionsMode": "disable" }, "allowManagedPermissionRulesOnly": true, "sandbox": { "enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "network": { "allowedDomains": ["git.internal.example.com", "registry.npmjs.org"] }, "credentials": { "files": [ { "path": "/.ssh", "mode": "deny" }, { "path": "/.aws/credentials", "mode": "deny" } ], "envVars": [ { "name": "GITHUB_TOKEN", "mode": "deny" } ] } }, "allowManagedHooksOnly": true, "disableSideloadFlags": true, "allowManagedMcpServersOnly": true, "strictKnownMarketplaces": [ { "source": "github", "repo": "example-corp/approved-plugins" } ], "requiredMinimumVersion": "2.1.193" }
{ "permissions": { "deny": [ "Read(.env*)", "Read(./secrets/**)", "WebFetch", "Bash(curl *)", "Bash(wget *)" ], "allow": [ "Bash(git *)", "Bash(make build)", "Bash(make test)", "Bash(make lint)" ], "disableBypassPermissionsMode": "disable" }, "allowManagedPermissionRulesOnly": true, "sandbox": { "enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "network": { "allowedDomains": ["git.internal.example.com", "registry.npmjs.org"] }, "credentials": { "files": [ { "path": "/.ssh", "mode": "deny" }, { "path": "/.aws/credentials", "mode": "deny" } ], "envVars": [ { "name": "GITHUB_TOKEN", "mode": "deny" } ] } }, "allowManagedHooksOnly": true, "disableSideloadFlags": true, "allowManagedMcpServersOnly": true, "strictKnownMarketplaces": [ { "source": "github", "repo": "example-corp/approved-plugins" } ], "requiredMinimumVersion": "2.1.193" }
What each line buys, in control terms
从控制角度来看,每一行能带来什么
permissions.deny keeps secrets out of the agent's context and blocks arbitrary network egress through tools; permissions.allow pre-approves the safe inner loop so the deny list doesn't turn into prompt fatigue.
permissions.deny 将密钥排除在代理的上下文之外,并阻止通过工具进行任意网络出口;permissions.allow 预先批准安全的内部循环,这样拒绝列表就不会变成提示疲劳。
disableBypassPermissionsMode plus allowManagedPermissionRulesOnly means no engineer, project file or command-line flag can widen the rules.
disableBypassPermissionsMode 加上 allowManagedPermissionRulesOnly 意味着没有工程师、项目文件或命令行标志可以放宽规则。
sandbox closes the gap permissions cannot. A tool-level deny on WebFetch doesn't stop a shell command reaching the network; the OS-level domain allowlist blocks egress outright.
sandbox 弥补了权限无法弥补的差距。WebFetch 上的工具级拒绝并不能阻止 shell 命令访问网络;操作系统级的域名允许列表直接阻止了网络出口。
failIfUnavailable and allowUnsandboxedCommands make the sandbox a gate: Claude Code refuses to start when the sandbox cannot initialize, and a command that fails inside the sandbox cannot be retried outside it.
failIfUnavailable 和 allowUnsandboxedCommands 使沙盒成为一个门:当沙盒无法初始化时,Claude Code 拒绝启动,并且在沙盒内失败的命令不能在其外部重试。
credentials closes the gap the deny rules leave open. permissions.deny governs Claude's file tools, but a sandboxed shell command could still read ~/.ssh or ~/.aws/credentials by default; this block denies those reads and strips the named secrets from the environment of every sandboxed command.
credentials 弥补了拒绝规则留下的空白。permissions.deny 管理 Claude 的文件工具,但沙盒化的 shell 命令默认情况下仍可以读取 ~/.ssh 或 ~/.aws/credentials;此块拒绝这些读取,并从每个沙盒化命令的环境中剥离指定的密钥。
allowManagedHooksOnly means the approval gates from this play are the only hooks that run; nothing local can add to or replace them.
allowManagedHooksOnly 意味着本演练中的批准门是唯一运行的 hooks;本地没有任何东西可以添加或替换它们。
disableSideloadFlags and strictKnownMarketplaces mean every skill, agent, hook and MCP server on an engineer's machine arrived through the organization's approved plugin marketplace, never from a home directory.
disableSideloadFlags 和 strictKnownMarketplaces 意味着工程师机器上的每个技能、代理、hook 和 MCP 服务器都是通过组织批准的插件市场到达的,绝不是来自主目录。
allowManagedMcpServersOnly makes the agent's tool surface an allowlist owned by the platform team.
allowManagedMcpServersOnly 使代理的工具表面成为由平台团队拥有的允许列表。
requiredMinimumVersion refuses to start on a version below the approved floor, so the controls are enforced by a build the organization has actually assessed.
requiredMinimumVersion 拒绝在低于批准底线的版本上启动,因此控制由组织实际评估过的构建来强制执行。
Consider the above a starting point to tailor, rather than a recommendation to copy. Every deny trades against capability, and the right balance depends on the data classification of the repo. The settings reference documents every key, including the managed-only ones: code.claude.com/docs/en/settings
将上述内容视为定制的起点,而不是复制的建议。每一次拒绝都会与能力进行权衡,正确的平衡取决于仓库的数据分类。设置参考文档记录了每个键,包括仅托管键:code.claude.com/docs/en/settings
How to measure it (for the hooks themselves)
如何衡量它(对于 hooks 本身)
Leading indicator
领先指标
Time spent waiting on each approval gate. Every hook decision is written to the OpenTelemetry export with a timestamp and an allow or block verdict, so the wait is visible per gate.
在每个批准门上等待花费的时间。每个 hook 决定都会带时间戳和允许或阻止的判定写入 OpenTelemetry 导出,因此每个门的等待时间都是可见的。
Lagging indicator
滞后指标
Gate violations reaching production before and after hooks from the incident tracker.
门违规到达生产环境的情况在 hooks 实施前后的对比,数据来自事件追踪器。
CI/CD integration and deployment
CI/CD 集成与部署
Run Claude Code non-interactively inside the CI/CD pipeline, sandbox the execution so long-running agents run safely, expose deployment through MCP integrations, and rehearse the rollback paths before the agent ever needs them.
在 CI/CD 流水线内以非交互方式运行 Claude Code,对执行进行沙盒化以便长时间运行的代理安全运行,通过 MCP 集成公开部署,并在代理需要之前排练回滚路径。
TraditionalPipelines run deterministic scripts, and anything that needs judgment waits for a human. For example, triaging the flaky test, writing the changelog, or working out why the build broke. Deployment and rollback are runbooks a human follows under pressure.
传统:流水线运行确定性脚本,任何需要判断的事情都等待人类。例如,分类不稳定的测试、编写变更日志,或弄清楚构建为什么中断。部署和回滚是人类在压力下遵循的运维手册。
AI-nativeClaude runs non-interactively inside the pipeline for the judgment steps, in a sandbox with scoped credentials. Deployment tooling is exposed to the agent through MCP, so the workflow that wrote and tested the change can also ship it and roll it back, inside gates the organization defines per environment.
AI 原生:Claude 在流水线内非交互地运行判断步骤,位于具有范围凭据的沙盒中。部署工具通过 MCP 暴露给代理,因此编写和测试更改的工作流也可以发布它并将其回滚,在组织为每个环境定义的门内。
Getting started
入门
Prerequisites
先决条件
Claude in the PR review loop and hooks as approval gates, because the gates must exist before automation accelerates anything through them.
PR 审查循环中的 Claude 和作为批准门的 hooks,因为在自动化加速通过它们之前,门必须存在。
Infrastructure
基础设施
A CI platform with the claude-code-action installed, or any runner that can call claude -p; model access through the API, or Bedrock, Foundry, or Vertex where traffic must stay on the organization's cloud agreement; MCP servers for the deployment targets; a sandbox profile for agent jobs with no standing production credentials.
安装了 claude-code-action 的 CI 平台,或任何可以调用 claude -p 的运行器;通过 API 进行模型访问,或者在流量必须保留在组织云协议上的情况下通过 Bedrock、Foundry 或 Vertex;用于部署目标的 MCP 服务器;具有无常设生产凭据的代理作业沙盒配置文件。
How to execute it
如何执行它
- The platform engineer starts with read-only judgment steps. Use
claude -pin a pipeline job to triage a failed build, summarize a flaky test, or draft the changelog. - Add write steps behind the existing gates for jobs like fixing lint, updating generated docs, or addressing review comments via the
@claudementions. Anything the agent writes arrives as a PR through branch protection, and the agent has no route to push to main. - Execution is sandboxed. Agent jobs run in containers under a network policy with short-lived scoped tokens, and hold no production credentials by default.
- Expose deployment through MCP. Deploy, status, and rollback become tools, scoped per environment, so the agent's deployment powers are an allowlist rather than a shell script with credentials.
- Tier the autonomy by environment. In development, the agent deploys freely. In production, the agent prepares the release and the release manager authorizes it, and a hook enforces the production gate. Staging sits somewhere in the middle.
- Rollback should be the most rehearsed path in the pipeline, a single command that the agent can run and that is exercised regularly in staging. The closing the loop play (Stage 6: Maintenance) calls this rollback when a control band is breached, so it has to be proven in advance.
- 平台工程师从只读判断步骤开始。在管道作业中使用
claude -p来分诊失败的构建、总结不稳定测试,或起草变更日志。 - 在现有门禁之后添加写入步骤,用于修复 lint、更新生成的文档或通过
@claude提及处理审查意见等作业。代理写入的任何内容都通过分支保护以 PR 形式到达,代理没有直接推送到 main 的路径。 - 执行在沙箱中进行。代理作业在容器中运行,受网络策略保护,使用短期的受限令牌,默认不持有生产凭据。
- 通过 MCP 暴露部署。部署、状态和回滚成为工具,按环境划分范围,因此代理的部署权限是一个白名单,而不是带有凭据的 shell 脚本。
- 按环境划分自主权限层级。在开发环境中,代理自由部署。在生产环境中,代理准备发布,由发布经理授权,且钩子强制执行生产门禁。预发布环境介于两者之间。
- 回滚应是管道中最常演练的路径,一条代理可以运行的单一命令,并在预发布环境中定期演练。闭环策略(第6阶段:维护)在控制带被突破时调用此回滚,因此必须提前验证。
What it looks like (pipeline step)
它看起来什么样(管道步骤)
- name: Triage failed build
if: failure()
run: >
claude -p "Read the build log at out/build.log. Identify the most
likely cause, say whether the failure looks flaky or real, and write a
three-line summary for the PR thread." >> triage.md
- name: Triage failed build
if: failure()
run: >
claude -p "Read the build log at out/build.log. Identify the most
likely cause, say whether the failure looks flaky or real, and write a
three-line summary for the PR thread." >> triage.md
Governance considerations
治理考量
The governing principle is that the agent may act up to the production gate and cannot pass it. The controls below enforce this principle.
核心原则是代理可以行动到生产门禁,但不能通过它。以下控制措施强制执行此原则。
- Branch protection turns anything the agent writes into a PR, with no direct path to main.
- The production deploy hook blocks the release until a named release manager authorizes it. Each non-interactive run acts under the agent's own identity, so the pipeline log separates what the agent did from what the engineer who triggered it did.
- Per-environment permission tiers set how much the agent may do on the way to the gate.
- 分支保护将代理写入的任何内容变为 PR,没有直接到 main 的路径。
- 生产部署钩子在指定的发布经理授权之前阻止发布。每次非交互式运行都在代理自己的身份下执行,因此管道日志将代理所做的工作与触发它的工程师所做的工作区分开来。
- 按环境划分的权限层级设定了代理在到达门禁之前可以执行多少操作。
How to measure it
如何衡量
Leading indicator
领先指标
The share of pipeline failures triaged without paging a human taken from the CI/CD pipeline logs.
无需人工介入即可分诊的管道失败占比,数据取自 CI/CD 管道日志。
Lagging indicator
滞后指标
DevOps Research and Assessment (DORA) measures, which the CI system and deployment tooling already emit.
DevOps 研究与评估(DORA)指标,由 CI 系统和部署工具已经输出。
06
06
Maintain
维护
The loop closes. A trigger invokes Claude with no person in the invocation path, and what it finds re-enters the pipeline as intent.md.
闭环完成。一个触发器在调用路径中无人参与的情况下调用 Claude,它发现的内容以 intent.md 形式重新进入管道。
Maintenance and closing the loop
维护与闭环
So far, we've discussed how to add Claude to each stage of the SDLC process, with each stage requiring a human to launch the initial steps. This stage, however, shifts the focus to autonomous running of Claude to close the loop.
到目前为止,我们已经讨论了如何在 SDLC 流程的每个阶段添加 Claude,每个阶段都需要人工来启动初始步骤。然而,这个阶段将重点转向 Claude 的自主运行以实现闭环。
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: Maintenance 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.
例如,一个持续运行的监控代理可以在缺陷工单提交后,创建一个 intent.md,并流经需求、规划、构建测试和审查阶段。第6阶段:维护以无头模式运行,阶段之间设有独立的置信度门禁,一个确定性检查或一个对抗性审查代理决定前一阶段的输出是继续还是升级到人工处理。
TraditionalMaintenance is a reactive phase. All tickets or incidents wait on a person to act on it 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.
传统维护是一个被动阶段。所有工单或事件都等待人工采取行动并重新启动流程。警报可能在凌晨3点触发而被遗漏,工单可能停留在积压队列中直到有人处理,复盘行动可能根本无法到达代码库——如果另一个火情先爆发的话。
AI-nativeA 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.
AI 原生方式下,触发器(如控制带突破、工单、频道消息或计划)在调用路径中无人参与的情况下调用 Claude。Claude 进行诊断,仅通过门控路径行动,并将其发现写入 intent.md,随后经过上述各阶段。人们分诊和审查这些工作,不再需要启动它。
Closing the loop
闭环
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.
一个确定性脚本监控生产环境,在控制带被突破时调用 Claude。监控突破是闭环自主运行模式的一个有益示例,而本阶段末尾的 Claude Tag(公开测试版)部分涵盖了通过不同渠道到达的工作。
Getting started
入门指南
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).
Intent.md 为闭环提供了重新启动的结构化输出。Claude 加速了 PR 审查,钩子作为行动边界,以及 CI/CD 的回滚路径(由最高自主权层级调用)。
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.
检测脚本可查询的指标存储(Prometheus、CI 系统的 API 或等效物),对仓库的读取访问,在 CI 中非交互运行 Claude Code 的方式,或用于接收 webhook 服务的 Agent SDK。
How to execute it
如何执行
- 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.
- 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.
- Response tiers are defined in version-controlled config (
bands.yamlbelow). 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. - 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.
- The agent writes its diagnosis as
intent.mdin 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. - 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.
- When a fix ships, add an eval for the incident (the continuous evals play) to ensure that such issues are protected against going forwards.
- 服务所有者或平台工程师选择一个具有稳定滚动基线的指标,例如 CI 测试失败率、部署后 5xx 率或 PR 周期时间。
- 他们编写检测脚本,通常是在滚动窗口上计算均值和标准差,并配合规则(Western Electric 或类似规则),使得控制带既能捕捉缓慢漂移也能捕捉突增。脚本经过版本控制和单元测试,检测完全保持确定性,不涉及任何模型。
- 响应层级在版本控制的配置中定义(下方的
bands.yaml)。在 1σ 时脚本仅记录日志,在 2σ 时调用 Claude 只读诊断,在 3σ 时 Claude 可以行动,但只能通过向审查门禁提交 PR 或触发预批准的运行手册。 - 触发层可以是 GitHub 或 GitLab 中的计划工作流、来自现有监控栈的 webhook,或网络内的 Cron 作业。Claude 以无状态方式运行,作为 CI 运行器上的非交互步骤或沙箱容器中的 Agent SDK 服务,CI/CD 策略涵盖了部署和模型访问选项。由于运行是无状态且非交互的,一个循环可以在没有人启动的情况下开始和结束。
- 代理将其诊断以第1阶段:规划的格式写入
intent.md,涵盖异常及其证据、提议的结果、受影响的系统和任何未决问题。从那里,发现像其他任何内容一样经过管道。 - 服务所有者或值班工程师分诊队列,将面向产品的发现路由给产品所有者。立即修复、安排或驳回。驳回会调整控制带并帮助减少噪音。
- 当修复发布时,为事件添加一个评估(持续评估策略),以确保此类问题在未来得到防护。
What it looks like (for example, a bands.yaml monitoring CI test failure rate)
它看起来什么样(例如,监控 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] }
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] }
Governance considerations
治理考量
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.
层级边界由版本控制配置强制执行,权限和托管设置拒绝生产访问。调用、发现和分诊决策都带有时间戳记录。服务所有者分诊和批准发现,由此产生的变更通过正常的 PR 审查门禁,代理可能触发的运行手册已提前获得批准。
How to measure it
如何衡量
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.
从控制带突破到分诊队列中出现 intent.md 的时间,对比从事件到复盘行动的旧时间。检测脚本的日志包含突破时间戳和事件层级。
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.
成为已合并修复的发现占比(分诊队列对比实际 PR 历史),以及同类事件的重复率,后者应随着修复将案例添加到评估套件中而下降。
Examples
示例
- 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.
- 当 CI 测试失败率突破 3σ 时,代理隔离不稳定测试或提交回滚 PR,由审查门禁决定。
- 当部署后 5xx 率在窗口内有部署时突破 3σ 时,代理触发现有的回滚管道。
- 当 PR 周期时间触发漂移规则时,代理为工程领导层编写报告,表明该框架适用于流程指标以及生产指标。
Detection stays deterministic. Claude is invoked once a band is breached, and the tier sets what it may do.
检测保持确定性。Claude 在控制带被突破时被调用,层级设定了它可以做什么。
Recurring codebase scans
定期代码库扫描
A security scan is a point-in-time statement about a codebase under a particular model, and both halves go stale: the code changes every week, and each model generation finds vulnerabilities the previous one missed. The AI-native answer is to run the scan on a schedule, without a human in the invocation path, and to send what it finds through the same gates as any other change to the codebase.
安全扫描是在特定模型下对代码库的某个时间点声明,两半都会过时:代码每周都在变化,每一代模型都会发现上一代遗漏的漏洞。AI 原生的答案是按计划运行扫描,在调用路径中不包含人工,并将发现的内容通过与代码库任何其他变更相同的门禁。
Claude Security is the hosted form of scheduled scanning. Connect a GitHub repository, and scans run on Claude Mythos 5 in Anthropic's infrastructure, with each finding validated before it is reported and a confidence rating attached. Suggested patches are reviewed and applied in Claude Code on the web. The organization gets the findings without needing access to the model itself.
Claude Security 是计划扫描的托管形式。连接一个 GitHub 仓库,扫描在 Anthropic 基础设施上的 Claude Mythos 5 上运行,每个发现在报告前都经过验证并附带置信度评级。建议的补丁在 Claude Code 网页版中审查和应用。组织无需直接访问模型即可获得发现。
TraditionalSecurity scanning is an event with a scan launched before a release or an audit. The report goes to a tracker, and the backlog is worked down by hand until the next event. Code written in between is covered by whatever the PR review caught.
传统安全扫描是一个在发布或审计前启动扫描的事件。报告发送到跟踪器,积压项由人工处理直到下一次事件。在此期间编写的代码仅由 PR 审查所捕获的内容覆盖。
AI-nativeScans run on a schedule against every connected repository, on the most capable model available, with findings validated before anyone reads them. Each finding is handled the way a breached control band is: a fix that fits in one PR goes through the review gate, and anything larger becomes an intent.md. Coverage is dated from the last run, not from the first
AI 原生方式下,扫描按计划对每个已连接的仓库运行,使用最强大的可用模型,发现在任何人阅读之前都经过验证。每个发现的处理方式与突破控制带相同:适合一个 PR 的修复通过审查门禁,更大的内容则成为 intent.md。覆盖范围从最近一次运行算起,而非第一次。
Getting started
入门指南
Prerequisites
先决条件
The PR review gate and hooks as approval gates (Stage 5: Deploy), so that findings go through review like any other change. The intent.md format from Stage 1: Plan for findings too large for a single PR.
Infrastructure
基础设施
Claude Security is available to Claude Enterprise organizations in public beta. It needs the Anthropic GitHub App installed on the target repositories (cloud-hosted github.com), Claude Code on the Web enabled, Extra Usage turned on with a spend limit set, premium seats for the people who run scans, and the feature switched on by an admin at claude.ai/admin-settings/claude-code. Scans are billed on consumption at Mythos 5 rates, so the spend limit should match the size and number of repositories.
Claude Security 已在公开测试阶段向 Claude Enterprise 组织提供。它需要在目标仓库(云托管的 github.com)上安装 Anthropic GitHub App,启用 Claude Code on the Web,开启 Extra Usage 并设置支出限额,为运行扫描的人员提供高级席位,以及由管理员在 claude.ai/admin-settings/claude-code 开启该功能。扫描按 Mythos 5 费率根据消耗计费,因此支出限额应与仓库的规模和数量相匹配。
How to execute it
如何执行它
- The security lead connects the repositories and organizes them into projects by repo, service, or team, so ownership of findings is clear from the start.
- Run a first full scan of the most critical repositories, including ones that have been scanned before by other tools or by earlier models. Treat the first scan as the baseline. The first scan will likely surface findings in code that was considered clean.
- Set a schedule per project. Weekly is a sensible default for actively developed services; scope scans to a directory or branch where a repository is large or mixed.
- Triage findings with the confidence rating in hand. Dismiss with a reason, so the dismissal is recorded and the same finding does not return as new on the next run.
- For a bounded finding, open the suggested patch in Claude Code on the Web, review it, and send it through the PR review gate like any other change. The agent that proposed the fix has no route to approve it.
- For anything wider than one patch, such as an architectural weakness or a pattern repeated across services, write it up as
intent.mdin the Stage 1 format and start it at Plan. - When a fix is released to production, add an eval for the vulnerability class to the suite from the continuous evals play, so the configuration that steers the agent is tested against that class from then on.
- Export findings as CSV or Markdown, or use webhooks, to keep the organization's existing tracker and audit systems as the system of record where auditors already expect them.
- 安全主管连接这些仓库,并按仓库、服务或团队将它们组织成项目,以便从一开始就明确发现的责任归属。
- 对最关键的仓库运行首次全面扫描,包括那些以前曾由其他工具或早期模型扫描过的仓库。将首次扫描视为基线。首次扫描可能会在曾被视为干净的代码中浮现出问题。
- 为每个项目设定时间表。对于活跃开发的服务,每周是一个合理的默认设置;当仓库较大或混合时,可将扫描范围限定到特定目录或分支。
- 借助置信度评级对发现进行分诊。关闭并附上理由,以便记录该关闭操作,且相同的发现不会在下一次运行中作为新发现再次出现。
- 对于范围明确的发现,在 Claude Code on the Web 中打开建议的补丁,对其进行审查,并像任何其他更改一样将其送入 PR 审查门禁。提出修复建议的代理没有途径批准该修复。
- 对于范围超出单个补丁的问题,例如架构缺陷或跨服务重复出现的模式,以 Stage 1 格式将其编写为
intent.md,并从 Plan 阶段开始。 - 当修复发布到生产环境时,将针对该漏洞类别的评估添加到持续评估剧本的套件中,以便从那时起,引导代理的配置将针对该类别进行测试。
- 将发现导出为 CSV 或 Markdown,或使用 webhooks,以将组织现有的跟踪器和审计系统作为审计人员已经期望的系统记录源。
Governance considerations
治理考量
The scan runs under the organization's admin controls meaning what repositories are connected, who holds a scan seat, and the spend limit are all set centrally. Every finding has a validation result and a confidence rating, and every dismissal has a reason, so the scan history is an audit record of what was found, fixed, and consciously accepted.
扫描在组织的管理员控制项下运行,这意味着连接哪些仓库、谁持有扫描席位以及支出限额都是在中心位置设置的。每个发现都有验证结果和置信度评级,每次关闭都有其原因,因此扫描历史是一份审计记录,记录了什么被发现、被修复以及被有意接受的内容。
Fixes reach production through the PR review gate and branch protection rather than from the scan itself. Claude Security augments existing static analysis and dependency scanning. The deterministic checks stay in CI, and the model-driven scan covers the context-dependent vulnerabilities those checks are not built to find.
修复通过 PR 审查门禁和分支保护到达生产环境,而不是源自扫描本身。Claude Security 增强了现有的静态分析和依赖扫描。确定性检查保留在 CI 中,而模型驱动的扫描涵盖了那些检查机制未被设计用于发现的上下文相关漏洞。
How to measure it
如何衡量它
Leading indicator
领先指标
Share of connected repositories on a schedule, and time from a finding being reported to its patch entering the PR review gate, read from the scan history and the PR metadata.
按计划安排的已连接仓库份额,以及从发现报告到其补丁进入 PR 审查门禁的时间,均可从扫描历史和 PR 元数据中读取。
Lagging indicator
滞后指标
Vulnerabilities found by the scheduled scan set against those found in production or by external report, from the incident tracker; and the trend in findings per scan on repositories that have been through several runs, which should fall as fixes and evals accumulate.
将计划扫描发现的漏洞与生产环境中或通过外部报告发现的漏洞(来自事件跟踪器)进行对比;以及经历过多次运行的仓库在每次扫描中发现问题的趋势,该趋势应随着修复和评估的积累而下降。
Claude on call with Claude Tag
使用 Claude Tag 进行 Claude 值班
Incidents can also arrive via other means such as workplace communication apps, like Slack or Teams. Incidents can look like a 10pm 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.
事件也可能通过其他途径到达,例如职场通讯应用,如 Slack 或 Teams。事件可能表现为晚上 10 点在事件频道中要求紧急修复的 Slack 消息,现在可以立即采取行动。Claude Tag(目前在 Slack 中处于公开测试阶段)使 Claude 以其自身的身份成为这些频道的成员,因此每个新事件都会有一名第一响应者,且响应本身成为未来事件循环及记忆的一部分。
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, writes the post-mortem to a version-controlled lessons file that future investigations can read.
对话和机构知识保留在频道中,频道中的任何人都可以引导并对响应采取行动。任何团队成员都可以测试假设、探索新选项并进行实时调查,同时频道历史记录增加了可审计性。通过访问 MCP,Claude 验证指标已恢复到基线并在话题中予以确认,将事后复盘写入受版本控制的教训文件中,以供未来的调查读取。
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. See: how Claude Tag runs on-call for CI/CD at Anthropic.
事件并不是 Claude Tag 承担的唯一工作。通过 MCP 在工单上被标记或在频道中被询问时,Claude 会以相同的方式对工作进行分诊。一个小巧且边界清晰的修复会作为 PR 通过审查门禁到达,而任何更大的工作都会被编写为 intent.md 用于 Stage 1: Plan,此时循环便开始自我驱动。参见:Claude Tag 如何在 Anthropic 为 CI/CD 值班。


The channel is the audit trail: request, diagnosis, human authorization and fix all stay where the incident was handled.
频道就是审计跟踪:请求、诊断、人员授权和修复都保留在处理事件的地方。
Closing thoughts
结束语
Models and harnesses have become more advanced, allowing organizations to not just transform how they produce code, but the entire software development lifecycle.
模型和配套框架变得更加先进,使得组织不仅能够改变他们生产代码的方式,还能改变整个软件开发生命周期。
This transformation keeps human judgement central to the process and considers the governance and regulation requirements of large enterprise organizations.
这种转变将人类的判断力置于流程的核心,并考虑了大型企业组织的治理和监管要求。
This guide consolidated many of the real best practices our Applied AI team executes on a daily basis for our customers, and we hope you found it a practical and actionable resource.
本指南整合了我们的 Applied AI 团队每天为客户执行的许多真实最佳实践,我们希望您发现它是一份实用且具有可操作性的资源。
The loop keeps running. Human judgement stays above it.
循环持续运行。人类的判断力始终凌驾于其上。
Resources and acknowledgments
资源与致谢
The documentation below is what a platform team needs to set those controls up, in roughly the order you would roll them out.
以下文档是平台团队设置这些控制措施所需的,顺序大致为您推出它们的顺序。
Thanks to Jim Blackhurst, Will Steuk, and Jamal Arif for their contributions to this guide, which was inspired by and built on much of their previous work.
感谢 Jim Blackhurst、Will Steuk 和 Jamal Arif 对本指南的贡献,该指南受到他们之前大量工作的启发并在此基础上建立。