How to stop an agent doing something, and what each harness gives you to control it. Permission rules decide what the agent may do; a sandbox limits what a command can reach even when it is allowed.
Block a command, for example git push
| Claude Code | |
|---|---|
| How | A deny rule in the permission settings |
| File | .claude/settings.json |
| Example | |
| How it matches | shell-operator-aware Bash command matching with wrapper stripping and leading environment-assignment handling |
| What wins | deny, then ask, then allow; a matching deny survives every permission mode and cannot be overridden by a hook allow |
| Watch out for | Environment runners and nested interpreters such as sh -c can hide the inner command; deny those runners too or use OS containment for a hard boundary. 2.1.309 fixes publisher-reported redirect/variable/subshell and wrapped cd+git permission checks. These fixes do not turn shell matching into a universal OS security boundary. |
What you can control
| Claude Code | |
|---|---|
| Decisions | allow, ask, deny |
| Permission rules | Built in Cover: tool, command, path, network, MCP Match by: tool rules with tool-specific specifiers Conflicts: deny, then ask, then allow; first match within the winning class Docs |
| Sandbox | Built in Limits: filesystem, network Enforced separately from permission rules. 2.1.304 fixes Linux sandbox startup for denyRead globs with literal bracket segments, and extends the deletion safety prompt to rm -r of mounted-drive roots. Publisher notes; no sandbox probe. 2.1.305 adds sandbox.allowNestedUserNamespaces on Linux for programs such as Chromium/rootless podman. Publisher warns this allows bypassing sandbox file protections; it is not an equivalent containment guarantee. 2.1.309 publisher fixes: shell startup files running outside containment, macOS symlink denyWrite matching, writes to --mcp-config, Linux write-deny lifetime for background commands, and worktree-isolation command checks. No sandbox runtime probe. 2.1.309 changes unavailable-sandbox fallback: excluded commands ask before writing to write-list paths and the unsandboxed fallback is refused there. Desktop/VS Code bypass-mode dangerous deletion now denies with a rewrite hint. 2.1.311 publisher fixes Linux sandboxed Bash failing when a --plugin-dir is also an added directory with blockReadsOutsideWorkingDirectories enabled. No containment probe. Docs |
| Approval prompts | Built in Modes: default, acceptEdits, plan, auto, dontAsk, bypassPermissions Remember an approval: once, session, project-command 2.1.302 published changes: claude -p and Agent SDK sessions with no permission mode start in default mode on third-party providers, with telemetry off or on a fresh install. Explicit --permission-mode auto retains auto. This is a launch default, not a change to configured-rule precedence. 2.1.307 added claude_code.safety_event OpenTelemetry records for calls that a rule, auto mode, safety check, hook or sandbox stops/prompts/returns; 2.1.312 stops sending this event. It was telemetry, not a hook or approval decision. 2026-10-26 auto-mode audit (publisher docs/changelog through 2.1.310; implementation unavailable): --permission-mode auto enables a safety classifier, separate from acceptEdits and bypassPermissions. Explicit ask rules still prompt and deny rules still block; routine working-directory reads/edits can skip classification. Claude documents server-side checks within model requests and fallback to client-side classifier requests when server review is unsupported. A missing or unusable verdict denies the action. Repeated blocks (3 consecutive or 20 total) fall back to prompting; non-interactive runs without a permission callback cannot answer that prompt. Enable a personal default with permissions.defaultMode = auto in ~/.claude/settings.json; auto does not take effect from project/local defaultMode settings. claude -p and Agent SDK default to default mode; select auto explicitly. Model/provider eligibility, server rollout and managed disableAutoMode still apply. Denial messages appear with tool calls in the conversation. No stable per-verdict transcript JSONL schema is established. Optional OpenTelemetry tool_decision classifier_verdict/permission_mode (2.1.301+) and safety_event (2.1.307–2.1.311 only) are separate from transcripts; see docs/research/automatic-approval.md. 2.1.312 publisher notes fix managed settings and organization policy not being fetched for the rest of the session after signing in from the VS Code extension. No policy-enforcement probe. Publisher updates: 2.1.314 adds permissions.blockWritesOutsideWorkingDirectories for Write/Edit/NotebookEdit in every permission mode; 2.1.319 adds permissions.denyInsteadOfPrompting in terminal sessions, subagents and teammates. 2.1.321 mod-owned $.tool.call/$.mcp.call do not prompt even under ask rules/dontAsk/headless, while deny rules and organization policy still apply. Mods are a separate execution surface. No enforcement probe. 2.1.323 publisher notes: explicitly requested auto mode now falls back to Manual (asks first) if unavailable. 2.1.328 adds auto mode for Opus 4.6/Sonnet 4.6 on Bedrock, Agent Platform, Foundry and Claude apps gateway, including interactive sessions with no configured permission mode. Model/provider and managed eligibility still apply; stable 2.1.311 is unchanged. Publisher evidence only. Docs |
| Skills granting tools | Built in Field: allowed-tools turn-scoped pre-approval while the skill is active; not a tool-availability restriction 2.1.304: under a policy allowing hooks from plugins only, a main-conversation skill whose hooks are excluded no longer receives its allowed-tools grant. 2.1.305: path-mounted Desktop plugins lose allowed-tools grants when managed allowManagedPermissionRulesOnly is enabled. This host/policy condition is separate from ordinary skill invocation. Docs |
| Hooks that decide | Built in
Can: allow, ask, deny A hook allow does not override matching ask or deny rules; a blocking hook takes precedence over allow rules. In 2.1.301, prompts for an ask decision from a plugin or skill hook identify its origin. Published telemetry adds classifier_verdict and permission_mode to tool_decision, and classifier_category when OTEL_LOG_TOOL_DETAILS=1. 2.1.302 published changes fix missing classifier_category on most auto-mode classifier blocks and preserve tool_use_id, tool_source and tool_parameters when the OpenTelemetry attribute limit is low; telemetry delivery remains unprobed. 2.1.304 mod tool.check can return decider: "person": only the permission dialog or host callback may approve; when neither can ask, the request is refused with the mod’s reason. The event also reports e.isReadOnly. This is the mod surface, separate from declarative PreToolUse hooks. 2.1.310 publisher fixes Windows PreToolUse/PermissionRequest allowing calls when Git Bash is missing and the hook command consists only of quoted strings. This supplements the distinct 2.1.309 Windows fixes; no execution probe. Docs |
| Where rules live |
Listed highest priority first. |
Sources
Claude Code
- Claude Code permissions, Documentation, checked 2026-10-15
- Claude Code 2.1.301 published changes, Documentation, checked 2026-10-16
- Claude Code 2.1.302 published changes; no runtime probe, Documentation, checked 2026-10-19
- Claude Code 2.1.304 published changes; no runtime probe, Documentation, checked 2026-10-21
- Claude Code 2.1.305 publisher changelog, Documentation, checked 2026-10-24
- Claude Code 2.1.309 publisher changelog, Documentation, checked 2026-10-24
- Claude Code 2.1.307 publisher changelog, Documentation, checked 2026-10-24
- Automatic approval: claude-modes, Documentation, checked 2026-10-26
- Automatic approval: claude-config, Documentation, checked 2026-10-26
- Automatic approval: claude-telemetry, Documentation, checked 2026-10-26
- Claude Code 2.1.304 classifier transcript context change; changelog reviewed through 2.1.310, Documentation, checked 2026-10-26
- Claude Code 2.1.314 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.319 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.321 publisher changelog, Documentation, checked 2026-11-12
- Claude Code 2.1.323 publisher changelog, Documentation, checked 2026-11-20
- Claude Code 2.1.328 publisher changelog, Documentation, checked 2026-11-20