Skip to main content
guidesSource-backed

Permission Design for Claude Agent SDK Agents

A practical walkthrough of least-privilege permission design in the Claude Agent SDK. Learn the evaluation order (hooks → deny → mode → allow → canUseTool), how allowedTools and disallowedTools differ, the six permission modes, and how to lock an agent to a fixed tool surface with dontAsk.

by JPette1783·added 2026-06-05·
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://code.claude.com/docs/en/agent-sdk/permissions, https://github.com/JSONbored/awesome-claude/blob/main/content/guides/permission-design-for-claude-agent-sdk-agents.mdx
Safety notes
allowedTools only pre-approves tools; it does NOT constrain bypassPermissions, where every tool runs. To block tools under bypass, use disallowedTools or scoped deny rules., Deny rules (for example Bash(rm *)) are enforced in every mode, including bypassPermissions; a bare-name deny removes the tool from context entirely., When the parent uses bypassPermissions, acceptEdits, or auto, subagents inherit it and cannot override per-subagent; prefer the least permissive mode that works.
Privacy notes
Permissions govern tool execution, not data flow; code and context still go to the model provider regardless of mode., The canUseTool callback sees tool inputs at runtime; avoid logging sensitive arguments from it., Settings-based allow/deny rules live in .claude/settings.json; keep secrets out of rule patterns.
Author
JPette1783
Submitted by
JPette1783
Claim status
unclaimed
Last verified
2026-06-05

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

63

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Needs review

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    No reviewed flag detected in metadata.

    Pending

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

Copy-ready — paste the snippet to get started.

Adoption plan

Balanced adoption plan

Current risk score 24/100. Use staged verification before broader rollout.

Risk 24

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    No review metadata found; increase manual validation.

    Pending
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Missing required evidence: Metadata review. Risk score 31.

Risk 31

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Missing

Review metadata is missing.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required gaps: Metadata review

Decision timeline

Decision timeline · balanced

Blocking gaps: Check metadata review status. Risk 28.

Risk 28

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is missing.

Pending

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

Blockers: Check metadata review status

Prerequisite readiness

Prerequisite readiness

3 prerequisites to line up before setup.

0/3 ready
Install & runtime1Configuration1General1

Safety & privacy surface

Safety & privacy surface

3 safety and 3 privacy notes across 3 risk areas. Review closely: credentials & tokens, permissions & scopes.

3 areas
  • SafetyPermissions & scopesallowedTools only pre-approves tools; it does NOT constrain bypassPermissions, where every tool runs. To block tools under bypass, use disallowedTools or scoped deny rules.
  • SafetyPermissions & scopesDeny rules (for example Bash(rm *)) are enforced in every mode, including bypassPermissions; a bare-name deny removes the tool from context entirely.
  • SafetyPermissions & scopesWhen the parent uses bypassPermissions, acceptEdits, or auto, subagents inherit it and cannot override per-subagent; prefer the least permissive mode that works.
  • PrivacyPermissions & scopesPermissions govern tool execution, not data flow; code and context still go to the model provider regardless of mode.
  • PrivacyExecution & processesThe canUseTool callback sees tool inputs at runtime; avoid logging sensitive arguments from it.
  • PrivacyCredentials & tokensSettings-based allow/deny rules live in .claude/settings.json; keep secrets out of rule patterns.

Safety notes

  • allowedTools only pre-approves tools; it does NOT constrain bypassPermissions, where every tool runs. To block tools under bypass, use disallowedTools or scoped deny rules.
  • Deny rules (for example Bash(rm *)) are enforced in every mode, including bypassPermissions; a bare-name deny removes the tool from context entirely.
  • When the parent uses bypassPermissions, acceptEdits, or auto, subagents inherit it and cannot override per-subagent; prefer the least permissive mode that works.

Privacy notes

  • Permissions govern tool execution, not data flow; code and context still go to the model provider regardless of mode.
  • The canUseTool callback sees tool inputs at runtime; avoid logging sensitive arguments from it.
  • Settings-based allow/deny rules live in .claude/settings.json; keep secrets out of rule patterns.

Prerequisites

  • The Claude Agent SDK installed for Python or TypeScript.
  • Knowledge of which tools and command patterns the agent legitimately needs.
  • For settings-based rules, the project setting source enabled (default).

Schema details

Install type
copy
Troubleshooting
No
Full copyable content
## Overview

The Agent SDK controls tool use through permission modes, declarative allow/deny
rules, hooks, and the `canUseTool` callback. Designing these well is how you get a
least-privilege agent that runs autonomously where it is safe and asks (or is
denied) where it is not.

## Evaluation order

When Claude requests a tool, the SDK checks, in order:

1. **Hooks** - can deny outright or pass on (a hook `allow` does not skip later
   deny/ask rules).
2. **Deny rules** - from `disallowedTools` and settings; a match blocks the tool
   even in `bypassPermissions`.
3. **Permission mode** - `bypassPermissions` approves; `acceptEdits` approves file
   ops; others fall through.
4. **Allow rules** - from `allowedTools` and settings; a match approves.
5. **canUseTool callback** - decides anything unresolved (skipped in `dontAsk`,
   which denies).

## Allow and deny rules

- `allowedTools: ["Read", "Grep"]` - auto-approves those; unlisted tools fall
  through to the mode.
- `disallowedTools: ["Bash"]` - removes the tool from context entirely.
- `disallowedTools: ["Bash(rm *)"]` - keeps Bash but denies matching calls in
  every mode.

Critically, `allowedTools` does **not** constrain `bypassPermissions`; to block
specific tools there, use `disallowedTools`.

## Permission modes

| Mode | Behavior |
| --- | --- |
| `default` | No auto-approvals; unmatched tools hit canUseTool. |
| `dontAsk` | Anything not pre-approved is denied; canUseTool never called. |
| `acceptEdits` | Auto-approves file edits and filesystem commands in scope. |
| `bypassPermissions` | Approves everything (hooks/deny still apply); use with caution. |
| `plan` | Read-only; Claude plans without editing. |
| `auto` (TS) | A model classifier approves or denies each call. |

Set it with `permissionMode` at query time, or change it mid-session with
`setPermissionMode()` / `set_permission_mode()`.

## Lock down an agent

For a headless, fixed tool surface, pair an allow list with `dontAsk`:

```typescript
const options = { allowedTools: ["Read", "Glob", "Grep"], permissionMode: "dontAsk" };
```

Listed tools are approved; anything else is denied outright rather than prompting.

## Interactive approvals

For runtime approval flows, implement the `canUseTool` callback (returns allow or
deny). For deterministic guardrails, use hooks. Declarative allow/ask/deny rules
can also live in `.claude/settings.json` when the project setting source is
enabled.

## Source

- Configure permissions: https://code.claude.com/docs/en/agent-sdk/permissions

About this resource

Overview

The Agent SDK controls tool use through permission modes, declarative allow/deny rules, hooks, and the canUseTool callback. Designing these well is how you get a least-privilege agent that runs autonomously where it is safe and asks (or is denied) where it is not.

Evaluation order

When Claude requests a tool, the SDK checks, in order:

  1. Hooks - can deny outright or pass on (a hook allow does not skip later deny/ask rules).
  2. Deny rules - from disallowedTools and settings; a match blocks the tool even in bypassPermissions.
  3. Permission mode - bypassPermissions approves; acceptEdits approves file ops; others fall through.
  4. Allow rules - from allowedTools and settings; a match approves.
  5. canUseTool callback - decides anything unresolved (skipped in dontAsk, which denies).

Allow and deny rules

  • allowedTools: ["Read", "Grep"] - auto-approves those; unlisted tools fall through to the mode.
  • disallowedTools: ["Bash"] - removes the tool from context entirely.
  • disallowedTools: ["Bash(rm *)"] - keeps Bash but denies matching calls in every mode.

Critically, allowedTools does not constrain bypassPermissions; to block specific tools there, use disallowedTools.

Permission modes

Mode Behavior
default No auto-approvals; unmatched tools hit canUseTool.
dontAsk Anything not pre-approved is denied; canUseTool never called.
acceptEdits Auto-approves file edits and filesystem commands in scope.
bypassPermissions Approves everything (hooks/deny still apply); use with caution.
plan Read-only; Claude plans without editing.
auto (TS) A model classifier approves or denies each call.

Set it with permissionMode at query time, or change it mid-session with setPermissionMode() / set_permission_mode().

Lock down an agent

For a headless, fixed tool surface, pair an allow list with dontAsk:

const options = { allowedTools: ["Read", "Glob", "Grep"], permissionMode: "dontAsk" };

Listed tools are approved; anything else is denied outright rather than prompting.

Interactive approvals

For runtime approval flows, implement the canUseTool callback (returns allow or deny). For deterministic guardrails, use hooks. Declarative allow/ask/deny rules can also live in .claude/settings.json when the project setting source is enabled.

Source

Source citations

Add this badge to your README

Show that Permission Design for Claude Agent SDK Agents is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/guides/permission-design-for-claude-agent-sdk-agents.svg)](https://heyclau.de/entry/guides/permission-design-for-claude-agent-sdk-agents)

How it compares

Permission Design for Claude Agent SDK Agents side by side with 2 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

2 trust signals differ across this comparison (Source provenance, Submitter).

Field

A practical walkthrough of least-privilege permission design in the Claude Agent SDK. Learn the evaluation order (hooks → deny → mode → allow → canUseTool), how allowedTools and disallowedTools differ, the six permission modes, and how to lock an agent to a fixed tool surface with dontAsk.

Open dossier

How to design custom tools for the Claude Agent SDK: in-process tool definitions with typed input schemas, permission scoping, structured isError results, and when to reach for an external MCP server instead.

Open dossier

A practical walkthrough of securely deploying Claude Agent SDK applications: the prompt-injection threat model, isolation options (sandbox runtime, containers, gVisor, VMs), least privilege, the proxy credential pattern, and filesystem controls.

Open dossier
Next steps
Trust
Review statusNot reviewedNot reviewedNot reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verified
Source provenanceDiffersSource-backedSubmission linkedSource submissionSource-backed
SubmitterDiffersJPette1783kiannidevJPette1783
Install riskReview firstReview firstReview first
Notes Safety ✓ Privacy ✓ Safety ✓ Privacy ✓ Safety ✓ Privacy ✓
Brand
Categoryguidesguidesguides
SourceSource-backedSource-backedSource-backed
AuthorJPette1783kiannidevJPette1783
Added2026-06-052026-06-142026-06-05
Platforms
Harness
Source repo
Safety notesallowedTools only pre-approves tools; it does NOT constrain bypassPermissions, where every tool runs. To block tools under bypass, use disallowedTools or scoped deny rules. Deny rules (for example Bash(rm *)) are enforced in every mode, including bypassPermissions; a bare-name deny removes the tool from context entirely. When the parent uses bypassPermissions, acceptEdits, or auto, subagents inherit it and cannot override per-subagent; prefer the least permissive mode that works.Tool descriptions are not enforcement—validate destructive inputs inside handlers. Wildcard `mcp__server__*` allowlists expand blast radius; prefer per-tool grants in production. Returning thrown exceptions fails the whole query; use isError responses for recoverable faults.Agents generate actions dynamically and can be influenced by content they process (prompt injection); apply defense in depth, not a single control. Use least privilege: mount only needed directories (prefer read-only), restrict network to specific endpoints, and drop Linux capabilities in containers. Inject credentials via a proxy outside the agent boundary so the agent never sees secrets; do not mount ~/.ssh, ~/.aws, .env, or similar into the agent.
Privacy notesPermissions govern tool execution, not data flow; code and context still go to the model provider regardless of mode. The canUseTool callback sees tool inputs at runtime; avoid logging sensitive arguments from it. Settings-based allow/deny rules live in .claude/settings.json; keep secrets out of rule patterns.Tool schemas and results enter model context every turn—avoid secrets in descriptions or payloads. Large tool sets increase context usage; defer rarely used tools via tool search. Structured outputs may log to host telemetry—redact customer fields at the handler boundary.Even read-only code mounts can expose credentials in .env, ~/.git-credentials, ~/.aws, .npmrc, and key files; exclude or sanitize them before mounting. Route egress through a proxy that enforces a domain allowlist and logs requests, so a compromised agent cannot exfiltrate data to arbitrary hosts. The built-in sandbox proxy does not inspect TLS; for stronger guarantees use a TLS-terminating proxy with its CA installed in the agent's trust store.
Prerequisites
  • The Claude Agent SDK installed for Python or TypeScript.
  • Knowledge of which tools and command patterns the agent legitimately needs.
  • For settings-based rules, the project setting source enabled (default).
  • Claude Agent SDK installed and a running `query` loop in TypeScript or Python.
  • Zod (TS) or JSON Schema (Python) literacy for tool input contracts.
  • A written list of side effects each custom tool may perform.
  • Decision record template for build vs buy on external MCP integrations.
  • A Claude Agent SDK application you intend to run beyond a trusted local laptop.
  • Knowledge of which files, endpoints, and credentials the agent legitimately needs.
  • Container, sandbox, or VM tooling appropriate to your isolation choice.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimed
Open 3 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.