Free tools Windows power users keep installed
One-click scans. No signup required.
Configure Claude Code hooks in a settings JSON file, then use a narrow event matcher so each handler runs only when needed. A local command hook is not itself a model prompt, but any output Claude Code adds to context can contribute to context size. Anthropic does not publish a per-hook token cost or guarantee that a hook configuration adds exactly zero tokens.
Choose where the hook should apply
Claude Code supports hooks in user, project, and local project settings. Put the configuration in the narrowest scope that fits your use:
As an Amazon Associate I earn from qualifying purchases.
| Settings file | Scope |
|---|---|
~/.claude/settings.json |
User settings |
.claude/settings.json |
Project settings |
.claude/settings.local.json |
Local project settings |
Anthropic also supports enterprise-managed policy settings. See the Claude Code hooks guide for the settings format and policy details.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChoose the lifecycle event and narrow the matcher
Hooks are grouped in a top-level hooks object by event name. An event entry can include a matcher and one or more handlers. The matcher limits which matching event instances run the handler; tool matchers are case-sensitive.
#1 Best Overall
| Event | When to use it |
|---|---|
PreToolUse |
Inspect or log a tool action before execution. |
PostToolUse |
Run a follow-up action, such as formatting after a write or edit. |
SessionStart |
Load context when a session begins. |
Stop |
Run deterministic checks when Claude stops. |
For tool events, use a specific case-sensitive name such as Write, or a pipe-separated matcher such as Write|Edit when both tools should trigger the handler. Avoid broad matching when the command is useful for only a subset of events. Anthropic’s hook guide and power-user tips describe these event patterns.
Example: format only after writes and edits
This minimal pattern runs a command handler after matching Write or Edit events:
Rank #2
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "./scripts/format-changed-file.sh"
}
]
}
]
}
}
Save the JSON in the settings file for the intended scope. Adapt the command to the repository and formatter you actually use; this is an illustrative configuration, not a tested formatter setup.
Recommended Free Tools
Limit unnecessary context, not just hook runs
A command hook and the information Claude Code receives from a hook are different things. The command runs when its event fires; hook output may be processed as JSON or added to context. Keep the matcher narrow to avoid irrelevant invocations, and keep stdout concise when it contains information intended for Claude. Suppress routine output the model does not need.
Rank #3
These are practical ways to limit unnecessary work and context, not measured token savings. Anthropic’s documentation does not specify token accounting for hook metadata, event inputs, or each output path, and it gives no per-hook token price or comparison figure. Therefore, a shell-command hook should not be described as guaranteed to add zero tokens.
Quick Recap
Best Value
Rank #4
Check the configuration against your use case
- Choose the settings file whose scope matches the project or user that needs the hook.
- Pick the lifecycle event that matches the task: before a tool, after it, at session start, or at stop.
- Use a case-sensitive tool matcher that names only the relevant tool or tools.
- Keep context-producing output to the information Claude needs.
- Do not infer a fixed token cost or exact savings from the fact that the handler is a local command.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




