Feature request: Hook event for /clear command

Status Closed — not planned
Maintainer reply ✓ Yes — dicksontsai
Activity 6 comments · opened Jan 29, 2026 · closed Mar 1, 2026
💡 Likely answer: A maintainer (dicksontsai, collaborator) responded on this thread — see the highlighted reply below.

Summary

Add a hook event that fires when the user runs /clear to reset the conversation.

Use Case

I use multi-project planning with progress tracking in markdown files. Currently I have:

  • SessionStart hook to load planning context
  • Stop hook to remind about updating progress docs

However, /clear bypasses both — it resets context without triggering SessionEnd or Stop. This means:

  1. Progress tracking reminders are skipped
  2. Planning context isn't reloaded after clear

Proposed Solution

Add a Clear or PreClear hook event that fires when /clear is invoked, before the context is wiped. This would allow:

  • Saving state before clear
  • Prompting about unsaved work
  • Running cleanup tasks

Alternatively, /clear could trigger SessionEnd then SessionStart to reuse existing hooks.

Workaround

Currently none — /clear cannot be intercepted or wrapped.

View original on GitHub ↗

6 Comments

github-actions[bot] · 8 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/6428
  2. https://github.com/anthropics/claude-code/issues/19086
  3. https://github.com/anthropics/claude-code/issues/21103

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

timwn · 8 months ago

This is important.. feels like we should be able to deterministically control the hook sequence.

github-actions[bot] · 7 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

dicksontsai collaborator · 7 months ago

SessionStart already fires with /clear. You'll need to use the proper matcher: https://code.claude.com/docs/en/hooks#sessionstart

timwn · 7 months ago

Yeah, it wasn't working reliably.
But, things have improved significantly.
What I was more interested in was control of the context. Which doesn't
seem like it will happen.

On Sun, Mar 8, 2026, 2:03 PM Dickson Tsai @.***> wrote:

dicksontsai left a comment (anthropics/claude-code#21578) <https://github.com/anthropics/claude-code/issues/21578#issuecomment-4019684880> SessionStart already fires with /clear. You'll need to use the proper matcher: https://code.claude.com/docs/en/hooks#sessionstart — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/21578#issuecomment-4019684880>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADXYWYS27Y7VXOGP4UKRNET4PW7YTAVCNFSM6AAAAACTH2F5ZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAMJZGY4DIOBYGA> . You are receiving this because you commented.Message ID: @.***>
github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.