Feature request: Add PostClear hook event for /clear command
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:
PostClear— fires after/clearcompletes, allowing re-initializationPreClear/PostClearpair — for cleanup before and re-init after- Re-fire
SessionStartafter/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
UserPromptSubmithook with state detection: Works but fires on every prompt, adding unnecessary overhead- Custom wrapper command: Can't control execution order — hooks would run before
/clearwipes 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
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗