Skip to main content

Customize or Disable Hooks

Goal

Change which hooks run automatically, add custom behavior to lifecycle events, or disable hooks that are unwanted.

Prerequisites

  • KMGraph installed with hooks configured (hooks/hooks.json present)
  • Claude Code (hooks are a Claude Code-specific feature)

How hooks work

KMGraph registers shell scripts with Claude Code's lifecycle events via hooks/hooks.json. The events are:

EventWhen it fires
SessionStartWhen Claude Code opens a session
PreToolUseBefore a tool is called
PostToolUseAfter a tool returns
StopWhen Claude Code ends a response
NotificationWhen a notification is sent

The master script scripts/hooks-master.sh routes each event to sub-scripts in scripts/.

Steps

View the current hook configuration

cat hooks/hooks.json

Disable a specific hook behavior

To disable the post-tool lesson check (which prompts to capture lessons after certain tool uses), comment it out in scripts/hooks-master.sh:

# Disable lesson check
# source "${SCRIPT_DIR}/post-tool-lesson-check.sh"

Add custom behavior to a lifecycle event

Create a new script in scripts/ and add a source call in hooks-master.sh at the appropriate event branch:

# In hooks-master.sh, under the PostToolUse branch:
source "${SCRIPT_DIR}/my-custom-hook.sh"

Disable all hooks

Remove or rename hooks/hooks.json:

mv hooks/hooks.json hooks/hooks.json.disabled

Reload Claude Code for the change to take effect.

Re-enable hooks

mv hooks/hooks.json.disabled hooks/hooks.json

Individual hook scripts

ScriptWhat it doesSafe to disable?
post-tool-lesson-check.shPrompts for lesson capture after solvingYes
platform-file-change-check.shDetects changes to CLAUDE.md / AGENTS.mdYes
pre-commit-knowledge-gate.shBlocks commits that skip knowledge captureYes (reduces automation)
session-end-prompt.shPrompts for session summary on StopYes
plan-mirror.shMirrors plan files from ~/.claude/plans/ to docs/plans/Yes
notification-dispatch.shSends webhook notificationsYes (if webhook not configured)

Verify

After changes, start a new Claude Code session and check that the hook behavior matches expectations. The SessionStart hook output appears at session start.

Next steps