0–5 min: choose scenario
Pick one realistic failure: wrong command, secret exposure, bad PR, unsafe MCP tool, or prompt injection.
Success checkThe team tests a concrete incident, not a generic fear.
Agentic coding operations · Updated 2026-06-27
A practical response playbook for teams using Claude Code, OpenAI Codex CLI, hooks, MCP servers, and repository automation when a coding agent makes a bad change or exposes risk.
Agentic coding governance reduces risk, but it does not remove incidents. A coding agent can run the wrong command, modify a sensitive file, create a bad PR, leak a prompt into logs, touch secrets, use unsafe MCP tools, or generate a patch that reviewers misunderstand.
This playbook is the operational follow-up to the Agentic Coding Bakeoff and Governance Checklist. It gives teams a repeatable sequence: stop the run, preserve evidence, revoke or rotate credentials, revert or contain changes, notify owners, investigate root cause, and update policy before the next rollout.
RepoDaily verdict
Treat coding-agent incidents like engineering incidents with a smaller but explicit playbook. Stop the agent first, preserve logs and diffs, protect secrets, revert unsafe changes, notify the owning team, document root cause, and update command policy, denied paths, hooks, MCP scopes, and PR review rules before re-enabling the workflow.
| Incident type | Immediate action | Containment | Policy update |
|---|---|---|---|
| Wrong command run | Stop the agent and save transcript/command log | Check filesystem, build outputs, and touched services | Add denied command or approval trigger |
| Sensitive file modified | Freeze branch and block merge | Revert diff, review git history, inspect generated artifacts | Add denied path, CODEOWNER, or senior approval |
| Secret exposure | Stop run, preserve evidence without reposting secret | Revoke/rotate token and scan logs, commits, caches | Move secret source, tighten workspace prep, update redaction rules |
| Unsafe MCP/tool use | Disable tool/server and capture scopes used | Review external calls, tokens, browser/file access, data touched | Reduce scopes, pin server, add owner approval |
| Bad PR merged | Revert or hotfix, stop further agent merges | Run tests, monitor errors, notify affected owners | Strengthen PR checklist and merge ownership |
| Prompt injection followed | Save malicious instruction source and transcript | Inspect files/comments/issues that steered the agent | Add instruction hierarchy, read-only rules, and source-trust notes |
| Benchmark misuse | Stop deployment of benchmark output | Review copyright, assets, user data, and provenance | Add benchmark scope and publishing policy |
| Reviewer misunderstanding | Pause agent-generated merges | Review diff, tests, assumptions, and review comments | Require generated-code labels and reviewer attestation |
Score the team before allowing coding agents beyond a pilot.
| Control | 0 points | 1 point | 2 points | Owner question |
|---|---|---|---|---|
| Stop mechanism | No clear stop action | Manual stop known by one person | Run can be stopped and tools disabled by owner | Who can stop an agent run now? |
| Evidence capture | Logs lost or scattered | Some transcript kept | Prompt, commands, diff, tests, approvals preserved | What evidence is mandatory? |
| Secret response | No rotation path | Manual rotation known | Revoke/rotate/scan steps documented | Which tokens could the agent see? |
| Rollback path | No rollback owner | Revert possible | Revert/hotfix/yank path and owners defined | How do we undo a bad merge? |
| Tool inventory | Unknown hooks/MCP/tools | Partial inventory | Owners, scopes, tokens, versions tracked | Which external tools were active? |
| Policy feedback loop | Incident not reflected in policy | Ad hoc notes | Policy, denied paths, prompts, reviews updated | What changed before re-enabling? |
Use this exercise before giving coding agents write access to a new repository class.
Pick one realistic failure: wrong command, secret exposure, bad PR, unsafe MCP tool, or prompt injection.
Success checkThe team tests a concrete incident, not a generic fear.
Name who stops the run and where transcript, commands, diffs, tests, and approvals are stored.
Success checkEvidence capture is explicit and redacted.
Walk through revert, revoke/rotate, disable tool, notify owner, and monitor steps.
Success checkEach containment action has an owner.
Classify the control failure: command policy, denied path, tool scope, stale docs, reviewer miss, or prompt injection.
Success checkThe cause maps to a control, not blame only.
Write the policy patch and decide whether the agent workflow is disabled, restricted, or re-enabled.
Success checkThe workflow changes before it resumes.
| Scenario | First 15 minutes | Before re-enable |
|---|---|---|
| Agent deleted or rewrote files unexpectedly | Stop run, inspect git status, save transcript, restore from git or backup | Add denied commands/paths and require approval for destructive operations |
| Agent touched `.env` or credentials | Stop sharing transcript, revoke/rotate suspected secrets, scan logs and commits | Move secrets out of workspace and add secret-prep checklist |
| Agent used browser/MCP tool on private data | Disable tool, capture scopes and external calls, notify data owner | Reduce scopes, add allowlist, require owner approval |
| Agent PR broke production after merge | Revert/hotfix, stop agent merges, notify service owner, monitor errors | Add generated-code label, stricter CI, and reviewer attestation |
| Agent followed malicious README/issue instruction | Save source instruction, inspect files read, block merge | Add instruction hierarchy and source-trust guidance |
| Website cloning benchmark used unsafe assets | Stop deployment, review asset provenance and copyright scope | Add benchmark publishing and asset policy |
| Reviewer approved code they did not understand | Pause owner’s agent merge permission, review diff and tests | Require reviewer explanation and generated-code checklist |
If transcripts, commands, diffs, and tool scopes are lost, the team can only guess what happened.
Do not paste exposed tokens into chat or incident docs. Record redacted evidence and rotate credentials.
Re-enabling the same workflow without a policy change turns a one-time incident into a repeat pattern.
A human merge does not absolve the agent. The reviewer and workflow both need analysis.
Hooks, MCP servers, browsers, files, and cloud APIs expand blast radius unless scopes are inventoried and reduced.
Benchmark output should not be deployed without provenance, asset, copyright, and owner review.
Write a one-page card with owner contacts and exact actions to pause agents, disable tools, block merges, and stop deploys.
Store redacted prompt, transcript, commands, changed files, tests, approvals, tool scopes, and final decision in the incident record.
Separate secret rotation from code rollback so token handling is not delayed by normal PR review.
Every incident should produce a policy PR: denied path, command approval, MCP scope, hook review, or PR checklist change.
Require owner sign-off, updated policy, and one safe validation run before restoring write access.
Tag incidents by command, path, secret, tool, prompt injection, PR review, benchmark misuse, or release/deploy impact.
Short answers for teams operating coding agents safely.
Stop the active run and preserve evidence. Do not keep interacting with the agent while the blast radius is unknown.
Rotate whenever the agent could have read, logged, committed, or transmitted a credential. Treat uncertainty as exposure for sensitive scopes.
Reverting is containment, not root-cause fix. Update policy, prompts, denied paths, tool scopes, or reviewer rules before re-enabling.
The human owner of the task or merge owns the incident, with support from repo, security, or platform owners depending on impact.
Feedback
Anonymous feedback helps RepoDaily improve what is actually useful.