Search the documentation
30 pages for pretooluse.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
migration
Claude Developer Platform · in the page
managed-agents/migration
…| | `PreToolUse` / `PostToolUse` hooks | Your client already sees every `agent.custom_tool_use` event before responding; put the logic…
How the agent loop works
Claude Code CLI · in the page
agent-sdk/agent-loop
…------------------- | :----------------------------------------- | | `PreToolUse` | Before a tool executes | Validate inputs, block dangerous commands | | `PostToolUs…
Use Claude Code features in the SDK
Claude Code CLI · in the page
agent-sdk/claude-code-features
…ClaudeAgentOptions, HookMatcher, ResultMessage import asyncio # PreToolUse hook callback. Positional args: # input_data: HookInput dict with tool_name, tool_input, hook_event_name # tool…
Intercept and control agent behavior with hooks
Claude Code CLI · in the page
agent-sdk/hooks
…execution and the SDK fires an event: a tool is about to be called (`PreToolUse`), a tool returned a result (`PostToolUse`), a subagent started or stopped, the agent is idle, or execution finished. S…
Configure permissions
Claude Code CLI · in the page
agent-sdk/permissions
…sk rules below; those are evaluated regardless of the hook result. A `PreToolUse` hook allow also can't approve an `rm` or `rmdir` removal targeting a [critical path](/docs/en/permission-modes#critica…
Agent SDK reference - Python
Claude Code CLI · in the page
agent-sdk/python
…bypassPermissions`, never invoke it. To gate every tool call, use a [`PreToolUse` hook](/docs/en/agent-sdk/hooks) instead. An allow rule doesn't pre-approve the [actions no mode auto-approves](/docs/…
Agent SDK reference - TypeScript
Claude Code CLI · in the page
agent-sdk/typescript
…bypassPermissions`, never invoke it. To gate every tool call, use a [`PreToolUse` hook](/docs/en/agent-sdk/hooks) instead. An allow rule doesn't pre-approve the [actions no mode auto-approves](/docs/…
Handle approvals and user input
Claude Code CLI · in the page
agent-sdk/user-input
…or `plan` mode. For logic that must apply to every tool call, use a [`PreToolUse` hook](/docs/en/agent-sdk/hooks), which executes before the rest of the flow and can allow, deny, or modify requests.…
Manage multiple agents with agent view
Claude Code CLI · in the page
agent-view
…When a [`PermissionRequest`](/docs/en/hooks#permissionrequest) or [`PreToolUse`](/docs/en/hooks#pretooluse) hook returns output Claude Code can't validate for the call the session is asking about, t…
Claude Code changelog
Claude Code CLI · in the page
changelog
…d background sessions waiting silently when a `PermissionRequest` or `PreToolUse` hook prints an invalid answer: the `claude agents` row now names the hook and the schema error * Fixed hooks silentl…
Manage costs effectively
Claude Code CLI · in the page
costs
…eading multiple files to understand the structure. For example, this PreToolUse hook filters test output to show only failures: <Tabs> <Tab title="settings.json"> Add this to your [settings.js…
Debug your configuration
Claude Code CLI · in the page
debug-your-config
…| Add explicit patterns for each variant, or use a [PreToolUse hook](/docs/en/hooks-guide) or the [sandbox](/docs/en/sandboxing) for a hard guarantee.…
Extend Claude Code
Claude Code CLI · in the page
features-overview
…dit `.env`" in CLAUDE.md or a skill is a request, not a guarantee. A `PreToolUse` hook that blocks the edit is enforcement. If a rule must hold every time, make it a hook rather than a prompt instruct…
Hooks reference
Claude Code CLI · in the page
hooks
…op`, and `StopFailure` * on every tool call inside the agentic loop: `PreToolUse` and `PostToolUse`, except [`EndConversation`](/docs/en/tools-reference#endconversation-tool-behavior) calls, which ski…
Automate actions with hooks
Claude Code CLI · in the page
hooks-guide
…s.sh ``` </Step> <Step title="Register the hook"> Add a `PreToolUse` hook to `.claude/settings.json` that runs the script before any `Edit` or `Write` tool call: ```json theme={null}…
JetBrains IDEs
Claude Code CLI · in the page
jetbrains
…` because there's nothing to configure. If your organization uses a [`PreToolUse` hook](/docs/en/hooks#pretooluse) to allowlist MCP tools, though, you'll need to know it exists. **Selection and open-…
How Claude remembers your project
Claude Code CLI · in the page
memory
…uration. To block an action regardless of what Claude decides, use a [PreToolUse hook](/docs/en/hooks-guide) instead. The more specific and concise your instructions, the more consistently Claude foll…
Monitoring
Claude Code CLI · in the page
monitoring-usage
…------------ | | `hook_event` | Hook event type, such as `PreToolUse` | | | `hook_name` | Full hook name, such as `PreToolUse:Write` |…
Choose a permission mode
Claude Code CLI · in the page
permission-modes
…targeting a [critical path](#critical-paths), which no allow rule or `PreToolUse` hook `"allow"` approves * The [cross-session messaging safeguards](#skip-all-checks-with-bypasspermissions-mode) ## C…
Configure permissions
Claude Code CLI · in the page
permissions
…described here, a [permission mode](/docs/en/permission-modes), or a [PreToolUse hook](#extend-permissions-with-hooks). </Note> When [auto mode](/docs/en/permission-modes#eliminate-prompts-with-auto-…
Plugins reference
Claude Code CLI · in the page
plugins-reference
…| | `PreToolUse` | Before a tool call executes. Can block it…
Example settings files
Claude Code CLI · in the page
settings-example
…http://collector.example.com:4317" }, "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command"…
Create custom subagents
Claude Code CLI · in the page
sub-agents
…onal rules with hooks For more dynamic control over tool usage, use `PreToolUse` hooks to validate operations before they execute. This is useful when you need to allow some operations of a tool whil…
Tools reference
Claude Code CLI · in the page
tools-reference
…r the field names each tool passes to `tool_input` in hooks, see the [PreToolUse input reference](/docs/en/hooks#pretooluse-input). ## Agent tool behavior The Agent tool spawns a subagent in a separ…
Use Claude Code in VS Code
Claude Code CLI · in the page
vs-code
…p` because there's nothing to configure. If your organization uses a `PreToolUse` hook to allowlist MCP tools, though, you'll need to know it exists. **Selection and open-file context.** While connec…
Week 13 · March 23–27, 2026
Claude Code CLI · in the page
whats-new/2026-w13
…json .claude/settings.json {5} theme={null} { "hooks": { "PreToolUse": [{ "hooks": [{ "if": "Bash(git commit *)", "type": "command", "command": ".clau…
Week 14 · March 30 – April 3, 2026
Claude Code CLI · in the page
whats-new/2026-w14
…<code>defer</code> value for <code>permissionDecision</code> in <code>PreToolUse</code> hooks: <code>-p</code> sessions pause at a tool call and exit with a <code>deferred\_tool\_use</code> payload so…
Week 32 · August 3–7, 2026
Claude Code CLI · in the page
whats-new/2026-w32
…onger hides part of a command from the approval dialog</div> <div>PreToolUse auto-allow hooks no longer bypass tool restrictions in Claude Code's internal side tasks such as summaries and compacti…
Orchestrate subagents at scale with dynamic workflows
Claude Code CLI · in the page
workflows
…* **Bypass permissions mode**: Claude Code approves the call. * **A `PreToolUse` hook**: a [hook](/docs/en/hooks#pretooluse) that returns `allow` for the call approves it. * **Your host**: a [`--perm…
Code in Claude Desktop on 3P
Claude Documentation · in the page
third-party/claude-desktop/code
…"ask"` require approval on each call in Code sessions, enforced via a PreToolUse hook and Claude Code `permissions.ask` rules.…