Install command
Not provided
Use the built-in /hooks menu to inspect Claude Code hooks and configure them in settings.json so shell commands run deterministically at lifecycle events like PreToolUse, PostToolUse, and Stop.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Not provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
100/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
3 safety and 2 privacy notes across 2 risk areas. Review closely: credentials & tokens.
`/hooks` is a built-in Claude Code slash command that opens an interactive menu for reviewing your configured hooks. Hooks let you run your own shell commands (or HTTP calls, prompts, agents, and MCP tools) automatically at defined points in Claude Code's lifecycle, giving you deterministic control over formatting, linting, testing, notifications, and guardrails instead of relying on the model to choose to run them.
> Note: There is no `/hooks-generator` command and no `--auto-format`, `--auto-test`, `--post-edit`, or similar flags. The real workflow is: run `/hooks` to inspect what is configured, then edit your `settings.json` to add or change hooks. This page documents that real, documented behavior.
## The `/hooks` command
Type `/hooks` in an interactive Claude Code session to open a menu that shows:
- Every configured hook event and how many hooks are attached to it
- The matcher groups under each event
- Full handler details (the command, URL, or prompt that runs)
- The source of each hook (User, Project, Local, Plugin, Session, or Built-in)
The `/hooks` menu is a read-only browser. To add, change, or remove hooks, edit the JSON settings files directly (see below).
## Where hooks are configured
Hooks are defined under a top-level `hooks` key in a settings file. Locations, in order of precedence:
| Location | Scope | Shareable |
| --- | --- | --- |
| `~/.claude/settings.json` | All your projects | No |
| `.claude/settings.json` | One project | Yes (commit to repo) |
| `.claude/settings.local.json` | One project | No (gitignored) |
| Managed policy settings | Organization-wide | Yes |
## Configuration structure
The `hooks` object nests three levels: event name, a list of matcher groups, and a list of handlers per group.
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh"
}
]
}
]
}
}
```
### Hook events
Documented lifecycle events include (non-exhaustive):
- Session: `SessionStart`, `SessionEnd`, `Setup`
- Per turn: `UserPromptSubmit`, `Stop`, `Notification`
- Per tool call: `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PermissionRequest`
- Other: `SubagentStart`, `SubagentStop`, `PreCompact`, `PostCompact`
### Matchers
The `matcher` field filters when a hook fires. For tool events it matches the tool name:
- `"*"`, `""`, or omitted: match everything
- `Edit|Write`: a `|`-separated list of tool names
- `mcp__memory__.*`: a JavaScript regex (used here to match all tools from an MCP server)
For `SessionStart` the matcher is the session source (`startup`, `resume`, `clear`, `compact`); other events match against their own values (see the reference).
### Handler fields
A `command` handler runs a shell command. Common fields:
- `type` (required): `"command"`, `"http"`, `"mcp_tool"`, `"prompt"`, or `"agent"`
- `command`: the shell command or executable path
- `timeout`: seconds before the hook is canceled
- `async`: run in the background without blocking
## How a command hook receives data
Command hooks receive a JSON object on **stdin** describing the event. They do not use `$FILE_PATH`-style substitution variables. Available top-level input fields include `session_id`, `transcript_path`, `cwd`, `permission_mode`, and `hook_event_name`, plus event-specific fields such as the tool input. Parse stdin (for example with `jq`) to read the file path or command being acted on.
The hook's behavior is driven by its **exit code**:
- Exit `0`: success; JSON on stdout (if any) is parsed for a decision
- Exit `2`: blocking error; stderr is shown and the action is blocked
- Other codes: non-blocking error; stderr is shown and execution continues
## Example: format files after edits
A `PostToolUse` hook that runs your formatter after Claude edits or writes a file. The hook script reads the edited file path from the JSON on stdin.
`.claude/settings.json`:
```json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format.sh"
}
]
}
]
}
}
```
`.claude/hooks/format.sh`:
```bash
#!/bin/bash
FILE=$(jq -r '.tool_input.file_path')
[ -n "$FILE" ] && npx prettier --write "$FILE"
```
## Example: block a destructive Bash command
A `PreToolUse` hook can deny a tool call before it runs by returning a permission decision on stdout (with exit `0`):
`.claude/hooks/block-rm.sh`:
```bash
#!/bin/bash
CMD=$(jq -r '.tool_input.command')
if echo "$CMD" | grep -q 'rm -rf'; then
jq -n '{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: "Destructive command blocked"
}
}'
else
exit 0
fi
```
## Example: notify when a turn finishes
A `Stop` hook that fires when Claude finishes responding:
```json
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Done\" with title \"Claude Code\"'",
"async": true
}
]
}
]
}
}
```
## When to use hooks
- Run formatters, linters, or type-checks deterministically after every edit
- Enforce guardrails (block dangerous commands) at `PreToolUse`
- Set up or tear down environment state at `SessionStart` / `SessionEnd`
- Send notifications at `Stop` or `Notification`
## Disabling hooks
To turn off all user and project hooks (managed-policy hooks are unaffected), set in settings:
```json
{
"disableAllHooks": true
}
```
## Related custom commands
Because hooks are configured by editing settings files, you can wrap your own workflow in a **custom slash command** (a user-created Markdown file in `.claude/commands/`). For example, create `.claude/commands/add-format-hook.md` describing the change you want, then invoke it with `/add-format-hook`. That is a custom recipe you author, not a built-in feature, and it still results in edits to `settings.json` using the structure above./hooks/hooks is a built-in Claude Code slash command that opens an interactive menu for reviewing your configured hooks. Hooks let you run your own shell commands (or HTTP calls, prompts, agents, and MCP tools) automatically at defined points in Claude Code's lifecycle, giving you deterministic control over formatting, linting, testing, notifications, and guardrails instead of relying on the model to choose to run them.
Note: There is no
/hooks-generatorcommand and no--auto-format,--auto-test,--post-edit, or similar flags. The real workflow is: run/hooksto inspect what is configured, then edit yoursettings.jsonto add or change hooks. This page documents that real, documented behavior.
/hooks commandType /hooks in an interactive Claude Code session to open a menu that shows:
The /hooks menu is a read-only browser. To add, change, or remove hooks, edit the JSON settings files directly (see below).
Hooks are defined under a top-level hooks key in a settings file. Locations, in order of precedence:
| Location | Scope | Shareable |
|---|---|---|
~/.claude/settings.json |
All your projects | No |
.claude/settings.json |
One project | Yes (commit to repo) |
.claude/settings.local.json |
One project | No (gitignored) |
| Managed policy settings | Organization-wide | Yes |
The hooks object nests three levels: event name, a list of matcher groups, and a list of handlers per group.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh"
}
]
}
]
}
}
Documented lifecycle events include (non-exhaustive):
SessionStart, SessionEnd, SetupUserPromptSubmit, Stop, NotificationPreToolUse, PostToolUse, PostToolUseFailure, PermissionRequestSubagentStart, SubagentStop, PreCompact, PostCompactThe matcher field filters when a hook fires. For tool events it matches the tool name:
"*", "", or omitted: match everythingEdit|Write: a |-separated list of tool namesmcp__memory__.*: a JavaScript regex (used here to match all tools from an MCP server)For SessionStart the matcher is the session source (startup, resume, clear, compact); other events match against their own values (see the reference).
A command handler runs a shell command. Common fields:
type (required): "command", "http", "mcp_tool", "prompt", or "agent"command: the shell command or executable pathtimeout: seconds before the hook is canceledasync: run in the background without blockingCommand hooks receive a JSON object on stdin describing the event. They do not use $FILE_PATH-style substitution variables. Available top-level input fields include session_id, transcript_path, cwd, permission_mode, and hook_event_name, plus event-specific fields such as the tool input. Parse stdin (for example with jq) to read the file path or command being acted on.
The hook's behavior is driven by its exit code:
0: success; JSON on stdout (if any) is parsed for a decision2: blocking error; stderr is shown and the action is blockedA PostToolUse hook that runs your formatter after Claude edits or writes a file. The hook script reads the edited file path from the JSON on stdin.
.claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format.sh"
}
]
}
]
}
}
.claude/hooks/format.sh:
#!/bin/bash
FILE=$(jq -r '.tool_input.file_path')
[ -n "$FILE" ] && npx prettier --write "$FILE"
A PreToolUse hook can deny a tool call before it runs by returning a permission decision on stdout (with exit 0):
.claude/hooks/block-rm.sh:
#!/bin/bash
CMD=$(jq -r '.tool_input.command')
if echo "$CMD" | grep -q 'rm -rf'; then
jq -n '{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: "Destructive command blocked"
}
}'
else
exit 0
fi
A Stop hook that fires when Claude finishes responding:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Done\" with title \"Claude Code\"'",
"async": true
}
]
}
]
}
}
PreToolUseSessionStart / SessionEndStop or NotificationTo turn off all user and project hooks (managed-policy hooks are unaffected), set in settings:
{
"disableAllHooks": true
}
Because hooks are configured by editing settings files, you can wrap your own workflow in a custom slash command (a user-created Markdown file in .claude/commands/). For example, create .claude/commands/add-format-hook.md describing the change you want, then invoke it with /add-format-hook. That is a custom recipe you author, not a built-in feature, and it still results in edits to settings.json using the structure above.
Configure Claude Code Hooks with /hooks side by side with its closest alternative on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
| Field | Use the built-in /hooks menu to inspect Claude Code hooks and configure them in settings.json so shell commands run deterministically at lifecycle events like PreToolUse, PostToolUse, and Stop. Open dossier | Claude Code slash command that generates a new .claude/commands/*.md file from a template, with optional arguments, frontmatter, and team-sharing support. Open dossier |
|---|---|---|
| Next stepsDiffers | ||
| Trust | ||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed |
| Submitter | — | — |
| Install risk | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — |
| Category | commands | commands |
| Source | source-backed | source-backed |
| Author | JSONbored | JSONbored |
| Added | 2025-10-25 | 2025-10-25 |
| Platforms | Claude Code | Claude Code |
| Source repo | — | — |
| Safety notes | ✓Hooks execute shell commands automatically with your user permissions whenever their event fires. A misconfigured or malicious hook can run destructive commands (file deletion, network calls, credential access) without further confirmation. PreToolUse hooks can allow or deny tool calls and PostToolUse hooks run after tools succeed; review hook commands before committing them to a shared .claude/settings.json so teammates do not inherit unexpected execution. Prefer `.claude/settings.json` for reviewed, team-shared hooks and `.claude/settings.local.json` for personal, gitignored hooks; use `disableAllHooks` to turn off user/project hooks when running untrusted code. | ✓Creates .md files in .claude/commands/ in the current project directory; review generated content before committing. |
| Privacy notes | ✓Command and HTTP hooks receive event JSON on stdin including `session_id`, `transcript_path`, `cwd`, and tool input (such as file paths and Bash commands); a hook that forwards this data over the network can expose local file contents, paths, or command arguments to third parties. HTTP hooks can include headers with interpolated environment variables (restricted by `allowedEnvVars`); avoid embedding secrets in hook configuration that is committed to a repository. | ✓Creates .md files in your local .claude/commands/ directory; no content is sent externally. |
| Prerequisites | — none listed | — none listed |
| Install | — | |
| Config | — | — |
| Citations | ||
| Claim | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Migrate or refactor a big codebase in safe, reviewable stages with Claude Code.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.