Allow only pre-approved tools with dontAsk mode
If you set dontAsk mode, Claude Code auto-denies every tool call that would otherwise prompt you. Claude runs only actions matching your permissions.allow rules, read-only Bash commands, and calls approved by a PreToolUse hook. Use this mode for CI pipelines or restricted environments where you pre-define exactly what Claude may do; the session never waits for input. The status bar shows ⏵⏵ don't ask on while this mode is active.
Claude Code denies calls matching your explicit ask rules rather than prompting. It also denies the built-in AskUserQuestion tool even if your allow rules match it, and does the same to connector tools your organization set to ask in sessions where that setting reaches Claude Code. It denies MCP tools marked _meta["anthropic/requiresUserInteraction"] the same way, because their approval card needs an answer this mode never collects; this requires Claude Code v2.1.199 or later.
rm and rmdir removals targeting a critical path, such as rm -rf / and rm -rf ~, are denied even when an allow rule matches them or a PreToolUse hook allows them.
Cloud sessions on Claude Code on the web ignore defaultMode: "dontAsk"; see bypassPermissions for details.
Set it at startup with the flag:
claude --permission-mode dontAsk