Skip to content

v0.3.0 — /clear safety: safe restart with auto context recovery

Choose a tag to compare

@mikeadolan mikeadolan released this 27 May 02:16
· 6 commits to main since this release

/clear safety — the brain makes /clear a safe restart button

For every other Claude Code user, /clear is destructive — it wipes context to free tokens and you lose continuity. With claude-brain, /clear now becomes a safe restart: the brain captures everything in real-time (already did), and on the first prompt after /clear it automatically restores context so Claude picks up where you left off.

Added

  • session-end hook — /clear trigger detection. Reads the reason field from the SessionEnd stdin JSON. On reason == "clear", writes a CLEAR_CHECKPOINT marker to the ended session's notes instead of the generic fallback. Skips the auto-tag suggestion so Claude can write proper tags during post-/clear recovery.
  • user-prompt-submit hook — post-/clear detection + context recovery. On each prompt, checks if a session in the same project ended < 5 minutes ago with a CLEAR_CHECKPOINT marker and a different session_id from the current one. When matched, injects recovery context: the current project summary, the last 10 exchanges (user + assistant) from the ended session, and instructions to write proper notes for the ended session before responding to the user.
  • Works around upstream bug. Anthropic's SessionStart hook does NOT fire on /clear (GitHub #34072, open). The UserPromptSubmit-based detection is a workaround that does not depend on the buggy SessionStart trigger, so it works today.

Fixed

  • Stale script count in README.md, synced to actual count (25 Python scripts).

Upgrade: cd /your/install/path && git pull