/clear command causes transcript file issues breaking Stop hooks context extraction
Bug Description
When using the /clear command in Claude Code, the Stop hook fails to extract context from the conversation transcript, causing it to fall back to a generic message instead of generating contextual responses.
Steps to Reproduce
- Set up a Stop hook that reads transcript files to generate contextual responses
- Have a conversation with Claude Code
- Use the
/clearcommand - Continue the conversation
- When Claude completes a response, the Stop hook receives a transcript path that doesn't exist
Expected Behavior
After /clear, the Stop hook should still be able to access the current session's transcript with messages that come after the clear command.
Actual Behavior
The Stop hook receives a transcript path but the file doesn't exist in the filesystem, causing context extraction to fail.
Debug Information
# Hook receives this data:
{"session_id":"1e8899c0-9589-41ba-84a2-2429ea69bc0d","transcript_path":"/Users/teren/.claude/projects/-Users-teren-projects-orion/1e8899c0-9589-41ba-84a2-2429ea69bc0d.jsonl","hook_event_name":"Stop","stop_hook_active":false}
# But the file doesn't exist:
ls: /Users/teren/.claude/projects/-Users-teren-projects-orion/1e8899c0-9589-41ba-84a2-2429ea69bc0d.jsonl: No such file or directory
Environment
- Claude Code version: 1.0.33 (latest)
- OS: macOS 24.5.0 (Darwin)
- Hook type: Stop hook
Additional Context
This appears related to issue #2538 where /clear doesn't fully reset context. In this case, it seems the transcript file is either:
- Deleted when
/clearis used but the hook still receives the old path - Never recreated after
/clearfor the continuing session - Stored in a different location after
/clear
Impact
This breaks any Stop hooks that rely on reading conversation context to provide intelligent responses, forcing them to use generic fallback messages.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗