$ recombobulate _
home / tips / use-prompt-hooks-to-let-claude-guard-its-own-tool-calls
0

Use Prompt Hooks to Let Claude Guard Its Own Tool Calls

bagwaa @bagwaa · Mar 26, 2026 · Configuration
use-prompt-hooks-to-let-claude-guard-its-own-tool-calls

Prompt hooks are a hook type that sends a single-turn prompt to Claude for evaluation, letting an LLM decide whether a tool call should be allowed. Instead of writing bash scripts with regex to catch dangerous commands, you describe the policy in plain English.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "prompt",
            "prompt": "A developer tool wants to run this shell command: $ARGUMENTS. Should this be allowed? Deny if it modifies production databases, deletes important files, or accesses secrets. Respond with JSON: {\"decision\": \"allow\"} or {\"decision\": \"deny\", \"reason\": \"...\"}",
            "model": "fast-model",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

The $ARGUMENTS placeholder is replaced with the hook's input JSON, which includes the full tool call details. The fast model evaluates the policy and returns a structured decision.

This is more flexible than bash-based guards because the LLM can understand intent, not just pattern-match. A command like psql -c "DROP TABLE users" would be caught even without a hardcoded list of dangerous SQL keywords.

For even more powerful evaluation, use the agent hook type instead, which can spawn a subagent with access to tools like Read, Grep, and Glob to investigate before deciding:

{
  "type": "agent",
  "prompt": "Check if this file edit is safe: $ARGUMENTS. Read the target file first.",
  "timeout": 60
}

Guard your tool calls with natural language policies instead of brittle regex.


via Claude Code Hooks

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Switch to the Stable Update Channel with autoUpdatesChannel

The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.

bagwaa @bagwaa · 1 hour ago
0
Set Claude's Response Language with the language Setting

The language setting makes Claude respond in your preferred language by default, across every session and project.

bagwaa @bagwaa · 1 hour ago
0
Customize or Remove Claude's Git Attribution with the attribution Setting

The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.

bagwaa @bagwaa · 1 hour ago