← Claude Docs

Handle approvals and user input - Claude Code Docs

Claude Docs · April 22, 2026
Applications handling Claude integrations must surface user input requests through a canUseTool callback, which pauses execution when Claude needs permission to use tools like deleting files or when it requires clarifying answers to multiple-choice questions. The callback receives the tool name, input parameters, and context, and returns either an Allow or Deny response, with options to modify inputs, reject requests with explanations, suggest alternatives, or redirect entirely. For clarifying questions generated by the AskUserQuestion tool, the application displays Claude's generated questions and options to users and returns their selections.

Detailed Analysis

Claude Code's approval and user input system operates through a structured callback architecture that intercepts tool usage requests before execution, requiring explicit human authorization at defined decision points. The central mechanism is the `canUseTool` callback, which fires whenever Claude attempts to use a tool that has not been pre-approved through permission rules or modes. This callback pauses execution indefinitely — remaining suspended until the application returns a response — and receives three key arguments: the tool name, the input parameters Claude intends to pass, and additional context including optional permission suggestions and a cancellation signal. Beyond tool approvals, the same callback handles clarifying questions when Claude invokes the `AskUserQuestion` tool, presenting users with multiple-choice options generated by Claude itself. Developers cannot inject their own questions into this flow; any application-level user queries must be handled separately outside the callback system.

The response options available to developers extend well beyond a simple binary allow-or-deny decision. When allowing a tool call, developers can pass through the original input unchanged or modify it prior to execution — sanitizing file paths, adding constraints, or scoping access — with Claude receiving only the result and not being informed that the input was altered. Denial responses include a developer-supplied message that Claude reads and uses to adjust its subsequent approach, enabling patterns like suggesting alternatives or redirecting behavior. The most aggressive intervention option uses streaming input to send Claude an entirely new instruction, bypassing the current tool request altogether. This layered response taxonomy gives application developers fine-grained control over Claude's actions without requiring them to interrupt the broader task flow.

The architecture reflects a deliberate design philosophy that treats human oversight as a first-class constraint rather than an afterthought. By pausing execution at the callback level rather than allowing tools to run and then seeking post-hoc approval, the system enforces a consent-before-action model that mirrors the broader "brilliant junior developer" framing in Claude Code's documentation — capable and autonomous within a session, but not permitted to act unilaterally on consequential operations like file deletion, command execution, or database interactions. The TypeScript SDK's support for the `defer` hook decision, which allows the process to exit and resume later from a persisted session when a user may take an extended period to respond, further illustrates that the system is designed to accommodate real-world human response latency without forcing either timeout failures or indefinitely running processes.

This approval model connects to a broader trend in agentic AI development where the central engineering challenge has shifted from model capability to safe, controllable delegation. As AI coding assistants move from suggestion-based tools toward agents that directly modify codebases, execute shell commands, and interact with external services, the permission layer becomes the primary interface through which organizations manage risk. Claude Code's `canUseTool` callback is structurally analogous to permission prompt systems appearing across other agent frameworks, reflecting an emerging consensus that agentic systems require explicit, auditable human checkpoints at tool-use boundaries — particularly for destructive or irreversible operations. The ability to modify tool inputs before execution is especially notable, as it enables organizations to enforce policies (such as restricting file paths or sanitizing commands) at the infrastructure level without relying solely on prompt-level instructions to the model.

The dual function of the callback — handling both tool permissions and clarifying questions through the same interface — suggests Anthropic is consolidating human-in-the-loop interactions into a single, predictable architectural pattern rather than distributing them across ad hoc mechanisms. This consistency reduces the cognitive overhead for developers building on Claude Code's SDK, since any moment requiring human judgment surfaces through the same callback regardless of whether the question is about authorization or task direction. As AI agents are deployed in more complex, multi-step workflows spanning CI/CD pipelines, IDE integrations, and Slack interfaces, standardizing these interruption points becomes increasingly important for building reliable, auditable automation systems that retain meaningful human control at scale.

Read original article →