[BUG] SessionStart:resume hook payload missing 'cwd' field
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
When resuming a session with claude --resume, the SessionStart hook payload does not include a cwd field. Hooks that depend on cwd (e.g. semgrep mcp -k inject-secure-defaults) crash with a KeyError and Claude Code reports a SessionStart:resume hook error banner.
The cwd field is present on startup but absent on resume, compact, and clear events.
What Should Happen?
The SessionStart hook payload should always include cwd regardless of the event type (startup, resume, compact, clear). When resuming, Claude Code is invoked from a directory — that directory is the cwd and should be included.
Error Messages/Logs
SessionStart:resume hook error
Underlying error from semgrep mcp -k inject-secure-defaults:
inject_secure_defaults_context (hook) failed: 'cwd'
KeyError: 'cwd'
File ".../semgrep/mcp/hooks/inject_secure_defaults.py", line 66, in get_hook_event_name
return (str(hook_data["hook_event_name"]), str(hook_data["cwd"]))
Steps to Reproduce
- Install the semgrep Claude Code plugin (
/plugin install semgrep@claude-plugins-official) - Start Claude Code in a project directory
- Exit (
/exit) - Resume with
claude --resumein the same directory - Observe
SessionStart:resume hook errorbanner
Why This Is a Claude Code Bug
claude --resume is invoked from a directory. The cwd is unambiguously known at hook execution time. Omitting it from the payload breaks any hook that needs to know where it's running — which is a reasonable and common need (e.g. scanning the current project for security issues).
Note: the hook crashing on a missing key is a secondary issue for semgrep to handle defensively, but the root cause is the missing field.
Related
- #33815 —
$CLAUDE_PROJECT_DIRunset in hook env (related: project context not available in hooks)
Claude Code Version
2.1.74 (Windows 11)
Platform
Windows 11 Pro
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗