0–5 分钟:choose scenario
选择一个真实 failure:wrong command、secret exposure、bad PR、unsafe MCP tool 或 prompt injection。
成功标准团队测试具体 incident,而不是泛泛恐惧。
Agentic coding operations · 更新 2026-06-27
面向使用 Claude Code、OpenAI Codex CLI、hooks、MCP servers 和 repository automation 的团队:当 coding agent 做出坏变更或暴露风险时如何响应。
Agentic coding governance 会降低风险,但不会消灭 incident。Coding agent 可能运行错误命令、修改敏感文件、创建坏 PR、把 prompt 暴露到 logs、触碰 secrets、使用不安全 MCP tools,或生成 reviewer 没真正理解的 patch。
这份 playbook 是 Agentic Coding Bakeoff 与 Governance Checklist 之后的运营层:stop the run、preserve evidence、revoke/rotate credentials、revert/contain changes、notify owners、investigate root cause,并在下一次 rollout 前 update policy。
RepoDaily 判断
把 coding-agent incidents 当作工程 incident 处理,只是 playbook 更小、更明确。先 stop agent,保存 logs 和 diffs,保护 secrets,revert unsafe changes,通知 owner,记录 root cause,并在重新启用 workflow 前更新 command policy、denied paths、hooks、MCP scopes 和 PR review rules。
| Incident 类型 | 立即动作 | Containment | Policy update |
|---|---|---|---|
| Wrong command run | 停止 agent,保存 transcript/command log | 检查 filesystem、build outputs 和 touched services | 增加 denied command 或 approval trigger |
| Sensitive file modified | 冻结 branch 并阻止 merge | Revert diff,review git history,检查 generated artifacts | 增加 denied path、CODEOWNER 或 senior approval |
| Secret exposure | 停止 run,保存 evidence 但不要重复传播 secret | Revoke/rotate token,并扫描 logs、commits、caches | 迁移 secret source,收紧 workspace prep,更新 redaction rules |
| Unsafe MCP/tool use | 禁用 tool/server 并捕获 scopes used | Review external calls、tokens、browser/file access、data touched | 缩小 scopes,pin server,增加 owner approval |
| Bad PR merged | Revert 或 hotfix,停止后续 agent merges | 运行 tests,monitor errors,通知 affected owners | 强化 PR checklist 和 merge ownership |
| Prompt injection followed | 保存 malicious instruction source 和 transcript | 检查 steering agent 的 files/comments/issues | 增加 instruction hierarchy、read-only rules 和 source-trust notes |
| Benchmark misuse | 停止部署 benchmark output | Review copyright、assets、user data 和 provenance | 增加 benchmark scope 和 publishing policy |
| Reviewer misunderstanding | 暂停 agent-generated merges | Review diff、tests、assumptions 和 review comments | 要求 generated-code labels 和 reviewer attestation |
在 coding agents 超出 pilot 前,先给团队打分。
| 控制项 | 0 分 | 1 分 | 2 分 | Owner 问题 |
|---|---|---|---|---|
| Stop mechanism | 没有明确停止动作 | 只有一个人知道手动 stop | Owner 能 stop run 并 disable tools | 现在谁能停止 agent run? |
| Evidence capture | Logs 丢失或分散 | 保留部分 transcript | Prompt、commands、diff、tests、approvals 已保存 | 哪些 evidence 是必需的? |
| Secret response | 没有 rotation path | 手动 rotation 已知 | Revoke/rotate/scan 步骤已记录 | Agent 可能看到哪些 tokens? |
| Rollback path | 没有 rollback owner | 可以 revert | Revert/hotfix/yank path 和 owners 已定义 | 坏 merge 怎么撤? |
| Tool inventory | hooks/MCP/tools 未知 | 部分 inventory | Owners、scopes、tokens、versions 被跟踪 | 哪些 external tools 当时启用? |
| Policy feedback loop | Incident 不反映到 policy | Ad hoc notes | Policy、denied paths、prompts、reviews 已更新 | 重新启用前改变了什么? |
在给 coding agents 新 repository class 写权限前使用。
选择一个真实 failure:wrong command、secret exposure、bad PR、unsafe MCP tool 或 prompt injection。
成功标准团队测试具体 incident,而不是泛泛恐惧。
指定谁 stop run,以及 transcript、commands、diffs、tests、approvals 存在哪里。
成功标准Evidence capture 明确且 redacted。
走一遍 revert、revoke/rotate、disable tool、notify owner 和 monitor steps。
成功标准每个 containment action 都有 owner。
分类 control failure:command policy、denied path、tool scope、stale docs、reviewer miss 或 prompt injection。
成功标准原因映射到 control,而不是只归咎个人。
写 policy patch,并决定 agent workflow 是 disabled、restricted 还是 re-enabled。
成功标准Workflow 在恢复前已经改变。
| 场景 | 前 15 分钟 | 重新启用前 |
|---|---|---|
| Agent 意外删除或重写文件 | Stop run,检查 git status,保存 transcript,从 git 或 backup restore | 增加 denied commands/paths,并要求 destructive operations approval |
| Agent 触碰 `.env` 或 credentials | 停止传播 transcript,revoke/rotate suspected secrets,扫描 logs 和 commits | 把 secrets 移出 workspace,增加 secret-prep checklist |
| Agent 通过 browser/MCP tool 使用 private data | 禁用 tool,捕获 scopes 和 external calls,通知 data owner | 缩小 scopes,增加 allowlist,要求 owner approval |
| Agent PR merge 后破坏 production | Revert/hotfix,停止 agent merges,通知 service owner,monitor errors | 增加 generated-code label、更严格 CI 和 reviewer attestation |
| Agent 遵循恶意 README/issue 指令 | 保存 source instruction,检查被读取 files,阻止 merge | 增加 instruction hierarchy 和 source-trust guidance |
| Website cloning benchmark 使用不安全 assets | 停止部署,review asset provenance 和 copyright scope | 增加 benchmark publishing 和 asset policy |
| Reviewer 批准了自己没理解的代码 | 暂停该 owner 的 agent merge permission,review diff 和 tests | 要求 reviewer explanation 和 generated-code checklist |
如果 transcripts、commands、diffs 和 tool scopes 丢失,团队只能猜发生了什么。
不要把 exposed tokens 粘进聊天或 incident docs。记录 redacted evidence 并 rotate credentials。
不改 policy 就重新启用同一 workflow,会把一次 incident 变成重复模式。
人类点了 merge 不代表 agent 没问题。Reviewer 和 workflow 都需要分析。
Hooks、MCP servers、browsers、files 和 cloud APIs 会扩大 blast radius,除非 scopes 被盘点和缩小。
Benchmark output 未经 provenance、asset、copyright 和 owner review,不应部署。
写一张一页卡片,包含 owner contacts 和 pause agents、disable tools、block merges、stop deploys 的具体动作。
在 incident record 里保存 redacted prompt、transcript、commands、changed files、tests、approvals、tool scopes 和 final decision。
把 secret rotation 和 code rollback 分开处理,避免 token handling 被普通 PR review 拖慢。
每次 incident 都应产生一个 policy PR:denied path、command approval、MCP scope、hook review 或 PR checklist change。
恢复写权限前,要求 owner sign-off、updated policy 和一次 safe validation run。
按 command、path、secret、tool、prompt injection、PR review、benchmark misuse 或 release/deploy impact 打标签。
给安全运营 coding agents 的团队提供简短答案。
停止 active run 并保存 evidence。在 blast radius 未知时,不要继续和 agent 互动。
只要 agent 可能读取、记录、commit 或传输了 credential,就应 rotate。敏感 scopes 下,不确定也按暴露处理。
Revert 是 containment,不是 root-cause fix。重新启用前还要更新 policy、prompts、denied paths、tool scopes 或 reviewer rules。
Task 或 merge 的 human owner 负责 incident,根据影响由 repo、security 或 platform owners 支持。
Feedback
匿名反馈只用于判断内容是否真正有用。