Skip to content

PreCommit and SessionStart are not valid hook events but aren't documented as invalid #138

@electroheadfx

Description

@electroheadfx

PreCommit and SessionStart are not valid hook events but aren't documented as invalid

Problem

The settings.json hook system currently only supports PreToolUse, PostToolUse, Notification, Stop, and SubagentStop as hook events. However, PreCommit and SessionStart — which are intuitive lifecycle events — are silently rejected with a generic schema error rather than a clear "unknown hook event" message.

The error output says:

├ PreCommit: Invalid key in record
└ SessionStart
  └ 0
    └ hooks: Expected array, but received undefined

SessionStart is particularly confusing: it's rejected not because the event name is invalid, but because the validator still tries to parse the hook body and fails on the missing hooks array wrapper — masking the real issue (unsupported event type).

Suggested improvements

  1. Validate hook event names first — before checking the shape of the hook body, reject unknown keys with a clear message like: "SessionStart" is not a valid hook event. Valid events: PreToolUse, PostToolUse, Notification, Stop, SubagentStop

  2. Consider adding SessionStart and PreCommit as hook events — both are common workflow needs:

    • SessionStart: run setup commands (check tool versions, load context, display status)
    • PreCommit: run checks before Claude Code creates a git commit (lint, detect-changes, etc.)

Environment

  • Claude Code (latest as of 2026-04-07)
  • macOS, ~/.claude/settings.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions