Feature request: PreClear hook event for /clear command

Resolved 💬 3 comments Opened Feb 16, 2026 by bkjou Closed Feb 19, 2026

Feature Request

Problem

The /clear command wipes conversation context but does not fire any hook before executing. This means:

  • No opportunity to save session state before context is lost
  • SessionEnd is documented to fire with reason: "clear" but doesn't actually fire (see #6428)
  • Users with session-logging workflows (via hooks) lose coverage on /clear

Proposed Solution

Add a PreClear hook event that fires before /clear wipes the conversation context. This would allow users to:

  • Run session loggers that read the transcript before context is gone
  • Save plan/progress state
  • Perform any cleanup before the reset

Input shape

Similar to SessionEnd:

{
  "session_id": "abc123",
  "transcript_path": "/Users/.../.claude/projects/.../transcript.jsonl",
  "cwd": "/Users/...",
  "hook_event_name": "PreClear"
}

Use Case

I use agent hooks on SessionEnd and PreCompact to auto-log session summaries to a daily journal. /clear is the one gap — context disappears with no hook firing. A PreClear event would close this gap and make the hook system complete for session lifecycle coverage.

Alternatives Considered

  • Relying on SessionEnd — doesn't fire on /clear (#6428)
  • Manual /log-session before /clear — easy to forget
  • PreCompact — only covers automatic compaction, not manual /clear

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗