From abstract
Guides selection of hook scope (plugin, project, global) based on audience, version control needs, and persistence requirements when authoring Claude Code hooks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/abstract:hook-scope-guideThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill helps you choose the right location for Claude Code hooks based on their purpose, audience, and persistence needs.
This skill helps you choose the right location for Claude Code hooks based on their purpose, audience, and persistence needs.
abstract:hook-authoring)abstract:hooks-eval)
hooks/hooks.jsonis automatically loaded by Claude Code when the plugin is enabled. Do NOT add"hooks": "./hooks/hooks.json"to yourplugin.json- this causes duplicate load errors. Thehooksfield inplugin.jsonis only needed for additional hook files beyond the standardhooks/hooks.json.
| Scope | Location | Audience | Committed? | Persistence |
|---|---|---|---|---|
| Plugin | hooks/hooks.json in plugin | Plugin users | With plugin | When plugin enabled |
| Project | .claude/settings.json | Team members | Yes (repo) | Per project |
| Global | ~/.claude/settings.json | Only you | Never | All sessions |
Only plugin users → Plugin hooks
All team members on this project → Project hooks
/src/production/ configsOnly me, everywhere → Global hooks
Yes, as part of a distributable plugin → Plugin hooks Yes, shared with team in repo → Project hooks No, keep private → Global hooks
Only when my plugin is active → Plugin hooks Always in this specific project → Project hooks Always, in every project I work on → Global hooks
Location: <plugin-root>/hooks/hooks.json
When to use:
Configuration:
{
"PreToolUse": [
{
"matcher": "Read",
"hooks": [{
"type": "command",
"command": "echo \"Plugin reading: $(jq -r '.tool_input.file_path')\" >> ${CLAUDE_PLUGIN_ROOT}/log.txt"
}]
}
]
}
Note: Use string matchers (
"Read") not object matchers ({"toolName": "Read"}).
Key features:
${CLAUDE_PLUGIN_ROOT} for plugin-relative pathsExamples:
Location: .claude/settings.json (in project root)
When to use:
Configuration:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "cmd=$(jq -r '.tool_input.command // empty'); if [[ \"$cmd\" == *\"production\"* ]]; then echo 'BLOCKED: Production access requires approval'; exit 1; fi"
}]
}
]
}
}
Note: Use string matchers (
"Bash") not object matchers.
Key features:
Examples:
Location: ~/.claude/settings.json
When to use:
Configuration:
{
"hooks": {
"PreToolUse": [
{
"hooks": [{
"type": "command",
"command": "echo \"$(date): $(jq -r '.tool_name')\" >> ~/.claude/audit.log"
}]
}
]
}
}
Key features:
Examples:
Claude Code loads settings in this priority (highest first):
claude --flag).claude/settings.local.json).claude/settings.json)~/.claude/settings.json)Important: Multiple hooks from different scopes can respond to the same event. When they do, all matching hooks execute in parallel.
Is this hook part of a plugin's core functionality?
├─ YES → Plugin hooks (hooks/hooks.json in plugin)
└─ NO ↓
Should all team members on this project have this hook?
├─ YES → Project hooks (.claude/settings.json)
└─ NO ↓
Should this hook apply to all my Claude sessions?
├─ YES → Global hooks (~/.claude/settings.json)
└─ NO → Reconsider if you need a hook at all
Plugin hooks:
Project hooks:
Global hooks:
SessionStart hooks now receive additional input fields via stdin:
| Field | Type | Description |
|---|---|---|
session_id | string | Unique session identifier |
source | enum | "startup" | "resume" | "clear" | "compact" |
agent_type | string | Agent name if --agent flag used, empty otherwise |
The agent_type field enables scope-appropriate context injection:
# Skip heavy context for review agents
input_data = json.loads(sys.stdin.read())
if input_data.get("agent_type") in ["code-reviewer", "quick-query"]:
print(json.dumps({"hookSpecificOutput": {"additionalContext": "Minimal"}}))
This is particularly useful for:
hooks/hooks.json, .claude/settings.json, or
~/.claude/settings.json) is confirmed to exist or is created at the correct path."hooks": "./hooks/hooks.json" to plugin.json (duplicate-load
guard); this absence is verified before the hook is deployed.npx claudepluginhub athola/claude-night-market --plugin abstractCreates, modifies, and debugs Claude Code hooks including PreToolUse, PostToolUse, Stop, and more. Covers plugin vs. user config formats, matchers, security patterns, and lifecycle limitations.
Guides implementation of event-driven hooks in Claude Code plugins using prompt-based validation and bash commands for PreToolUse, Stop, and session events.
Claude Code hooks configuration and development. Use when the user mentions hooks, PreToolUse, PostToolUse, SessionStart, SubagentStart, PermissionRequest, or TaskCompleted.