# Command Hook

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

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** type: command

## Think of it like

It is like a note that says run this now.

## 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

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

## Example code

```json
{
  "type": "command",
  "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check.sh"
}
```

Run a script from the project's hooks folder.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [HTTP Hook](https://learn.benibix.com/term/ai/http-hook)
- [Hook Exit Code](https://learn.benibix.com/term/ai/hook-exit-code)
- [CLAUDE_PROJECT_DIR](https://learn.benibix.com/term/ai/claude-project-dir-variable)

![The five hook types, what each one runs, and its default timeout.](https://learn.benibix.com/diagrams/hook-handler-types.svg)

---

Source: https://learn.benibix.com/term/ai/command-hook
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
