Skip to content
BENIBIX Learn

Command Hook

AI⌨️ Claude CodeConfiguration

Also known as type: command

A hook that runs a shell command and reads JSON from its input.

Think of it like

It is like a note that says run this now.

Example

Lucy writes a small script that reads the tool input with jq. A command hook runs it before each Bash call.

Why it matters

It is the most common hook type, and the other kinds answer in the same JSON shape.

Definition

A command hook is a hook whose type is command, so it runs a shell command. The command gets the event's details as JSON on standard input. It answers with its exit code, and with text or JSON on standard output. It runs with your own user's rights, so it can touch any file you can. Its default timeout is 600 seconds.

Example code

json
{
  "type": "command",
  "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check.sh"
}
Run a script from the project's hooks folder.
The command type is the default most hooks use.

Common mistake

Adding a command hook from a repo you have not read. It runs with your full rights.

Key takeaways

  1. 1
    Runs a command. In a shell.
  2. 2
    JSON in, answer out. stdin, exit code.
  3. 3
    Your full rights. Read it first.