如何借助 AI 分阶段重塑你的软件开发生命周期。
Category Enterprise AI Claude Code
Product Claude Enterprise Claude Code Claude Tag
Date August 21, 2026
Reading time 5 min
Share Copy linkhttps://claude.com/blog/the-ai-native-sdlc-playbook
Author(s) Louis Claxton
代码不再是瓶颈
各组织已开始以一年前难以想象的速度使用 AI 编写代码,然而围绕代码的流程却未能以同样的速度跟进。
许多工程团队仍然沿用相同的审批关卡、评审、交接和策略,这拖慢了通过 Claude Code 等智能体编码方案所取得的效率提升。
软件开发生命周期(SDLC)是将软件从想法推进到生产环境的过程。大多数组织都运行着同一套六阶段流程的某种版本,涵盖规划、设计、构建、测试、部署和维护软件。传统上,每个阶段都是一个独立的环节,由不同的角色负责。产品经理编写需求,技术架构师将其转化为设计,工程师实现设计,受监管企业的 QA 团队进行验证,发布团队负责上线,运维团队监控运行状况。工作通过文档、工单和签批在各个阶段之间流转。
传统的软件开发生命周期(SDLC)流程繁重,以确保每一步都有问责和控制。然而,传统 SDLC 的设计初衷是在编写和实现代码是最耗时、最昂贵阶段的时代最大化效率,而如今情况已不再如此。PRD、估算流程和产品安全评审的存在,都是为了在可能长达数周、数月甚至数季度的开发工作中强制各方对齐。
传统 SDLC 还包含一些假设每一步都由人类执行的管控措施。而创造最大价值的组织已经围绕智能体 AI 现在所能做到的事情重建了流程,同时确保人类始终参与其中。在本指南中,我们将介绍我们的 Applied AI 团队在 SDLC 各个阶段内部集成 Claude 的若干最佳实践,以加速开发并让流程运行得更快,这些实践灵感来源于我们与客户的合作。
当代码不再是瓶颈,且构建阶段运行速度快于传统 SDLC 所能允许的范围时,三件事将成为现实:
瓶颈转移到了构建阶段左右两侧的环节。主要是规划、审查/测试和部署,这些环节仍以人类速度运行。控制手段开始与现实脱节,变得难以驾驭。当代码由人类编写时,逐行审查是有意义的,但一旦智能体编写了大部分代码差异(diff),这种方式就跟不上了。治理成本随之增加,因为例外情况仍然要通过每周或每月召开的会议和委员会来流转处理。
构建不再是制约因素——围绕它的人类速度环节才是。人类速度的各个阶段保持原有耗时,而构建阶段则压缩至数小时。
我们以安全瓶颈为例。安全团队的规模是按人类产出配置的,因此当智能体将代码产出成倍放大时,要么审查队列不断积压,要么代码在审查不足的情况下就发布了。受监管的组织无法接受任何一种结果,因此其安全和策略检查必须跟上智能体的节奏。
为了更好地实现智能体 AI 的生产力收益并保障其安全性,传统的 SDLC 生命周期需要经历与实施阶段同等程度的变革。
目录
- 代码不再是瓶颈
- 行动方案(Plays)
- 阶段 1 —— 规划
- 阶段 2 —— 设计
- 阶段 3 —— 构建
- 阶段 4 —— 测试
- 阶段 5 —— 部署
- 阶段 6 —— 维护
- 结语
什么是 AI 原生 SDLC?
AI 原生 SDLC 是一种重新构想的过程,它将传统的控制目标与新的执行机制相结合。该过程不再是线性流程,而是变成一个循环,AI 被嵌入到每一个环节。AI 原生 SDLC 促进了后续行动方案的自动化交接和触发,有助于解决传统 SDLC 各阶段之间交接的手动且笨拙的问题。
转变
下表展示了由 Claude 支持的传统 SDLC 与 AI 原生 SDLC 之间的两个极端。大多数组织处于这两列之间的某个位置。
| 阶段 | 传统 SDLC | AI 原生 SDLC |
|---|---|---|
| 规划 | 需求由委员会收集,通过研讨会和签字审批来提炼,由人工撰写成文 | Claude 直接从源头综合痛点,并将其捕获到 intent.md 中,该文件既可供人类阅读,也可供机器执行 |
| 设计 | 规格由分析师编写,由设计师解析 | 需求与设计被压缩进与智能体的单次工作会话中,由编码为技能的标准化规范引导,并在 git 中进行版本管理。 |
| 构建 | 测试和代码由人工编写,文档则在主要开发完成之后撰写。 | 测试和代码由 AI 生成,机构知识以版本化的机器可读 CLAUDE.md 文件和技能形式维护。 |
| 测试 | 在阶段边界设置 QA 关卡。 | 持续评估贯穿实现过程。 |
| 部署 | 人工审查每一行代码,治理在审查周期中进行,且往往执行不一致。 | 多层智能体审查,人工审查仅保留给受监管和关键代码。治理在 AI 行动时强制执行,以钩子作为审批关卡。 |
| 维护 | 人工监控生产环境中的缺陷。 | 智能体监控实时部署。任何超出控制范围的情况都会被诊断,并作为新的 intent.md 写回循环中。 |
贯穿右栏的主线是已提交的工件。每个阶段结束时都会将一个工件写入版本控制(包括 intent.md、spec.md、plan.md、diff 及其测试、包含审查结论的 PR 以及事件记录),下一阶段则从读取该工件开始。在早期阶段,.md 文件是主要工件,因为产品负责人和智能体都能读取并操作同一文件。从构建阶段起,工件变为代码及其记录。提交链同时也是审计追踪:谁要求了什么、智能体产出了什么、谁批准了什么。
人类仍对所有需要判断力的决策负责。在智能体 SDLC 世界中,人类的注意力随需要审查的工件一同转移。
每个阶段都提交一个可供下一阶段读取的工件。意图、规格、计划、diff 和审查结论共同构成审计追踪。
剧本
剧本是剧本库的核心,分为六个非线性阶段(规划、设计、构建、测试、部署、维护),共同覆盖完整生命周期。
每个剧本涵盖:
变更内容;入门指南;具体的实施步骤;治理考量;以及如何衡量其是否奏效。
这些步骤是模块化的,各组织可以根据自身独特需求,选择在不同时间优先改造不同阶段。每个玩法都在“前置条件”下注明其依赖项,依赖关系图对此作了进一步说明。
一个阶段以提交工件结束,提交动作随即启动下一阶段。被接受的 intent.md 触发需求与设计环节,获批的 spec.md 触发计划模式,合并的 PR 触发流水线,而生产环境中的控制带被突破则写入下一份 intent.md,如此循环往复。
首先,你手动为每个步骤提供提示词,最终状态是一个循环:每个被接受的工件都会触发下一道关卡。人工注意力集中在关卡处,审查智能体标记的内容,而不是从头开始每个阶段。
这些玩法按阶段列出;箭头表示采用它们的顺序。两者并不相同。从任何一个“黏土”玩法开始——没有箭头指向它,因此它不需要任何前置条件。对于任何其他玩法,指向它的箭头所对应的玩法就是需要先采用的玩法。
计划
想法不再需要等待有人将其写成文档。意图只被捕获一次,用提出者自己的话表达,作为受版本控制的工件,供下一阶段直接使用。
捕获为 intent.md
启动软件开发流程的 intent.md 可以通过不同途径进入。一个人有了想法、提交了一张工单,或者通过告警发现了一起事件(见第 6 阶段:维护)。
当一个人有了想法时,他们会与 Claude 进行头脑风暴,并生成一份 markdown 格式的原型规格说明。在传统 SDLC 中,同一个人随后必须说服产品团队的一名成员,与其一起或代其将想法写成文档。
由 Claude 生成的原型规格说明是人类可读的、受版本控制的,并且可被下一阶段直接使用。该原型规格说明保存为 intent.md。
无论意图来源于事件触发还是智能体,所遵循的步骤都是相同的:产品负责人会在提交 agent 编写的 intent.md 之前对其进行审查和修正。
传统方式:一个想法在任何人能够行动之前,需要经过待办事项条目、用户故事、故事点和细化会议。所有权在每次交接时转移,因此最终到达工程团队的内容,与最初提出者的本意已经相隔了好几个环节。
AI 原生方式:提出者与 Claude 进行头脑风暴,并将结果记录为 intent.md,这是一份用提出者自己的语言写成的原型规格说明。该产物包含想要什么、为什么想要,以及在哪些约束条件下。重复性流程通过技能(skills)进行编码。
快速上手
前置条件
无。
基础设施
为非工程师人员提供 Claude 访问权限(claude.ai 或 Cowork);一份各方认可的 intent.md 模板;一个共享的、受版本控制的 intent 存放位置,由产品负责人关注。对于单一产品,最简单的存放位置是产品仓库中的 intent/ 文件夹。这种设置使产物链与由其衍生的代码保持相邻。只有当 intent 跨越多个仓库时,专门的 intent 仓库才值得投入额外开销,而在单体仓库中它就是一个目录。第 3 阶段:构建 侧边栏介绍了该存放位置与已保存记录的 Jira 或需求工具之间的关系。
设置这一环境是平台或工程团队的一次性任务。技术团队成员需要搭建 intent 存放位置并决定谁可以写入,因为许多贡献者将来自整个组织的不同部门。
一旦仓库创建完成,没有 git 经验的贡献者无需直接使用 git。相反,通过连接到版本控制系统(例如 GitHub)的连接器,可以让 Claude 代表他们从 claude.ai 或 Cowork 提交 markdown 文件。
如何执行
- 提出者用自己的语言向 Claude 描述问题。提出者可以描述他们今天无法做到的事情、受该想法影响的人群、更好的状态是什么样的,或者哪些内容不在范围内。不需要任何正式语言。
- 进行头脑风暴,直到想法变得具体。Claude 会提出分析师会问的问题:范围、用户、约束条件,以及成功是什么样子的。
- 让 Claude 按照组织模板把结果写成 intent.md,该模板可由技术团队成员编码为技能包,并由负责人签字确认。这份文档可以涵盖问题、预期成果、受影响的用户和系统、约束条件以及待解决的问题。
- 发起人纠正 Claude 理解错的任何内容。
- 将 intent.md 提交到共享主目录。作者和时间戳会一并记录在案,产品负责人从那里接手这个想法。
markdown Intent:理赔状态自助查询 作者:J. Ortiz(理赔运营部)。状态:草稿。
问题 客户致电联络中心询问理赔进度。客服人员大约有三分之一的工作时间花在仅查询状态的通话上。
预期成果 客户可以在门户中查看理赔状态、下一步操作和预计完成日期。
受影响的用户和系统 理赔客服人员、门户团队、理赔核心 API。
约束条件 门户会话中不新增任何 PII。仅使用现有身份验证。
待解决的问题 第三方损失理算师是否也需要访问权限?
治理考量
证据就是已提交的 intent.md,其中列出了作者、时间戳和完整的修订历史。它记录在 intent 主目录的 git 历史中。产品负责人进行审批,将意图送入第二阶段:设计 的接受或拒绝决定,会以合并或关闭评审的形式记录下来。
如何衡量
先行指标
从首次对话到提交 intent.md 的时间,通过读取 intent 主目录上的 git 历史获得,其中记录了作者和时间戳。预期是将数周的需求收集和细化周期缩短到数小时。
滞后指标
存活率,即产品负责人接受进入第二阶段:设计 而非关闭的 intent.md 文件占比。接受或拒绝决定以合并该工件或关闭评审的形式记录。此外,还包括在针对同一变更的首次 spec.md 提交之后,对 intent.md 所做的修改次数。
设计
需求和设计合并为一次会话。策略在编写 spec 时即被应用,而不是在数周后的评审中才发现。
需求和设计
经产品负责人批准后,Claude 会采用已接受的 intent.md 并生成需求与设计规格说明书。此过程由组织在品牌、安全、合规和用户体验方面的技能所引导。
产品负责人审阅该规格说明书,但不会亲自撰写。此流程的目标是生成一份工程团队可以据此规划的规格说明书,并标注出需要关注的领域。
前端工作是这方面最清晰的例子。一旦 intent.md 被接受,产品负责人会基于 intent.md 在 Claude Design(测试版)中制作设计原型,对原型进行迭代,然后将其导出到 Claude Code 进行构建。
传统模式中,需求和设计是由不同团队执行的独立阶段。分析师将想法正式化为需求,然后设计师再将这些需求解析为设计。这种分离是为了明确责任,但过程缓慢且信息有损。
AI 原生模式中,两个阶段在同一个提示会话中完成。Claude 接受 intent.md 并生成需求与设计规格说明书,受组织技能约束,并标注出需要关注的领域。
快速入门
前提条件
编写一个 intent.md 文件,并将品牌、安全、合规和用户体验策略编写为技能。
基础设施
一位拥有 Claude 访问权限的产品负责人。无需工程技能。
执行方式
- 产品负责人开启一个会话,加载组织的技能,并附上 intent.md。
- 产品负责人的提示词指向 intent.md,指明约束条件,并要求标注出需要关注的领域。首先手动运行此流程,然后将其固化为组织级别的斜杠命令。此后,将 intent 主页中 intent.md 的接受作为触发器,在合并时触发一个非交互式任务,加载组织的技能运行该流程,并将 spec.md 作为拉取请求提交(第 5 阶段:部署中的 CI/CD 部分涵盖了相关管道)。从那时起,产品负责人的首次介入就是审阅。
- 同一位产品负责人对照原始想法审阅规格说明书。该规格说明书是否解决了所述问题?intent.md 中提出的开放性问题是否已得到解答或被继续推进?
- 先处理被标记的问题,因为这些都是分析人员会升级上报的要点。产品负责人会在工程团队看到规格说明之前,逐一与对应的策略负责人解决这些问题。
- 将 spec.md 与 intent.md 一起提交。这对文件记录了所要求的内容和所决定的内容。
- 产品负责人决定规格说明和意图是否进入构建阶段,对于组织归类为较高风险的事项,会咨询技术负责人。这个决定始终由人类团队成员做出,而接受规格说明正是启动第 3 阶段(构建)中计划模式运行的开端。
实际效果(提示词)
markdown 阅读所附的 intent.md,并产出一份将其集成到我们现有代码库中的需求与设计规格说明。运用你可用的技能,使计划符合我们的品牌指南、安全策略和 UX 标准。将规格说明完整记录为 spec.md,随时可以交给工程团队。清晰描述任何值得关注的领域,尤其是当你无法同时满足相互冲突的策略时。
治理考量
现行策略不是在数周后的评审中才被发现,而是在编写规格说明的同时就被读取和应用。组织的技能作为约束条件施加于规格说明之上。规格说明、生成它的提示词,以及生效中的技能版本,全部记录在版本控制中。产品负责人签署批准规格说明,并将标记的问题转交给指定的策略负责人。
如何衡量
先行指标
同一变更从 intent.md 提交到 spec.md 提交之间的耗时(两个 git 时间戳),与旧的“需求加设计”周期进行比较。
滞后指标
构建开始后的需求返工量。统计同一变更在首个 plan.md 提交之后产生的 spec.md 提交次数。Git log 可以直接给出这个数据。
构建
没有已批准的计划,就不会实施任何内容。机构知识变成智能体读取的文件,护栏以代码形式运行,而非依赖习惯。
Claude Code 计划模式作为默认起点
工程师以计划模式启动 Claude Code 会话,将第 2 阶段(设计)中已批准的 spec.md 交给 Claude,并让它对工程师进行访谈,不断迭代计划,直到工程师对计划满意为止。
传统方式:工程师阅读设计后开始编写代码。变更将如何实施——具体到哪些文件和哪些测试——都保留在工程师的脑海中,至多写在工单评论里。其他人无法审查。审查者看到的第一样东西是最终的差异(diff),而到那时返工已经变得缓慢。
AI 原生方式:工作始于 Claude 在计划模式(plan mode)下生成的一份书面计划,在该模式下它可以读取代码库而不做任何修改。工程师在代码编写之前修正计划,批准后的版本作为 plan.md 提交,供后续阶段对照检查。
开始使用
前置条件
意图工件(intent.md 或 spec.md)如果存在会有帮助,CLAUDE.md 文件同样有用。
基础设施
能够访问代码仓库的 Claude Code。
如何执行
- 工程师以计划模式与 Claude 开启会话。
- 工程师将 intent.md 和 spec.md 交给 Claude,要求其生成一份实施计划,计划中需指明变更涉及的文件、工作顺序以及用于验证的测试。
- 通过提问来审视计划:该变更可能破坏什么、哪一步风险最高、Claude 选择了哪些其他方案而未采用。
- 反复迭代,直到一位从未看过这段对话的工程师仅凭计划就能实施该变更。
- 将批准后的计划提交为 plan.md。该计划加入审计追踪,PR 审查环节(阶段 5:部署)将对照它检查最终的差异。
- 接受计划并让 Claude 实施。有了扎实的计划,实施往往一次就能完成。
- 当实施偏离计划时,在同一提交中更新 plan.md。可考虑使用钩子(hook)强制两者保持同步。
示例(plan.md)
markdown 计划:理赔状态自助查询(源自 intent.md 2026-06-02)
变更文件 portal/src/claims/StatusPanel.tsx(新增)、claims-api/routes/status.py、claims-api/tests/teststatus.py
工作顺序
- 在现有认证之后添加状态端点。
- 将面板对接该端点。
- 接入门户导航。
风险 claims-core API 速率限制为 50 rps;面板必须做缓存。
验证 teststatus.py 覆盖四种理赔状态;截图与已批准的模型一致。
治理考量
设计评审发生在任何代码生成之前,此时改变方向仍只是编辑文档的问题。计划模式本身强制执行这一点,因为在工程师接受计划之前,Claude 无法编辑文件。计划及其修订版本会连同接受者信息一起被记录。常规变更由工程师批准,而组织归类为较高风险的事项则交由技术负责人或架构师处理。
如何衡量
先行指标
首次实现即合并的变更占比,以及从计划批准到合并 PR(含 PR 元数据中所需数据)的时间。
滞后指标
每次变更的返工周期(同样来自 PR 元数据),以及合并后的差异与已提交的 plan.md 的匹配频率。
自动模式下的 Claude Code
Claude Code 也可以以自动模式运行,在此模式下,工程师批准计划,并在满意且迭代完善后,Claude 无需每次编辑都提示即可应用每项变更。随着后续实践中的防护措施逐渐成熟(经过调优的 CLAUDE.md、编码策略的技能、阻止不安全操作的安全钩子,以及 Claude 可以运行的测试套件),自动接受成为常规工作的默认方式:一份紧凑的 spec.md、较小的爆炸半径,以及测试已覆盖的代码。
现在的转变方向是:从用户盯着智能体做编辑并审查操作,转向在更长的自主会话结束后审查产物。自动接受模式配合 worktrees 使用时,还能进一步实现个人和团队层面的并行化,并且是自主运行 SDLC 以及闭环完成第 6 阶段(维护)所述流程的基础。
侧栏 遗留系统与事实来源
适用于流程产生的每一份产物。
现有的 SDLC 流程很可能已经在跟踪产物,只是不是以 markdown 文件的形式。工作项可能在 Jira 中,需求在带有内置监管可追溯性的工具中,设计在 Figma 中,变更审批则由变更委员会处理。这些系统很难被取代,因为审计人员和监管机构已经接受它们,而且其他团队也依赖它们,因此 AI 原生的 SDLC 必须适应现有体系。
在向 AI 原生 SDLC 过渡时,对于流程产生的每一个工件,都要指定一个系统作为唯一事实来源,其他所有系统只保留副本或指向原件的链接。可以通过以下配置来建立唯一事实来源,具体选择因工件而异:
以代码仓库为唯一事实来源。Markdown 工件是权威记录,遗留系统引用提交中的文件。对于工程主导的组织来说,这可能是最简洁的配置之一,因为所有记录都存在于一个工具中,且只有一个时间戳权威。
以遗留系统为唯一事实来源。Jira、ServiceNow 或需求工具保存权威记录,Markdown 工件是工作副本。Claude 在会话开始时读取记录,并在生成规格或计划的同一会话中,通过 MCP 连接器将结果写回。
以链接为最低标准。所有工件都注明记录 ID,所有遗留记录都包含 Markdown 文件的提交 SHA。在向 AI 原生 SDLC 过渡时,链接是一个很好的起点,同时要接受存在两个事实来源的现实。
遗留系统和 Markdown 优先系统可以共存,只要两者之间有链接,或者其中一个被声明为唯一事实来源。
CLAUDE.md
CLAUDE.md 为 Claude 提供了新成员所需的上下文,涵盖约定、命令、架构以及团队最常犯的错误。过去存在于人们头脑中和 wiki 上的知识,变成了一份智能体在每次会话开始时都会读取的文件,由整个团队维护,并在每次犯错时迭代更新。
开始使用
前置条件
无。
基础设施
一个代码仓库、已安装的 Claude Code,以及一位熟悉代码库的工程师。
执行方式
- 在仓库中运行 /init。Claude 会根据它发现的内容生成一份初始的 CLAUDE.md。
- 将生成的文件精简到新成员第一天就需要的内容。保留构建、测试和 lint 命令、重要的约定,以及 Claude 经常出错的地方。
- 将 CLAUDE.md 提交到仓库根目录的 git 中,这样整个团队共享一个版本,变更也会像代码一样接受审查。
- 这里有一条实用规则:当 Claude 连续两次犯同样的错误时,就把修正写进 CLAUDE.md。
- 内容保持在一页以内,因为 Claude 会在会话开始时读取全部内容,任何过时的信息都只会白白占用上下文。
实际效果示例(CLAUDE.md)
javascript 支付服务
命令
- 构建:make build
- 测试:make test(单元测试)、make itest(集成测试,需要 docker)
- 代码检查:make lint(在 CI 中运行;推送前先修复)
约定
- Java 21、Spring Boot 3。不再新增 Lombok。
- 金额一律使用 BigDecimal,绝不用 double。
- 每个端点都需要在 src/itest 中编写集成测试。
架构
- api/ 存放 REST 控制器,core/ 存放领域逻辑,adapters/ 对接外部系统。
- Kafka 事件定义在 schemas/ 中;绝不手动编辑生成的类。
Claude 容易出错的地方
- 不要升级依赖版本;这些由平台团队统一管理。
- 旧版 v1/ 包已冻结;改动一律放在 v2/ 中。
治理考量
CLAUDE.md 纳入版本控制,因此智能体所遵循的指令是可审查、可审计的。团队约定通过该文件落地,对它的修改会记录在 git 历史中,代码所有者会在 PR 评审中审批这些改动。
如何衡量效果
先行指标
Claude 重复犯下本应由 CLAUDE.md 避免的错误的频率。对 CLAUDE.md 的修正或改动应在 git 历史中留痕。
滞后指标
新成员从加入团队到首个 PR 被合并所需的时间(依据 PR 历史统计)。
技能作为机构知识
技能是组织将机构知识落地为可操作能力的方式。其指令明确、纳入版本控制、适用范围广,并在政策变化时集中更新。经验法则:为必须一致执行的机构知识编写技能;不要为应属于 CLAUDE.md 或提示词的组件编写技能。
快速上手
前置条件
无需任何前置条件。有 CLAUDE.md 会有所帮助,因为它能把智能体的工作知识保留在仓库中,但技能并不依赖它。
基础设施
每项策略都有指定的负责人和书面的权威来源。
执行方式
- 挑选一条目前执行不一致的知识点。可以是安全标准、API 设计约定或品牌规范。
- 把它写成一个技能,也就是一个包含 SKILL.md 的文件夹,其 frontmatter 说明该技能何时触发,正文说明该做什么。工程师根据政策所有者的权威来源编写该技能,并借助 Claude 辅助完成。
- 将该技能放在仓库的 .claude/skills/ 目录下,使其随代码一起发布,或者通过插件在组织范围内分发。
- 测试该技能能否触发。用不同方式让 Claude 执行相关任务,并确认每次都能加载该技能。
- 当政策发生变化时,修改该技能,并让政策所有者签字确认这一变更。
- 工程师会在下一次会话中自动获取新版本。
实际效果示例(.claude/skills/secure-api-review/SKILL.md)
markdown
name: secure-api-review description: 应用 API 安全标准。在创建或修改面向外部的端点、审查 API 代码或生成 OpenAPI 规范时使用。
安全 API 审查
当你创建或修改 API 端点时:
- 身份验证:每个端点都需要网关 JWT;除 /health 外不允许匿名路由。
- 输入验证:根据 OpenAPI 模式验证请求体,并拒绝未知字段。
- 审计:每个改变状态的端点都会发出包含操作者、操作、实体和时间戳的审计事件。
- 数据分类:模式中标记为 pii 的字段绝不能出现在日志或错误消息中。
运行 scripts/check-endpoints.sh 并将其输出包含在你的总结中。
治理考量
技能是一种控制手段,尽管是建议性的。它使 Claude 在编写代码时更有可能应用该政策,但没有任何机制强制某个会话必须遵守它。对于必须始终成立的政策,需要在技能背后加上确定性的保障,例如阻止该操作的钩子,或在 PR 阶段重新检查政策的审查环节。技能使违规变得罕见,而钩子使违规几乎不可能发生。技能调用会记录在会话轨迹中,政策所有者像审查代码一样审查技能变更。
如何衡量
先行指标
从政策所有者批准政策变更到更新后的技能合并所用的时间,取自技能文件夹上的 PR。
滞后指标
对引用该策略的 PR 审查结果进行复核,一旦技能在代码编写过程中应用了该策略,此类结果应趋近于零。若结果未趋近于零,要么是技能未触发,要么是其文本已偏离官方策略。
钩子作为构建阶段的护栏
技能是建议性控制,而钩子是其背后的确定性层。Claude 的大部分操作发生在实现阶段的文件编辑和 shell 命令上,因此构建阶段是钩子最常触发的地方。
构建阶段的钩子可以:
阻止对受保护路径的编辑,例如生成的类或冻结的包;在文件编辑后运行格式化和 lint 检查,使偏差永不累积;防止凭据出现在 diff 中。
为任何策略必须无条件成立的技能提供支撑。钩子会在每次匹配的操作上运行,因此构建阶段的钩子应保持快速,并限定在发生变更的文件范围内。更重的检查(如完整测试套件)应放在提交或 PR 阶段。
需要人工审批的钩子应归属于第 5 阶段(部署)的门禁,因为构建期间的审批提示会把人员重新拉回所有并行会话的关键路径上。
并行会话与子智能体
一名工程师可以同时驱动多条工作流。
并行会话是另一个完整的 Claude Code 实例,在各自的 git worktree 中处理独立任务。每个独立会话互不知晓彼此,工程师的调度是它们唯一的共同点。
子智能体在单个会话内作为受限助手运行,拥有自己的上下文窗口和工具限制,适合在多个任务中重复出现的工作,例如验证应用按预期运行。
并行会话提高了工程师同时进行的任务数量,而子智能体则让每个会话专注于自身任务。工程师的职责是调度和审查所有这些工作。
传统方式下,一名工程师一次只处理一个任务,并将一天或一周的相当大一部分时间花在构建、测试和审查上。等待期间切换任务虽有可能,但上下文切换带来的疲劳足以让大多数人选择不这么做。
AI 原生模式:一位工程师同时运行多个 Claude 会话,每个会话在自己的工作树中处理各自的任务。重复性工作变成子智能体,拥有自己的上下文和工具限制。工程师的职责转变为编排调度,并最终转向构建和监控循环。
入门指南
前置条件
CLAUDE.md 文件,因为所有会话都会读取该文件。反馈循环(第 4 阶段:测试)在这里也有帮助,因为当会话能够自行验证其工作时,工程师所需的监督就更少了。
基础设施
一个 git 仓库,因为隔离性来自工作树,并且权限设置经过调整,使得会话不会因组织认为安全的命令而等待审批提示。
执行方式
- 工程师利用计划模式剧本(第 3 阶段:构建)中的计划,将工作拆分为涉及不同文件的任务,以确定哪些工作相互独立。共享文件的任务在单个会话中依次运行。
- 每个并行任务都有自己的工作树,例如在一个终端中运行 `claude --worktree feature-auth`,在另一个终端中运行 `claude --worktree fix-rate-limit`。工作树是在各自分支上的独立检出,可防止会话在文件上发生冲突。
- 两到三个会话是合理的起点。实际上限取决于一个人能妥善审查多少条流,因此只有在审查跟得上的情况下才增加会话。
- 将重复性工作转变为子智能体,这些子智能体在 `.claude/agents/` 目录下的 markdown 文件中定义,每个子智能体都有名称、使用场景描述以及可访问的工具。示例包括:一个代码简化器,在主智能体完成后去除不必要的复杂性;一个验证器,运行应用并检查行为;一个研究员,探索代码库并汇报结果,而不会淹没主上下文。将这些定义提交到 git 中,以便整个团队共享。
示例(.claude/agents/verifier.md)
javascript
name: verifier description: Runs the app and checks the change works before the session reports done tools: Bash, Read
使用 `make run` 启动应用。测试变更后的行为以及两个最邻近的流程。报告你运行了什么、看到了什么,以及任何与 plan.md 不符的行为。不要修复任何问题,只做报告。
治理考量
会话越多意味着产出越多,因此控制措施必须来自仓库中的配置。仓库中的钩子和权限设置适用于所有会话,会话所执行的操作会被记录并归属于运行该会话的工程师。
如何衡量
先行指标
在审查质量保持的前提下,每位工程师的并发会话数(从 OpenTelemetry 导出中统计),以及一天中用于引导而非等待的时间占比。
滞后指标
每位工程师每周合并的变更数,结合根据 PR 历史确定的返工率一起解读。
为 Claude 建立反馈回路
始终为 Claude 提供一种验证自身工作的方式,无论是测试、构建还是截图对比。会话会在工程师看到之前自行检查工作并修复自身错误。
反馈回路不应与验证子智能体(阶段 3:构建)混淆。反馈回路贯穿整个任务,运行次数与工作量相当。而验证子智能体则是将会话认为工作完成后的最终检查打包的一种方式——通过运行一个全新的上下文窗口来实现。这样,最终结论就不会受到产生代码时那些假设的影响。
传统方式 代码是否可用的信号来得太晚。CI 要几分钟后,测试人员要几天后,生产环境要几周后。当智能体生成代码时,迟到的信号意味着必须有人检查它的全部输出,而这个人就成了瓶颈。
AI 原生方式 会话在有人看到之前就获得了一种自行检查工作的方式。运行测试、运行构建、截图。Claude 会不断迭代直到检查通过,因此到达工程师手中的内容已经通过了检查。建立这个回路是运行会话的工程师的职责,下面的步骤就是为他们编写的。
入门
前置条件
无。
基础设施
一个测试套件和一个构建,各自通过一条命令即可在本地运行。对于 UI 工作,让 Claude 看到结果的方式至关重要——可以是浏览器工具,也可以是通过 MCP 接入的截图工具。
如何执行
- 如果今天检查工作需要一系列命令和一些环境知识,就将其封装到单个目标中,例如“make test”或“npm test”,并在失败时以非零状态码退出。
- 在 CLAUDE.md 的 Commands(命令)部分,列出每条命令,并附上一个健康输出的示例。
- 设定一个目标,并使其可量化,这样 Claude 无需询问你即可自行检查工作,例如:“teststatus.py 中的所有测试均通过”、“截图与所附的 mock 一致”,或“端点返回 200 并带有新字段”。
- 对于 bug 修复,先编写失败的测试。请 Claude 将 bug 复现为测试,运行它,并确认它因你预期的原因而失败。提交该测试。然后才请 Claude 在不修改测试的情况下使其通过,并利用最后一步中的测试文件钩子来强制执行此限制。一个在修复之前就已存在、且智能体无法重写的测试,就是 bug 已消除的证明。
- 对于 UI 工作,通过视觉检查来闭环。给 Claude 一个浏览器或截图工具,给它 mock,让它迭代。实现、截图、对比、调整。两三轮是正常的,而且每一轮结果都应有所改进。
- 将验证纳入“完成”的定义。指令写在 CLAUDE.md 中。在报告任务完成之前运行测试,并展示输出。
- 最后,这个循环本身也需要保护,因为修复代码的智能体绝不能削弱对该代码的检查。在修复任务期间,阻止对测试文件进行编辑的钩子就能做到这一点。另一种做法是在审查时检查 diff,并拒绝任何涉及测试的更改。
实际效果(CLAUDE.md 验证块)
javascript 验证你的工作
- 构建:make build(必须以“Build succeeded”结束)
- 测试:make test(全部通过;绝不跳过或删除失败的测试)
- 代码检查:make lint(零警告)
在报告任何任务完成前,运行以上全部三项,并粘贴输出。如果测试失败,修复代码,而不是测试。
治理考量
强制执行的内容
任务报告完成前的验证,以及修复期间阻止智能体编辑测试文件的限制,这两者都在组织希望得到保障的地方以钩子形式实现。
证据是什么
“make test”的字面输出、构建日志,或 Claude 运行并粘贴的截图对比,因此证据来自工具链本身。
记录位置
在会话记录中(OpenTelemetry 导出会将其转发到组织的可观测性堆栈),以及在 PR 的检查运行中,审查者和任何后续审计人员都能看到这些内容。
谁负责审批
审查 PR 的代码所有者,他们可以专注于意图和风险,因为机械性的证据已经附上了。
如何衡量
领先指标
智能体编写变更的首次 CI 通过率,CI 系统本身已经支持这一指标。
滞后指标
每个 PR 的审查时间(来自 PR 元数据),一旦测试能捕获过去需要审查者人工发现的问题,这一时间应当下降;以及来自事件跟踪系统的变更失败率。
CI 中的持续评估
评估是 AI 原生版的阶段门控 QA。在实践中,这意味着每当智能体的配置发生变化时,就会运行一套评估套件。当换入新模型或重写提示词时,评估套件会判断智能体是否仍能按照同样的标准完成工作。
评估应被视为一套活套件。随着模型不断改进,曾经具有区分度的用例会逐渐失效,必须根据持续监控中出现的新的情况添加新的用例。
根据具体使用场景,有些团队可能更倾向于按固定节奏离线运行这些评估,而不是在每次变更时都运行。以下步骤针对的是持续评估。
入门
前置条件
CLAUDE.md 和反馈循环(阶段 4:测试)。
基础设施
能够以非交互方式运行 Claude Code 的 CI,以及带有评估运行预算的 API 密钥。
如何执行
- 平台工程师从近期工作中收集 20 到 50 个真实任务,并附上预期/可接受的结果。
- 将每个任务编写为一个评估项,即提示词加上定义可接受结果的检查项(测试通过、lint 无报错、行为不变、策略得到遵守)。
- 该套件在 CI 中按计划以非交互方式运行,并在 CLAUDE.md、技能或钩子发生任何变更时运行,因为这些配置会引导智能体的行为,理应获得与代码同等的回归测试待遇。
- 根据结果对配置变更设置门禁。导致通过率下降的技能变更在合并前需要经过审查。
- 每次生产事故都会对应一个评估项,由负责该事故的团队编写,并作为回归测试保留在套件中。
它看起来是什么样(.github/workflows/agent-evals.yml)
yaml name: Agent evals on: pullrequest: 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: ANTHROPICAPIKEY: ${{ secrets.ANTHROPICAPIKEY }} 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
治理考量
评估为QA提供了一道能跟上智能体产出的把关闸门。通过率阈值作为合并检查强制执行,运行过程会被记录以便随时间对比结果,而负责该配置变更的团队负责审批。
如何衡量
领先指标
评估通过率随时间的变化(由测试套件在每次运行时报告),以及一次生产事故需要多久才能转化为一个永久性的评估用例。
滞后指标
在CI中捕获的回归问题,与根据事故追踪系统得出的生产环境中发现的回归问题之间的对比。
部署
双向审查运行,治理在智能体行动时强制执行。智能体负责生产门禁之前的所有工作,门禁之后则一概不做。
PR 审查循环中的 AI
Claude 既给出审查,也接收审查。它根据组织的政策审查传入的 PR,并处理自己 PR 上收到的审查意见。这让工程师在 PR 审查中能够专注于行为本身,而这归结为判断意图和风险。
传统审查 审查容量是按人工产出规划的。一个 PR 要等待审查者通读全部内容,审查质量随审查者的负载而波动,作者在积压不断增长的同时还要不断催促。
AI 原生 所有 PR 都获得一组完全相同的审查流程,发现的问题按严重程度排序。人工注意力上移一个层级,聚焦于变更是否符合计划意图、风险是否可接受。
入门指南
前置条件
来自阶段3:构建的更新版 CLAUDE.md 文件;如果审查通过则强制执行书面政策、已定义的子智能体。
基础设施
一个安装了 Claude 集成的代码仓库,要么是由管理员启用的托管代码审查(研究预览)服务,要么是在你自己的 CI 中运行的 claude-code-action,在需要时通过 AWS Bedrock、Google Vertex 或 Microsoft Foundry 进行模型调用(CI/CD 方案涵盖了部署选项)。要求代码所有者批准的分支保护策略也值得采用。
如何执行
- 托管代码审查服务是最快的入门方式。管理员启用它并选择代码仓库。当你需要控制流水线,或希望 API 调用通过你自己的云协议路由时,可以在自己的 CI 中使用 claude-code-action 运行审查(CI/CD 方案涵盖了这些管道细节)。
- 技术负责人将审查策略写成仓库根目录下的 REVIEW.md,分为组织关心的几个方面:缺陷和逻辑错误;安全性和漏洞;对照规范(来自需求方案的 spec.md)、实施计划(来自计划模式方案的 plan.md)和设计原则的合规性。REVIEW.md 还定义了什么是“重要”问题,什么是“小问题”,以及哪些内容需要跳过。
- 技术负责人设定人工阈值。审查发现本身不会批准或阻止 PR,分支保护仍然要求代码所有者批准。想要根据审查发现来把关合并的平台工程师,可以读取检查运行发布的严重性计数,该计数以机器可读的汇总形式呈现。
- 当审查者或作者在审查评论中标记 @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 已强制检查的内容均被排除在外。
实际效果(REVIEW.md)
markdown 审查说明
通过项 运行三轮审查,并为每条发现标注其所属轮次:
- 缺陷:逻辑错误、边界情况处理不当、细微回归
- 安全:注入风险、认证漏洞、日志中的 PII(个人身份信息)
- 合规:变更符合 spec.md、plan.md 及我们的设计原则
“重要”在此处的含义 将“重要”级别保留给会导致行为异常、数据泄露或违反策略的发现。风格和命名问题属于小问题(nit)。
限制小问题数量 每次审查最多报告五个小问题;其余以计数形式汇总。
不报告 src/gen/ 下的生成文件以及 CI 已强制检查的任何内容。
治理考量
职责分离得到保留,因为编写代码的智能体无法批准自己的代码。REVIEW.md 中的审查策略适用于所有 PR,发现、修复、评级和批准均记录在 PR 历史中,因此 PR 本身就是审计记录。批准由人类通过分支保护机制完成,并参考审查发现。
如何衡量
先行指标
首次审查时间,应缩短至分钟级别,以及无需人工触碰分支即可解决的审查评论占比,数据直接存储在 Git 上。
滞后指标
合并前捕获的缺陷和漏洞与流入生产的缺陷和漏洞之比,数据来自 PR 历史和事件跟踪系统。
Hook 作为批准门禁
构建阶段使用 Hook 作为护栏,在无人工介入的情况下允许或阻止操作(第 3 阶段:构建)。Hook 也可以进行询问,暂停操作直到特定人员批准,这正是发布门禁所需要的。
这个剧本位于第 5 阶段:部署,因为发布审批是最清晰的用例,但钩子并非仅限部署场景:只要 Claude 采取行动,钩子就会运行。例如,钩子可以在第 3 阶段:构建期间阻止在没有变更工单的情况下修改迁移文件和基础设施,也可以在第 4 阶段:测试期间阻止智能体在修复任务中编辑测试文件。
快速上手
前置条件
无。
基础设施
一份书面清单,列出变更流程所需的各项审批。
执行方式
- 工程领导层与变更管理和合规团队共同列出必须保留的人工审批关卡,例如变更管理签核、发布授权,以及对受保护路径的编辑权限。
- 平台工程师将每个关卡实现为一个钩子,即在 Claude 行动之前运行的脚本,该脚本可以允许、询问或阻止操作。
- 团队级钩子放在 git 中的 .claude/settings.json 里,而不可协商的钩子则放在由平台或 IT 管理员拥有的托管设置中,个人工程师无法将其关闭。
- 阻止操作时应说明原因,因此当钩子阻止某个操作时,原因和审批途径会显示在 Claude 的输出中。
效果示例(.claude/settings.json)
json { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "${CLAUDEPROJECTDIR}/.claude/hooks/production-gate.sh" } ] } ] } }
关卡脚本本身(.claude/hooks/production-gate.sh)
bash #!/bin/bash 生产环境部署需要具名的发布授权 cmd=$(jq -r '.toolinput.command' < /dev/stdin) if [[ "$cmd" == "deploy" && "$cmd" == "production" ]]; then if [ -z "$RELEASEAPPROVAL" ]; then echo "生产环境部署需要发布授权。" >&2 exit 2 # exit 2 阻止该操作;消息会传递给 Claude fi fi exit 0
治理考量
钩子就是审批关卡。关卡条件每次都会强制执行,对所有人都一视同仁。允许和阻止的决定都会带有时间戳记录。关卡还定义了什么算作审批,无论是已批准的变更工单还是发布经理的签核。
实际案例:受监管企业的托管设置
由平台团队通过 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": "GITHUBTOKEN", "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 约束的是 Claude 的文件工具,但默认情况下,沙箱内的 shell 命令仍可能读取 ~/.ssh 或 ~/.aws/credentials;这一块配置会拒绝这些读取操作,并从每条沙箱命令的环境中剥离指定的密钥。
allowManagedHooksOnly 意味着本方案中的审批闸门是唯一会运行的钩子;本地任何内容都无法新增或替换它们。
`disableSideloadFlags` 和 `strictKnownMarketplaces` 意味着工程师机器上的每个技能、智能体、钩子和 MCP 服务器都必须来自组织批准的插件市场,绝不会来自个人主目录。
`allowManagedMcpServersOnly` 使智能体的工具面成为由平台团队拥有的允许列表。
`requiredMinimumVersion` 拒绝在低于批准下限的版本上启动,因此这些控制措施由组织实际评估过的构建来强制执行。
请将上述内容视为定制的起点,而非照搬的建议。每一项拒绝都会以能力为代价,而正确的平衡取决于仓库的数据分类。设置参考文档记录了每个键,包括仅托管管理的键:code.claude.com/docs/en/settings
如何衡量(针对钩子本身)
先行指标
在每个审批关卡上等待的时间。每个钩子决策都会连同时间戳以及允许或阻止的判定写入 OpenTelemetry 导出,因此每个关卡的等待时间都是可见的。
滞后指标
在钩子部署前后,从事件跟踪器中统计到达生产环境的关卡违规数量。
CI/CD 集成与部署
在 CI/CD 流水线中以非交互方式运行 Claude Code,对执行进行沙箱化,使长时间运行的智能体安全运行,通过 MCP 集成暴露部署能力,并在智能体需要回滚路径之前预先演练这些路径。
传统流水线运行确定性脚本,任何需要判断的事情都要等待人工处理。例如,对不稳定测试进行分类、编写变更日志,或排查构建失败的原因。部署和回滚是人工在压力下遵循的操作手册。
AI 原生的 Claude 以非交互方式在流水线中运行,负责需要判断的步骤,运行在具有限定凭据的沙箱中。部署工具通过 MCP 暴露给智能体,因此编写和测试变更的工作流也可以发布变更并回滚变更,这一切都在组织按环境定义的关卡内进行。
入门
前置条件
将 Claude 纳入 PR 审查循环,并将钩子作为审批关卡,因为关卡必须先存在,自动化才能加速任何流程通过它们。
基础设施
一个安装了 claude-code-action 的 CI 平台,或任何能够调用 `claude -p` 的 runner;通过 API 或 Bedrock、Foundry、Vertex 获得模型访问权限(在流量必须保留在组织云协议范围内的场景下);用于部署目标的 MCP 服务器;以及一个不持有常驻生产凭据的智能体任务沙箱配置文件。
如何执行
- 平台工程师从只读的判断步骤开始。在流水线任务中使用 `claude -p` 来分诊失败的构建、总结不稳定的测试,或起草变更日志。
- 在现有门禁之后添加写入步骤,用于修复 lint 问题、更新生成的文档,或通过 @claude 提及来处理评审意见等任务。智能体写入的任何内容都会以 PR 的形式通过分支保护机制提交,且智能体没有任何途径直接推送到 main 分支。
- 执行过程是沙箱化的。智能体任务在容器中运行,受网络策略约束,使用短期作用域 token,默认不持有任何生产凭据。
- 通过 MCP 暴露部署能力。部署、状态查询和回滚都成为工具,按环境限定作用域,因此智能体的部署权限是一个允许列表,而不是一个携带凭据的 shell 脚本。
- 按环境分级授予自主权。在开发环境中,智能体可以自由部署。在生产环境中,智能体准备发布版本,由发布经理授权,并通过钩子强制执行生产门禁。预发环境则介于两者之间。
- 回滚应该是流水线中演练最充分的路径——一个智能体可以执行的单一命令,并在预发环境中定期演练。闭环玩法(第 6 阶段:维护)在控制带被突破时会调用此回滚,因此它必须事先得到验证。
实际效果(流水线步骤)
markdown
- 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
治理考量
治理原则是:智能体可以一直行动到生产门禁之前,但绝不能越过它。以下控制措施用于强制执行这一原则。
分支保护会将智能体写入的任何内容转化为 PR,且不存在直接通往主分支的路径。生产部署钩子会阻止发布,直到指定的发布经理授权为止。每次非交互式运行都以智能体自身的身份执行,因此流水线日志能将智能体的操作与触发它的工程师的操作区分开来。按环境划分的权限层级决定了智能体在到达关卡之前可以执行多少操作。
如何衡量
先行指标
从 CI/CD 流水线日志中提取的、无需呼叫人工即可完成分诊的流水线失败占比。
滞后指标
DevOps 研究与评估(DORA)指标,这些指标由 CI 系统和部署工具已经生成。
维护
闭环形成。一个触发器在调用路径中没有任何人工参与的情况下调用 Claude,而它发现的内容会以 intent.md 的形式重新进入流水线。
维护与闭环
到目前为止,我们讨论了如何将 Claude 添加到 SDLC 流程的每个阶段,每个阶段都需要人工启动初始步骤。然而,这一阶段将重点转向让 Claude 自主运行以形成闭环。
例如,一个持续运行的监控智能体可以在 bug 工单被创建后,生成一个 intent.md,并依次经历需求、计划、构建、测试和审查阶段。第 6 阶段:维护以无人值守模式运行,在阶段之间设置独立的置信度关卡——可以是确定性检查,也可以是对抗性审查智能体——来决定前一阶段的输出是继续流转,还是升级给人工处理。
传统的维护是一个被动响应的阶段。所有工单或事件都需要等待人工采取行动并重新启动流程。凌晨 3 点触发的告警可能会被错过,工单可能会一直躺在待办列表中直到有人接手,而如果另一场事故先发生,事后总结的行动可能根本不会落实到代码库中。
AI 原生模式。诸如控制带越界、工单、频道消息或定时计划之类的触发器会在路径中无人工参与的情况下调用 Claude。Claude 进行诊断,仅通过受控路由采取行动,并将其发现写入 intent.md,随后该文件会经过上述各个阶段。人工负责分诊和审查这些工作,而不再需要启动它们。
形成闭环
一个确定性的脚本监控生产环境,当控制带被突破时调用 Claude。对突破的监控是循环自主运行模式的一个有用示例,而本阶段末尾的 Claude Tag(公开测试版)部分则涵盖通过不同渠道进入的工作。
入门指南
前置条件
Intent.md 为循环提供结构化输出以重新启动。Claude 加速 PR 审查、钩子作为操作边界,以及 CI/CD 的回滚路径(由最高自主层级调用)。
基础设施
一个检测脚本可查询的指标存储(Prometheus、CI 系统的 API 或等效方案)、仓库的读取权限、在 CI 中以非交互方式运行 Claude Code 的途径,或用于接收 webhook 的服务的 Agent SDK。
执行方式
- 服务所有者或平台工程师选择一个具有稳定滚动基线的指标,例如 CI 测试失败率、部署后 5xx 错误率或 PR 周期时间。
- 他们编写检测脚本,通常采用滚动窗口上的均值和标准差,并配合规则(Western Electric 或类似规则),使控制带既能捕捉缓慢漂移也能捕捉突发尖峰。脚本进行版本控制并配有单元测试,检测过程完全保持确定性,不涉及任何模型。
- 响应层级在版本控制的配置中定义(如下文的 bands.yaml)。在 1σ 时脚本仅记录日志,在 2σ 时调用 Claude 以只读方式诊断,在 3σ 时 Claude 可以采取行动,但仅限于向审查门禁提交 PR 或触发预先批准的 runbook。
- 触发层可以是 GitHub 或 GitLab 中的定时工作流、来自现有监控栈的 webhook,或网络内部的 Cron Job。Claude 以无状态方式运行,要么作为 CI 运行器上的非交互步骤,要么作为沙箱容器中的 Agent SDK 服务,CI/CD 部分涵盖部署和模型访问选项。由于运行是无状态且非交互的,循环可以在无人启动的情况下开始和结束。
- 智能体将其诊断以 intent.md 的形式写入第 1 阶段:计划格式,涵盖异常及其证据、提议的结果、受影响的系统以及任何未解决的问题。之后,发现结果像其他任何内容一样进入流水线。
- 服务负责人或值班工程师对队列进行分诊,将面向产品的发现项路由给产品负责人。可选择立即修复、安排计划或直接驳回。驳回操作会调整各分档区间,有助于降低噪音。
- 当修复上线时,为该事件添加一个评估用例(持续评估体系会发挥作用),以确保此类问题在未来得到防护。
实际效果示例(例如,一个用于监控 CI 测试失败率的 bands.yaml 配置)
yaml metric: citestfailurerate baseline: rolling30d rules: westernelectric tiers: 1sigma: { action: log } 2sigma: { action: diagnose, tools: "Read,Grep,Bash(gh run view )" } 3sigma: { action: propose, routes: [pullrequest, runbook:rollback-deploy] }
治理考量
分档边界由版本控制的配置强制执行,权限和托管设置禁止生产环境访问。调用记录、发现项和分诊决策均带有时间戳。服务负责人对发现项进行分诊和审批,由此产生的变更走常规 PR 审查流程,智能体可能触发的运行手册(runbook)也事先经过审批。
如何衡量
先行指标
从分档被突破到分诊队列中出现 intent.md 的时间,对比以往从事件发生到事后复盘行动的时间。检测脚本的日志中包含事件的分档突破时间戳和事件等级。
滞后指标
发现项中最终成为已合并修复的比例(分诊队列对比实际 PR 历史),以及同类事件的重复发生率——随着修复不断为评估套件补充用例,这一比例应当下降。
示例
当 CI 测试失败率突破 3σ 时,智能体会隔离不稳定的测试或发起回滚 PR,由审查流程决定最终处理方式。当部署后 5xx 错误率在部署窗口内突破 3σ 时,智能体会触发现有的回滚流水线。当 PR 周期时间触发漂移规则时,智能体会为工程管理层撰写报告,这表明该机制同样适用于流程指标和生产指标。
检测过程保持确定性。一旦分档被突破,Claude 才会被调用,而分档等级决定了它可以执行的操作。
Claude 值班,由 Claude 标记
事件也可能通过其他途径传入,例如 Slack 或 Teams 等职场通讯应用。事件可能表现为晚上 10 点在事件频道里发来的一条紧急修复消息,而现在可以立即处理。Claude Tag(目前已在 Slack 中提供公开测试版)让 Claude 以自身身份成为这些频道的成员,因此每起新事件都会有一位第一响应人,而响应本身也会成为循环的一部分,并为未来事件积累记忆。
对话和机构知识保留在频道内,频道中的任何人都可以引导并执行响应。任何团队成员都可以实时检验假设、探索新选项并进行调查,频道历史记录则增强了可审计性。通过访问 MCP,Claude 会验证指标已恢复到基线水平,并在线程中确认这一点,同时将事后复盘写入一个受版本控制的经验教训文件中,供未来的调查阅读。
事件并非 Claude Tag 接手的唯一工作。无论是通过 MCP 在工单上被标记,还是在频道中被直接指派,Claude 都会以同样的方式对工作进行分类。一个范围明确的小修复会以 PR 的形式通过审查门禁,而任何更大的工作则会被写成 intent.md 进入第一阶段:规划,此时循环便开始自我驱动。
频道就是审计轨迹:请求、诊断、人工授权和修复都保留在事件处理的地方。
结语
模型和工具链已变得更加先进,使组织不仅能够转变代码生产方式,还能重塑整个软件开发生命周期。
这一转变将人类判断力保持在流程的核心位置,并兼顾大型企业组织的治理与合规要求。
本指南汇集了我们的 Applied AI 团队每天为客户执行的许多真实最佳实践,希望您能从中获得实用且可操作的参考。
循环持续运转,人类判断始终居于其上。
资源与致谢
以下文档是平台团队建立这些控制机制所需的资料,大致按照您推出的顺序排列。
为你的组织设置 Claude Code——管理员决策地图;从这里开始 code.claude.com/docs/en/admin-setup 设置参考与优先级,包括每一个仅限管理的键 code.claude.com/docs/en/settings 来自 Claude 管理控制台的服务器托管设置 code.claude.com/docs/en/server-managed-settings 权限 code.claude.com/docs/en/permissions 沙箱——操作系统级别的文件系统和网络隔离 code.claude.com/docs/en/sandboxing 钩子——指南 code.claude.com/docs/en/hooks-guide 钩子——参考 code.claude.com/docs/en/hooks 技能 code.claude.com/docs/en/skills 插件和私有市场——技能和钩子如何在组织范围内分发 code.claude.com/docs/en/plugin-marketplaces 托管 MCP——对智能体工具面的集中控制 code.claude.com/docs/en/managed-mcp 企业部署概览——Bedrock、Vertex、Foundry code.claude.com/docs/en/third-party-integrations 企业网络配置 code.claude.com/docs/en/network-config 监控(OpenTelemetry)code.claude.com/docs/en/monitoring-usage 分析仪表板 code.claude.com/docs/en/analytics 合规 API——企业活动流、聊天检索与删除 platform.claude.com/docs/en/manage-claude/compliance-api 安全模型 code.claude.com/docs/en/security
感谢 Jim Blackhurst、Will Steuk 和 Jamal Arif 对本指南的贡献,本指南的灵感来源于并建立在他们此前的大量工作之上。
相关文章
面向初创公司的 Claude Code 指南
面向初创公司的 Claude Code 指南面向初创公司的 Claude Code 指南
面向初创公司的 Claude Code 指南面向初创公司的 Claude Code 指南
使用计算机操作、技能 API 和文件 API 构建生产级智能体
产品公告
使用计算机操作、技能 API 和文件 API 构建生产级智能体使用计算机操作、技能 API 和文件 API 构建生产级智能体
使用计算机操作、技能 API 和文件 API 构建生产级智能体使用计算机操作、技能 API 和文件 API 构建生产级智能体
Anthropic 的 AI 教学与学习方法
产品公告
Anthropic 的 AI 教学与学习方法Anthropic 的 AI 教学与学习方法
Anthropic 的 AI 教学与学习方法
Claude 随叫随到:Claude Tag 如何充当 Anthropic 应对 CI/CD 故障的第一响应者
借助 Claude 变革组织的运营方式
Claude Tag
编程
How to transform your software development lifecycle with AI—stage by stage.
Category Enterprise AI Claude Code
Product Claude Enterprise Claude Code Claude Tag
Date August 21, 2026
Reading time 5 min
Share Copy linkhttps://claude.com/blog/the-ai-native-sdlc-playbook
Author(s) Louis Claxton
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, releases 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.
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.
Table of contents
- Code is no longer the bottleneck
- Plays
- Stage 1 — Plan
- Stage 2 — Design
- Stage 3 — Build
- Stage 4 — Test
- Stage 5 — Deploy
- Stage 6 — Maintain
- Closing thoughts
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.
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 |
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.
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.
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.
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.
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
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.
Traditional An 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-native The 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.
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.
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.
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.md using 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.md to the shared home. Author and timestamp join the record, and the product owner picks the idea up from there.
markdown 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.
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.
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.
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.
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.
Traditional Requirements 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-native Both 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.
Getting started
Prerequisites
Write an intent.md file, with brand, security, compliance, and UX policies written as skills.
Infrastructure
A product owner with Claude access. No engineering skill is required.
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 of intent.md in 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 commit spec.md as 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.md answered 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.md alongside intent.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.
What it looks like (the prompt)
markdown 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.
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.
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
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.
Traditional An 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-native Work 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.
Getting started
Prerequisites
The intent artifact (intent.md or spec.md) if one exists, and the CLAUDE.md file helps.
Infrastructure
Claude Code with access to the repository.
How to execute it
- The engineer starts the session in plan mode with Claude.
- The engineer gives Claude the intent.md and the spec.md and 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.md in the same commit. Consider using a hook to enforce synchronization between the two.
What it looks like (plan.md)
markdown 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/teststatus.py
Order of work
- Add the status endpoint behind existing auth.
- Panel against the endpoint.
- Wire into the portal nav.
Risks The claims-core API rate-limits at 50 rps; the panel must cache.
Proof teststatus.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.
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.
Lagging indicator
Rework cycles per change, again from the PR metadata, and how often the merged diff still matches the committed 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.
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.
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.
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.
Getting started
Prerequisites
None.
Infrastructure
A repo, Claude Code installed, and one engineer who knows the codebase well.
How to execute it
- Run /init in the repo. Claude generates a starting CLAUDE.md from 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.md into 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.
What it looks like (CLAUDE.md)
javascript 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.
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.
Lagging indicator
Time to first merged PR for a new member of the team from PR history.
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.
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.
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.md whose 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// 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.
What it looks like (.claude/skills/secure-api-review/SKILL.md)
markdown
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:
- Authentication: every endpoint requires the gateway JWT; no anonymous routes outside /health.
- Input validation: validate request bodies against the OpenAPI schema and reject unknown fields.
- Audit: every state-changing endpoint emits an audit event with actor, action, entity and timestamp.
- 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.
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.
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.
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.
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.
Traditional One 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-native One 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.
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.
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.
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-auth in one terminal and claude --worktree fix-rate-limit in 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.
What it looks like (.claude/agents/verifier.md)
javascript
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.
Lagging indicator
Changes merged per engineer per week read alongside the rework rate as determined per the PR history.
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.
Traditional The 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.
AI-native The 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.
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.
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 teststatus.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.
What it looks like (CLAUDE.md verification block)
javascript 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.
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.
Who approves
The code owner reviewing the PR, who can concentrate on intent and risk because the mechanical evidence is already attached.
How to measure it
Leading indicator
First-pass CI success rate for agent-written changes, which the CI system already supports.
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.
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.
Getting started
Prerequisites
The CLAUDE.md and feedback loop (Stage 4: Test).
Infrastructure
CI that can run Claude Code non-interactively, and an API key with budget for eval runs.
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.
What it looks like (.github/workflows/agent-evals.yml)
yaml name: Agent evals on: pullrequest: 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: ANTHROPICAPIKEY: ${{ secrets.ANTHROPICAPIKEY }} 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.
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.
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
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.
Traditional Review 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.
AI-native All 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.
Getting started
Prerequisites
An updated CLAUDE.md file from Stage 3: Build; skills if the review passes enforce written policies, defined subagents.
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.
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.md at the repo root, divided into the passes the organization cares about: bugs and logical errors; security and vulnerabilities; compliance against the spec (spec.md from the requirements play), the implementation plan (plan.md from the plan mode play) and design principles. REVIEW.md also 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 @claude on 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 review requests 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 into CLAUDE.md as part of that review, and because review reads CLAUDE.md the mistake is caught from the next PR onwards. Review also flags when a change has made CLAUDE.md outdated.
- 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.
What it looks like (REVIEW.md)
markdown 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.
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.
Lagging indicator
Defects and vulnerabilities caught before merge set against those escaping to production, from the PR history and the incident tracker.
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.
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.json in 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.
What it looks like (.claude/settings.json)
json { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "${CLAUDEPROJECTDIR}/.claude/hooks/production-gate.sh" } ] } ] } }
And the gate itself (.claude/hooks/production-gate.sh)
bash #!/bin/bash Production deploys require a named release authorization cmd=$(jq -r '.toolinput.command' < /dev/stdin) if [[ "$cmd" == "deploy" && "$cmd" == "production" ]]; then if [ -z "$RELEASEAPPROVAL" ]; 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.
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.
{ "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": "GITHUBTOKEN", "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.
disableBypassPermissionsMode plus allowManagedPermissionRulesOnly means no engineer, project file or command-line flag can widen the rules.
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.
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.
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.
allowManagedHooksOnly means the approval gates from this play are the only hooks that run; nothing local can add to or replace them.
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.
allowManagedMcpServersOnly makes the agent's tool surface an allowlist owned by the platform team.
requiredMinimumVersion refuses 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
How to measure it (for the hooks themselves)
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.
Lagging indicator
Gate violations reaching production before and after hooks from the incident tracker.
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.
Traditional Pipelines 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-native Claude 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.
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.
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.
How to execute it
- The platform engineer starts with read-only judgment steps. Use claude -p in 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 @claude mentions. 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.
What it looks like (pipeline step)
markdown
- 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.
How to measure it
Leading indicator
The share of pipeline failures triaged without paging a human taken from the CI/CD pipeline logs.
Lagging indicator
DevOps Research and Assessment (DORA) measures, which the CI system and deployment tooling already emit.
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.
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.
Traditional Maintenance 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.
AI-native A trigger such as a control-band breach, a ticket, a channel message or a schedule invokes Claude without a person in the path. Claude diagnoses, acts only through gated routes, and writes what it finds as intent.md, which then goes through the stages described above. People triage and review that work, and no longer have to start it.
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.
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).
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.
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.yaml below). At 1σ the script only logs, at 2σ it invokes Claude read-only to diagnose, and at 3σ Claude may act, though only by opening a PR into the review gate or triggering a pre-approved runbook.
- 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.md in the Stage 1: Plan format, covering the anomaly and its evidence, a proposed outcome, the affected systems and any open questions. From there the finding goes through the pipeline like anything else.
- 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.
What it looks like (for example, a bands.yaml monitoring CI test failure rate)
yaml metric: citestfailurerate baseline: rolling30d rules: westernelectric tiers: 1sigma: { action: log } 2sigma: { action: diagnose, tools: "Read,Grep,Bash(gh run view )" } 3sigma: { action: propose, routes: [pullrequest, 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.
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.
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.
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.
Detection stays deterministic. Claude is invoked once a band is breached, and the tier sets what it may do.
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.
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.
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.
Set up Claude Code for your organization — the admin decision map; start here code.claude.com/docs/en/admin-setupSettings reference and precedence, including every managed-only key code.claude.com/docs/en/settingsServer-managed settings from the Claude admin console code.claude.com/docs/en/server-managed-settingsPermissions code.claude.com/docs/en/permissionsSandboxing — OS-level filesystem and network isolation code.claude.com/docs/en/sandboxingHooks — guide code.claude.com/docs/en/hooks-guideHooks — reference code.claude.com/docs/en/hooksSkills code.claude.com/docs/en/skillsPlugins and private marketplaces — how skills and hooks are distributed organization-wide code.claude.com/docs/en/plugin-marketplacesManaged MCP — central control of the agent's tool surface code.claude.com/docs/en/managed-mcpEnterprise deployment overview — Bedrock, Vertex, Foundry code.claude.com/docs/en/third-party-integrationsEnterprise network configuration code.claude.com/docs/en/network-configMonitoring (OpenTelemetry)code.claude.com/docs/en/monitoring-usageThe analytics dashboard code.claude.com/docs/en/analyticsCompliance API — Enterprise activity feed, chat retrieval and deletion platform.claude.com/docs/en/manage-claude/compliance-apiSecurity model code.claude.com/docs/en/security
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.
Related posts
The Claude Code guide for startups
The Claude Code guide for startupsThe Claude Code guide for startups
The Claude Code guide for startupsThe Claude Code guide for startups
Build production agents with computer use, the Skills API, and the Files API
Product announcements
Build production agents with computer use, the Skills API, and the Files APIBuild production agents with computer use, the Skills API, and the Files API
Build production agents with computer use, the Skills API, and the Files APIBuild production agents with computer use, the Skills API, and the Files API
Anthropic’s approach to teaching and learning AI
Product announcements
Anthropic’s approach to teaching and learning AIAnthropic’s approach to teaching and learning AI
Anthropic’s approach to teaching and learning AIAnthropic’s approach to teaching and learning AI
Claude on call: How Claude Tag serves as Anthropic’s first responder for CI/CD failures
Transform how your organization operates with Claude
Claude Tag
Coding