Summary
Add a new hook event SessionStart that fires once at the beginning of each Claude Code session. Its stdout is injected into the conversation context — functioning as a project-scoped, committed, automatically-applied equivalent of --append-system-prompt.
Motivation
--append-system-prompt solves context injection at session start, but has two key limitations:
-
VSCode Extension: When using Claude Code as a VSCode extension, sessions are started through the IDE — there is no way to pass --append-system-prompt or any CLI arguments. This makes the flag unusable for the majority of interactive sessions.
-
CLI usage: Even when using the CLI directly, the flag requires passing it on every invocation. This is user-dependent and not tied to the project.
Critical [C] rules in CLAUDE.md (e.g., "load flow diagrams at session start") rely entirely on the model remembering to execute them, which is unreliable even when documented in multiple places.
A SessionStart hook would make this automatic, project-scoped, and team-consistent — regardless of whether the session is started via CLI or VSCode.
Decisions (Pre-clarified)
| Decision |
Choice |
Rationale |
| Hook event name |
SessionStart |
Clear, matches existing PreToolUse/PostToolUse naming |
| stdout behavior |
Inject into context |
Matches --append-system-prompt behavior |
| Matcher field |
Not required |
No tool to match against at session start |
| Config location |
settings.json / settings.local.json |
Consistent with existing hook config |
Specification
Comparison with --append-system-prompt
|
--append-system-prompt |
SessionStart hook |
| Scope |
Per CLI invocation |
Per project (committed in settings) |
| VSCode support |
Not available |
Works in all environments |
| Team consistency |
Each dev must remember the flag |
Automatic for everyone |
| Dynamic content |
Static string only |
Can run commands (cat, scripts) |
| Config location |
CLI args |
settings.json / settings.local.json |
| Reproducibility |
User-dependent |
Guaranteed |
Proposed Configuration
Proposed Behavior
- Fires once per session, before the first user message is processed
- stdout is injected into conversation context (like
--append-system-prompt)
- stderr is shown as informational output to the user
- No
matcher field needed (no tool to match against)
- Non-zero exit code: warn but don't abort session
- Works in both CLI and VSCode extension environments
Equivalent CLI usage today (CLI only)
claude --append-system-prompt "$(cat .claude/flows/*.md)"
This workaround is not possible in VSCode — the hook would close that gap.
Documentation Updates
| File |
Change |
| Claude Code hooks docs |
Add SessionStart to hook events table |
| CLI reference |
Cross-reference with --append-system-prompt |
| VSCode extension docs |
Document hook support in IDE context |
Files & Directories to Check
| Path |
Reason |
CLAUDE.md |
Contains [C] rule for session-start flow loading |
.claude/settings.local.json |
Existing hook configuration |
.claude/flows/*.md |
Example files that need loading at session start |
docs/standards/mcp.md |
Documents hook/settings configuration patterns |
Acceptance Criteria
Risks & Mitigation
| Risk |
Impact |
Mitigation |
| Large stdout bloats context |
High token usage per session |
Document size recommendations, warn if output exceeds threshold |
| Slow commands delay session start |
Poor UX |
Add timeout (e.g., 5s default), show progress indicator |
| Command fails silently |
Missing context without user awareness |
Show stderr warnings, log failures |
Alternative Approach
Instead of (or in addition to) a SessionStart hook, the VSCode extension could be extended to allow users to configure CLI arguments (like --append-system-prompt) for new sessions — e.g., via VSCode settings or a workspace-level config. This would make existing CLI flags accessible in the IDE without introducing a new hook event type.
Summary
Add a new hook event
SessionStartthat fires once at the beginning of each Claude Code session. Its stdout is injected into the conversation context — functioning as a project-scoped, committed, automatically-applied equivalent of--append-system-prompt.Motivation
--append-system-promptsolves context injection at session start, but has two key limitations:VSCode Extension: When using Claude Code as a VSCode extension, sessions are started through the IDE — there is no way to pass
--append-system-promptor any CLI arguments. This makes the flag unusable for the majority of interactive sessions.CLI usage: Even when using the CLI directly, the flag requires passing it on every invocation. This is user-dependent and not tied to the project.
Critical
[C]rules in CLAUDE.md (e.g., "load flow diagrams at session start") rely entirely on the model remembering to execute them, which is unreliable even when documented in multiple places.A
SessionStarthook would make this automatic, project-scoped, and team-consistent — regardless of whether the session is started via CLI or VSCode.Decisions (Pre-clarified)
SessionStartPreToolUse/PostToolUsenaming--append-system-promptbehaviorsettings.json/settings.local.jsonSpecification
Comparison with
--append-system-prompt--append-system-promptSessionStarthookcat, scripts)settings.json/settings.local.jsonProposed Configuration
Proposed Behavior
--append-system-prompt)matcherfield needed (no tool to match against)Equivalent CLI usage today (CLI only)
claude --append-system-prompt "$(cat .claude/flows/*.md)"This workaround is not possible in VSCode — the hook would close that gap.
Documentation Updates
SessionStartto hook events table--append-system-promptFiles & Directories to Check
CLAUDE.md[C]rule for session-start flow loading.claude/settings.local.json.claude/flows/*.mddocs/standards/mcp.mdAcceptance Criteria
SessionStarthook event fires once at the beginning of each new sessionmatcherfield required in configurationsettings.json(shared) andsettings.local.json(local)PreToolUse/PostToolUseeventsRisks & Mitigation
Alternative Approach
Instead of (or in addition to) a
SessionStarthook, the VSCode extension could be extended to allow users to configure CLI arguments (like--append-system-prompt) for new sessions — e.g., via VSCode settings or a workspace-level config. This would make existing CLI flags accessible in the IDE without introducing a new hook event type.