Skip to main content

Module sessionstart

Module sessionstart 

Source
Expand description

sessionstart subcommand — registered as Claude Code’s SessionStart hook, once per part (--part 1 … --part 8). Delivers the agent’s memory (docs/specs/SPEC_GLOBAL_MEMORY_DELIVERY_2026_09_27.md §7 P2).

A SessionStart hook’s additionalContext reaches the model without a visible turn, but only up to about 10,000 characters per hook command (the CLI swaps anything longer for a file preview). So the sidecar splits the memory into labelled parts, and each hook command asks for its own:

  1. read the hook’s stdin (session_id, source);
  2. POST /api/v1/agent/memory/session-start/part for part N — the sidecar decides whether this source gets a delivery at all (resume and fork don’t) and how many parts there are;
  3. print {"hookSpecificOutput":{"hookEventName":"SessionStart", "additionalContext":…}} and flush it;
  4. POST …/session-start/ack, so the sidecar knows this part reached the CLI. Once every part is acknowledged the pane gets its notice.

Every failure (no env, sidecar down, no part for this number) degrades to exit 0 with nothing printed: a hook must never block or break a session start, and an empty stdout is a hook with nothing to add.

Structs§

Args
CLI args for sessionstart.
PartRequest 🔒
SessionStartInput 🔒
The fields of the SessionStart stdin payload this hook uses.

Constants§

ACK_PATH 🔒
ACK_TIMEOUT 🔒
PART_PATH 🔒
PART_TIMEOUT 🔒
The CLI waits for every SessionStart hook before the session starts, so a slow or wedged sidecar must not hold it up for long. Composing reads a handful of small files on the same host.

Functions§

hook_output 🔒
The hook’s stdout for a part: the shape Claude Code reads a SessionStart hook’s added context from.
run
Entry point. Always Ok(()): see the module doc.