/clear command causes transcript file issues breaking Stop hooks context extraction

Resolved 💬 1 comment Opened Jul 6, 2025 by teren-papercutlabs Closed Jul 8, 2025

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

  1. Set up a Stop hook that reads transcript files to generate contextual responses
  2. Have a conversation with Claude Code
  3. Use the /clear command
  4. Continue the conversation
  5. 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:

  1. Deleted when /clear is used but the hook still receives the old path
  2. Never recreated after /clear for the continuing session
  3. 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.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗