Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
HomeDocsSearch
Search the documentation

41 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 logi… How the agent loop works Claude Code CLI · in the page agent-sdk/agent-loop …ooks are: | Hook | When it fires | Common uses | | :- | :- | :- | | `PreToolUse` | Before a tool executes | Validate inputs, block dangerous commands | | `PostToolUse` | After a tool returns | Audit… Use Claude Code features in the SDK Claude Code CLI · in the page agent-sdk/claude-code-features …ry, ClaudeAgentOptions, HookMatcher, ResultMessage import asyncio # PreToolUse hook callback. Positional args: # input_data: HookInput dict with tool_name, tool_input, hook_event_name # tool_use… 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 …k rules below, which are evaluated regardless of the hook result. A `PreToolUse` hook that returns `allow` also can't approve an `rm` or `rmdir` command whose target Claude Code recognizes as a [crit… 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 …o respond than your process can reasonably stay running, register a [`PreToolUse` hook](/docs/en/agent-sdk/hooks) that returns the [`defer` decision](/docs/en/hooks#defer-a-tool-call-for-later) instea… 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… Configure auto mode Claude Code CLI · in the page auto-mode-config …pointed. For a checkpoint that inspects the full command text, add a [PreToolUse hook](/docs/en/hooks.md#pretooluse). Pick the mechanism that matches how firm the boundary needs to be: | Boundary |… Claude Code changelog Claude Code CLI · in the page changelog …t blocking when the hook's program exits with code 2, and on Windows `PreToolUse` and `PermissionRequest` hooks with `"shell": "powershell"` failing open when Git for Windows isn't installed * Fixed a… Common workflows Claude Code CLI · in the page common-workflows …er, and Claude Code ignores it in project and local settings. Your [`PreToolUse` hooks](/docs/en/hooks#pretooluse) don't run when Claude Code includes a file you reference with `@`, because it makes… 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: **settings.json** Add this to your [settings.json](/docs/en/settings.… Debug your configuration Claude Code CLI · in the page debug-your-config …an interactive session and in `claude doctor`. If the array is under `PreToolUse` or `PermissionRequest`, none of that file's other hooks load either. * The hook is in a skill's frontmatter, and neith… Error reference Claude Code CLI · in the page errors …cy-settings) | | `Managed settings contain invalid entries, including PreToolUse/PermissionRequest hooks that are NOT loaded; fix or remove each entry:` | [Configuration warnings](#managed-settings-ho… 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 ….claude/hooks/protect-files.sh ``` **3. 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.md) instead. The more specific and concise your instructions, the more consistently Claude f… Monitoring Claude Code CLI · in the page monitoring-usage …caller's span when `TRACEPARENT` is set in the environment. When a `PreToolUse` hook [defers a tool call](/docs/en/hooks.md#defer-a-tool-call-for-later), Claude Code saves the trace context of the t… Choose a permission mode Claude Code CLI · in the page permission-modes …r` [critical-path removals](#critical-paths), which no allow rule or `PreToolUse` hook `"allow"` approves * The [cross-session messaging safeguards](#skip-all-checks-with-bypasspermissions-mode) * Rea… Configure permissions Claude Code CLI · in the page permissions …cribed here, a [permission mode](/docs/en/permission-modes.md), or a [PreToolUse hook](#extend-permissions-with-hooks). When [auto mode](/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode)… Plugin manifest reference Claude Code CLI · in the page plugins/manifest-reference …ap: ```json config/extra-hooks.json theme={null} { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "\"${CLAUDE_PLUGIN_… Manage mods for your organization Claude Code CLI · in the page plugins/mods/admin …eny a tool call, and draw in the interface. * **Permission rules and `PreToolUse` hooks take precedence over a user's mod.** With the guard loaded, by default a user's mod can't approve a call that a… React to events with a mod Claude Code CLI · in the page plugins/mods/events …such as `command` for Bash * **When `tool.check` fires**: after the [`PreToolUse` hooks](/docs/en/hooks#pretooluse) run, and before the permission prompt, [auto mode](/docs/en/permission-modes.md#elim… Mods overview Claude Code CLI · in the page plugins/mods/overview …default a mod's approval doesn't get a call past your `ask` rules or `PreToolUse` hooks. Without either, a mod can approve a call that an `ask` rule would prompt for, or that your `PreToolUse` hook bl… Mods reference Claude Code CLI · in the page plugins/mods/reference …Set only when `kind` is `re-entry`. `rewritten` if a `tool.call` or [`PreToolUse`](/docs/en/hooks#pretooluse) hook changed the mods API call the event came from, or an `agent.spawn` hook changed an ag… Troubleshoot a mod Claude Code CLI · in the page plugins/mods/troubleshoot …or [`turn.step`](/docs/en/plugins/mods/reference#turns) hook, or a [`PreToolUse`](/docs/en/hooks#pretooluse) settings hook. The message doesn't say which. The message tells Claude to issue the call… Example settings files Claude Code CLI · in the page settings-example …d(./.env.*)", "Read(./secrets/**)" ] }, "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "comma… All settings Claude Code CLI · in the page settings-reference …sh tool call: ```json settings.json theme={null} { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "~/.claude/hooks/ch… 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.md#pretooluse-input). ## Agent tool behavior The Agent tool spawns a subagent in a se… 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": ".claude/hooks… Week 14 · March 30 – April 3, 2026 Claude Code CLI · in the page whats-new/2026-w14 …retry manually with `r`New `defer` value for `permissionDecision` in `PreToolUse` hooks: `-p` sessions pause at a tool call and exit with a `deferred_tool_use` payload so an SDK app or custom UI can s… Week 32 · August 3–7, 2026 Claude Code CLI · in the page whats-new/2026-w32 …ode padding no longer hides part of a command from the approval dialogPreToolUse 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 …ermissions mode. * **A hook**: return `"allow"` for the call from a [`PreToolUse`](/docs/en/hooks#pretooluse) hook. In [plan mode](/docs/en/permission-modes.md#analyze-before-you-edit-with-plan-mode),… Changelog Claude Documentation · in the page cowork/changelog …even with nobody at the computer. * (breaking) Changed what a failed `PreToolUse` hook does on Windows computers without Git for Windows: if it sets none of `shell`, `args`, or `onFailure`, it now blo… 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. Argument-scoped rules such as `Bash(curl *)` are [applied as managed poli… MCP, plugins, skills, and hooks Claude Documentation · in the page third-party/claude-desktop/extensions …sh accepts, such as a quoted program path followed by arguments. A [`PreToolUse`](https://code.claude.com/docs/en/hooks#pretooluse) hook that runs this way and has no `onFailure` field blocks the too…
Feedback