Claude Agent SDK permissions decide whether tool calls auto-run, ask, or are denied; sandboxing limits what an allowed process can actually reach. Use deny rules for prohibited capabilities, narrow allow rules for routine actions, approval callbacks for contextual decisions, and operating-system isolation for defense in depth. Never use bypass mode with untrusted work.
You will design a permission profile, understand the modes, and connect an approval decision to exact tool input and runtime identity.
Claude combines explicit allow/deny rules, permission mode, hooks/callbacks, and tool configuration. Deny should win for forbidden capabilities. Modes include normal/default behavior, auto-accepting edits, not asking, planning, and a bypass mode with substantially greater risk. Verify current semantics in the official permissions page.
For a code-fixing agent, allow edits only inside a disposable workspace, block secret paths, constrain shell commands, require approval for network or destructive actions, and run inside a sandbox/container.
Permission rules govern SDK tool calls. Sandboxing governs filesystem, process, network, and resource access even if a permission or tool is misconfigured. Use both:
Display tool name, normalized arguments, affected resources, data destination, expected impact, and expiry. Authenticate the approver, bind the decision to a proposal hash, and record the reason. On resume, recheck current state and policy.
Failure injection: Allow Bash(npm test*) but craft an argument that exploits shell interpretation. Prefer structured command execution or a narrow test tool; treat pattern rules as one control, not proof of safety.
Test deny precedence, prompt injection, path traversal, symlink escape, shell metacharacters, network egress, secret access, expired approvals, and bypass configuration. Verify at both SDK and operating-system layers.
Threat-model a repository-fixing agent and implement a three-layer policy: SDK rules, tool gateway, and container isolation. Write an escape-oriented test plan.