The AI-Native SDLC Playbook
AI 原生 SDLC 实践指南:阶段性重塑软件研发生命周期
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.
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.
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, release teams ship it, and operations monitors what is running. Work moves between the phases through documents, tickets, and sign-offs.
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.
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.
When code is no longer the bottleneck and the build phase runs faster than the traditional SDLC allows for, three things become true:
- 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.
代码编写不再是瓶颈
过去一年中,各组织开始利用 AI 以一年前无法想象的速度编写代码。然而,围绕代码构建的组织流程与协作机制,却未曾以同等节奏进化。
许多工程团队依然维持着原有的审批卡点、漫长评审、多重交接与过时规范,导致使用 Claude Code 等智能体编码方案所带来的生产力跃升被严重阻滞。
软件研发生命周期(Software Development Life Cycle,简称 SDLC)是将一个想法转化为生产环境运行软件的核心流程。绝大多数组织都遵循着大同小异的六个阶段:规划(Plan)、设计(Design)、构建(Build)、测试(Test)、部署(Deploy)以及运维(Maintain)。在传统模式下,每个阶段都是由不同角色主导的离散步骤:产品经理撰写需求 PRD,技术架构师将其转化为架构设计,工程师动手编写代码,监管企业的 QA 团队进行质量验证,发布团队负责上线,而运维团队监控生产运行。工作成果通过文档、工单和签字确认在各阶段之间流转。
传统软件研发生命周期(SDLC)流程之所以如此繁重,核心是为了在每一步确保问责机制与有效控制。然而,传统 SDLC 设计的初衷,是为了在一个“编写和实现代码是最耗时且最昂贵阶段”的时代实现效率最大化——而今天,这一前提已经彻底不复存在。详尽的 PRD、估时仪式和繁复的产品安全评审,其存在都是为了在长达数周、数月甚至数个季度的漫长开发周期中强行对齐各方预期。
传统 SDLC 的各项管控机制还隐含了一个底层假设:每一个环节都由人类亲自执行。而收益最大化的领先组织,已经围绕智能体 AI(Agentic AI)的能力重塑了整个研发流程,同时确保人类在关键决策环路中(Human-in-the-loop)保持掌控。在这份指南中,我们将深入解析 Anthropic Applied AI 团队内部深度整合 Claude 的多项最佳实践,涵盖 SDLC 各阶段的加速方案与提效指南。
当编写代码不再是瓶颈,构建阶段的速度远超传统 SDLC 流程所能容纳的极限时,会出现三个必然事实:
- 瓶颈向构建阶段的左右两侧转移:主要集中在规划、评审/测试和部署环节,因为这些环节依然以人类的原有速度运行。
- 原有的管控机制脱离现实并难以为继:当一行行代码由人工敲出时,逐行人工代码审查(Code Review)是合理的;但当智能体生成了大部分代码差集(diff)时,人工逐行审查根本无法跟上节奏。
- 治理成本急剧飙升:因为任何异常与例外仍需通过每周或每月召开的例会与委员会进行裁决。


- Build phase
- 构建/实现阶段:指根据设计图和需求具体编写代码、完成程序功能的阶段。在智能体支持下,原本需要数周的工作被压缩到数小时。
- Human-speed steps
- 人类速度环节:指需求审批、跨部门会签、人工逐行 Code Review 和手动发布等依然依赖人类排期与脑力操作的环节,耗时通常以天或周计算。
- Bottleneck shift
- 瓶颈转移:当代码生成变得极快后,整体交付速度不再由“写代码有多快”决定,而是被“前后审批与测试有多慢”卡死。
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?
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 原生 SDLC 是一个重新构想的软件工程体系,它将传统的核心控制目标与全新的执行手段相结合。研发流程不再是单向线性的流水线,而是一个紧密协同的闭环,AI 深度嵌入到每一个节点中。AI 原生 SDLC 强调自动化的成果交接与后续动作的自动触发,从而彻底解决传统 SDLC 阶段之间人工交接的低效与割裂。


- Plan (规划)
- 捕获业务意图,生成结构化的
intent.md需求原型文件。 - Design (设计)
- 对照代码库与组织规范 Skills,由 AI 和架构师共同生成
spec.md技术方案。 - Build (构建)
- 在
CLAUDE.md和 Plan Mode 指引下生成落地计划plan.md并自动编写代码。 - Test (测试)
- 智能体运行即时验证命令,CI 流水线执行自动化 Agent Evals 评测。
- Deploy (部署)
- 智能体多轮预审 PR,通过代码化 Hooks 严格拦截未授权的发布动作。
- Maintain (运维)
- 监控指标偏离基线时,智能体自动诊断排障并将结论写回闭环形成新意图。
The shifts
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.
| 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 与在 Claude 支持下的 AI 原生 SDLC 之间的核心差异。大多数现代化组织目前正处于由左向右迁移的光谱之中。
| 阶段 | 传统 SDLC 模式 | AI 原生 SDLC 模式 |
|---|---|---|
| 规划 (Plan) | 委员会收集需求,通过多次研讨会与签字确认层层提炼,人工手写 PRD 文档 | Claude 直接从原始业务源头归纳痛点,并沉淀为既适合人类阅读又可供机器直接执行的 intent.md |
| 设计 (Design) | 分析师撰写技术规范,设计师逐行拆解解读 | 需求与架构设计压缩为与智能体的一次协作会话,由沉淀为 Skills(技能)的标准规范指引,全量纳入 Git 版本控制 |
| 构建 (Build) | 手工编写测试与代码,开发主体完成后才补写技术文档 | AI 生成测试与代码,组织知识库作为机器可读且受版本控制的 CLAUDE.md 文件和 Skills 进行维护 |
| 测试 (Test) | 在各阶段边界设立人工质量把关(QA gates) | 持续性评测(Continuous evals)贯穿于整个实现过程之中 |
| 部署 (Deploy) | 人工逐行审查所有代码,合规治理分散在评审周期中且执行标准常不一致 | 分层的智能体自动审查,人类精力聚焦于受监管与关键核心代码。在 AI 操作时通过 Hooks 实时执行治理与审批门禁 |
| 运维 (Maintain) | 运维人员人工值守生产环境监控与故障排查 | 智能体持续监控线上部署。一旦指标突破控制带,自动完成故障诊断并生成新的 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.
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.
贯穿右侧 AI 原生模式的核心脉络是版本受控的工件(Committed Artifact)。每个阶段都以向版本控制系统提交一个标准化文件作为结束(包括 intent.md、spec.md、plan.md、代码 diff 与配套测试、带评审结论的 PR、事故排障记录),而下一阶段则通过读取该文件自动启动。在早期阶段,Markdown(.md)是主导工件,因为业务负责人与 AI 智能体都能无障碍地理解并操作同一份文件;从构建阶段开始,工件则延伸至代码本体及其衍生记录。这一连串的 Git Commit 链条同时构成了不可篡改的审计追踪线索:谁提出了诉求、智能体生成了什么、最终由谁审核批准。
在所有需要人类专业判断的决策节点上,人类始终承担最终责任。在智能体 SDLC 体系中,人类的关注点随同审查工件的形态发生了跃迁。
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.
These 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.
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.
实践矩阵(Plays Overview)
实践矩阵是本指南的核心,按六个非线性阶段划分(规划、设计、构建、测试、部署、运维),完整覆盖软件研发生命周期。
每个实践方案均包含:
- 发生的变化(What changes);
- 准备起步(Getting started);
- 具体落地步骤(Concrete steps for implementation);
- 治理与合规考量(Governance considerations);
- 度量成效的指标体系(How you measure whether it worked)。
这些步骤是高度模块化的,团队可根据自身痛点自主决定推进的优先级。每个实践均在“先决条件(Prerequisites)”中明确了依赖项,如下图依赖拓扑所示。
阶段以提交工件结束,该提交随即触发下一阶段。通过验收的 intent.md 触发需求与设计会话,审批通过的 spec.md 触发规划模式(Plan Mode),合并的 PR 触发自动化流水线,而生产环境告警则自动撰写下一份 intent.md,从而让闭环持续流转。
起步时,可以通过手工 Prompt 驱动各个环节;终局状态则是一个由工件自动触发卡点的自治循环。人类精力聚焦于各个卡点的质量把关,审查智能体提炼的关键问题,而非每次从空白草稿从头开始。


- Capture intent
- 捕获业务意图(阶段一):把发起人的问题、目标和约束沉淀为版本受控的
intent.md,供后续阶段读取。 - CLAUDE.md
- CLAUDE.md 规范底座(阶段三):存放仓库上下文、约定、命令和防错守则,供智能体每次会话读取。
- Feedback loop
- 即时反馈循环(阶段四):让智能体在汇报完成前自行运行构建与测试,自检并修复缺陷。
- Hooks
- 确定性护栏(阶段五):用 Hook 在代码变更或发布时强制执行策略,阻断高危操作与格式偏离。
- Plan mode
- 规划模式(阶段三):在编写代码前先生成可审阅的
plan.md,由工程师批准后再实施。 - Skills
- Skills 制度化知识(阶段三):将安全、品牌、API 等组织规则封装为智能体可按需读取的模块。
- Subagents
- 子智能体(阶段三):在主会话内用受限上下文和工具执行专门任务,例如验证应用是否按预期运行。
- Evals
- 持续自动化评测(阶段四):通过 CI 持续检查智能体和工程能力,防止 Prompt 或配置变更造成回退。
- Requirements & design
- 需求与架构设计(阶段二):把
intent.md转化为可供工程实施的spec.md技术规范。 - PR review
- PR 审查(阶段五):智能体先审查逻辑与合规问题,人类在合并前确认并处理高风险事项。
- CI/CD
- 持续集成与部署(阶段五):在受控流水线中运行测试、审查和发布,必要时保留回滚能力。
- Closing the loop
- 闭环自愈(阶段六):监控生产指标突破控制带后生成新的
intent.md,重新进入研发循环。
Plan
规划阶段 · Plan
Capture as 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).
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.
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.
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 捕获业务意图
作为启动软件开发源头的 intent.md,可以来自不同途径:员工产生的一个新创意、客服工单系统汇总的痛点,或是线上监控警报发现的异常事故(参见阶段六:运维)。
当业务人员产生一个想法时,他们直接与 Claude 进行头脑风暴,共同生成一份 Markdown 格式的原始规格草案(proto-spec)。在传统 SDLC 中,这个人必须先说服产品团队的一位 PM 协助撰写详尽需求。
由 Claude 协助生成的原始草案既易于人类阅读,又受到版本控制,并能立即被下一阶段消费。这份草案被保存为 intent.md。
无论意图源自事件触发器还是智能体,执行逻辑完全相同:产品负责人在 intent.md 被 Commit 提交入库之前,对智能体草拟的内容进行复核与修正。
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.
intent.md。工件明确包含想要什么、为什么想要以及受何种约束。高频重复流程沉淀为 Skills(技能)。
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.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.
intent.md 模板;一个由产品负责人监控的、共享且受版本控制的意图存放仓库。对于单产品,最简方案是在产品代码库中建立 intent/ 文件夹,确保工件链紧挨着衍生出的代码。专用的意图仓库只在需求跨越多个代码库时才值得维护;在单体大仓(Monorepo)中它只是一个子目录。阶段三(构建)的侧栏将介绍该主目录如何与现有的 Jira 等需求工具协同。设置该基础设施是平台或工程团队的一次性工作。技术团队成员负责搭建存放目录并配置写入权限,因为未来许多贡献者将来自组织各部门。
仓库建立后,非技术背景的业务贡献者无需学习 Git 命令行,通过版本控制连接器(如 GitHub Connector)即可让 Claude 在网页端代为提交 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:该模板可配置为团队专属 Skill(由技术成员配置并由组长审核),涵盖:问题定义、期望产出、受影响用户与系统、硬性约束条件以及待澄清问题。 - 发起人校正 Claude 理解有偏差的地方。
- 将
intent.md提交至指定目录:作者与时间戳随之固化,产品负责人据此接手推进。
What it looks like (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.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?
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,记录了作者、时间戳及完整版本历史。产品负责人的审核决定(是将该意图推进到阶段二还是予以关闭)通过 Pull Request 的合并或关闭记录完整归档。
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 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.intent.md 正式 Commit 的耗时。预期从传统的数周需求调研梳理周期骤降至数小时内。intent.md 比例;以及在同一需求的首份 spec.md 提交后,intent.md 发生后续修改的频次。Design
设计阶段 · Design
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.
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.
需求与技术方案设计
一旦获得产品负责人批准,Claude 便读取通过验收的 intent.md,并输出一份需求与设计技术规范。这一过程由组织沉淀在品牌、安全、合规与 UX 领域的 Skills(技能) 作为硬性指引。
产品负责人负责审核该规范,但无需亲自撰写。该流程的目标是产出一份工程团队可以直接据此规划实施的 spec.md,并显式标出值得关注的风险点。
前端开发是最直观的范例:一旦 intent.md 被接受,产品负责人可直接在 Claude Design(Beta)中基于 intent.md 快速生成界面原型并迭代打磨,随后将其导出至 Claude Code 进行构建。
intent.md and produces a requirements and design spec, constrained by the organization's skills, with areas of concern flagged.
intent.md 并输出受组织 Skills 约束的需求与设计规范,显式高亮疑难问题。
intent.md file, with brand, security, compliance, and UX policies written as skills.intent.md 文件,并将品牌、安全、合规与 UX 策略编写为 Skills。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.
具体落地步骤
- 产品负责人开启一个挂载了组织 Skills 的会话,并附上
intent.md。 - 产品负责人的 Prompt 指向
intent.md,明确约束条件并要求主动高亮风险点。起步时可手工执行,后续可固化为组织级斜杠命令(Slash Command)。最终状态是将intent.md的合并设为自动触发器,通过非交互式任务自动生成spec.md并发起 PR(阶段五的 CI/CD 将介绍该链路)。届时产品负责人的首要工作即为评审。 - 产品负责人对照原始想法审核该规范:规范是否解决了所阐述的问题?
intent.md中的未决问题是否得到解答或妥善传递? - 首先解决被标记出的风险隐患,这些往往是分析师需要上报的关键问题。在工程团队接触规范前,产品负责人与各策略负责人对齐解决。
- 将
spec.md与intent.md一并提交入库。这对文件共同记录了“提出了什么诉求”与“作出了何种设计决策”。 - 产品负责人决定是否将规范和意图推进至构建阶段,对高风险项目可咨询技术主管。人类团队成员始终保留最终决定权,接受该规范即可启动阶段三(构建)的规划模式。
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.
实操提示词模版 (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.
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.
治理考量
合规策略不再是在几周后的评审会上被偶然发现,而是在撰写规范的当下即被实时读取和应用。组织的 Skills 作为硬性约束作用于规范。规范本身、生成它的 Prompt 以及生效的 Skill 版本均完整记录在版本控制中。产品负责人签字确认,并将高亮隐患分发至对应责任人。
intent.md commit and the spec.md commit for the same change (two git timestamps), compared with the old requirements-plus-design cycle.spec.md commits dated after the first plan.md commit for the same change. Git log will give this directly.intent.md 提交到对应 spec.md 提交的耗时(对照两个 Git 时间戳),与以往的需求加设计周期进行对比。plan.md 提交之后发生的 spec.md 修改提交次数。Build
构建阶段 · Build
Claude Code plan mode as the default starting point
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.
以 Claude Code 规划模式作为默认起点
工程师在开启 Claude Code 会话时,默认从规划模式(Plan Mode)启动。工程师将阶段二生成的 spec.md 交付给 Claude,让智能体主动提问澄清,迭代生成可落地的实施计划 plan.md,直到工程师完全满意为止。
plan.md for later stages to check against.
plan.md。
intent.md or spec.md) if one exists, and the CLAUDE.md file helps.intent.md 或 spec.md),配合 CLAUDE.md 文件效果更佳。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 Code 中进入 Plan Mode(规划模式)。
- 交付
intent.md与spec.md,要求 Claude 产出包含:改动文件清单、实施先后次序及验证测试方案的落地计划。 - 向智能体发起质询:“本次改动可能破坏什么现有功能?最危险的步骤是什么?为什么不采用备选方案?”
- 持续打磨计划,直到一位从未参与会话的第三方工程师仅凭该
plan.md也能独立实施。 - 将批准后的计划提交为
plan.md纳入版本控制,后续的 PR 审查将严格对照该文件检验代码。 - 切换为执行模式,让 Claude 依据计划编写代码。通常在详尽计划指引下,代码实现可一次性高质量通过。
- 若实现过程中偏离计划,必须在同一个 Commit 中同步修正
plan.md。建议使用 Hook 强制确保两者同步。
What it looks like (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.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.
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.
治理考量
设计评审在生成任何代码之前完成,此时调整方向仅需修改文档。Plan Mode 本身强制执行了这一约束,因为在工程师批准计划之前,Claude 无法编辑任何文件。计划及其修订记录连同批准人一同归档。常规改动由工程师审批,高风险改动流转至技术主管或架构师。
plan.md.plan.md 保持一致的概率。Claude Code on auto mode
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.
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.
Claude Code 自动执行模式
Claude Code 还支持在 Auto Mode(自动执行模式)下运行。工程师对计划感到满意并批准后,Claude 可以在无需每一步人工确认的情况下连续执行修改。随着后续实践中的护栏逐渐成熟(调优完备的 CLAUDE.md、封装了策略的 Skills、阻断高危操作的 Hooks 以及 Claude 可自行运行的测试套件),对于边界清晰、影响范围小且已有测试覆盖的常规工作,自动接受模式将成为默认选择。
工程师的重心由此从“盯视智能体每一次修改”转变为“在较长的自主会话后集中审阅工件”。结合 Worktrees 使用时,自动模式进一步支持个人及团队的并行工作,这是实现自治 SDLC 与阶段六运维闭环的基础。
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.
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:
- 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.
- 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.
- 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.
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.
传统遗留系统与唯一事实源 (Source of Truth)
本原则适用于研发流程中产出的所有工件。
现有的 SDLC 流程通常已经在追踪各类工件,只是它们并不以 Markdown 文件的形式存在:任务项在 Jira 中,需求在具有合规追溯性的系统里,设计在 Figma 中,而变更审批通过变更委员会流转。这些系统很难被轻易取代,因为审计员和监管机构已经认可它们,其他团队也依赖它们,因此 AI 原生 SDLC 必须与现有系统相兼容。
在向 AI 原生 SDLC 转型的过程中,对于流程产出的每一项工件,必须明确指定一个系统作为“唯一事实源(Source of Truth)”,其他系统仅保留副本或指向原件的链接。针对不同工件,可采取以下配置策略:
- 以代码仓库为唯一事实源:Markdown 工件是权威记录,传统系统仅引用 Git Commit 中的文件。这是工程主导型组织中最干净的架构,所有记录都在统一的时间戳权威下集中管理。
- 以传统系统为唯一事实源:Jira、ServiceNow 或专用需求工具保存权威记录,Markdown 工件作为工作副本。Claude 在会话开始时读取记录,并通过 MCP 连接器在同一次会话中将产出的 spec 或 plan 写回传统系统。
- 以相互链接作为最低基线:所有工件记录对应系统的 ID,所有传统系统记录保存 Markdown 文件的 Commit SHA。这是过渡初期的实用选择。
传统系统与 Markdown 优先系统完全可以和平共存,关键在于建立两者之间的双向链接或明确哪一方为唯一权威。
The 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.md 为 Claude 提供了一位新入职员工所需的所有核心上下文,涵盖编码约定、常用命令、架构分层以及团队最常遇到的错误清单。以往零散在脑海或 Wiki 中的隐性知识,沉淀为智能体在每次会话开始时必读的文件,由全团队共同维护,每犯一次错误便迭代更新一次。
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。 - 将生成的文件精简至新员工第一天真正所需的内容。保留构建、测试和代码检查命令、关键约定以及 Claude 反复犯错的事项。
- 将
CLAUDE.md提交至仓库根目录,使全团队共享统一版本,其变更像代码一样经过评审。 - 建立工作守则:当 Claude 犯了两次同样的错误时,纠正指令必须写入
CLAUDE.md。 - 将文件体积控制在一页以内。因为 Claude 会在每次会话开始时全量读取它,任何过时的内容都会白白消耗上下文窗口。
What it looks like (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/.
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/.
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 历史中,并由 Code Owner 在 PR 评审中签字确认。
CLAUDE.md should have caught. The corrections or changes to the CLAUDE.md should be tracked within the git history.CLAUDE.md 拦截的错误的频次。通过 Git 追踪对 CLAUDE.md 的修订记录。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.
Skills:制度化组织工程知识
Skills 是组织将其制度化知识转化为可操作能力的方式。其指令清晰明确、纳入版本控制、广泛应用并在策略变更时集中更新。核心准则:针对必须一致执行的制度化知识编写 Skill;不要为属于 CLAUDE.md 或单次 Prompt 的零散组件编写 Skill。
CLAUDE.md helps, because it keeps the agent's working knowledge in the repo, but a skill does not depend on it.CLAUDE.md 效果更佳,但 Skill 本身不依赖它。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:一个包含
SKILL.md的文件夹,其 Frontmatter 定义触发条件,正文定义具体操作。由工程师协助策略负责人编写。 - 将 Skill 放置在仓库的
.claude/skills/<name>/目录下随代码交付,或通过 Plugin 在全组织范围内分发。 - 测试 Skill 是否正确触发:以不同方式向 Claude 派发相关任务,确认每次均正确加载该 Skill。
- 当策略发生变更时,修改 Skill 并由策略负责人签字确认。
- 工程师将在下一次会话中自动获取最新版本。
What it looks like (.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.
Skills 定义示例 (.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.
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.
治理考量
Skill 是一种建议性控制(Advisory Control)。它促使 Claude 在编写代码时遵循策略,但无法硬性阻断违规操作。对于必须毫无例外遵守的策略,需要配合确定性控制机制(如阻断操作的 Hook 或在 PR 中二次校验的评审流程)。Skill 让违规变得罕见,Hook 让违规几乎不可能发生。Skill 的调用记录在会话日志中,策略所有者像审查代码一样审查 Skill 的修改。
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.
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.
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.
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.
Hooks 作为构建阶段的确定性护栏
Skill 是建议性控制,而 Hook(钩子) 则是其背后的确定性防线。在实现阶段,Claude 的绝大部分操作是文件编辑和 Shell 命令,因此构建阶段也是 Hook 触发最频繁的地方。
构建阶段的 Hook 可以做到:
- 阻断对受保护路径的修改(如自动生成的类或已被冻结的旧包);
- 在文件编辑后自动运行格式化与 Lint 工具,避免代码风格漂移;
- 阻止将密钥凭据写入代码差集。
为所有必须绝对保持的策略配备 Hook。Hook 在每次匹配的动作发生时执行,因此构建阶段的 Hook 应保持极高的执行速度,并仅作用于发生变动的文件。全量测试套件等重量级检查应放在 Commit 或 PR 阶段。
需要人工审批的 Hook 属于阶段五(部署)的门禁范畴,因为在构建过程中弹出审批提示会让所有并行会话重新回到等待人类的单线瓶颈中。
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.
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.
并行会话与子智能体(Subagents)
一名工程师可以同时推进多条工作流。
并行会话(Parallel Session)是指另一个完整的 Claude Code 实例,在专属的 Git Worktree 中执行独立的开发任务。各个独立会话之间互不知晓,负责调度把关的工程师是它们唯一的交集。
子智能体(Subagent)则运行在单个会话内部,作为拥有受限上下文窗口和工具权限的专属助手,适用于在多项任务中反复出现的工作(如验证应用程序是否按预期运行)。
并行会话提升了一名工程师可以并发处理的任务数量,而子智能体则让各个会话专注于自身任务。工程师的核心职责转变为统筹调度与成果审查。
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 文件(所有会话都会读取)。阶段四的即时反馈循环也大有帮助,因为会话能够自我验证时对工程师的监督依赖更低。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.
具体落地步骤
- 工程师利用阶段三产出的
plan.md将工作拆分为触及不同文件的独立任务。相互关联的任务则放在单个会话中按序执行。 - 为每个并行任务分配专属 Worktree,例如在不同终端中分别执行
claude --worktree feature-auth与claude --worktree fix-rate-limit。Worktree 是独立分支上的独立检出目录,杜绝了文件冲突。 - 初学者建议从 2 到 3 个并行会话起步。上限取决于个人能够充分审查的工作流数量。
- 将重复性工作定义为子智能体,保存在
.claude/agents/的 Markdown 文件中,指定名称、触发时机与允许使用的工具。例如:精简冗余代码的简化器、运行应用验证行为的验证器、检索代码库并汇报总结的研究员。将定义提交至 Git 共享。
What it looks like (.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.
子智能体定义示例 (.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.
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.
治理考量
会话增多意味着产出成倍增加,因此管控必须来自于仓库中的统一配置。Hooks 和权限规则对所有会话生效,会话的各项操作均被完整记录并归属到对应的运行工程师。
Test
测试阶段 · Test
Give Claude a feedback loop
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.
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.
为 Claude 建立即时反馈循环
务必始终为 Claude 提供验证自身工作的途径,无论是自动化测试、构建流程还是截图对比。会话应当在工程师介入之前,自行检验工作并修复自身出现的错误。
即时反馈循环不应与验证子智能体(Verifier Subagent)混淆。反馈循环贯穿于任务全过程,反复多次运行;而验证子智能体是在会话认为工作全部完成后,通过独立的崭新上下文窗口执行最终检验,确保结论不受此前生成代码时的假设偏见所影响。
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中的所有测试全部通过”、“UI 截图与所附原型一致”或“接口返回 200 并包含新字段”。 - 针对 Bug 修复,先写失败的测试:要求 Claude 先将 Bug 重现为测试用例,运行并确认其失败原因符合预期,提交该测试;随后要求 Claude 在不修改该测试文件的前提下修复代码(由 Hook 强制拦截)。一个在修复前存在且智能体无法篡改的测试,是 Bug 已彻底消除的最有力证据。
- 针对 UI 工作,建立视觉验证闭环:提供截图工具与原型图,让智能体执行“实现→截图→对比→微调”的循环。通常两到三轮迭代即可显著提升品质。
- 将验证作为“完成”的必要条件,写入
CLAUDE.md:在汇报完成前必须运行全部测试并附上执行输出。 - 保护验证循环本身:修复代码的智能体绝对不能有权限弱化对该代码的校验规则。通过 Hook 在修复期间禁止修改测试文件,或在 PR 评审中检查 diff 并驳回篡改测试的改动。
What it looks like (CLAUDE.md verification block)
## 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.
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.
make test 的控制台原始输出、构建日志或 Claude 运行并截取的图片对比差集,直接来源于工具链。Continuous evals in 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.
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.
在 CI 中运行持续自动化 Evals
Evals(智能体评测)是 AI 原生体系中阶段性质量保证(QA)的等价物。在实际应用中,它表现为一套在智能体配置发生变更时自动运行的评测套件。当更换新模型或重写 Prompt 时,Eval 套件能够明确指出智能体是否仍能保持既定的工程水准。
Evals 是一套动态演进的活套件。随着模型能力的提升,过去具有区分度的测试用例会逐渐失效,必须根据日常监控中发现的新问题不断补充新用例。
根据团队需求,部分团队可选择离线定期运行,部分团队则在每次变更时持续执行。以下步骤针对持续集成(CI)中的持续评测。
CLAUDE.md and feedback loop (Stage 4: Test).CLAUDE.md 与即时反馈循环(阶段四)。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 个真实任务及其预期/可接受的交付成果。
- 将每个任务编写为 Eval:包括 Prompt 以及定义合格的校验规则(测试通过、Lint 无警告、行为未变、策略合规)。
- 在 CI 中定时或在
CLAUDE.md、Skills 或 Hooks 发生改动时非交互式运行该套件。因为这些配置负责指引智能体,理应像代码一样接受回归测试。 - 将配置变更与评测结果挂钩:降低通过率的 Skill 改动在修复前禁止合并。
- 每次生产事故发生后,由责任团队为其编写一个 Eval 用例,永久纳入套件作为回归防线。
What it looks like (.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
CI 工作流示例 (.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
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.
治理考量
Evals 为 QA 团队提供了一个能够跟上智能体产出吞吐速率的质量把关卡点。通过率阈值作为合并检查(Merge Check)强制执行,所有运行均被记录以便进行历史对比,配置的归属团队负责签署变更批准。
Deploy
部署阶段 · Deploy
AI in the PR review loop
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.
PR 评审流中的 AI 深度协作
Claude 在 PR 流程中同时扮演审查者与被审查者的双重角色:它对照组织策略审查提交的 PR,同时也负责在自身的 PR 中响应并处理人类提出的评审意见。这使工程师能够将精力集中在行为层面的审阅上,本质上即对意图与风险进行最终裁决。
CLAUDE.md file from Stage 3: Build; skills if the review passes enforce written policies, defined subagents.CLAUDE.md;用于执行特定策略的 Skills;已定义的子智能体。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 流量走企业专属云协议,则使用
claude-code-action在自建 CI 中运行。 - 技术主管在仓库根目录编写审查策略
REVIEW.md,划分为团队关心的审查轮次:Bug 与逻辑缺陷;安全与漏洞风险;对照需求规范(spec.md)、实施计划(plan.md)与设计原则的合规性。明确定义何为“重大隐患(Important)”,何为“琐碎挑刺(Nit)”以及应跳过的内容。 - 技术主管设定人工介入阈值:智能体的发现本身不直接批准或阻断 PR,分支保护依然强制要求 Code Owner 审批。平台工程师可读取 Check Run 输出的机器可读严重性统计,设立自动门禁。
- 当审阅者或作者在评论区
@claude时,Claude 会自动分析意见并推送修复提交,PR 讨论区完整记录诉求与代码变更。在托管服务中,输入@claude review可请求重新评审。对于由 Claude 创建的 PR,更可让 Claude 全程跟进直至合并(通过自定义斜杠命令自动处理未决评论和失败检查,直至 PR 全绿等待批准)。 - 评审结论反哺
CLAUDE.md:当评审第二次发现同类错误时,该修正直接写入CLAUDE.md;后续评审读取该文件,即可在下一次 PR 中提前拦截。 - 技术主管每月对发现的问题进行评分调优,并在
REVIEW.md中限制 Nit 的数量上限,排除自动生成路径与 CI 已覆盖的常规检查。
What it looks like (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.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.
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.
治理考量
严格维持职责分离原则(Separation of Duties):编写代码的智能体绝对没有权限自行批准 PR。REVIEW.md 中的审查策略统一作用于所有 PR,发现、修复、评分与批准全部留存在 PR 历史中构成不可篡改的审计档案。审批最终由人类通过分支保护机制完成。
Hooks as approval gates
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.
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.
Hooks 作为自动化审批门禁
构建阶段将 Hook 用作无人介入的确定性护栏(阶段三)。Hook 同样可以暂停操作并请求特定责任人批准,这正是发布门禁所必需的能力。
虽然该实践归在阶段五(部署),但 Hook 并不局限于部署:它在 Claude 操作的任何地方均可运行。例如在阶段三阻断无变更工单的数据库迁移与基础设施修改,或在阶段四修复缺陷期间阻止智能体篡改测试文件。
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 操作前执行,可返回允许、询问或阻断。
- 团队级 Hook 配置在 Git 中的
.claude/settings.json,不可妥协的强制 Hook 配置在平台或 IT 管理员拥有的托管设置中,工程师个人无法关闭。 - 阻断操作时必须提供明确说明:当 Hook 拦截操作时,原因及申请审批的途径会直接显示在 Claude 的输出中。
What it looks like (.claude/settings.json)
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{ "type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/production-gate.sh" }
]
}
]
}
}
Hook 配置 (.claude/settings.json)
{
"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)
#!/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
门禁拦截脚本 (.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
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 即为审批门禁。门禁条件在任何时间对所有人一律强制执行。允许与阻断决定均带有时间戳归档。门禁明确定义了何为有效批准(无论是审批通过的变更工单还是发布经理的签字)。
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.
{
"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.denykeeps secrets out of the agent's context and blocks arbitrary network egress through tools;permissions.allowpre-approves the safe inner loop so the deny list doesn't turn into prompt fatigue.disableBypassPermissionsModeplusallowManagedPermissionRulesOnlymeans no engineer, project file or command-line flag can widen the rules.sandboxcloses 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.failIfUnavailableandallowUnsandboxedCommandsmake 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.credentialscloses the gap the deny rules leave open.permissions.denygoverns Claude's file tools, but a sandboxed shell command could still read~/.sshor~/.aws/credentialsby default; this block denies those reads and strips the named secrets from the environment of every sandboxed command.allowManagedHooksOnlymeans the approval gates from this play are the only hooks that run; nothing local can add to or replace them.disableSideloadFlagsandstrictKnownMarketplacesmean 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.allowManagedMcpServersOnlymakes the agent's tool surface an allowlist owned by the platform team.requiredMinimumVersionrefuses to start on a version below the approved floor, so the controls are enforced by a build the organization has actually assessed.
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
强监管企业的集中管控设置 (Managed Settings)
由平台团队通过 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阻止密钥凭据进入智能体上下文,并拦截工具发起的任意网络外联;permissions.allow预先批准安全的开发循环命令,避免频繁确认引发操作疲劳。disableBypassPermissionsMode配合allowManagedPermissionRulesOnly确保任何工程师、项目文件或命令行参数都无法放宽权限。sandbox补齐工具层无法覆盖的安全缝隙:工具级的 WebFetch 拦截无法阻止 Shell 命令访问网络,而操作系统级的域名白名单从底层直接阻断未授权外联。failIfUnavailable与allowUnsandboxedCommands将沙箱变为强制门禁:沙箱无法初始化时 Claude Code 拒绝启动,在沙箱内失败的命令绝对禁止在沙箱外重试。credentials封堵权限死角:permissions.deny管控文件读取,但沙箱中的 Shell 命令默认仍可能读取~/.ssh或~/.aws/credentials;此配置直接禁止此类读取,并从每个沙箱命令的环境变量中剥离指定敏感 Token。allowManagedHooksOnly确保本实践中的审批门禁是唯一生效的 Hook,本地配置无法覆盖或追加。disableSideloadFlags与strictKnownMarketplaces确保机器上的所有 Skill、Agent、Hook 和 MCP 服务全部来自组织审核的官方插件市场,杜绝从个人目录侧载。allowManagedMcpServersOnly使智能体的工具扩展接口成为平台团队统一管理的白名单。requiredMinimumVersion强制要求客户端版本不低于指定基线,确保安全合规控制由经过企业评估的构建版本所执行。
上述配置可作为根据自身业务定制的基准参考。每项阻断都需要在安全性与工程效率之间权衡,更多高级配置可参阅官方文档:code.claude.com/docs/en/settings
CI/CD integration and deployment
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 深度集成与自动化部署
在 CI/CD 流水线中非交互式运行 Claude Code,对执行环境进行沙箱隔离以确保长时间运行的安全,通过 MCP 接口暴露部署工具,并在智能体实际使用前反复演练回滚路径。
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 或支持调用 claude -p 的 CI 平台;通过 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分析构建失败日志、总结 Flaky 测试或起草更新日志。 - 在现有门禁后增加写入步骤:如自动修复 Lint、更新文档或响应
@claude评论。智能体写入的内容均通过分支保护作为 PR 提交,无权直接推送到 main 分支。 - 对执行进行沙箱隔离:智能体任务在容器中运行,遵循网络策略与短期作用域 Token,默认不持有生产环境凭据。
- 通过 MCP 暴露部署能力:将部署、状态查询与回滚封装为按环境划分作用域的 MCP 工具,使智能体的部署权限成为受控白名单,而非持有凭据的裸 Shell 脚本。
- 按环境划分自治等级:在开发环境中智能体自由部署;在生产环境中智能体准备发布包并由发布经理授权,由 Hook 强制执行生产门禁;预发布环境介于两者之间。
- 将回滚打造为流水线中最经得起检验的路径:一条智能体可调用的单命令回滚,在预发布环境中定期演练。阶段六(运维)在指标失控时会调用该回滚,因此必须提前验证可靠性。
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
流水线步骤示例 (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
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 分支的可能。
- 生产部署 Hook 阻断发布动作,直至获得指定发布经理的显式授权。非交互式运行在独立身份下执行,流水线日志清晰分离智能体操作与触发工程师的操作。
- 按环境划分的权限阶梯严格限制智能体在通往门禁过程中的操作边界。
Maintain
intent.md.运维阶段 · Maintain
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.
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.
运维与闭环流转
到目前为止,我们探讨了如何在 SDLC 的各个阶段引入 Claude,每个阶段仍需要人类发起初始动作。而阶段六则将重心转向 Claude 的自主运行,以彻底完成闭环。
例如,一个持续运行的监控智能体在收到 Bug 工单后,自动创建 intent.md,并自主流转推进需求、计划、构建测试与评审阶段。阶段六支持无头运行(Headless),阶段之间设立独立的置信度门禁(确定性检查或对抗性审查智能体),决定是将上一阶段成果继续向下流转还是升级转交人类。
intent.md, which then goes through the stages described above. People triage and review that work, and no longer have to start it.
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(公开测试版)则涵盖了来自沟通频道的实时工单处理。
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(为闭环重启提供结构化输入);AI 辅助的 PR 审查;作为行动边界的 Hooks;以及 CI/CD 自动化回滚路径。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 Rules),使监控既能捕获突发尖刺也能识别缓慢漂移。脚本纳入版本控制与单元测试,检测过程保持完全确定性,不引入模型推断。
- 在版本控制的配置文件中定义分级响应策略(如下方的
bands.yaml):1σ 仅记录日志;2σ 以只读方式调用 Claude 诊断原因;3σ 允许 Claude 采取行动(仅限发起 PR 进入评审门禁或触发预先批准的 Runbook)。 - 触发层可采用 GitHub/GitLab 定时工作流、现有监控系统的 Webhook 或内网 Cron Job。Claude 以无状态方式运行在 CI 运行器或沙箱容器中。由于运行是无状态且非交互式的,闭环可以自主启动与结束。
- 智能体将诊断结论以阶段一(规划)的
intent.md格式输出,涵盖异常现象与证据、预期修复目标、受影响系统及未决疑问。随后该发现像常规需求一样进入流水线。 - 服务负责人或值班工程师对队列进行分类处理,将产品相关发现流转至产品负责人:立即修复、排期或忽略。忽略操作有助于进一步调优控制带、减少噪音。
- 当修复上线后,为该事故补充对应的 Eval 测试用例(阶段四的持续评测),确保同类问题在未来受到永久防护。
What it looks like (for example, a bands.yaml monitoring CI test failure rate)
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] }
监控规则配置 (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] }
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 评审门禁,智能体允许触发的 Runbook 均预先经过人工核准。
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 呈现在分类队列中的耗时,与过去从发生事故到采取复盘动作的时间进行对比。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σ 时,智能体自动隔离 Flaky 测试或创建 Revert 回滚 PR,由评审门禁作出裁决。
- 当发布后 5xx 错误率在发布窗口内突破 3σ 时,智能体自动触发预设的回滚流水线。
- 当 PR 周期时长触发漂移规则时,智能体自动为工程管理层输出诊断分析报告,证明该框架同样适用于研发过程指标。
Claude on call with Claude Tag
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.
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.
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.
利用 Claude Tag 实现智能体线上值班与事故排查
线上事故同样可能源于工作协同应用(如 Slack 或 Teams)。例如深夜 10 点在应急响应频道收到的加急修复请求,现在可以被立即响应处理。Claude Tag(公开测试版目前已支持 Slack)使 Claude 能够以独立身份加入这些协作频道,使每起新事故都能获得第一响应者,响应过程本身也成为闭环与未来事故的知识沉淀。
对话与组织知识保留在频道中,频道内的任何成员都可以指导并参与响应。全员均可实时验证假设、探索新方案,频道历史记录进一步增强了审计可追溯性。通过 MCP 访问权限,Claude 验证指标恢复至基线并在讨论串中确认,将复盘总结写入版本控制的经验教训库供后续调查读取。
故障排障并非 Claude Tag 的唯一职责。无论通过 MCP 在工单中被标记还是在频道中被直接提问,Claude 都以相同方式分流工作:小范围修复直接发起 PR 进入评审门禁;较大需求则整理为 intent.md 进入阶段一(规划),研发闭环由此实现源源不断地自我驱动。


- Claude on call
- 智能体值班/告警自愈:当监控系统在 Slack 报警时,Claude 自动调取日志和监控图表,自动定位最近变更的代码并给出根因分析报告。
- Human authorization
- 人工授权卡点:在执行任何高风险生产操作(如自动重启服务、发布修复补丁、执行数据库变更)前,必须由值班工程师在频道中点击确认授权。
- Closing the loop
- 完成经验闭环:事故分析报告直接沉淀为经验知识库,并反哺回
CLAUDE.md或作为新intent.md,防止同类问题再次发生。
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.
结语与总结
基础模型与工程框架的进化,使组织不仅能够改变编写代码的方式,更能够重塑整个软件研发生命周期。
这种重塑始终将人类的专业判断置于核心决策位,并充分满足了大型企业组织严苛的治理与合规监管要求。
本指南凝聚了 Anthropic Applied AI 团队日常为客户落地实施的大量真实最佳实践,希望它能成为你团队行之有效的实操指南。
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 对本指南作出的卓越贡献,本指南深受其前期开创性工作的启发并在此基础上构建而成。