Feature request: Add PostClear hook event for /clear command

Resolved 💬 4 comments Opened Mar 4, 2026 by msdavid Closed Mar 7, 2026

Summary

When /clear is issued, it effectively resets the session context — but unlike a true session start, no hooks fire. This means any SessionStart hooks that establish critical context (memory injection, environment symlinks, config loading) are lost and not re-run.

Problem

Projects that rely on SessionStart hooks to bootstrap context lose that context after /clear with no way to re-establish it. For example:

  • Memory indexes injected at session start disappear
  • Environment symlinks verified at startup aren't re-checked
  • Proposal files that need review aren't re-surfaced

/clear is functionally a "new session within a session," but the hook system doesn't treat it as one.

Proposed Solution

Add a new hook event — either:

  1. PostClear — fires after /clear completes, allowing re-initialization
  2. PreClear / PostClear pair — for cleanup before and re-init after
  3. Re-fire SessionStart after /clear — simplest option, since the use case is identical

Option 3 would be the most ergonomic: projects already define SessionStart hooks, and /clear should trigger them the same way a fresh session does.

Use Case

We maintain a project with SessionStart hooks that:

  • Inject a memory index (YAML) into context for agent retrieval
  • Verify and create environment symlinks
  • Surface pending memory proposals for user review

After /clear, all of this is gone and there's no hook-based way to restore it. The workaround (a UserPromptSubmit hook that detects cleared state) adds overhead to every single prompt.

Alternatives Considered

  • UserPromptSubmit hook with state detection: Works but fires on every prompt, adding unnecessary overhead
  • Custom wrapper command: Can't control execution order — hooks would run before /clear wipes context, or the re-injected context gets wiped immediately after
  • Manual re-initialization: Error-prone and defeats the purpose of hooks

🤖 Generated with Claude Code

View original on GitHub ↗

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