From claude-code
Knowledge bank for Claude Code hooks - event lifecycle, hook types, configuration, community patterns, best practices, and troubleshooting. Triggers on: claude code hooks, hook events, PreToolUse, PostToolUse, SessionStart, UserPromptSubmit, hook configuration, settings.json hooks, auto-format hook, command hook, prompt hook, agent hook, hook not working, hook debug, PermissionRequest, SubagentStart, SubagentStop, Stop hook, PreCompact, SessionEnd.
npx claudepluginhub nathanvale/side-quest-plugins --plugin claude-codeThis skill is limited to using the following tools:
Expert guidance for Claude Code hooks -- event lifecycle, hook types (command, prompt, agent), configuration, community patterns, best practices, and troubleshooting.
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
Expert guidance for Claude Code hooks -- event lifecycle, hook types (command, prompt, agent), configuration, community patterns, best practices, and troubleshooting.
This skill delegates all community-intel behavior to shared files. Keep this block minimal and consistent across skills.
../../shared/community-intel.adapter.json (relative to this file).../../shared/community-intel-workflow.md exists.--upgrade was passed, follow workflow sync-report behavior and stopParse the user's question into one or more categories. If you already classified in Step 1b, reuse that classification.
If a question spans multiple categories, identify the primary concern and secondary categories. Address primary first, then connect to secondary categories with separate headed sections.
| Category | Keywords / Signals | Reference File |
|---|---|---|
| Events & Lifecycle | event, lifecycle, SessionStart, PreToolUse, PostToolUse, Stop, when fires, matcher, SubagentStart, SubagentStop, PreCompact, SessionEnd | event-reference.md |
| Types & Config | settings.json, command hook, prompt hook, agent hook, matcher, config, location, /hooks menu, async, timeout | hook-types-and-config.md |
| Decision & Control | block, allow, deny, exit code, output, permission, modify input, decision, hookSpecificOutput, context injection | decision-control.md |
| Recipes & Patterns | auto-format, guard, firewall, notify, checkpoint, how do I, example, recipe, pattern | community-patterns.md |
| Best Practices | best practice, performance, architecture, should I, anti-pattern, when to use, security | best-practices.md |
| Troubleshooting | not working, not firing, isn't firing, isnt firing, debug, error, broken, help, infinite loop, JSON failed | troubleshooting.md |
| Plugins & Skills | plugin hook, skill hook, hooks.json, CLAUDE_PLUGIN_ROOT, agent hook lifecycle, frontmatter, managed policy | hooks-in-plugins.md |
Read the relevant reference files based on the classification. Always read the primary reference file for the category. Verified intel was already loaded in Step 1d.
For multi-category questions, read all relevant files.
Every response should follow this structure:
claude --debug, Ctrl+O, /hooks)${CLAUDE_PLUGIN_ROOT})HALT_STATUS_LINE is set by the shared workflow, place it at the top of the response before the answer(from community intel, MMM YYYY)User: How do I auto-format code when Claude edits a file?
Skill: [Reads community-patterns.md]
Use a PostToolUse hook with an Edit|Write matcher. Add this to .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}
]
}
]
}
}
For Biome: replace with `jq -r '.tool_input.file_path' | xargs npx biome check --write`
**Gotcha:** Formatting on every edit adds context window noise.
Consider formatting on commit instead, or use `async: true`
so it doesn't block Claude's flow.
User: Block dangerous git commands like force push
Skill: [Reads community-patterns.md + decision-control.md]
Use a PreToolUse hook that checks Bash commands against dangerous patterns.
Exit code 2 blocks the command, and stderr tells Claude why.
Add to .claude/settings.json:
[provides settings.json config + block-dangerous.sh script]
The matcher "Bash" ensures it only fires on shell commands.
PreToolUse fires before execution, so the command never runs.
User: My hook isn't firing
Skill: [Detects Troubleshooting intent -> force refresh]
Skill: "Refreshing community intel - this takes about 60 seconds."
Skill: [Reads troubleshooting.md + hook-types-and-config.md + verified-intel.md]
Common causes in order of likelihood:
1. **Wrong matcher** -- matchers are case-sensitive regex.
Check: `/hooks` menu, verify it appears under the correct event.
2. **Wrong event** -- PreToolUse fires before execution,
PostToolUse fires after.
3. **Script not executable** -- `chmod +x ./my-hook.sh`
4. **PermissionRequest in -p mode** -- not supported in
non-interactive mode. Use PreToolUse instead.
Debug: `claude --debug` shows which hooks matched and their output.
Toggle verbose mode with `Ctrl+O`.
[Includes relevant verified intel findings]
Community intel synced: auto-promoted 1 new finding across 1 topic.
*(from community intel, Jan 2026)*
User: /hooks --upgrade
Skill: [Detects --upgrade flag, runs shared workflow in sync-report mode]
Skill: [Refreshes + auto-promotes findings]
Skill: "Community intel sync complete for /hooks. Auto-promoted 2 findings across 2 topics."