← How I Use AI Dispatch #3

#3 Updated April 8, 2026

Hooks: automatic context and guardrails

Use hooks to inject context, block dangerous actions, and automate repetitive checks every time Claude Code runs.

Hooks are shell scripts that Claude Code runs automatically on specific events — prompt submission, tool execution, file edits. You configure them once and they enforce rules in every session. Typical uses:

My most-used hook: dictation context. I dictate with Wispr Flow. Speech-to-text as a non-native English speaker occasionally mishears words or drops articles. A prompt-submit hook tells Claude the input was dictated so it silently corrects artifacts instead of asking for clarification.

Save this as ~/.claude/hooks/dictation-context.sh:

#!/bin/bash
cat <<'EOF'
DICTATION NOTICE: The user's prompt was likely dictated
using Wispr Flow (speech-to-text). The user is a native
Chinese (Mandarin) speaker. The transcription may contain:
- Homophones or near-homophones (e.g. "EA" → "it")
- Misheard technical terms or proper nouns
- Missing or wrong articles, prepositions, or plurals
- Run-on sentences or missing punctuation

Mentally correct any likely transcription artifacts and
interpret the intended meaning. Do not ask for clarification
on obvious transcription errors — just fix them silently.
EOF

Then activate it in ~/.claude/settings.json:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "type": "command",
        "command": "$HOME/.claude/hooks/dictation-context.sh"
      }
    ]
  }
}

Adapt the script to your own native language — just change "Chinese (Mandarin)" and the example error patterns to match your accent.

For a curated collection of other hook ideas, see this tweet by @zodchiii. Full documentation: official hooks docs.