Feature request: session-start hook
Feature Request
Add a session-start hook event that fires when a new Claude Code conversation begins, before any user interaction.
Use Case
Our team's CLAUDE.md contains the instruction:
Claude should WARN THE USER if it is started in a directory other than the repo root OR a project root.
This is important in our monorepo because starting Claude Code in a subdirectory like project/etc/ means .claude/ settings and skills won't be inherited correctly.
The problem: even though the instruction is in CLAUDE.md, the model doesn't reliably act on it at conversation start. It's a model behavior issue — the instruction exists, but there's no guarantee it gets prioritized before the model starts responding to the user's first message.
A session-start hook would let us enforce this programmatically with a simple shell script that checks pwd against known project roots and emits a warning. This is more reliable than depending on the model to self-check.
Proposed Behavior
A new hook event type (e.g., session-start or on-init) that:
- Fires once when a new Claude Code session begins
- Runs before the user's first prompt is processed
- Can output warnings/messages that are surfaced to the model and/or user
- Supports the same shell command configuration as existing hooks
Workarounds Considered
- Shell alias: Wrapping the
claudecommand to checkpwdbefore launch. Works but is per-user setup, not portable with the repo. user-prompt-submithook: Fires on every message, not just the first. Would need state tracking to avoid repeated warnings.- Memory files: Redundant with CLAUDE.md — the instruction already exists, the issue is enforcement timing.
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Update: UserPromptSubmit hook doesn't solve this
We tried implementing this as a
UserPromptSubmithook in the project's.claude/settings.json. The hook works correctly when loaded, but there's a chicken-and-egg problem:<repo-root>/.claude/settings.jsonproject/etc/), the project-level.claude/settings.jsonisn't loadedA global hook (
~/.claude/settings.json) could work technically, but it would need repo-specific logic in a global config, which isn't portable or maintainable.This reinforces the need for a proper session-start hook — or alternatively, a way for project-level hooks to be discovered from parent directories even when Claude Code is started in a subdirectory.
A SessionStart hooks already exists for this purpose. See https://code.claude.com/docs/en/hooks#sessionstart
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.