Feature Request: SessionStart hook for pre-session initialization

Resolved 💬 5 comments Opened Jan 10, 2026 by RedhatEnt Closed Feb 24, 2026

Description

I'd like to request a SessionStart hook that fires when a Claude Code session begins, before the first user message is processed. This would allow users to run custom initialization logic at startup.

Use Case

I've built a personal knowledge/memory system that integrates with Claude Code. Currently I rely on CLAUDE.md instructions to tell Claude what to do at startup (read files, query APIs, display context). But this is fragile - it depends on Claude following instructions rather than guaranteed execution.

A SessionStart hook would let me:

  • Automatically query my external system for relevant context
  • Inject session-specific information before the conversation begins
  • Load prior session state reliably
  • Run environment setup scripts

Proposed Solution

Add a SessionStart hook similar to existing SessionEnd hooks:

{
  "hooks": {
    "SessionStart": [
      {
        "type": "command",
        "command": "/path/to/init-session.sh"
      }
    ]
  }
}

SessionStart hook input (JSON via stdin):

{
  "session_id": "...",
  "cwd": "...",
  "git_branch": "...",
  "resumed": false
}

SessionStart hook output (optional, via stdout):

{
  "inject_context": "Context to add to system prompt: ...",
  "env_vars": {"KEY": "value"}
}

Benefits

  1. Guaranteed initialization rather than instruction-dependent behavior
  2. Enables reliable integration with external systems
  3. Symmetric with existing SessionEnd hooks
  4. Allows project-specific context injection based on working directory
  5. Supports session resumption awareness

Related

This complements #17237 (PreCompact/PostCompact hooks) - together they would enable full lifecycle context management for users building persistent memory systems.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗